[gcc r17-2887] match: Combine two patterns into one for. [PR19832]

Kael Andrew Franco via Gcc-cvs <[email protected]> Sun, 2 Aug 2026 11:54:45 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:529304e456c9be38139325e3c2567f7d2a93e7c8

commit r17-2887-g529304e456c9be38139325e3c2567f7d2a93e7c8
Author: Kael Andrew Alonzo Franco <[email protected]>
Date:   Sun Aug 2 07:53:46 2026 -0400

    match: Combine two patterns into one for. [PR19832]
    
    From r14-3606, this reduce genmatch's outputted C++ code.
    
    Bootstrapped and tested on x86_64-pc-linux-gnu.
    
            PR tree-optimization/19832
    
    gcc/ChangeLog:
    
            * match.pd: Combine two patterns into one for.

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

diff --git a/gcc/match.pd b/gcc/match.pd
index 2731456ba108..cfaead7c67dd 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6845,13 +6845,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
 (for cnd (cond vec_cond)
  /* (a != b) ? (a - b) : 0 -> (a - b) */
- (simplify
-  (cnd (ne:c @0 @1) (minus@2 @0 @1) integer_zerop)
-  @2)
  /* (a != b) ? (a ^ b) : 0 -> (a ^ b) */
- (simplify
-  (cnd (ne:c @0 @1) (bit_xor@2 @0 @1) integer_zerop)
-  @2)
+ (for op (minus bit_xor)
+  (simplify
+   (cnd (ne:c @0 @1) (op@2 @0 @1) integer_zerop)
+   @2))
  /* (a != b) ? (a & b) : a -> (a & b) */
  /* (a != b) ? (a | b) : a -> (a | b) */
  /* (a != b) ? min(a,b) : a -> min(a,b) */