https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83201

Sean <brlcad at mac dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brlcad at mac dot com

--- Comment #23 from Sean <brlcad at mac dot com> ---
Sorry for digging up the past, but recently ran into a related implementation
issue in OpenBSD's qsort implementation and came across this discussion.  While
I understand the proposed patch was rejected, it looks like it also degraded
the implementation to single byte swaps.

Admittedly untested, but a possible solution that I think would make LTO happy
(avoids aliasing the pointer) and doesn't change the implementation profile
would be to cast it differently since it's always dealing with a simple type
alignment check on long/int/char.  Something like this:

#define SWAPINIT(TYPE, a, es) swaptype_ ## TYPE = (uintptr_t)a % sizeof(TYPE)
|| es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1;

Maybe a more acceptable alternative compromise since it would have a nearly
identical performance profile with it still swap-optimizing int and long.

Reply via email to