]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: Simplify `(A ==/!= B) &/| (((cast)A) CMP C)`
authorAndrew Pinski <apinski@marvell.com>
Wed, 20 Sep 2023 21:54:31 +0000 (14:54 -0700)
committerAndrew Pinski <pinskia@gmail.com>
Tue, 26 Sep 2023 15:01:18 +0000 (08:01 -0700)
commitc3c6f30496d945b77dcb7f4ad8c3f8094f5a64a4
tree37f490138e1ea09e1c889303f4337b369ad50f71
parent68fa82e2d8f868a233103102dff2449a416bc566
MATCH: Simplify `(A ==/!= B) &/| (((cast)A) CMP C)`

This patch adds support to the pattern for `(A == B) &/| (A CMP C)`
where the second A could be casted to a different type.
Some were handled correctly if using seperate `if` statements
but not if combined with BIT_AND/BIT_IOR.
In the case of pr111456-1.c, the testcase would pass if
`--param=logical-op-non-short-circuit=0` was used but now
can be optimized always.

OK? Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/106164
PR tree-optimization/111456

gcc/ChangeLog:

* match.pd (`(A ==/!= B) & (A CMP C)`):
Support an optional cast on the second A.
(`(A ==/!= B) | (A CMP C)`): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cmpbit-6.c: New test.
* gcc.dg/tree-ssa/cmpbit-7.c: New test.
* gcc.dg/tree-ssa/pr111456-1.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/cmpbit-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/cmpbit-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr111456-1.c [new file with mode: 0644]