aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorKazu Hirata <kazu@codesourcery.com>2005-06-23 16:04:09 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2005-06-23 16:04:09 +0000
commite57f2b4144b1346f1461faaf0d610699e794a8f2 (patch)
tree4a87e6c81eafd68c0f78223179ac6386a7acd539 /gcc/tree-vrp.c
parenta31de5014b57e76226aed7e968466e6d026cb260 (diff)
downloadgcc-e57f2b4144b1346f1461faaf0d610699e794a8f2.zip
gcc-e57f2b4144b1346f1461faaf0d610699e794a8f2.tar.gz
gcc-e57f2b4144b1346f1461faaf0d610699e794a8f2.tar.bz2
re PR tree-optimization/22117 (VRP thinks <ptr type> + <ptr type> is always nonnull.)
gcc/ PR tree-optimization/22117 * tree-vrp.c (extract_range_from_binary_expr): Compute a correct range when adding two pointers. testsuite/ PR tree-optimization/22117 * gcc.dg/tree-ssa/pr22117.c: New. From-SVN: r101272
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 81b0c0a..284208b 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1073,7 +1073,14 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr)
ivopts is generating expressions with pointer multiplication
in them. */
if (code == PLUS_EXPR)
- set_value_range_to_nonnull (vr, TREE_TYPE (expr));
+ {
+ if (range_is_nonnull (&vr0) || range_is_nonnull (&vr1))
+ set_value_range_to_nonnull (vr, TREE_TYPE (expr));
+ else if (range_is_null (&vr0) && range_is_null (&vr1))
+ set_value_range_to_null (vr, TREE_TYPE (expr));
+ else
+ set_value_range_to_varying (vr);
+ }
else
{
/* Subtracting from a pointer, may yield 0, so just drop the