https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85275

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
So after my fix for the related PR85116 we'll still not identify the loop as
do-while-loop because its latch isn't empty (it contains the IV increment).

As-is the loop probably should be header-copied but we should stop at the
first exit.

Index: gcc/tree-ssa-loop-ch.c
===================================================================
--- gcc/tree-ssa-loop-ch.c      (revision 259669)
+++ gcc/tree-ssa-loop-ch.c      (working copy)
@@ -328,6 +340,11 @@ ch_base::copy_headers (function *fun)
          bbs[n_bbs++] = header;
          gcc_assert (bbs_size > n_bbs);
          header = exit->dest;
+         /* Make sure to stop copying after we copied the first exit test.
+            Without further heuristics we do not want to rotate the loop
+            any further.  */
+         if (loop_exits_from_bb_p (loop, exit->src))
+           break;
        }

       if (!exit)

Reply via email to