diff --git a/gcc/match.pd b/gcc/match.pd index a2e205b3207..4edfa2ae2c9 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3239,16 +3239,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (match (unsigned_integer_sat_trunc @0) (bit_ior:c (negate (convert (gt @0 INTEGER_CST@1))) (convert @0)) - (with { + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && TYPE_UNSIGNED (TREE_TYPE (@0))) + (with + { unsigned itype_precision = TYPE_PRECISION (TREE_TYPE (@0)); unsigned otype_precision = TYPE_PRECISION (type); - wide_int trunc_max = wi::mask (itype_precision / 2, false, itype_precision); + wide_int trunc_max = wi::mask (otype_precision, false, itype_precision); wide_int int_cst = wi::to_wide (@1, itype_precision); } - (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) - && TYPE_UNSIGNED (TREE_TYPE (@0)) - && otype_precision < itype_precision - && wi::eq_p (trunc_max, int_cst))))) + (if (otype_precision < itype_precision && wi::eq_p (trunc_max, int_cst)))))) /* x > y && x != XXX_MIN --> x > y x > y && x == XXX_MIN --> false . */