aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBernd Schmidt <bernd.schmidt@analog.com>2008-11-03 14:28:35 +0000
committerBernd Schmidt <bernds@gcc.gnu.org>2008-11-03 14:28:35 +0000
commitf4c59f4fd20bf116aa94e1efdd131746b1f3daa6 (patch)
tree3077f0e616f18ce43df44ef0fdbade3a9d9d64ef /gcc
parentda4b6efcd6ed9d2c6f3b100dc8552753276df586 (diff)
downloadgcc-f4c59f4fd20bf116aa94e1efdd131746b1f3daa6.zip
gcc-f4c59f4fd20bf116aa94e1efdd131746b1f3daa6.tar.gz
gcc-f4c59f4fd20bf116aa94e1efdd131746b1f3daa6.tar.bz2
bfin.c (bfin_optimize_loop): Properly handle case where we have one entry point in the loop which isn't the head.
* config/bfin/bfin.c (bfin_optimize_loop): Properly handle case where we have one entry point in the loop which isn't the head. From-SVN: r141548
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/bfin/bfin.c41
2 files changed, 35 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9a3d1bd..32ebb5d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-03 Bernd Schmidt <bernd.schmidt@analog.com>
+
+ * config/bfin/bfin.c (bfin_optimize_loop): Properly handle case
+ where we have one entry point in the loop which isn't the head.
+
2008-11-03 Richard Guenther <rguenther@suse.de>
PR middle-end/37573
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 3f3f9dc..e9c6297 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -4059,12 +4059,33 @@ bfin_optimize_loop (loop_info loop)
print_rtl_single (dump_file, loop->loop_end);
}
+ /* Create a sequence containing the loop setup. */
start_sequence ();
if (loop->init != NULL_RTX)
emit_insn (loop->init);
seq_end = emit_insn (loop->loop_init);
+ /* If the loop isn't entered at the top, also create a jump to the entry
+ point. */
+ if (!loop->incoming_src && loop->head != loop->incoming_dest)
+ {
+ rtx label = BB_HEAD (loop->incoming_dest);
+ /* If we're jumping to the final basic block in the loop, and there's
+ only one cheap instruction before the end (typically an increment of
+ an induction variable), we can just emit a copy here instead of a
+ jump. */
+ if (loop->incoming_dest == loop->tail
+ && next_real_insn (label) == last_insn
+ && asm_noperands (last_insn) < 0
+ && GET_CODE (PATTERN (last_insn)) == SET)
+ {
+ seq_end = emit_insn (copy_rtx (PATTERN (last_insn)));
+ }
+ else
+ seq_end = emit_insn (gen_jump (label));
+ }
+
seq = get_insns ();
end_sequence ();
@@ -4084,21 +4105,19 @@ bfin_optimize_loop (loop_info loop)
basic_block new_bb;
edge e;
edge_iterator ei;
-
+
+#ifdef ENABLE_CHECKING
if (loop->head != loop->incoming_dest)
{
+ /* We aren't entering the loop at the top. Since we've established
+ that the loop is entered only at one point, this means there
+ can't be fallthru edges into the head. Any such fallthru edges
+ would become invalid when we insert the new block, so verify
+ that this does not in fact happen. */
FOR_EACH_EDGE (e, ei, loop->head->preds)
- {
- if (e->flags & EDGE_FALLTHRU)
- {
- rtx newjump = gen_jump (loop->start_label);
- emit_insn_before (newjump, BB_HEAD (loop->head));
- new_bb = create_basic_block (newjump, newjump, loop->head->prev_bb);
- gcc_assert (new_bb = loop->head->prev_bb);
- break;
- }
- }
+ gcc_assert (!(e->flags & EDGE_FALLTHRU));
}
+#endif
emit_insn_before (seq, BB_HEAD (loop->head));
seq = emit_label_before (gen_label_rtx (), seq);