[gcc r17-2903] match: Combine four simplify into one for. [PR63387]

Kael Andrew Franco via Gcc-cvs <[email protected]> Mon, 3 Aug 2026 19:26:21 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:8239d935883516d5c1b51f68d56c926deeaafc8e

commit r17-2903-g8239d935883516d5c1b51f68d56c926deeaafc8e
Author: Kael Andrew Alonzo Franco <[email protected]>
Date:   Mon Aug 3 15:25:43 2026 -0400

    match: Combine four simplify into one for. [PR63387]
    
    This reduce genmatch's outputted C++ code.
    
    Bootstrapped and regtested on x86_64-pc-linux-gnu.
    
            PR tree-optimization/63387
    
    gcc/ChangeLog:
    
            * match.pd: Combine four simplify into one for.
    
    Signed-off-by: Kael Andrew Franco <[email protected]>

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

diff --git a/gcc/match.pd b/gcc/match.pd
index 00a0adaba87e..8700541fc3f3 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7958,20 +7958,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
      (cmp2 @0 { build_zero_cst (TREE_TYPE (@0)); }))))))
 
 /* Unordered tests if either argument is a NaN.  */
-(simplify
- (bit_ior (unordered @0 @0) (unordered @1 @1))
- (if (types_match (@0, @1))
-  (unordered @0 @1)))
-(simplify
- (bit_and (ordered @0 @0) (ordered @1 @1))
- (if (types_match (@0, @1))
-  (ordered @0 @1)))
-(simplify
- (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
- @2)
-(simplify
- (bit_and:c (ordered @0 @0) (ordered:c@2 @0 @1))
- @2)
+(for bitop (bit_ior   bit_and)
+     op    (unordered ordered)
+ (simplify
+  (bitop (op @0 @0) (op @1 @1))
+  (if (types_match (@0, @1))
+   (op @0 @1)))
+ (simplify
+  (bitop:c (op @0 @0) (op:c@2 @0 @1))
+  @2))
 
 /* A & (2**N - 1) <= 2**K - 1 -> A & (2**N - 2**K) == 0
    A & (2**N - 1) >  2**K - 1 -> A & (2**N - 2**K) != 0