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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kael Andrew Franco <[email protected]>:

https://gcc.gnu.org/g:0621cf67366ffa2215cdd081b1ca1c3c577e8b70

commit r17-3166-g0621cf67366ffa2215cdd081b1ca1c3c577e8b70
Author: Kael Andrew Alonzo Franco <[email protected]>
Date:   Sat Aug 8 22:04:12 2026 -0400

    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 <[email protected]>

Reply via email to