diff options
author | Pan Li <pan2.li@intel.com> | 2025-08-01 10:37:58 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2025-08-11 21:10:09 +0800 |
commit | deb0a4c80414697d07e808b1d2500229eb281600 (patch) | |
tree | 89aa9f0d1376bdf67d7cb3c102cdc6a3aa7a8cee /gcc | |
parent | 388984693487ae0626e9f24d31ebf152254a5227 (diff) | |
download | gcc-deb0a4c80414697d07e808b1d2500229eb281600.zip gcc-deb0a4c80414697d07e808b1d2500229eb281600.tar.gz gcc-deb0a4c80414697d07e808b1d2500229eb281600.tar.bz2 |
Match: Add form 2 for unsigned SAT_MUL
This patch would like to try to match the the unsigned
SAT_MUL form 2, aka below:
#define DEF_SAT_U_MUL_FMT_2(T) \
T __attribute__((noinline)) \
sat_u_mul_##T##_fmt_2 (T a, T b) \
{ \
T result; \
if (__builtin_mul_overflow(a, b, &result)) \
return -1; \
else \
return result; \
}
While T is uint8_t, uint16_t, uint32_t and uint64_t.
gcc/ChangeLog:
* match.pd: Add form 2 for unsigned SAT_MUL.
Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/match.pd | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 06a4a91..66e8a78 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3623,6 +3623,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) bool c2_is_max_p = wi::eq_p (c2, max); } (if (widen_prec > prec && c2_is_max_p))))) + (match (unsigned_integer_sat_mul @0 @1) + /* SAT_U_MUL (X, Y) = { + T result; + if (__builtin_mul_overflow (X, Y, &result)) + return -1; + else + return -(T)overflow_p | result; + } + while T can be uint8_t, uint16_t, uint32_t and uint64_t. */ + (cond^ (ne (imagpart (IFN_MUL_OVERFLOW:c@2 @0 @1)) integer_zerop) + integer_minus_onep (realpart @2)) + (if (types_match (type, @0, @1)))) ) /* The boundary condition for case 10: IMM = 1: |