diff mbox

Fix PR54458

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

Commit Message

Richard Biener Sept. 4, 2012, 9:22 a.m. UTC
This fixes PR54458 where DOM jump threading turns a loop into
one with multiple latches but does not mark it so.

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

Richard.

2012-09-04  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/54458
	* tree-ssa-threadupdate.c (thread_through_loop_header): If we
	turn the loop into one with multiple latches mark it so.

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

Comments

Markus Trippelsdorf Sept. 8, 2012, 6:17 a.m. UTC | #1
On 2012.09.04 at 11:22 +0200, Richard Guenther wrote:
> 
> This fixes PR54458 where DOM jump threading turns a loop into
> one with multiple latches but does not mark it so.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
> 
> Richard.
> 
> 2012-09-04  Richard Guenther  <rguenther@suse.de>
> 
> 	PR tree-optimization/54458
> 	* tree-ssa-threadupdate.c (thread_through_loop_header): If we
> 	turn the loop into one with multiple latches mark it so.

This commit causes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54520
diff mbox

Patch

Index: gcc/tree-ssa-threadupdate.c
===================================================================
--- gcc/tree-ssa-threadupdate.c	(revision 190889)
+++ gcc/tree-ssa-threadupdate.c	(working copy)
@@ -1037,11 +1037,21 @@  thread_through_loop_header (struct loop
 	}
       free (bblocks);
 
+      /* If the new header has multiple latches mark it so.  */
+      FOR_EACH_EDGE (e, ei, loop->header->preds)
+	if (e->src->loop_father == loop
+	    && e->src != loop->latch)
+	  {
+	    loop->latch = NULL;
+	    loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
+	  }
+
       /* Cancel remaining threading requests that would make the
 	 loop a multiple entry loop.  */
       FOR_EACH_EDGE (e, ei, header->preds)
 	{
 	  edge e2;
+
 	  if (e->aux == NULL)
 	    continue;
 
Index: gcc/testsuite/gcc.dg/torture/pr54458.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr54458.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr54458.c	(working copy)
@@ -0,0 +1,20 @@ 
+/* { dg-do compile } */
+
+unsigned int a, b, c;
+
+void
+foo (unsigned int x)
+{
+  do
+    {
+      if (a == 0 ? 1 : 1 % a)
+	for (; b; b--)
+	  lab:;
+      else
+	while (x)
+	  ;
+      if (c)
+	goto lab;
+    }
+  while (1);
+}