re PR tree-optimization/24142 (VRP miscompiles unzip inflate.c)
authorDiego Novillo <dnovillo@redhat.com>
Sun, 2 Oct 2005 20:15:55 +0000 (20:15 +0000)
committerDiego Novillo <dnovillo@gcc.gnu.org>
Sun, 2 Oct 2005 20:15:55 +0000 (16:15 -0400)
PR 24142
* tree-vrp.c (vrp_meet): Fix call to range_includes_zero_p in
case of anti-ranges.

testsuite/

PR 24142
* gcc.c-torture/execute/pr24142.c: New test.

From-SVN: r104874

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

index e712977ecfa662ffbafc439980bf1db005594507..e27296ff10057b4e5c8396aa4fdade5e6dc3b2da 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-02  Diego Novillo  <dnovillo@redhat.com>
+
+       PR 24142
+       * tree-vrp.c (vrp_meet): Fix call to range_includes_zero_p in
+       case of anti-ranges.
+
 2005-10-02  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c/18851
index d90b90b069de4ee5e21f00bb84bb58b3b4cc7280..98bfad4bc91a8cf00996a04f3009945f291990d3 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-02  Diego Novillo  <dnovillo@redhat.com>
+
+       PR 24142
+       * gcc.c-torture/execute/pr24142.c: New test.
+
 2005-10-01  Diego Novillo  <dnovillo@redhat.com>
 
        PR 24141
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr24142.c b/gcc/testsuite/gcc.c-torture/execute/pr24142.c
new file mode 100644 (file)
index 0000000..eed3e8b
--- /dev/null
@@ -0,0 +1,19 @@
+void abort (void);
+
+int f (int a, int b)
+{
+  if (a == 1)
+    a = 0;
+  if (b == 0)
+    a = 1;
+  if (a != 0)
+    return 0;
+  return 1;
+}
+
+int main (void)
+{
+  if (f (1, 1) != 1)
+    abort ();
+  return 0;
+}
index de7a931cb1562b71372b3203e4fed6539a195998..7d7e0c9e9c37618a81758e0222e145a551be1ce5 100644 (file)
@@ -3454,11 +3454,15 @@ vrp_meet (value_range_t *vr0, value_range_t *vr1)
 no_meet:
   /* The two range VR0 and VR1 do not meet.  Before giving up and
      setting the result to VARYING, see if we can at least derive a
-     useful anti-range.  */
+     useful anti-range.  FIXME, all this nonsense about distinguishing
+     anti-ranges from ranges is necessary because of the odd
+     semantics of range_includes_zero_p and friends.  */
   if (!symbolic_range_p (vr0)
-      && !range_includes_zero_p (vr0)
+      && ((vr0->type == VR_RANGE && !range_includes_zero_p (vr0))
+         || (vr0->type == VR_ANTI_RANGE && range_includes_zero_p (vr0)))
       && !symbolic_range_p (vr1)
-      && !range_includes_zero_p (vr1))
+      && ((vr1->type == VR_RANGE && !range_includes_zero_p (vr1))
+         || (vr1->type == VR_ANTI_RANGE && range_includes_zero_p (vr1))))
     {
       set_value_range_to_nonnull (vr0, TREE_TYPE (vr0->min));