diff options
author | Christophe Lyon <christophe.lyon@linaro.org> | 2016-01-07 14:33:19 +0100 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2016-01-07 14:58:54 +0100 |
commit | ceed650db42cc32a57d536f612afb3dc639d52d7 (patch) | |
tree | 4afd29d3cc48f34bc0ac21872647a3e9b7954ae9 | |
parent | dad84c9a5ef6b373364319202be3f01036ea3fa3 (diff) |
Fix bug #1980
gcc/
Revert backport from trunk r230150.
2015-11-11 Richard Biener <rguenth@gcc.gnu.org>
Jiong Wang <jiong.wang@arm.com>
PR tree-optimization/68234
* tree-vrp.c (vrp_visit_phi_node): Extend SCEV check to those loop PHI
node which estimiated to be VR_VARYING initially.
gcc/testsuite/
Revert backport from trunk r230150.
2015-11-11 Richard Biener <rguenth@gcc.gnu.org>
Jiong Wang <jiong.wang@arm.com>
* gcc.dg/tree-ssa/pr68234.c: New testcase.
gcc/
Revert backport from trunk r230754.
2015-11-23 Richard Biener <rguenth@gcc.gnu.org>
Jiong Wang <jiong.wang@arm.com>
PR tree-optimization/68317
PR tree-optimization/68326
* tree-vrp.c (adjust_range_with_scev): Call drop_tree_overflow if the
final min and max are not infinity.
gcc/testsuite/
Revert backport from trunk r230754.
2015-11-23 Richard Biener <rguenther@suse.de>
Jiong Wang <jiong.wang@arm.com>
PR tree-optimization/68317
PR tree-optimization/68326
* gcc.dg/pr68317.c: New testcase.
Change-Id: I3480edeff6d03eaa42c4d859b274f43f2441b70a
-rw-r--r-- | gcc/testsuite/gcc.dg/pr68317.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr68234.c | 24 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 50 |
3 files changed, 14 insertions, 75 deletions
diff --git a/gcc/testsuite/gcc.dg/pr68317.c b/gcc/testsuite/gcc.dg/pr68317.c deleted file mode 100644 index 7b565639588..00000000000 --- a/gcc/testsuite/gcc.dg/pr68317.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2" } */ - -void bar (int); - -void -foo () -{ - int index = 0; - - for (index; index <= 10; index--) - /* Result of the following multiply will overflow - when converted to signed int. */ - bar ((0xcafe + index) * 0xdead); -} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr68234.c b/gcc/testsuite/gcc.dg/tree-ssa/pr68234.c deleted file mode 100644 index e7c2a95aa4c..00000000000 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr68234.c +++ /dev/null @@ -1,24 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp2" } */ - -extern int nc; -void ff (unsigned long long); - -void -f (void) -{ - unsigned char resp[1024]; - int c; - int bl = 0; - unsigned long long *dwords = (unsigned long long *) (resp + 5); - for (c = 0; c < nc; c++) - { - /* PR middle-end/68234, this signed division should be optimized into - right shift as vrp pass should deduct range info of 'bl' falls into - positive number. */ - ff (dwords[bl / 64]); - bl++; - } -} - -/* { dg-final { scan-tree-dump ">> 6" "vrp2" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index fda0b3f04b5..877b7d580a7 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4488,17 +4488,6 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop, && is_positive_overflow_infinity (max))) return; - /* Even for valid range info, sometimes overflow flag will leak in. - As GIMPLE IL should have no constants with TREE_OVERFLOW set, we - drop them except for +-overflow_infinity which still need special - handling in vrp pass. */ - if (TREE_OVERFLOW_P (min) - && ! is_negative_overflow_infinity (min)) - min = drop_tree_overflow (min); - if (TREE_OVERFLOW_P (max) - && ! is_positive_overflow_infinity (max)) - max = drop_tree_overflow (max); - set_value_range (vr, VR_RANGE, min, max, vr->equiv); } @@ -8988,11 +8977,20 @@ vrp_visit_phi_node (gphi *phi) /* If we dropped either bound to +-INF then if this is a loop PHI node SCEV may known more about its value-range. */ - if (cmp_min > 0 || cmp_min < 0 + if ((cmp_min > 0 || cmp_min < 0 || cmp_max < 0 || cmp_max > 0) - goto scev_check; - - goto infinite_check; + && (l = loop_containing_stmt (phi)) + && l->header == gimple_bb (phi)) + adjust_range_with_scev (&vr_result, l, phi, lhs); + + /* If we will end up with a (-INF, +INF) range, set it to + VARYING. Same if the previous max value was invalid for + the type and we end up with vr_result.min > vr_result.max. */ + if ((vrp_val_is_max (vr_result.max) + && vrp_val_is_min (vr_result.min)) + || compare_values (vr_result.min, + vr_result.max) > 0) + goto varying; } /* If the new range is different than the previous value, keep @@ -9018,28 +9016,8 @@ update_range: /* Nothing changed, don't add outgoing edges. */ return SSA_PROP_NOT_INTERESTING; -varying: - set_value_range_to_varying (&vr_result); - -scev_check: - /* If this is a loop PHI node SCEV may known more about its value-range. - scev_check can be reached from two paths, one is a fall through from above - "varying" label, the other is direct goto from code block which tries to - avoid infinite simulation. */ - if ((l = loop_containing_stmt (phi)) - && l->header == gimple_bb (phi)) - adjust_range_with_scev (&vr_result, l, phi, lhs); - -infinite_check: - /* If we will end up with a (-INF, +INF) range, set it to - VARYING. Same if the previous max value was invalid for - the type and we end up with vr_result.min > vr_result.max. */ - if ((vr_result.type == VR_RANGE || vr_result.type == VR_ANTI_RANGE) - && !((vrp_val_is_max (vr_result.max) && vrp_val_is_min (vr_result.min)) - || compare_values (vr_result.min, vr_result.max) > 0)) - goto update_range; - /* No match found. Set the LHS to VARYING. */ +varying: set_value_range_to_varying (lhs_vr); return SSA_PROP_VARYING; } |