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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The actual bug is much older though, as shown e.g. on
__attribute__((noipa)) unsigned
foo (int x)
{
  unsigned long long a = (0x800000000000ccccULL << x) | (0x800000000000ccccULL
>> (64 - x));
  unsigned int b = a;
  return (b << 24) | (b >> 8);
}

int
main ()
{
  if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4 || __SIZEOF_LONG_LONG__ != 8)
    return 0;
  if (foo (1) != 0x99000199U)
    __builtin_abort ();
  return 0;
}
with the first if commented out and -O1 -fno-inline this is miscompiled e.g.
even with r105000.
For rotates, I guess we can swap them only if they have the same modes, or at
least we shouldn't if the outer one is narrower than the inner one.

Reply via email to