[PATCH 2/2] match: Combine two patterns into one for. [PR19832]

Kael Andrew Franco <[email protected]> Sat, 1 Aug 2026 10:31:32 -0400
Newsgroups gmane.comp.gcc.patches
Message-ID <CACAb0qcB-KRRocnwkPbtu7dPGHVM4zDT2_T6PM44HLGtcGgazg@mail.gmail.com>
From 296ae59671c343e7f9ba51a786fe8be8206e3849 Mon Sep 17 00:00:00 2001
From: Kael Andrew Alonzo Franco <[email protected]>
Date: Fri, 31 Jul 2026 20:45:43 -0400
Subject: [PATCH 2/2] 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.

Signed-off-by: Kael Andrew Franco <[email protected]>
---
 gcc/match.pd | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index aa7cada1b64..5b8340ca900 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) */
-- 
2.55.0