This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/63568] Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask)
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 16 Dec 2014 13:44:50 +0000
- Subject: [Bug middle-end/63568] Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask)
- Auto-submitted: auto-generated
- References: <bug-63568-4 at http dot gcc dot gnu dot org/bugzilla/>
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 ();
}
}