This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH COMMITTED: Fix for PR 31345


I just committed this patch to fix PR 31345.  We generated a useless
range [+INF, +INF(OVF)] which later led to an ICE as DOM did some
computations using the overflowed value and the result came back in
the second VRP pass and triggered the check in set_value_range.

Bootstrapped and tested on i686-pc-linux-gnu.  Committed to trunk.

I will also commit to 4.2 branch after testing.

Ian


gcc/ChangeLog:
2007-03-26  Ian Lance Taylor  <iant@google.com>

	PR tree-optimization/31345
	* tree-vrp.c (extract_range_from_binary_expr): Turn ranges like
	[+INF, +INF(OVF)] into VARYING.

gcc/testsuite/ChangeLog:
2007-03-26  Ian Lance Taylor  <iant@google.com>

	PR tree-optimization/31345
	* gcc.c-torture/compile/pr31345-1.c: New test.


Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 123218)
+++ gcc/tree-vrp.c	(working copy)
@@ -1982,10 +1982,18 @@ extract_range_from_binary_expr (value_ra
       return;
     }
 
+  /* We punt if:
+     1) [-INF, +INF]
+     2) [-INF, +-INF(OVF)]
+     3) [+-INF(OVF), +INF]
+     4) [+-INF(OVF), +-INF(OVF)]
+     We learn nothing when we have INF and INF(OVF) on both sides.
+     Note that we do accept [-INF, -INF] and [+INF, +INF] without
+     overflow.  */
   if ((min == TYPE_MIN_VALUE (TREE_TYPE (min))
-       || is_negative_overflow_infinity (min))
+       || is_overflow_infinity (min))
       && (max == TYPE_MAX_VALUE (TREE_TYPE (max))
-	  || is_positive_overflow_infinity (max)))
+	  || is_overflow_infinity (max)))
     {
       set_value_range_to_varying (vr);
       return;
Index: gcc/testsuite/gcc.c-torture/compile/pr31345-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr31345-1.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr31345-1.c	(revision 0)
@@ -0,0 +1,24 @@
+/* PR tree-optimization/31345
+   This caused a crash in VRP when dealing with overflow infinities.  */
+
+void
+dpsnaffle (const char *kbuf)
+{
+  int hash, thash, head[2], off;
+    {
+      int _DP_i;
+      (hash) = 19780211;
+        {
+          (hash) = (hash) + (kbuf)[_DP_i];
+        }
+      (hash) = ((hash) * 43321879) & 0x7FFFFFFF;
+    }
+  while (off != 0)
+    {
+      if (hash > thash) {}
+      else if (hash < thash)
+        {
+          off = head[2];
+        }
+    }
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]