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] Fix PR78788


The following patch fixes PR78788.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2016-12-13  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/78788
	* tree-vrp.c (set_value_range): Allow [-INF(OVF), +INF(OVF)].
	(set_and_canonicalize_value_range): Do not drop the above to
	VARYING.

	* gcc.dg/torture/pr78788.c: New testcase.

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 243599)
+++ gcc/tree-vrp.c	(working copy)
@@ -365,10 +365,6 @@ set_value_range (value_range *vr, enum v
 
       cmp = compare_values (min, max);
       gcc_assert (cmp == 0 || cmp == -1 || cmp == -2);
-
-      if (needs_overflow_infinity (TREE_TYPE (min)))
-	gcc_assert (!is_overflow_infinity (min)
-		    || !is_overflow_infinity (max));
     }
 
   if (flag_checking
@@ -506,14 +502,9 @@ set_and_canonicalize_value_range (value_
         }
     }
 
-  /* Drop [-INF(OVF), +INF(OVF)] to varying.  */
-  if (needs_overflow_infinity (TREE_TYPE (min))
-      && is_overflow_infinity (min)
-      && is_overflow_infinity (max))
-    {
-      set_value_range_to_varying (vr);
-      return;
-    }
+  /* Do not drop [-INF(OVF), +INF(OVF)] to varying.  (OVF) has to be sticky
+     to make sure VRP iteration terminates, otherwise we can get into
+     oscillations.  */
 
   set_value_range (vr, t, min, max, equiv);
 }

Index: gcc/testsuite/gcc.dg/torture/pr78788.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr78788.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr78788.c	(working copy)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+int a;
+long b;
+long c;
+void d()
+{
+  int e = 0;
+  for (; b; b++)
+    if (c)
+      {
+	e++;
+	e++;
+      }
+  while (e)
+    a = e -= 2;
+}


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