diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-24 19:10:55 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-24 19:10:55 +0000 |
commit | 458e27ec3cc5a4ee4edc7a1ac004c1394e37427a (patch) | |
tree | 97a0566806e8184e997baf818e519cac788dd9bd /gcc/tree-vrp.c | |
parent | 88c32270aa798c7e60d83f97eb456a440c7db5db (diff) | |
download | gcc-458e27ec3cc5a4ee4edc7a1ac004c1394e37427a.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146742 138bc75d-0d04-0410-961f-82ee72b054a4
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 e3d14b29182..8464ffddd89 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 |