[gcc r17-3561] match: Combine four loops into one loop for spaceship. [PR59429]

Kael Andrew Franco via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:91c43fae4628e5deee81ec70dd9a63a1d7ae5700

commit r17-3561-g91c43fae4628e5deee81ec70dd9a63a1d7ae5700
Author: Kael Andrew Alonzo Franco <[email protected]>
Date:   Wed Aug 19 16:03:33 2026 -0400

    match: Combine four loops into one loop for spaceship. [PR59429]
    
    This reduces genmatch's C++ output and encloses the 4th loop
    in INTEGRAL_TYPE_P (type) since the 3rd loop has an extra ).
    
    Bootstrapped and regtested on x86_64-pc-linux-gnu.
    
            PR tree-optimization/59429
    
    gcc/ChangeLog:
    
            * match.pd: Combine four loops into one loop for spaceship.
    
    Signed-off-by: Kael Andrew Franco <[email protected]>

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

diff --git a/gcc/match.pd b/gcc/match.pd
index 8ab46d83b147..bcfc7f0e8ce8 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -246,18 +246,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    all possible spaceship combinations.  */
 #if GIMPLE
 (if (INTEGRAL_TYPE_P (type))
-  (for op (lt ne)
+ (for ltne (lt ne)
+      gtne (gt ne)
   (match (spaceship @0 @1)
-    (cond^ (le @0 @1) (negate (convert? (op @0 @1))) integer_onep)))
-  (for op (lt ne)
+   (cond^ (le @0 @1) (negate (convert? (ltne @0 @1))) integer_onep))
   (match (spaceship @0 @1)
-    (cond^ (le @1 @0) (convert? (op @1 @0)) integer_minus_onep)))
-  (for op (gt ne)
+    (cond^ (le @1 @0) (convert? (ltne @1 @0)) integer_minus_onep))
   (match (spaceship @0 @1)
-    (cond^ (ge @0 @1) (convert? (op @0 @1)) integer_minus_onep))))
-  (for op (gt ne)
+    (cond^ (ge @0 @1) (convert? (gtne @0 @1)) integer_minus_onep))
   (match (spaceship @0 @1)
-    (cond^ (ge @1 @0) (negate (convert? (op @1 @0))) integer_onep)))
+    (cond^ (ge @1 @0) (negate (convert? (gtne @1 @0))) integer_onep))))
 #endif
 
 /* Simplifications of operations with one constant operand and
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.