This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Blackfin: Fix hardware loop optimizer failure

The hardware loop optimization code looks backwards from a placeholder "loop_end" instruction to find the last instruction in the loop, so that we can place the end label before it. This is also able to look past basic block boundaries, but there's an error in the code that can cause it to fail in cases of more complicated control flow: if the loop_end is alone in a basic block somewhere in a function, and that basic block is reachable by a jump to it, we'll generate incorrect code.

This patch disables hardware loops if we encounter such a situation. Committed as 146980.

Bernd -- This footer brought to you by insane German lawmakers. Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368 Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif

Index: ChangeLog
--- ChangeLog	(revision 146974)
+++ ChangeLog	(working copy)
@@ -3,6 +3,9 @@
 	* config/bfin/bfin.c (bfin_optimize_loop): If we need a scratch reg,
 	scan backwards to try to find a constant to initialize it.
+	* config/bfin/bfin.c (bfin_optimize_loop): When looking for the last
+	insn before the loop_end instruction, don't look past labels.
 2009-04-29  Richard Guenther  <>
 	PR middle-end/39937
Index: config/bfin/bfin.c
--- config/bfin/bfin.c	(revision 146974)
+++ config/bfin/bfin.c	(working copy)
@@ -4012,6 +4012,7 @@ bfin_optimize_loop (loop_info loop)
       if (single_pred_p (bb)
+	  && single_pred_edge (bb)->flags & EDGE_FALLTHRU
 	  && single_pred (bb) != ENTRY_BLOCK_PTR)
 	  bb = single_pred (bb);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]