middle-end: Wrong code for a != b | (a|b) != 0. [PR126742]

Since r17-2886, GCC does a wrong optimize with:

(a == b) & ((a|b) == 0) -> ((a|b) != 0)
(a != b) | ((a|b) != 0) -> ((a|b) == 0)

Should be:

(a == b) & ((a|b) == 0) -> ((a|b) == 0)
(a != b) | ((a|b) != 0) -> ((a|b) != 0)

Regtest missed this because gcc.dg/int-bwise-opt-2.c only test:

/* { dg-final { scan-tree-dump-times "a == b" 0 "optimized" } } */
/* { dg-final { scan-tree-dump-times "a != b" 0 "optimized" } } */

Make this test more rigorous by comparing the final code.

Bootstrapped and regtested on x86_64-pc-linux-gnu.

	PR middle-end/126742

gcc/ChangeLog:

	* match.pd: Fix wrong code.

gcc/testsuite/ChangeLog:

	* gcc.dg/int-bwise-opt-2.c: Also test for PR126742.

Signed-off-by: Kael Andrew Franco <kaelfandrew@gmail.com>
2 files changed