diff mbox

Fix PR80876

Message ID alpine.LSU.2.20.1705300946310.20726@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener May 30, 2017, 7:46 a.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2017-05-30  Richard Biener  <rguenther@suse.de>

	PR middle-end/80876
	* cfgexpand.c (expand_gimple_cond): Fixup preserving loops again.

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

Patch

Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c	(revision 248482)
+++ gcc/cfgexpand.c	(working copy)
@@ -2504,9 +2504,9 @@  expand_gimple_cond (basic_block bb, gcon
   new_bb->count = false_edge->count;
   new_bb->frequency = EDGE_FREQUENCY (false_edge);
   add_bb_to_loop (new_bb, dest->loop_father);
-  if (bb->loop_father->latch == bb
-      && bb->loop_father->header == dest)
-    bb->loop_father->latch = new_bb;
+  if (dest->loop_father->latch == bb
+      && dest->loop_father->header == dest)
+    dest->loop_father->latch = new_bb;
   new_edge = make_edge (new_bb, dest, 0);
   new_edge->probability = REG_BR_PROB_BASE;
   new_edge->count = new_bb->count;
Index: gcc/testsuite/gcc.dg/torture/pr80876.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr80876.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr80876.c	(working copy)
@@ -0,0 +1,42 @@ 
+/* { dg-do compile } */
+
+int sy;
+
+void
+fo (char o5)
+{
+  char yh = 0;
+
+  if (o5 == 0)
+    return;
+
+  while (o5 != 0)
+    if (0)
+      {
+	while (yh != 0)
+	  {
+	    o5 = 0;
+	    while (o5 < 2)
+	      {
+		sy &= yh;
+		if (sy != 0)
+		  {
+km:
+		    sy = yh;
+		  }
+	      }
+	    ++yh;
+	  }
+      }
+    else
+      {
+	o5 = sy;
+	goto km;
+      }
+}
+
+void
+on (void)
+{
+  fo (sy);
+}