[Bug tree-optimization/123311] Min(clz(a), clz(b))->clz(a|b) likewise for ctz

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123311

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

https://gcc.gnu.org/g:1743c12e3512bff3c9688dff7bba5b2ac43cd9d5

commit r17-2815-g1743c12e3512bff3c9688dff7bba5b2ac43cd9d5
Author: Eikansh Gupta <[email protected]>
Date:   Tue May 19 12:20:54 2026 +0530

    MATCH: Simplify min of clz/ctz to clz/ctz of bitwise or [PR123311]

    This adds match.pd simplifications for min(clz(x), clz(y)) and
    min(ctz(x), ctz(y)) to clz(x | y) and ctz(x | y).

    Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.

            PR tree-optimization/123311

    gcc/ChangeLog:

            * match.pd (min(clz(x), clz(y)) -> clz(x | y)): New pattern.
            (min(ctz(x), ctz(y)) -> ctz(x | y)): Likewise.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr123311-1.c: New test.
            * gcc.dg/tree-ssa/pr123311-2.c: New test.

    Signed-off-by: Eikansh Gupta <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.