re PR rtl-optimization/13159 (FAIL: gcc.c-torture/compile/930621-1.c)
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
Sat, 27 Dec 2003 19:51:17 +0000 (20:51 +0100)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Sat, 27 Dec 2003 19:51:17 +0000 (19:51 +0000)
PR opt/13159
* cfgloopanal.c (mark_irreducible_loops): Fix the strongly connected
components detection.
* loop-unswitch.c (unswitch_loop): Preserve simple preheaders.

* gcc.c-torture/compile/20031227-1.c: New test.

From-SVN: r75174

gcc/ChangeLog
gcc/cfgloopanal.c
gcc/loop-unswitch.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20031227-1.c [new file with mode: 0644]

index b4e12f3..cbd6f4b 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-27  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+
+       PR opt/13159
+       * cfgloopanal.c (mark_irreducible_loops): Fix the strongly connected
+       components detection.
+       * loop-unswitch.c (unswitch_loop): Preserve simple preheaders.
+
 2003-12-27  Bernardo Innocenti  <bernie@develer.com>
 
        * config/m68k/uclinux.h (LIB_SPEC): Add elf2flt magic required for
index 3d6e69e..74cebe0 100644 (file)
@@ -1247,7 +1247,7 @@ mark_irreducible_loops (struct loops *loops)
                   : e->dest->index + 1;
           if (closed[sidx])
            {
-             if (!closed[mri[sidx]])
+             if (mri[sidx] != -1 && !closed[mri[sidx]])
                {
                  if (mr[sidx] < mr[idx])
                    {
index f276b73..25728c2 100644 (file)
@@ -402,5 +402,9 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
   fix_loop_placement (loop);
   fix_loop_placement (nloop);
 
+  /* Preserve the simple loop preheaders.  */
+  loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX, loops);
+  loop_split_edge_with (loop_preheader_edge (nloop), NULL_RTX, loops);
+
   return nloop;
 }
index e0086f4..b124d13 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-27  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+
+       * gcc.c-torture/compile/20031227-1.c: New test.
+
 2003-12-23  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/bprob/bprob.exp: Load target-supports.exp
diff --git a/gcc/testsuite/gcc.c-torture/compile/20031227-1.c b/gcc/testsuite/gcc.c-torture/compile/20031227-1.c
new file mode 100644 (file)
index 0000000..41597bd
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR opt/13159 -- test unswitching a loop multiple times.  */
+
+void
+foo (void)
+{
+  long j, k, p, g;
+
+  while (p)
+    {
+      while (k < 0 && j < 0)
+       ;
+      if (g)
+       ;
+      else if (g)
+       ;      
+    }
+}