MATCH: Add simplifications of `(a == CST) & a`
commit0fb828af75732d39c644fd145c29d41ca14b8cb1
authorAndrew Pinski <apinski@marvell.com>
Sat, 16 Sep 2023 03:27:26 +0000 (16 03:27 +0000)
committerAndrew Pinski <apinski@marvell.com>
Mon, 18 Sep 2023 16:12:53 +0000 (18 16:12 +0000)
tree71355c5553c4143fa6a0449f8982d9a0a566629d
parent0db533114235539199f6698d8d52c5101107567e
MATCH: Add simplifications of `(a == CST) & a`

`(a == CST) & a` can be either simplified to simplying `a == CST`
or 0 depending on the first bit of the CST.
This is an extension of the already pattern of `X & !X` and allows
us to remove the 2 xfails on gcc.dg/binop-notand1a.c and gcc.dg/binop-notand4a.c.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/111431

gcc/ChangeLog:

* match.pd (`(a == CST) & a`): New pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/binop-notand1a.c: Remove xfail.
* gcc.dg/binop-notand4a.c: Likewise.
* gcc.c-torture/execute/pr111431-1.c: New test.
* gcc.dg/binop-andeq1.c: New test.
* gcc.dg/binop-andeq2.c: New test.
* gcc.dg/binop-notand7.c: New test.
* gcc.dg/binop-notand7a.c: New test.
gcc/match.pd
gcc/testsuite/gcc.c-torture/execute/pr111431-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/binop-andeq1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/binop-andeq2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/binop-notand1a.c
gcc/testsuite/gcc.dg/binop-notand4a.c
gcc/testsuite/gcc.dg/binop-notand7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/binop-notand7a.c [new file with mode: 0644]