aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hayes <m.hayes@elec.canterbury.ac.nz>1999-01-15 03:05:56 -0700
committerJeff Law <law@gcc.gnu.org>1999-01-15 03:05:56 -0700
commit98dcbc07f5136e439c5fb254fe94ed32e959c23c (patch)
tree619b471570a1cb06192dfa615752214a0e07bc47
parent9f16f9324c40bfe04279994e8a32a19e5fef5b58 (diff)
downloadgcc-98dcbc07f5136e439c5fb254fe94ed32e959c23c.zip
gcc-98dcbc07f5136e439c5fb254fe94ed32e959c23c.tar.gz
gcc-98dcbc07f5136e439c5fb254fe94ed32e959c23c.tar.bz2
unroll.c (loop_iterations): Return 0 if the last loop insn is not a jump insn or if...
8 * unroll.c (loop_iterations): Return 0 if the last loop insn is not a jump insn or if the loop has multiple back edges. From-SVN: r24680
-rw-r--r--gcc/unroll.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/gcc/unroll.c b/gcc/unroll.c
index 501a6e5..2c0bdef 100644
--- a/gcc/unroll.c
+++ b/gcc/unroll.c
@@ -3480,22 +3480,43 @@ loop_iterations (loop_start, loop_end, loop_info)
loop_info->unroll_number = 1;
loop_info->vtop = 0;
- /* First find the iteration variable. If the last insn is a conditional
- branch, and the insn before tests a register value, make that the
- iteration variable. */
-
/* We used to use prev_nonnote_insn here, but that fails because it might
accidentally get the branch for a contained loop if the branch for this
loop was deleted. We can only trust branches immediately before the
loop_end. */
last_loop_insn = PREV_INSN (loop_end);
+ /* ??? We should probably try harder to find the jump insn
+ at the end of the loop. The following code assumes that
+ the last loop insn is a jump to the top of the loop. */
+ if (GET_CODE (last_loop_insn) != JUMP_INSN)
+ {
+ if (loop_dump_stream)
+ fprintf (loop_dump_stream,
+ "Loop iterations: No final conditional branch found.\n");
+ return 0;
+ }
+
+ /* If there is a more than a single jump to the top of the loop
+ we cannot (easily) determine the iteration count. */
+ if (LABEL_NUSES (JUMP_LABEL (last_loop_insn)) > 1)
+ {
+ if (loop_dump_stream)
+ fprintf (loop_dump_stream,
+ "Loop iterations: Loop has multiple back edges.\n");
+ return 0;
+ }
+
+ /* Find the iteration variable. If the last insn is a conditional
+ branch, and the insn before tests a register value, make that the
+ iteration variable. */
+
comparison = get_condition_for_loop (last_loop_insn);
if (comparison == 0)
{
if (loop_dump_stream)
fprintf (loop_dump_stream,
- "Loop iterations: No final conditional branch found.\n");
+ "Loop iterations: No final comparison found.\n");
return 0;
}