diff mbox

Fix PR55270

Message ID alpine.LNX.2.00.1301291138000.6889@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Jan. 29, 2013, 10:39 a.m. UTC
This fixes PR55270 - we need to fixup loops after phicprop as
that removes edges without doing so.  The following patch makes
us rely on cfgcleanup scheduled after the pass for this.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-01-29  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/55270
	* tree-ssa-dom.c (eliminate_degenerate_phis): If we changed
	the CFG, schedule loops for fixup.

	* gcc.dg/torture/pr55270.c: New testcase.
diff mbox

Patch

Index: gcc/tree-ssa-dom.c
===================================================================
--- gcc/tree-ssa-dom.c	(revision 195530)
+++ gcc/tree-ssa-dom.c	(working copy)
@@ -3006,7 +3006,12 @@  eliminate_degenerate_phis (void)
     }
 
   if (cfg_altered)
-    free_dominance_info (CDI_DOMINATORS);
+    {
+      free_dominance_info (CDI_DOMINATORS);
+      /* If we changed the CFG schedule loops for fixup by cfgcleanup.  */
+      if (current_loops)
+	loops_state_set (LOOPS_NEED_FIXUP);
+    }
 
   /* Propagation of const and copies may make some EH edges dead.  Purge
      such edges from the CFG as needed.  */
Index: gcc/testsuite/gcc.dg/torture/pr55270.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr55270.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr55270.c	(working copy)
@@ -0,0 +1,22 @@ 
+/* { dg-do compile } */
+
+unsigned a, b, c;
+
+void f(void)
+{
+  for(; a; a++)
+    {
+      long *p1 = (long *)&b;
+
+      if(*p1)
+	return;
+
+      if(b && (*p1 = b) || c && ++*p1)
+	{
+	  unsigned *p2 = &b;
+
+	  for(*p2 = 0; *p2 < 1;)
+	    for(; b; b++);
+	}
+    }
+}