]> git.ipfire.org Git - thirdparty/gcc.git/commit
match: Improve the `x ==/!= ~x` pattern [PR118483]
authorAndrew Pinski <quic_apinski@quicinc.com>
Thu, 16 Jan 2025 04:17:09 +0000 (20:17 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 21 Jan 2025 22:07:48 +0000 (14:07 -0800)
commitdae2b6246c00f4389b617ffaa30459bd22d9fe13
treef8243ab06909d0b6cdeb823bf23ba3dfe30074d5
parent0d25d45c9d3a54b21f9dce43beb0b5ced4db0409
match: Improve the `x ==/!= ~x` pattern [PR118483]

This improves this pattern by 2 ways:
* Allow for an optional convert, similar to how the few other
  `a OP ~a` patterns also allow for an optional convert.
* Use bitwise_inverted_equal_p/maybe_bit_not instead of directly
  matching bit_not. Just like the other patterns do too.

Note pr118483-2.c used to optimized for aarch64-linux-gnu with GCC 4.9.4
on the RTL level even though the gimple level was missing it.

PR tree-optimization/118483

gcc/ChangeLog:

* match.pd (`x ==/!= ~x`): Allow for an optional convert
and use itwise_inverted_equal_p/maybe_bit_not instead of
directly matching bit_not.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr118483-1.c: New test.
* gcc.dg/tree-ssa/pr118483-2.c: New test.
* gcc.dg/tree-ssa/pr118483-3.c: New test.
* gcc.dg/tree-ssa/pr118483-4.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr118483-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr118483-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr118483-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr118483-4.c [new file with mode: 0644]