diff options
author | Pan Li <pan2.li@intel.com> | 2024-06-17 14:56:42 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2024-06-18 21:44:04 +0800 |
commit | 9b109826e0b0473572395f5837b455d57fa5a93c (patch) | |
tree | 9489aeaf3767b0a76c623d4ff91aeec73c31a6dc | |
parent | 7f9be55a4630134a237219af9cc8143e02080380 (diff) | |
download | gcc-9b109826e0b0473572395f5837b455d57fa5a93c.zip gcc-9b109826e0b0473572395f5837b455d57fa5a93c.tar.gz gcc-9b109826e0b0473572395f5837b455d57fa5a93c.tar.bz2 |
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.li@intel.com>
-rw-r--r-- | gcc/match.pd | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 99968d3..5c330a4 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) |