This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.0] PR20648
- From: Andreas Schwab <schwab at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 07 Apr 2005 14:57:51 +0200
- Subject: [4.0] PR20648
This is the patch for PR20648 backported to 4.0 branch (which has a
slightly different context). Tested on ia64-suse-linux. OK?
Andreas.
PR middle-end/20648
* bb-reorder.c (duplicate_computed_gotos): Do not unfactor
a computed goto if the edge to the computed goto block has
incoming abnormal edges. Clarify how the function works.
Index: gcc/bb-reorder.c
===================================================================
RCS file: /backup/gcc-cvs/gcc/gcc/bb-reorder.c,v
retrieving revision 1.92.2.1
diff -u -a -p -r1.92.2.1 bb-reorder.c
--- gcc/bb-reorder.c 21 Mar 2005 23:03:57 -0000 1.92.2.1
+++ gcc/bb-reorder.c 7 Apr 2005 12:23:14 -0000
@@ -2033,32 +2033,49 @@ duplicate_computed_gotos (void)
max_size = uncond_jump_length * PARAM_VALUE (PARAM_MAX_GOTO_DUPLICATION_INSNS);
candidates = BITMAP_ALLOC (NULL);
- /* Build the reorder chain for the original order of blocks.
- Look for a computed jump while we are at it. */
+ /* Look for blocks that end in a computed jump, and see if such blocks
+ are suitable for unfactoring. If a block is a candidate for unfactoring,
+ mark it in the candidates. */
FOR_EACH_BB (bb)
{
+ rtx insn;
+ edge e;
+ edge_iterator ei;
+ int size, all_flags;
+
+ /* Build the reorder chain for the original order of blocks. */
if (bb->next_bb != EXIT_BLOCK_PTR)
bb->rbi->next = bb->next_bb;
- /* If the block ends in a computed jump and it is small enough,
- make it a candidate for duplication. */
- if (computed_jump_p (BB_END (bb)))
- {
- rtx insn;
- int size = 0;
-
- FOR_BB_INSNS (bb, insn)
- if (INSN_P (insn))
- {
- size += get_attr_length (insn);
- if (size > max_size)
- break;
- }
-
- if (size <= max_size
- && can_duplicate_block_p (bb))
- bitmap_set_bit (candidates, bb->index);
- }
+ /* Obviously the block has to end in a computed jump. */
+ if (!computed_jump_p (BB_END (bb)))
+ continue;
+
+ /* Only consider blocks that can be duplicated. */
+ if (find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX)
+ || !can_duplicate_block_p (bb))
+ continue;
+
+ /* Make sure that the block is small enough. */
+ size = 0;
+ FOR_BB_INSNS (bb, insn)
+ if (INSN_P (insn))
+ {
+ size += get_attr_length (insn);
+ if (size > max_size)
+ break;
+ }
+ if (size > max_size)
+ continue;
+
+ /* Final check: there must not be any incoming abnormal edges. */
+ all_flags = 0;
+ FOR_EACH_EDGE (e, ei, bb->preds)
+ all_flags |= e->flags;
+ if (all_flags & EDGE_COMPLEX)
+ continue;
+
+ bitmap_set_bit (candidates, bb->index);
}
/* Nothing to do if there is no computed jump here. */
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."