[Bug tree-optimization/119402] [14/15/16 Regression] `((-bool) & _6) & (~_6)` is not optimized to 0 on some targets since r14-5673
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 13 20:45:46 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119402
--- Comment #9 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:80c77d9a1cfbfde3a437361fa95be326fcdf3e58
commit r16-6752-g80c77d9a1cfbfde3a437361fa95be326fcdf3e58
Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Date: Mon Jan 12 18:58:47 2026 -0800
match: Add simplification of `(a*zero_one_valued_p) & b` if `a & b`
simplifies [PR119402]
This is a small reassociation for `a*bool & b` into `(a & b) * bool`
checking if
`a & b` simplifies. Since it could be the case `b` is `~a` or `a` or
something
else that might simplify when anding with `a`.
Note this fixes a regression for aarch64 where the cost of a multiply vs
`&-` changed
in GCC 14 and can no longer optimize some cases at the RTL level.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/119402
gcc/ChangeLog:
* match.pd (`(a*zero_one_valued_p) & b`): New pattern.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/bitops-14.c: New test.
* gcc.dg/tree-ssa/bitops-15.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
More information about the Gcc-bugs
mailing list