[Bug tree-optimization/125104] `(a & ~CST) ^ CST` -> `a | CST`

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun May 24 16:31:13 GMT 2026


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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:365e5618bc6fcb62560450677e0fe4f5ba96345e

commit r17-705-g365e5618bc6fcb62560450677e0fe4f5ba96345e
Author: Raven Hallsby <karl@hallsby.com>
Date:   Sat May 23 21:09:16 2026 -0500

    match: Optimize `(~y & x) ^ y` into (y | x) [PR125104]

    Despite a similar rule existing earlier in match.pd, this simplify
    rule is needed because the front-end (before pass 006.original)
    performs trivial constant optimizations, such as ~1 -> -2 on
    integers (at least those defined as `int`).

            PR tree-optimization/125104

    gcc/ChangeLog:

            * match.pd (`(~y & x) ^ y`): New Pattern.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr125104.c: New test.


More information about the Gcc-bugs mailing list