diff options
author | Yvan Roux <yvan.roux@linaro.org> | 2015-12-28 09:40:41 +0100 |
---|---|---|
committer | Linaro Code Review <review@review.linaro.org> | 2015-12-30 12:12:09 +0000 |
commit | 41fa3f1b335b8274596f2db5c20162b3f30aa54a (patch) | |
tree | 33b62a19b7e40a7ba534d803b99dcd8a1ac4697d | |
parent | 0a0679afd918911c9021b126e67c5d5e939a5db2 (diff) |
gcc/
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/
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: Ibdbbbc35a0a23de5adcddf25eebffeda7a1e578e
-rw-r--r-- | gcc/testsuite/gcc.dg/pr68317.c | 15 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 11 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr68317.c b/gcc/testsuite/gcc.dg/pr68317.c new file mode 100644 index 00000000000..7b565639588 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68317.c @@ -0,0 +1,15 @@ +/* { 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/tree-vrp.c b/gcc/tree-vrp.c index ec43bc64729..fda0b3f04b5 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4488,6 +4488,17 @@ 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); } |