This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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 ();
    }
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]