]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: [PR111282] Simplify `a & (b ^ ~a)` to `a & b`
authorAndrew Pinski <pinskia@gmail.com>
Tue, 10 Oct 2023 19:45:56 +0000 (12:45 -0700)
committerAndrew Pinski <pinskia@gmail.com>
Wed, 11 Oct 2023 16:45:51 +0000 (09:45 -0700)
commite8d418df3dc609f27487deece796d4aa69004b8c
tree80b4a620828e3e420688d03e3e6fea9ff4acf1e7
parentacfca27eaf4960069f7a49039f1407b956669ec1
MATCH: [PR111282] Simplify `a & (b ^ ~a)` to `a & b`

While `a & (b ^ ~a)` is optimized to `a & b` on the rtl level,
it is always good to optimize this at the gimple level and allows
us to match a few extra things including where a is a comparison.

Note I had to update/change the testcase and-1.c to avoid matching
this case as we can match -2 and 1 as bitwise inversions.

PR tree-optimization/111282

gcc/ChangeLog:

* match.pd (`a & ~(a ^ b)`, `a & (a == b)`,
`a & ((~a) ^ b)`): New patterns.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/and-1.c: Update testcase to avoid
matching `~1 & (a ^ 1)` simplification.
* gcc.dg/tree-ssa/bitops-6.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/and-1.c
gcc/testsuite/gcc.dg/tree-ssa/bitops-6.c [new file with mode: 0644]