diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4768b9635f8..6cfaac1690d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2018-10-17 Aldy Hernandez + + * tree-vrp.c (extract_range_from_multiplicative_op): Remove + overflow wraps argument. + (extract_range_from_binary_expr_1): Do not pass overflow wraps to + wide_int_range_multiplicative_op. + * wide-int-range.cc (wide_int_range_mult_wrapping): Remove + overflow wraps argument. + (wide_int_range_multiplicative_op): Same. + (wide_int_range_lshift): Same. + (wide_int_range_div): Same. + * wide-int-range.h (wide_int_range_multiplicative_op): Same. + (wide_int_range_lshift): Same. + (wide_int_range_div): Same. + 2018-10-17 Aldy Hernandez * wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index c519613bb28..0a42da7005e 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1003,13 +1003,12 @@ extract_range_from_multiplicative_op (value_range *vr, wide_int vr1_lb = wi::to_wide (vr1->min); wide_int vr1_ub = wi::to_wide (vr1->max); bool overflow_undefined = TYPE_OVERFLOW_UNDEFINED (type); - bool overflow_wraps = TYPE_OVERFLOW_WRAPS (type); unsigned prec = TYPE_PRECISION (type); if (wide_int_range_multiplicative_op (res_lb, res_ub, - code, TYPE_SIGN (type), prec, - vr0_lb, vr0_ub, vr1_lb, vr1_ub, - overflow_undefined, overflow_wraps)) + code, TYPE_SIGN (type), prec, + vr0_lb, vr0_ub, vr1_lb, vr1_ub, + overflow_undefined)) set_and_canonicalize_value_range (vr, VR_RANGE, wide_int_to_tree (type, res_lb), wide_int_to_tree (type, res_ub), NULL); @@ -1549,8 +1548,7 @@ extract_range_from_binary_expr_1 (value_range *vr, wi::to_wide (vr0.max), wi::to_wide (vr1.min), wi::to_wide (vr1.max), - TYPE_OVERFLOW_UNDEFINED (expr_type), - TYPE_OVERFLOW_WRAPS (expr_type))) + TYPE_OVERFLOW_UNDEFINED (expr_type))) { min = wide_int_to_tree (expr_type, res_lb); max = wide_int_to_tree (expr_type, res_ub); @@ -1595,7 +1593,6 @@ extract_range_from_binary_expr_1 (value_range *vr, dividend_min, dividend_max, divisor_min, divisor_max, TYPE_OVERFLOW_UNDEFINED (expr_type), - TYPE_OVERFLOW_WRAPS (expr_type), extra_range_p, extra_min, extra_max)) { set_value_range_to_varying (vr); diff --git a/gcc/wide-int-range.cc b/gcc/wide-int-range.cc index a85fe9f9ad7..8978b5aecfd 100644 --- a/gcc/wide-int-range.cc +++ b/gcc/wide-int-range.cc @@ -268,7 +268,7 @@ wide_int_range_mult_wrapping (wide_int &res_lb, Return TRUE if we were able to perform the operation. - NOTE: If code is MULT_EXPR and TYPE_OVERFLOW_WRAPS, the resulting + NOTE: If code is MULT_EXPR and !TYPE_OVERFLOW_UNDEFINED, the resulting range must be canonicalized by the caller because its components may be swapped. */ @@ -281,8 +281,7 @@ wide_int_range_multiplicative_op (wide_int &res_lb, wide_int &res_ub, const wide_int &vr0_ub, const wide_int &vr1_lb, const wide_int &vr1_ub, - bool overflow_undefined, - bool overflow_wraps) + bool overflow_undefined) { /* Multiplications, divisions and shifts are a bit tricky to handle, depending on the mix of signs we have in the two ranges, we @@ -296,7 +295,7 @@ wide_int_range_multiplicative_op (wide_int &res_lb, wide_int &res_ub, (MIN0 OP MIN1, MIN0 OP MAX1, MAX0 OP MIN1 and MAX0 OP MAX0 OP MAX1) and then figure the smallest and largest values to form the new range. */ - if (code == MULT_EXPR && overflow_wraps) + if (code == MULT_EXPR && !overflow_undefined) return wide_int_range_mult_wrapping (res_lb, res_ub, sign, prec, vr0_lb, vr0_ub, vr1_lb, vr1_ub); @@ -320,7 +319,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, signop sign, unsigned prec, const wide_int &vr0_lb, const wide_int &vr0_ub, const wide_int &vr1_lb, const wide_int &vr1_ub, - bool overflow_undefined, bool overflow_wraps) + bool overflow_undefined) { /* Transform left shifts by constants into multiplies. */ if (wi::eq_p (vr1_lb, vr1_ub)) @@ -330,8 +329,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, return wide_int_range_multiplicative_op (res_lb, res_ub, MULT_EXPR, sign, prec, vr0_lb, vr0_ub, tmp, tmp, - overflow_undefined, - /*overflow_wraps=*/true); + /*overflow_undefined=*/false); } int overflow_pos = prec; @@ -387,8 +385,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, LSHIFT_EXPR, sign, prec, vr0_lb, vr0_ub, vr1_lb, vr1_ub, - overflow_undefined, - overflow_wraps); + overflow_undefined); return false; } @@ -785,7 +782,6 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, const wide_int ÷nd_min, const wide_int ÷nd_max, const wide_int &divisor_min, const wide_int &divisor_max, bool overflow_undefined, - bool overflow_wraps, bool &extra_range_p, wide_int &extra_min, wide_int &extra_max) { @@ -796,8 +792,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, return wide_int_range_multiplicative_op (wmin, wmax, code, sign, prec, dividend_min, dividend_max, divisor_min, divisor_max, - overflow_undefined, - overflow_wraps); + overflow_undefined); /* If flag_non_call_exceptions, we must not eliminate a division by zero. */ @@ -818,8 +813,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, code, sign, prec, dividend_min, dividend_max, divisor_min, wi::minus_one (prec), - overflow_undefined, - overflow_wraps)) + overflow_undefined)) return false; extra_range_p = true; } @@ -831,8 +825,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, code, sign, prec, dividend_min, dividend_max, wi::one (prec), divisor_max, - overflow_undefined, - overflow_wraps)) + overflow_undefined)) return false; } else diff --git a/gcc/wide-int-range.h b/gcc/wide-int-range.h index 0b2dd223987..961d26dbb08 100644 --- a/gcc/wide-int-range.h +++ b/gcc/wide-int-range.h @@ -42,14 +42,12 @@ extern bool wide_int_range_multiplicative_op (wide_int &res_lb, const wide_int &vr0_ub, const wide_int &vr1_lb, const wide_int &vr1_ub, - bool overflow_undefined, - bool overflow_wraps); + bool overflow_undefined); extern bool wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, signop sign, unsigned prec, const wide_int &, const wide_int &, const wide_int &, const wide_int &, - bool overflow_undefined, - bool overflow_wraps); + bool overflow_undefined); extern void wide_int_range_set_zero_nonzero_bits (signop, const wide_int &lb, const wide_int &ub, @@ -124,7 +122,6 @@ extern bool wide_int_range_div (wide_int &wmin, wide_int &wmax, const wide_int &divisor_min, const wide_int &divisor_max, bool overflow_undefined, - bool overflow_wraps, bool &extra_range_p, wide_int &extra_min, wide_int &extra_max);