re PR tree-optimization/32453 (ICE in build2_stat, at tree.c:3074 (extract_range_from...
authorRichard Guenther <rguenther@suse.de>
Thu, 21 Jun 2007 14:54:47 +0000 (14:54 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Jun 2007 14:54:47 +0000 (14:54 +0000)
2007-06-21  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/32453
* tree-vrp.c (extract_range_from_assert): Build POINTER_PLUS_EXPR
for pointer anti-range.

* gcc.c-torture/compile/pr32453.c: New testcase.

From-SVN: r125922

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr32453.c [new file with mode: 0644]
gcc/tree-vrp.c

index 2195e41..4e0d1dd 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/32453
+       * tree-vrp.c (extract_range_from_assert): Build POINTER_PLUS_EXPR
+       for pointer anti-range.
+
 2007-06-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/i386/i386.c (processor_target_table): Increase maximum
index 81721f9..cdcf8fb 100644 (file)
@@ -1,3 +1,8 @@
+2007-06-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/32453
+       * gcc.c-torture/compile/pr32453.c: New testcase.
+
 2007-06-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/31866
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr32453.c b/gcc/testsuite/gcc.c-torture/compile/pr32453.c
new file mode 100644 (file)
index 0000000..bdabac7
--- /dev/null
@@ -0,0 +1,11 @@
+void ucs2reverse_internal_loop_single (long *irreversible, int foo)
+{
+    unsigned char bytebuf[2];
+    const unsigned char *inptr = bytebuf;
+    if (irreversible == (void *)0)
+       ;
+    else 
+       inptr += 2;
+    if (inptr != bytebuf)
+       ((inptr - bytebuf > foo) ? (void) (0) : __assert_fail ());
+}
index 8fba946..937a76b 100644 (file)
@@ -1473,10 +1473,13 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
                    }
                  min = positive_overflow_infinity (TREE_TYPE (var_vr->min));
                }
-             else
+             else if (!POINTER_TYPE_P (TREE_TYPE (var_vr->min)))
                min = fold_build2 (PLUS_EXPR, TREE_TYPE (var_vr->min),
                                   anti_max,
                                   build_int_cst (TREE_TYPE (var_vr->min), 1));
+             else
+               min = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (var_vr->min),
+                                  anti_max, size_int (1));
              max = real_max;
              set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv);
            }