Commit e8f1d5cb by Aldy Hernandez Committed by Aldy Hernandez

tree-vrp.c (extract_range_from_multiplicative_op): Remove overflow wraps argument.

        * 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.

From-SVN: r265238
parent fa6b20f3
2018-10-17 Aldy Hernandez <aldyh@redhat.com> 2018-10-17 Aldy Hernandez <aldyh@redhat.com>
* 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 <aldyh@redhat.com>
* wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to * wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to
use sign as argument. use sign as argument.
* tree-vrp.c (extract_range_from_binary_expr_1): Pass sign to * tree-vrp.c (extract_range_from_binary_expr_1): Pass sign to
...@@ -1003,13 +1003,12 @@ extract_range_from_multiplicative_op (value_range *vr, ...@@ -1003,13 +1003,12 @@ extract_range_from_multiplicative_op (value_range *vr,
wide_int vr1_lb = wi::to_wide (vr1->min); wide_int vr1_lb = wi::to_wide (vr1->min);
wide_int vr1_ub = wi::to_wide (vr1->max); wide_int vr1_ub = wi::to_wide (vr1->max);
bool overflow_undefined = TYPE_OVERFLOW_UNDEFINED (type); bool overflow_undefined = TYPE_OVERFLOW_UNDEFINED (type);
bool overflow_wraps = TYPE_OVERFLOW_WRAPS (type);
unsigned prec = TYPE_PRECISION (type); unsigned prec = TYPE_PRECISION (type);
if (wide_int_range_multiplicative_op (res_lb, res_ub, if (wide_int_range_multiplicative_op (res_lb, res_ub,
code, TYPE_SIGN (type), prec, code, TYPE_SIGN (type), prec,
vr0_lb, vr0_ub, vr1_lb, vr1_ub, vr0_lb, vr0_ub, vr1_lb, vr1_ub,
overflow_undefined, overflow_wraps)) overflow_undefined))
set_and_canonicalize_value_range (vr, VR_RANGE, set_and_canonicalize_value_range (vr, VR_RANGE,
wide_int_to_tree (type, res_lb), wide_int_to_tree (type, res_lb),
wide_int_to_tree (type, res_ub), NULL); wide_int_to_tree (type, res_ub), NULL);
...@@ -1549,8 +1548,7 @@ extract_range_from_binary_expr_1 (value_range *vr, ...@@ -1549,8 +1548,7 @@ extract_range_from_binary_expr_1 (value_range *vr,
wi::to_wide (vr0.max), wi::to_wide (vr0.max),
wi::to_wide (vr1.min), wi::to_wide (vr1.min),
wi::to_wide (vr1.max), wi::to_wide (vr1.max),
TYPE_OVERFLOW_UNDEFINED (expr_type), TYPE_OVERFLOW_UNDEFINED (expr_type)))
TYPE_OVERFLOW_WRAPS (expr_type)))
{ {
min = wide_int_to_tree (expr_type, res_lb); min = wide_int_to_tree (expr_type, res_lb);
max = wide_int_to_tree (expr_type, res_ub); max = wide_int_to_tree (expr_type, res_ub);
...@@ -1595,7 +1593,6 @@ extract_range_from_binary_expr_1 (value_range *vr, ...@@ -1595,7 +1593,6 @@ extract_range_from_binary_expr_1 (value_range *vr,
dividend_min, dividend_max, dividend_min, dividend_max,
divisor_min, divisor_max, divisor_min, divisor_max,
TYPE_OVERFLOW_UNDEFINED (expr_type), TYPE_OVERFLOW_UNDEFINED (expr_type),
TYPE_OVERFLOW_WRAPS (expr_type),
extra_range_p, extra_min, extra_max)) extra_range_p, extra_min, extra_max))
{ {
set_value_range_to_varying (vr); set_value_range_to_varying (vr);
......
...@@ -268,7 +268,7 @@ wide_int_range_mult_wrapping (wide_int &res_lb, ...@@ -268,7 +268,7 @@ wide_int_range_mult_wrapping (wide_int &res_lb,
Return TRUE if we were able to perform the operation. 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 range must be canonicalized by the caller because its components
may be swapped. */ may be swapped. */
...@@ -281,8 +281,7 @@ wide_int_range_multiplicative_op (wide_int &res_lb, wide_int &res_ub, ...@@ -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 &vr0_ub,
const wide_int &vr1_lb, const wide_int &vr1_lb,
const wide_int &vr1_ub, const wide_int &vr1_ub,
bool overflow_undefined, bool overflow_undefined)
bool overflow_wraps)
{ {
/* Multiplications, divisions and shifts are a bit tricky to handle, /* Multiplications, divisions and shifts are a bit tricky to handle,
depending on the mix of signs we have in the two ranges, we 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, ...@@ -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 (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 MAX1) and then figure the smallest and largest values to form
the new range. */ 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, return wide_int_range_mult_wrapping (res_lb, res_ub,
sign, prec, sign, prec,
vr0_lb, vr0_ub, vr1_lb, vr1_ub); vr0_lb, vr0_ub, vr1_lb, vr1_ub);
...@@ -320,7 +319,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, ...@@ -320,7 +319,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub,
signop sign, unsigned prec, signop sign, unsigned prec,
const wide_int &vr0_lb, const wide_int &vr0_ub, const wide_int &vr0_lb, const wide_int &vr0_ub,
const wide_int &vr1_lb, const wide_int &vr1_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. */ /* Transform left shifts by constants into multiplies. */
if (wi::eq_p (vr1_lb, vr1_ub)) if (wi::eq_p (vr1_lb, vr1_ub))
...@@ -330,8 +329,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_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, return wide_int_range_multiplicative_op (res_lb, res_ub,
MULT_EXPR, sign, prec, MULT_EXPR, sign, prec,
vr0_lb, vr0_ub, tmp, tmp, vr0_lb, vr0_ub, tmp, tmp,
overflow_undefined, /*overflow_undefined=*/false);
/*overflow_wraps=*/true);
} }
int overflow_pos = prec; int overflow_pos = prec;
...@@ -387,8 +385,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, ...@@ -387,8 +385,7 @@ wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub,
LSHIFT_EXPR, sign, prec, LSHIFT_EXPR, sign, prec,
vr0_lb, vr0_ub, vr0_lb, vr0_ub,
vr1_lb, vr1_ub, vr1_lb, vr1_ub,
overflow_undefined, overflow_undefined);
overflow_wraps);
return false; return false;
} }
...@@ -785,7 +782,6 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, ...@@ -785,7 +782,6 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax,
const wide_int &dividend_min, const wide_int &dividend_max, const wide_int &dividend_min, const wide_int &dividend_max,
const wide_int &divisor_min, const wide_int &divisor_max, const wide_int &divisor_min, const wide_int &divisor_max,
bool overflow_undefined, bool overflow_undefined,
bool overflow_wraps,
bool &extra_range_p, bool &extra_range_p,
wide_int &extra_min, wide_int &extra_max) wide_int &extra_min, wide_int &extra_max)
{ {
...@@ -796,8 +792,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, ...@@ -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, return wide_int_range_multiplicative_op (wmin, wmax, code, sign, prec,
dividend_min, dividend_max, dividend_min, dividend_max,
divisor_min, divisor_max, divisor_min, divisor_max,
overflow_undefined, overflow_undefined);
overflow_wraps);
/* If flag_non_call_exceptions, we must not eliminate a division /* If flag_non_call_exceptions, we must not eliminate a division
by zero. */ by zero. */
...@@ -818,8 +813,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, ...@@ -818,8 +813,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax,
code, sign, prec, code, sign, prec,
dividend_min, dividend_max, dividend_min, dividend_max,
divisor_min, wi::minus_one (prec), divisor_min, wi::minus_one (prec),
overflow_undefined, overflow_undefined))
overflow_wraps))
return false; return false;
extra_range_p = true; extra_range_p = true;
} }
...@@ -831,8 +825,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax, ...@@ -831,8 +825,7 @@ wide_int_range_div (wide_int &wmin, wide_int &wmax,
code, sign, prec, code, sign, prec,
dividend_min, dividend_max, dividend_min, dividend_max,
wi::one (prec), divisor_max, wi::one (prec), divisor_max,
overflow_undefined, overflow_undefined))
overflow_wraps))
return false; return false;
} }
else else
......
...@@ -42,14 +42,12 @@ extern bool wide_int_range_multiplicative_op (wide_int &res_lb, ...@@ -42,14 +42,12 @@ extern bool wide_int_range_multiplicative_op (wide_int &res_lb,
const wide_int &vr0_ub, const wide_int &vr0_ub,
const wide_int &vr1_lb, const wide_int &vr1_lb,
const wide_int &vr1_ub, const wide_int &vr1_ub,
bool overflow_undefined, bool overflow_undefined);
bool overflow_wraps);
extern bool wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub, extern bool wide_int_range_lshift (wide_int &res_lb, wide_int &res_ub,
signop sign, unsigned prec, signop sign, unsigned prec,
const wide_int &, const wide_int &, const wide_int &, const wide_int &,
const wide_int &, const wide_int &, const wide_int &, const wide_int &,
bool overflow_undefined, bool overflow_undefined);
bool overflow_wraps);
extern void wide_int_range_set_zero_nonzero_bits (signop, extern void wide_int_range_set_zero_nonzero_bits (signop,
const wide_int &lb, const wide_int &lb,
const wide_int &ub, const wide_int &ub,
...@@ -124,7 +122,6 @@ extern bool wide_int_range_div (wide_int &wmin, wide_int &wmax, ...@@ -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_min,
const wide_int &divisor_max, const wide_int &divisor_max,
bool overflow_undefined, bool overflow_undefined,
bool overflow_wraps,
bool &extra_range_p, bool &extra_range_p,
wide_int &extra_min, wide_int &extra_max); wide_int &extra_min, wide_int &extra_max);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment