]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: [PR110937/PR100798] (a ? ~b : b) should be optimized to b ^ -(a)
authorAndrew Pinski <apinski@marvell.com>
Mon, 7 Aug 2023 17:47:09 +0000 (10:47 -0700)
committerAndrew Pinski <apinski@marvell.com>
Wed, 9 Aug 2023 19:21:04 +0000 (12:21 -0700)
commit7fb65f102851248bafa0815401d8bdcea6d7626c
tree6cbd86c8c1a93fac696f2785e3a051c23b2e2dd8
parent5c27c911f6beb445ce358032599bf83bd5808397
MATCH: [PR110937/PR100798] (a ? ~b : b) should be optimized to b ^ -(a)

This adds a simple match pattern for this case.
I noticed it a couple of different places.
One while I was looking at code generation of a parser and
also while I was looking at locations where bitwise_inverted_equal_p
should be used more.

Committed as approved after bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/110937
PR tree-optimization/100798

gcc/ChangeLog:

* match.pd (`a ? ~b : b`): Handle this
case.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bool-14.c: New test.
* gcc.dg/tree-ssa/bool-15.c: New test.
* gcc.dg/tree-ssa/phi-opt-33.c: New test.
* gcc.dg/tree-ssa/20030709-2.c: Update testcase
so `a ? -1 : 0` is not used to hit the match
pattern.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/20030709-2.c
gcc/testsuite/gcc.dg/tree-ssa/bool-14.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/bool-15.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-33.c [new file with mode: 0644]