diff mbox series

[v2,04/10] Match: Remove usadd_left_part_1 as it has only one reference [NFC]

Message ID 20241031062742.2709845-4-pan2.li@intel.com
State New
Headers show
Series [v2,01/10] Match: Simplify branch form 4 of unsigned SAT_ADD into branchless | expand

Commit Message

Li, Pan2 Oct. 31, 2024, 6:27 a.m. UTC
From: Pan Li <pan2.li@intel.com>

In previous, we extract matching usadd_left_part_1 to avoid duplication.
After we simplify some usadd patterns into cheap form, there will be
only one reference to this matching.  Thus, remove this matching pattern
and unfold it to the reference place.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/ChangeLog:

	* match.pd: Remove matching usadd_left_part_1 and unfold it at
	its reference place

Signed-off-by: Pan Li <pan2.li@intel.com>
---
 gcc/match.pd | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/gcc/match.pd b/gcc/match.pd
index 2390e96672e..94e9f094631 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3086,14 +3086,6 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        || POINTER_TYPE_P (itype))
       && wi::eq_p (wi::to_wide (int_cst), wi::max_value (itype))))))
 
-/* Unsigned Saturation Add */
-/* SAT_ADD = usadd_left_part_1 | usadd_right_part_1, aka:
-   SAT_ADD = (X + Y) | -((X + Y) < X)  */
-(match (usadd_left_part_1 @0 @1)
- (plus:c @0 @1)
- (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
-      && types_match (type, @0, @1))))
-
 /* SAT_ADD = usadd_left_part_2 | usadd_right_part_2, aka:
    SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | (IMAGPART_EXPR <.ADD_OVERFLOW> != 0) */
 (match (usadd_left_part_2 @0 @1)
@@ -3101,7 +3093,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
       && types_match (type, @0, @1))))
 
-/* SAT_ADD = usadd_left_part_1 | usadd_right_part_1, aka:
+/* SAT_ADD = (X + Y) | usadd_right_part_1, aka:
    SAT_ADD = (X + Y) | -((type)(X + Y) < X)  */
 (match (usadd_right_part_1 @0 @1)
  (negate (convert (lt (plus:c @0 @1) @0)))
@@ -3129,7 +3121,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
       && types_match (type, @0, @1))))
 
-/* We cannot merge or overload usadd_left_part_1 and usadd_left_part_2
+/* We cannot merge or overload (X + Y) and usadd_left_part_2
    because the sub part of left_part_2 cannot work with right_part_1.
    For example, left_part_2 pattern focus one .ADD_OVERFLOW but the
    right_part_1 has nothing to do with .ADD_OVERFLOW.  */
@@ -3138,7 +3130,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    SAT_U_ADD = (X + Y) | - ((X + Y) < X) or
    SAT_U_ADD = (X + Y) | - (X > (X + Y)).  */
 (match (unsigned_integer_sat_add @0 @1)
- (bit_ior:c (usadd_left_part_1 @0 @1) (usadd_right_part_1 @0 @1)))
+ (bit_ior:c (plus:c @0 @1) (usadd_right_part_1 @0 @1)))
 
 /* Unsigned saturation add, case 2 (branchless with .ADD_OVERFLOW):
    SAT_ADD = REALPART_EXPR <.ADD_OVERFLOW> | -IMAGPART_EXPR <.ADD_OVERFLOW> or