re PR tree-optimization/23129 (VRP propagates division of antiranges incorrectly)
authorJames A. Morrison <phython@gcc.gnu.org>
Tue, 2 Aug 2005 05:08:40 +0000 (05:08 +0000)
committerJames A. Morrison <phython@gcc.gnu.org>
Tue, 2 Aug 2005 05:08:40 +0000 (05:08 +0000)
2005-08-02  James A. Morrison  <phython@gcc.gnu.org>

        PR tree-optimization/23129
        * tree-vrp.c (extract_range_from_binary_expr): Set value range to
        varying for divisions with anti-ranges.

From-SVN: r102653

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

index 3be4e21..430e474 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-02  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR tree-optimization/23129
+       * tree-vrp.c (extract_range_from_binary_expr): Set value range to
+       varying for divisions with anti-ranges.
+
 2005-08-02  Jan Hubicka  <jh@suse.cz>
 
        * tree-ssa-dom.c (thread_across_edge): Remove updating here.
index 2efa499..0060ae6 100644 (file)
@@ -1,3 +1,7 @@
+2005-08-02  James A. Morrison  <phython@gcc.gnu.org>
+
+       * gcc.c-torture/execute/vrp-4.c: New test.
+
 2005-08-02  Jan Hubicka  <jh@suse.cz>
 
        * update-threading.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/vrp-4.c b/gcc/testsuite/gcc.c-torture/execute/vrp-4.c
new file mode 100644 (file)
index 0000000..23f2922
--- /dev/null
@@ -0,0 +1,20 @@
+extern void exit (int);
+extern void abort ();
+
+void test(int x, int y)
+{
+       int c;
+
+       if (x == 1) abort();
+       if (y == 1) abort();
+
+       c = x / y;
+
+       if (c != 1) abort();
+}
+
+int main()
+{
+       test(2, 2);
+       exit (0);
+}
index 68960e5..68bcb1e 100644 (file)
@@ -1136,7 +1136,8 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr)
         the new range.  */
 
       /* Divisions by zero result in a VARYING value.  */
-      if (code != MULT_EXPR && range_includes_zero_p (&vr1))
+      if (code != MULT_EXPR
+         && (vr0.type == VR_ANTI_RANGE || range_includes_zero_p (&vr1)))
        {
          set_value_range_to_varying (vr);
          return;