[Bug tree-optimization/122848] `zero_extend<a> & sign_extend<a>` is not optimized to `zero_extend<a>` for the gimple level

"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=122848

--- 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:ece564fdaa15a0da008cedd881afcd3f0f4dbd5a

commit r17-2824-gece564fdaa15a0da008cedd881afcd3f0f4dbd5a
Author: Eikansh Gupta <[email protected]>
Date:   Wed Jun 3 15:46:29 2026 +0530

    MATCH: Simplify zero/sign extension bit operations [PR122848]

    Fold bitwise operations involving zero and sign extensions from the same
    low-precision value.  The AND case folds to the zero extension, and the
    OR case folds to the sign extension.

            PR tree-optimization/122848

    gcc/ChangeLog:

            * match.pd (zero_extend & sign_extend -> zero_extend): New pattern.
            (zero_extend | sign_extend -> sign_extend): Likewise.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr122848.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.