]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: Move `a <= CST1 ? MAX<a, CST2> : a` optimization to match
authorAndrew Pinski <apinski@marvell.com>
Sun, 7 May 2023 18:39:03 +0000 (11:39 -0700)
committerAndrew Pinski <apinski@marvell.com>
Tue, 30 May 2023 15:43:22 +0000 (08:43 -0700)
commit17cca3c43e2f496dcef0ba79e04979b49439e0c3
tree0cb6dc27ca7bcce8b82c7c79bdb167c65aeae6df
parentb49bcb86851557d1a32fce1b867be786cecd6f94
MATCH: Move `a <= CST1 ? MAX<a, CST2> : a` optimization to match

This moves the `a <= CST1 ? MAX<a, CST2> : a` optimization
from phiopt to match. It just adds a new pattern to match.pd.

There is one more change needed before being able to remove
minmax_replacement from phiopt.

A few notes on the testsuite changes:
* phi-opt-5.c is now able to optimize at phiopt1 so remove
the xfail.
* pr66726-4.c can be optimized during fold before phiopt1
so need to change the scanning.
* pr66726-5.c needs two phiopt passes currently to optimize
to the right thing, it needed 2 phiopt passes before, the cast
from int to unsigned char is the reason.
* pr66726-6.c is what the original pr66726-4.c was testing
before the fold was able to optimize it.

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

gcc/ChangeLog:

* match.pd (`(a CMP CST1) ? max<a,CST2> : a`): New
pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/phi-opt-5.c: Remove last xfail.
* gcc.dg/tree-ssa/pr66726-4.c: Change how scanning
works.
* gcc.dg/tree-ssa/pr66726-5.c: New test.
* gcc.dg/tree-ssa/pr66726-6.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-5.c
gcc/testsuite/gcc.dg/tree-ssa/pr66726-4.c
gcc/testsuite/gcc.dg/tree-ssa/pr66726-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr66726-6.c [new file with mode: 0644]