From d493f913fd326016d8150c61f4f85b10932fe4cc Mon Sep 17 00:00:00 2001
From: rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 24 Jul 2003 18:54:26 +0000
Subject: [PATCH] 	* cfgloopmanip.c (duplicate_loop_to_header_edge):
 Update irreducible 	flag correctly.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69755 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog      |  5 +++++
 gcc/cfgloopmanip.c | 37 +++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 50ae6251715b..e7685659ac96 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-24  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+
+	* cfgloopmanip.c (duplicate_loop_to_header_edge): Update irreducible
+	flag correctly.
+
 2003-07-24  Zack Weinberg  <zack@codesourcery.com>
 
 	* c-decl.c: Search-and-replace change 'binding level' to
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 8892720069d3..26eb9fd6e3bf 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -988,6 +988,27 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
       /* Copy bbs.  */
       copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop, loops);
 
+      /* Note whether the blocks and edges belong to an irreducible loop.  */
+      if (add_irreducible_flag)
+	{
+	  for (i = 0; i < n; i++)
+	    new_bbs[i]->rbi->duplicated = 1;
+	  for (i = 0; i < n; i++)
+	    {
+	      new_bb = new_bbs[i];
+	      if (new_bb->loop_father == target)
+		new_bb->flags |= BB_IRREDUCIBLE_LOOP;
+
+	      for (ae = new_bb->succ; ae; ae = ae->succ_next)
+		if (ae->dest->rbi->duplicated
+		    && (ae->src->loop_father == target
+			|| ae->dest->loop_father == target))
+		  ae->flags |= EDGE_IRREDUCIBLE_LOOP;
+	    }
+	  for (i = 0; i < n; i++)
+	    new_bbs[i]->rbi->duplicated = 0;
+	}
+
       /* Redirect the special edges.  */
       if (is_latch)
 	{
@@ -1011,22 +1032,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
       if (orig && TEST_BIT (wont_exit, j + 1))
 	to_remove[(*n_to_remove)++] = new_spec_edges[SE_ORIG];
 
-      /* Note whether the blocks and edges belong to an irreducible loop.  */
-      if (add_irreducible_flag)
-	{
-	  for (i = 0; i < n; i++)
-	    {
-	      new_bb = new_bbs[i];
-	      if (new_bb->loop_father == target)
-		new_bb->flags |= BB_IRREDUCIBLE_LOOP;
-
-	      for (ae = new_bb->succ; ae; ae = ae->succ_next)
-		if (ae->src->loop_father == target
-		    || ae->dest->loop_father == target)
-		  ae->flags |= EDGE_IRREDUCIBLE_LOOP;
-	    }
-	}
-
       /* Record the first copy in the control flow order if it is not
 	 the original loop (i.e. in case of peeling).  */
       if (!first_active_latch)
-- 
GitLab