diff options
author | Richard Guenther <rguenther@suse.de> | 2009-04-24 19:10:55 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2009-04-24 19:10:55 +0000 |
commit | 77a302647e6de91919e0e9c8c2383326715e4eee (patch) | |
tree | 97a0566806e8184e997baf818e519cac788dd9bd /gcc/tree-vrp.c | |
parent | 2b6da65c33c24de56b95b42c5dd2c771c425ef7c (diff) | |
download | gcc-77a302647e6de91919e0e9c8c2383326715e4eee.zip gcc-77a302647e6de91919e0e9c8c2383326715e4eee.tar.gz gcc-77a302647e6de91919e0e9c8c2383326715e4eee.tar.bz2 |
tree-vrp.c (extract_range_from_binary_expr): Handle overflow from unsigned additions.
2009-04-24 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (extract_range_from_binary_expr): Handle overflow
from unsigned additions.
* gcc.dg/tree-ssa/vrp48.c: New testcase.
From-SVN: r146742
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index e3d14b2..8464ffd 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2248,6 +2248,22 @@ extract_range_from_binary_expr (value_range_t *vr, the same end of each range. */ min = vrp_int_const_binop (code, vr0.min, vr1.min); max = vrp_int_const_binop (code, vr0.max, vr1.max); + + /* If both additions overflowed the range kind is still correct. + This happens regularly with subtracting something in unsigned + arithmetic. + ??? See PR30318 for all the cases we do not handle. */ + if (code == PLUS_EXPR + && (TREE_OVERFLOW (min) && !is_overflow_infinity (min)) + && (TREE_OVERFLOW (max) && !is_overflow_infinity (max))) + { + min = build_int_cst_wide (TREE_TYPE (min), + TREE_INT_CST_LOW (min), + TREE_INT_CST_HIGH (min)); + max = build_int_cst_wide (TREE_TYPE (max), + TREE_INT_CST_LOW (max), + TREE_INT_CST_HIGH (max)); + } } else if (code == MULT_EXPR || code == TRUNC_DIV_EXPR |