]> git.ipfire.org Git - thirdparty/gcc.git/commit
match.pd: Implement missed optimization (~X | Y) ^ X -> ~(X & Y) [PR109986]
authorDrew Ross <drross@redhat.com>
Mon, 24 Jul 2023 15:51:28 +0000 (17:51 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 24 Jul 2023 15:51:28 +0000 (17:51 +0200)
commit2a3556376c69a1fb588dcf25225950575e42784f
treeede842f5da8a3d42f6ef1e7624e1b07e55bbe4fc
parentd90e81af8052e96ae3262ed3ac42682537fc42c6
match.pd: Implement missed optimization (~X | Y) ^ X -> ~(X & Y) [PR109986]

Adds a simplification for (~X | Y) ^ X to be folded into ~(X & Y).
Also adds the macro bitwise_equal_p for generic and gimple which
returns true iff EXPR1 and EXPR2 have the same value. This helps
to reduce the number of nop_converts necessary to match the pattern.

PR middle-end/109986

gcc/ChangeLog:

* generic-match-head.cc (bitwise_equal_p): New macro.
* gimple-match-head.cc (bitwise_equal_p): New macro.
(gimple_nop_convert): Declare.
(gimple_bitwise_equal_p): Helper for bitwise_equal_p.
* match.pd ((~X | Y) ^ X -> ~(X & Y)): New simplification.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/pr109986.c: New test.
* gcc.dg/tree-ssa/pr109986.c: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
gcc/generic-match-head.cc
gcc/gimple-match-head.cc
gcc/match.pd
gcc/testsuite/gcc.c-torture/execute/pr109986.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr109986.c [new file with mode: 0644]