[gcc r17-2885] match: Combine two patterns into for.
Kael Andrew Franco via Gcc-cvs <[email protected]> Sun, 2 Aug 2026 11:54:34 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:8640e4b2efcdc588969110d61a5cdcb23518bad6 commit r17-2885-g8640e4b2efcdc588969110d61a5cdcb23518bad6 Author: Kael Andrew Alonzo Franco <[email protected]> Date: Sun Aug 2 07:53:30 2026 -0400 match: Combine two patterns into for. This simplify r6-4336 so genmatch outputs less C++ code. Bootstrapped and regtested on x86_64-pc-linux-gnu. gcc/ChangeLog: * match.pd: Combine two patterns into for. Diff: --- gcc/match.pd | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index b757aaf6f695..eb9eac600d0f 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4510,27 +4510,27 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* Simplifications of MIN_EXPR, MAX_EXPR, fmin() and fmax(). */ (for minmax (min max) + maxmin (max min) (simplify (minmax @0 @0) @0) /* max(max(x,y),x) -> max(x,y) */ (simplify (minmax:c (minmax:c@2 @0 @1) @0) - @2)) + @2) + +/* min(max(x,y),y) -> y. + max(min(x,y),y) -> y. */ + (simplify + (minmax:c (maxmin:c @0 @1) @1) + @1)) + /* For fmin() and fmax(), skip folding when both are sNaN. */ (for minmax (FMIN_ALL FMAX_ALL) (simplify (minmax @0 @0) (if (!tree_expr_maybe_signaling_nan_p (@0)) @0))) -/* min(max(x,y),y) -> y. */ -(simplify - (min:c (max:c @0 @1) @1) - @1) -/* max(min(x,y),y) -> y. */ -(simplify - (max:c (min:c @0 @1) @1) - @1) /* max(a,-a) -> abs(a). */ (simplify (max:c @0 (negate @0))