[Bug middle-end/63568] Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask)

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 16 13:44:00 GMT 2014


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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
FWIW, I used this to check the whether the transformation is correct:

int
main ()
{
  for (int i = -1000; i < 1000; ++i)
    for (int a = -1000; a < 1000; ++a)
      for (int b = -1000; b < 1000; ++b)
    {
      int x = (a & ~i) | (b & i);
      int y = a ^ ((a ^ b) & i);
      //__builtin_printf ("%d %d\n", x, y);
      if (x != y)
        __builtin_abort ();
    }
}



More information about the Gcc-bugs mailing list