From 3cc2fdfd93efaf1b2e8bcffe84c20cbd1ffc4e96 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Mon, 17 Sep 2018 06:07:52 +0000 Subject: [PATCH] tree-vrp.c (extract_range_from_unary_expr): Do not special case symbolics or VR_VARYING ranges for ABS_EXPR. * tree-vrp.c (extract_range_from_unary_expr): Do not special case symbolics or VR_VARYING ranges for ABS_EXPR. * wide-int-range.cc (wide_int_range_abs): Return positive numbers when range will wrap. From-SVN: r264356 --- gcc/ChangeLog | 7 +++++++ gcc/tree-vrp.c | 5 ----- gcc/wide-int-range.cc | 9 ++++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9f6b4b53fc4..59b73ed0898 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-09-17 Aldy Hernandez + + * tree-vrp.c (extract_range_from_unary_expr): Do not special case + symbolics or VR_VARYING ranges for ABS_EXPR. + * wide-int-range.cc (wide_int_range_abs): Return positive numbers + when range will wrap. + 2018-09-15 Eric Botcazou PR middle-end/86864 diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 1adb919a6df..622ccbc2df7 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1894,11 +1894,6 @@ extract_range_from_unary_expr (value_range *vr, } else if (code == ABS_EXPR) { - if (vr0.type != VR_RANGE || symbolic_range_p (&vr0)) - { - set_value_range_to_varying (vr); - return; - } wide_int wmin, wmax; wide_int vr0_min, vr0_max; extract_range_into_wide_ints (&vr0, sign, prec, vr0_min, vr0_max); diff --git a/gcc/wide-int-range.cc b/gcc/wide-int-range.cc index 8a3dfd25684..a85fe9f9ad7 100644 --- a/gcc/wide-int-range.cc +++ b/gcc/wide-int-range.cc @@ -728,10 +728,13 @@ wide_int_range_abs (wide_int &min, wide_int &max, } /* If the new range has its limits swapped around (MIN > MAX), then - the operation caused one of them to wrap around, mark the new - range VARYING. */ + the operation caused one of them to wrap around. The only thing + we know is that the result is positive. */ if (wi::gt_p (min, max, sign)) - return false; + { + min = wi::zero (prec); + max = max_value; + } return true; } -- 2.30.2