]> git.ipfire.org Git - thirdparty/gcc.git/commit
match: Add simplification of `(a*zero_one_valued_p) & b` if `a & b` simplifies [PR119402]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 13 Jan 2026 02:58:47 +0000 (18:58 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Tue, 13 Jan 2026 20:42:29 +0000 (12:42 -0800)
commit80c77d9a1cfbfde3a437361fa95be326fcdf3e58
treec2485fefd728195a01ec87256fc6bd861ed8559a
parent7a456056ff9c2edc67cfcdf7bb8fe86176c66ec7
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>
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/bitops-14.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/bitops-15.c [new file with mode: 0644]