aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Law <law@gcc.gnu.org>1998-07-29 15:41:04 -0600
committerJeff Law <law@gcc.gnu.org>1998-07-29 15:41:04 -0600
commit15fec413e7f2b6d9ef82d220987389feed1ad3b1 (patch)
treedd6d6854d6e3adc3d7672a0402bee0e1fe9b48d9
parent47d41103c544ec845b1ffa9d58d9bac571373e62 (diff)
downloadgcc-15fec413e7f2b6d9ef82d220987389feed1ad3b1.zip
gcc-15fec413e7f2b6d9ef82d220987389feed1ad3b1.tar.gz
gcc-15fec413e7f2b6d9ef82d220987389feed1ad3b1.tar.bz2
unroll.c (unroll_loop): Do not abort for an UNROLL_MODULO or UNROLL_COMPLETELY loop that starts with a...
P * unroll.c (unroll_loop): Do not abort for an UNROLL_MODULO or UNROLL_COMPLETELY loop that starts with a jump to its exit code. From-SVN: r21476
-rw-r--r--gcc/unroll.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/gcc/unroll.c b/gcc/unroll.c
index c6de53b..72f1f04 100644
--- a/gcc/unroll.c
+++ b/gcc/unroll.c
@@ -431,15 +431,34 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
if (unroll_type == UNROLL_COMPLETELY || unroll_type == UNROLL_MODULO)
{
- /* Loops of these types should never start with a jump down to
- the exit condition test. For now, check for this case just to
- be sure. UNROLL_NAIVE loops can be of this form, this case is
- handled below. */
+ /* Loops of these types can start with jump down to the exit condition
+ in rare circumstances.
+
+ Consider a pair of nested loops where the inner loop is part
+ of the exit code for the outer loop.
+
+ In this case jump.c will not duplicate the exit test for the outer
+ loop, so it will start with a jump to the exit code.
+
+ Then consider if the inner loop turns out to iterate once and
+ only once. We will end up deleting the jumps associated with
+ the inner loop. However, the loop notes are not removed from
+ the instruction stream.
+
+ And finally assume that we can compute the number of iterations
+ for the outer loop.
+
+ In this case unroll may want to unroll the outer loop even though
+ it starts with a jump to the outer loop's exit code.
+
+ We could try to optimize this case, but it hardly seems worth it.
+ Just return without unrolling the loop in such cases. */
+
insn = loop_start;
while (GET_CODE (insn) != CODE_LABEL && GET_CODE (insn) != JUMP_INSN)
insn = NEXT_INSN (insn);
if (GET_CODE (insn) == JUMP_INSN)
- abort ();
+ return;
}
if (unroll_type == UNROLL_COMPLETELY)