MATCH: Add Max<Max<a,b>,a> -> Max<a,b> simplifcation
commit6d449531a60b56ed0f4aeb640aa9e46e4ec35208
authorAndrew Pinski <apinski@marvell.com>
Fri, 21 Jul 2023 00:36:29 +0000 (20 17:36 -0700)
committerAndrew Pinski <apinski@marvell.com>
Fri, 21 Jul 2023 07:33:39 +0000 (21 00:33 -0700)
tree0fd483bea3519274c60f081359221a2899eaa399
parent9a8782e63790842d1bfa03e12eecf73c4aaeb1f8
MATCH: Add Max<Max<a,b>,a> -> Max<a,b> simplifcation

This adds a simple match pattern to simplify
`max<max<a,b>,a>` to `max<a,b>`.  Reassociation handles
this already (r0-77700-ge969dbde29bfd396259357) but
seems like we should be able to handle this even before
reassociation.

This fixes part of PR tree-optimization/80574 but more
work is needed fix it the rest of the way. The original
testcase there is fixed but the RTL level is what fixes
it the rest of the way.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* match.pd (minmax<minmax<a,b>,a>->minmax<a,b>): New
transformation.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/reassoc-12.c: Disable all of
the passes that enables match-and-simplify.
* gcc.dg/tree-ssa/minmax-23.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/minmax-23.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/reassoc-12.c