public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3923] MATCH: Move `X <= MAX(X, Y)` before `MIN (X, C1) < C2` pattern
@ 2023-09-13 12:07 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2023-09-13 12:07 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4a937fa94fde09ab96b494b32ed4d569a199c5be

commit r14-3923-g4a937fa94fde09ab96b494b32ed4d569a199c5be
Author: Andrew Pinski <apinski@marvell.com>
Date:   Tue Sep 12 05:27:24 2023 +0000

    MATCH: Move `X <= MAX(X, Y)` before `MIN (X, C1) < C2` pattern
    
    Since matching C1 as C2 here will decrease how much other simplifications
    will need to happen to get the final answer.
    
    OK? Bootstrapped and tested on x86_64-linux-gnu.
    
    gcc/ChangeLog:
    
            * match.pd (`X <= MAX(X, Y)`):
            Move before `MIN (X, C1) < C2` pattern.

Diff:
---
 gcc/match.pd | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index ea4c7c5cf536..7ecf55685997 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3947,13 +3947,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (if (wi::lt_p (wi::to_wide (@1), wi::to_wide (@2),
 		  TYPE_SIGN (TREE_TYPE (@0))))
     (cmp @0 @2)))))
-/* MIN (X, C1) < C2 -> X < C2 || C1 < C2  */
-(for minmax (min     min     max     max     min     min     max     max    )
-     cmp    (lt      le      gt      ge      gt      ge      lt      le     )
-     comb   (bit_ior bit_ior bit_ior bit_ior bit_and bit_and bit_and bit_and)
- (simplify
-  (cmp (minmax @0 INTEGER_CST@1) INTEGER_CST@2)
-  (comb (cmp @0 @2) (cmp @1 @2))))
 
 /* X <= MAX(X, Y) -> true
    X > MAX(X, Y) -> false 
@@ -3965,6 +3958,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (cmp:c @0 (minmax:c @0 @1))
   { constant_boolean_node (cmp == GE_EXPR || cmp == LE_EXPR, type); } ))
 
+/* MIN (X, C1) < C2 -> X < C2 || C1 < C2  */
+(for minmax (min     min     max     max     min     min     max     max    )
+     cmp    (lt      le      gt      ge      gt      ge      lt      le     )
+     comb   (bit_ior bit_ior bit_ior bit_ior bit_and bit_and bit_and bit_and)
+ (simplify
+  (cmp (minmax @0 INTEGER_CST@1) INTEGER_CST@2)
+  (comb (cmp @0 @2) (cmp @1 @2))))
+
 /* Undo fancy ways of writing max/min or other ?: expressions, like
    a - ((a - b) & -(a < b))  and  a - (a - b) * (a < b) into (a < b) ? b : a.
    People normally use ?: and that is what we actually try to optimize.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-13 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13 12:07 [gcc r14-3923] MATCH: Move `X <= MAX(X, Y)` before `MIN (X, C1) < C2` pattern Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).