From: Pan Li <pan2...@intel.com> Like widen_mul based pattern, we would like introduce the mul based pattern as well. The pattern is quite simple compares to the widen_mul, thus add new instead of the for loop in match.pd.
gcc/ChangeLog: * match.pd: Add mul based unsigned SAT_MUL. Signed-off-by: Pan Li <pan2...@intel.com> --- gcc/match.pd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/match.pd b/gcc/match.pd index 4903552c82a..cd98e97125d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3598,7 +3598,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (convert@4 (min (widen_mult:c@3 (convert@5 (convert @0)) (convert@6 (convert @1))) INTEGER_CST@2)) - (if (types_match (type, @0, @1) && types_match (type, @4)) + (if (types_match (type, @0, @1)) (with { unsigned prec = TYPE_PRECISION (type); @@ -3611,6 +3611,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) bool widen_mult_p = cvt5_prec == cvt6_prec && widen_prec == cvt6_prec * 2; } (if (widen_prec > prec && c2_is_max_p && widen_mult_p))))) + (match (unsigned_integer_sat_mul @0 @1) + (convert@4 (min (mult:c@3 (convert @0) (convert @1)) INTEGER_CST@2)) + (if (types_match (type, @0, @1)) + (with + { + unsigned prec = TYPE_PRECISION (type); + unsigned widen_prec = TYPE_PRECISION (TREE_TYPE (@3)); + wide_int c2 = wi::to_wide (@2); + wide_int max = wi::mask (prec, false, widen_prec); + bool c2_is_max_p = wi::eq_p (c2, max); + } + (if (widen_prec > prec && c2_is_max_p))))) ) /* The boundary condition for case 10: IMM = 1: -- 2.43.0