+2005-06-23 Kazu Hirata <kazu@codesourcery.com>
+
+ PR tree-optimization/22117
+ * tree-vrp.c (extract_range_from_binary_expr): Compute a
+ correct range when adding two pointers.
+
2005-06-23 Jason Merrill <jason@redhat.com>
PR c++/19317
+2005-06-23 Kazu Hirata <kazu@codesourcery.com>
+
+ PR tree-optimization/22117
+ * gcc.dg/tree-ssa/pr22117.c: New.
+
2005-06-23 James A. Morrison <phython@gcc.gnu.org>
PR testsuite/22123
--- /dev/null
+/* PR tree-optimization/22117
+ VRP used think that &p[q] is nonzero even though p and q are both
+ known to be zero after entering the first two "if" statements. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp" } */
+
+void
+foo (int *p, int q)
+{
+ if (p == 0)
+ {
+ if (q == 0)
+ {
+ int *r = &p[q];
+ if (r != 0)
+ link_error ();
+ }
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "Folding predicate r_.* != 0B to 0" 1 "vrp" } } */
+/* { dg-final { cleanup-tree-dump "vrp" } } */
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