https://gcc.gnu.org/g:9b109826e0b0473572395f5837b455d57fa5a93c

commit r15-1408-g9b109826e0b0473572395f5837b455d57fa5a93c
Author: Pan Li <pan2...@intel.com>
Date:   Mon Jun 17 14:56:42 2024 +0800

    Match: Support form 11 for the unsigned scalar .SAT_SUB
    
    We missed one match pattern for the unsigned scalar .SAT_SUB,  aka
    form 11.
    
    Form 11:
      #define SAT_SUB_U_11(T) \
      T sat_sub_u_11_##T (T x, T y) \
      { \
        T ret; \
        bool overflow = __builtin_sub_overflow (x, y, &ret); \
        return overflow ? 0 : ret; \
      }
    
    Thus,  add above form 11 to the match pattern 
gimple_unsigned_integer_sat_sub.
    
    The below test suites are passed for this patch:
    1. The rv64gcv fully regression test with newlib.
    2. The rv64gcv build with glibc.
    3. The x86 bootstrap test.
    4. The x86 fully regression test.
    
    gcc/ChangeLog:
    
            * match.pd: Add form 11 match pattern for .SAT_SUB.
    
    Signed-off-by: Pan Li <pan2...@intel.com>

Diff:
---
 gcc/match.pd | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 99968d316eda..5c330a43ed01 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3186,13 +3186,20 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
       && types_match (type, @0, @1))))
 
-/* Unsigned saturation sub, case 7 (branch with .SUB_OVERFLOW).  */
+/* Unsigned saturation sub, case 7 (branch eq with .SUB_OVERFLOW).  */
 (match (unsigned_integer_sat_sub @0 @1)
  (cond^ (eq (imagpart (IFN_SUB_OVERFLOW@2 @0 @1)) integer_zerop)
   (realpart @2) integer_zerop)
  (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
       && types_match (type, @0, @1))))
 
+/* Unsigned saturation sub, case 8 (branch ne with .SUB_OVERFLOW).  */
+(match (unsigned_integer_sat_sub @0 @1)
+ (cond^ (ne (imagpart (IFN_SUB_OVERFLOW@2 @0 @1)) integer_zerop)
+   integer_zerop (realpart @2))
+ (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
+      && types_match (type, @0, @1))))
+
 /* x >  y  &&  x != XXX_MIN  -->  x > y
    x >  y  &&  x == XXX_MIN  -->  false . */
 (for eqne (eq ne)

Reply via email to