+ if (BLOCK_FOR_INSN (insn) == last_bb
+ /* INSN is a jump in the last block, ... */
+ && control_flow_insn_p (insn)
+ /* that is going to be moved over some instructions. */
+ && last != PREV_INSN (insn))
+ {
+ edge e;
+ basic_block bb;
+
+ /* An obscure special case, where we do have partially dead
+ instruction scheduled after last control flow instruction.
+ In this case we can create new basic block. It is
+ always exactly one basic block last in the sequence. */
+
+ e = find_fallthru_edge (last_bb->succs);
+
+ gcc_checking_assert (!e || !(e->flags & EDGE_COMPLEX));
+
+ gcc_checking_assert (BLOCK_FOR_INSN (insn) == last_bb
+ && !IS_SPECULATION_CHECK_P (insn)
+ && BB_HEAD (last_bb) != insn
+ && BB_END (last_bb) == insn);
+
+ {
+ rtx x;
+
+ x = NEXT_INSN (insn);
+ if (e)
+ gcc_checking_assert (NOTE_P (x) || LABEL_P (x));
+ else
+ gcc_checking_assert (BARRIER_P (x));
+ }
+
+ if (e)
+ {
+ bb = split_edge (e);
+ gcc_assert (NOTE_INSN_BASIC_BLOCK_P (BB_END (bb)));
+ }
+ else
+ {
+ /* Create an empty unreachable block after the INSN. */
+ rtx next = NEXT_INSN (insn);
+ if (next && BARRIER_P (next))
+ next = NEXT_INSN (next);
+ bb = create_basic_block (next, NULL_RTX, last_bb);
+ }
+
+ /* split_edge () creates BB before E->DEST. Keep in mind, that
+ this operation extends scheduling region till the end of BB.
+ Hence, we need to shift NEXT_TAIL, so haifa-sched.c won't go out
+ of the scheduling region. */
+ current_sched_info->next_tail = NEXT_INSN (BB_END (bb));
+ gcc_assert (current_sched_info->next_tail);
+
+ /* Append new basic block to the end of the ebb. */
+ sched_init_only_bb (bb, last_bb);
+ gcc_assert (last_bb == bb);
+ }