]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization: [PR100864] `(a&!b) | b` is not opimized to `a | b` for comparisons
authorAndrew Pinski <apinski@marvell.com>
Sat, 29 Jul 2023 03:27:03 +0000 (20:27 -0700)
committerAndrew Pinski <apinski@marvell.com>
Mon, 31 Jul 2023 17:12:06 +0000 (10:12 -0700)
commitb9237226fdc9387bccf584a811b30c5d3689ffd2
treea7d1b2ff27dae83884c33d2aff966d2eceac0e88
parentc6523ae786e36dccd64589682140e9221628bb5b
tree-optimization: [PR100864] `(a&!b) | b` is not opimized to `a | b` for comparisons

This is a new version of the patch.
Instead of doing the matching of inversion comparison directly inside
match, creating a new function (bitwise_inverted_equal_p) to do it.
It is very similar to bitwise_equal_p that was added in r14-2751-g2a3556376c69a1fb
but instead it says `expr1 == ~expr2`. A follow on patch, will
use this function in other patterns where we try to match `@0` and `(bit_not @0)`.

Changed the name bitwise_not_equal_p to bitwise_inverted_equal_p.

Committed as approved after a Bootstrapped and test on x86_64-linux-gnu with no regressions.

PR tree-optimization/100864

gcc/ChangeLog:

* generic-match-head.cc (bitwise_inverted_equal_p): New function.
* gimple-match-head.cc (bitwise_inverted_equal_p): New macro.
(gimple_bitwise_inverted_equal_p): New function.
* match.pd ((~x | y) & x): Use bitwise_inverted_equal_p
instead of direct matching bit_not.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bitops-3.c: New test.
gcc/generic-match-head.cc
gcc/gimple-match-head.cc
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/bitops-3.c [new file with mode: 0644]