OSDN Git Service

(unroll_loop): Add check for naive loop that ends with
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Feb 1997 21:43:33 +0000 (21:43 +0000)
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Feb 1997 21:43:33 +0000 (21:43 +0000)
conditional branch that does not branch back to loop start.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@13672 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/unroll.c

index 0e033ef..2ab6b2a 100644 (file)
@@ -637,6 +637,23 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
       copy_end = last_loop_insn;
     }
 
+  if (unroll_type == UNROLL_NAIVE
+      && GET_CODE (last_loop_insn) == JUMP_INSN
+      && start_label != JUMP_LABEL (last_loop_insn))
+    {
+      /* ??? The loop ends with a conditional branch that does not branch back
+        to the loop start label.  In this case, we must emit an unconditional
+        branch to the loop exit after emitting the final branch.
+        copy_loop_body does not have support for this currently, so we
+        give up.  It doesn't seem worthwhile to unroll anyways since
+        unrolling would increase the number of branch instructions
+        executed.  */
+      if (loop_dump_stream)
+       fprintf (loop_dump_stream,
+                "Unrolling failure: final conditional branch not to loop start\n");
+      return;
+    }
+
   /* Allocate a translation table for the labels and insn numbers.
      They will be filled in as we copy the insns in the loop.  */