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

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

https://gcc.gnu.org/g:56efa4a739786bb1c1c6dcdab0ad81cb1c55b970

commit r17-4693-g56efa4a739786bb1c1c6dcdab0ad81cb1c55b970
Author: Samarth Tandale <[email protected]>
Date:   Sun Sep 27 09:34:59 2026 -0600

    [PATCH v1] match.pd: Fold (a != 0) | (popcount(a) == n) and related
patterns [PR112094]

    Fold (a != 0) | (popcount(a) == n) into (a != 0) | (n == 0), and
    (a == 0) & (popcount(a) != n) into (a == 0) & (n != 0).

    This follows from x == 0 => popcount(x) == 0: when a == 0 the
    popcount comparison reduces to a comparison against zero, and when
    a != 0 the outer OR/AND already determines the result.

            PR tree-optimization/112094

    gcc/ChangeLog:
            * match.pd: Add fold for (a != 0) | (popcount(a) == n) and
            (a == 0) & (popcount(a) != n).

    gcc/testsuite/ChangeLog:
            * gcc.dg/fold-popcount-12.c: New test.
            * gcc.dg/fold-popcount-13.c: New test.

    Signed-off-by: Samarth Tandale <[email protected]>

Reply via email to