Fix part of PR 110293: `A NEEQ (A NEEQ CST)` part
commit285c9d042e90a7425b37697edc9ec93a1b03b486
authorAndrew Pinski <apinski@marvell.com>
Wed, 12 Jul 2023 07:33:14 +0000 (12 00:33 -0700)
committerAndrew Pinski <apinski@marvell.com>
Thu, 13 Jul 2023 14:54:55 +0000 (13 07:54 -0700)
tree8024b07d4cee15fc4ec1b389c61287fefeb58208
parentb175b4887f928118af997f6d4d75097a64dcec5d
Fix part of PR 110293: `A NEEQ (A NEEQ CST)` part

This fixes part of PR 110293, for the outer comparison case
being `!=` or `==`.  In turn PR 110539 is able to be optimized
again as the if statement for `(a&1) == ((a & 1) != 0)` gets optimized
to `false` early enough to allow FRE/DOM to do a CSE for memory store/load.

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

gcc/ChangeLog:

PR tree-optimization/110293
PR tree-optimization/110539
* match.pd: Expand the `x != (typeof x)(x == 0)`
pattern to handle where the inner and outer comparsions
are either `!=` or `==` and handle other constants
than 0.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr110293-1.c: New test.
* gcc.dg/tree-ssa/pr110539-1.c: New test.
* gcc.dg/tree-ssa/pr110539-2.c: New test.
* gcc.dg/tree-ssa/pr110539-3.c: New test.
* gcc.dg/tree-ssa/pr110539-4.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr110293-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr110539-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr110539-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr110539-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr110539-4.c [new file with mode: 0644]