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

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

https://gcc.gnu.org/g:421f09e24c9c82a9ff6a61dd0b65687175c90bff

commit r17-709-g421f09e24c9c82a9ff6a61dd0b65687175c90bff
Author: liuhongt <[email protected]>
Date:   Thu May 14 02:06:43 2026 -0700

    match.pd: Fold popcount(x ^ (x - 1)) to ctz(x) + 1 [PR124630]

    When X is nonzero, X ^ (X - 1) produces a mask of trailing zeros plus
    the lowest set bit, so popcount of that expression equals ctz(X) + 1.

    gcc/ChangeLog:

            PR middle-end/124630
            * match.pd (popcount (x ^ (x - 1))): Fold to ctz (x) + 1 when
            x is nonzero and CTZ is directly supported.

    gcc/testsuite/ChangeLog:

            PR middle-end/124630
            * gcc.dg/pr124630.c: New test.
            * gcc.target/i386/pr124630.c: New test.
  • [Bug tree-optimization/124630] ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to