basic_block jump_block, jump_dest_block, cbranch_dest_block;
edge cbranch_jump_edge, cbranch_fallthru_edge;
rtx cbranch_insn;
- rtx insn, next;
- rtx end;
/* Verify that there are exactly two successors. */
if (!cbranch_block->succ
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
- and cold sections. */
+ and cold sections.
+
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really
+ must be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
if (flag_reorder_blocks_and_partition
- && (jump_block->partition != jump_dest_block->partition
- || cbranch_jump_edge->crossing_edge))
+ && (BB_PARTITION (jump_block) != BB_PARTITION (jump_dest_block)
+ || (cbranch_jump_edge->flags & EDGE_CROSSING)))
return false;
/* The conditional branch must target the block after the
cbranch_fallthru_edge->flags &= ~EDGE_FALLTHRU;
update_br_prob_note (cbranch_block);
- end = BB_END (jump_block);
- /* Deleting a block may produce unreachable code warning even when we are
- not deleting anything live. Suppress it by moving all the line number
- notes out of the block. */
- for (insn = BB_HEAD (jump_block); insn != NEXT_INSN (BB_END (jump_block));
- insn = next)
- {
- next = NEXT_INSN (insn);
- if (NOTE_P (insn) && NOTE_LINE_NUMBER (insn) > 0)
- {
- if (insn == BB_END (jump_block))
- {
- BB_END (jump_block) = PREV_INSN (insn);
- if (insn == end)
- break;
- }
- reorder_insns_nobb (insn, insn, end);
- end = insn;
- }
- }
/* Delete the block with the unconditional jump, and clean up the mess. */
delete_basic_block (jump_block);
tidy_fallthru_edge (cbranch_jump_edge);
+ update_forwarder_flag (cbranch_block);
return true;
}
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
- and cold sections. */
+ and cold sections.
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really m
+ ust be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
+
if (flag_reorder_blocks_and_partition
&& find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX))
return false;
target = first = e->dest;
counter = 0;
+ /* If we are partitioning hot/cold basic_blocks, we don't want to mess
+ up jumps that cross between hot/cold sections.
+
+ Basic block partitioning may result in some jumps that appear
+ to be optimizable (or blocks that appear to be mergeable), but which
+ really must be left untouched (they are required to make it safely
+ across partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete
+ details. */
+
+ if (flag_reorder_blocks_and_partition
+ && first != EXIT_BLOCK_PTR
+ && find_reg_note (BB_END (first), REG_CROSSING_JUMP, NULL_RTX))
+ return false;
+
while (counter < n_basic_blocks)
{
basic_block new_target = NULL;
may_thread |= target->flags & BB_DIRTY;
if (FORWARDER_BLOCK_P (target)
+ && !(target->succ->flags & EDGE_CROSSING)
&& target->succ->dest != EXIT_BLOCK_PTR)
{
/* Bypass trivial infinite loops. */
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
- and cold sections. */
+ and cold sections.
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really
+ must be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
+
if (flag_reorder_blocks_and_partition
- && (a->partition != b->partition
+ && (BB_PARTITION (a) != BB_PARTITION (b)
|| find_reg_note (BB_END (a), REG_CROSSING_JUMP, NULL_RTX)))
return;
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
- and cold sections. */
+ and cold sections.
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really
+ must be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
+
if (flag_reorder_blocks_and_partition
&& (find_reg_note (BB_END (a), REG_CROSSING_JUMP, NULL_RTX)
- || a->partition != b->partition))
+ || BB_PARTITION (a) != BB_PARTITION (b)))
return;
real_b_end = BB_END (b);
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
- and cold sections. */
+ and cold sections.
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really
+ must be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
+
if (flag_reorder_blocks_and_partition
&& (find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX)
|| find_reg_note (BB_END (c), REG_CROSSING_JUMP, NULL_RTX)
- || b->partition != c->partition))
+ || BB_PARTITION (b) != BB_PARTITION (c)))
return NULL;
newpos1 = newpos2 = NULL_RTX;
/* If we have partitioned hot/cold basic blocks, it is a bad idea
- to try this optimization. */
+ to try this optimization.
+
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really
+ must be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
if (flag_reorder_blocks_and_partition && no_new_pseudos)
return false;
/* ... and part the second. */
nmatch = flow_find_cross_jump (mode, src1, src2, &newpos1, &newpos2);
- if (!nmatch)
+
+ /* Don't proceed with the crossjump unless we found a sufficient number
+ of matching instructions or the 'from' block was totally matched
+ (such that its predecessors will hopefully be redirected and the
+ block removed). */
+ if ((nmatch < PARAM_VALUE (PARAM_MIN_CROSSJUMP_INSNS))
+ && (newpos1 != BB_HEAD (src1)))
return false;
#ifndef CASE_DROPS_THROUGH
/* If we are partitioning hot/cold basic blocks, we don't want to
mess up unconditional or indirect jumps that cross between hot
- and cold sections. */
+ and cold sections.
+ Basic block partitioning may result in some jumps that appear to
+ be optimizable (or blocks that appear to be mergeable), but which really
+ must be left untouched (they are required to make it safely across
+ partition boundaries). See the comments at the top of
+ bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */
+
if (flag_reorder_blocks_and_partition
- && (bb->pred->src->partition != bb->pred->pred_next->src->partition
- || bb->pred->crossing_edge))
+ && (BB_PARTITION (bb->pred->src) != BB_PARTITION (bb->pred->pred_next->src)
+ || (bb->pred->flags & EDGE_CROSSING)))
return false;
/* It is always cheapest to redirect a block that ends in a branch to
}
if (mode & CLEANUP_CROSSJUMP)
- remove_fake_edges ();
+ remove_fake_exit_edges ();
clear_aux_for_blocks ();