@@ -878,8 +878,15 @@ rtl_merge_blocks (basic_block a, basic_block b)
a_end = PREV_INSN (del_first);
}
- else if (BARRIER_P (NEXT_INSN (a_end)))
- del_first = NEXT_INSN (a_end);
+
+ /* If there is a BARRIER between A & B, remove it. This can happen
+ if a block with no successors is if-converted. */
+ rtx end = NEXT_INSN (a_end);
+ while (end && NOTE_P (end) && !NOTE_INSN_BASIC_BLOCK_P (end))
+ end = NEXT_INSN (end);
+
+ if (BARRIER_P (end))
+ del_first = end;
/* Delete everything marked above as well as crap that might be
hanging out between the two blocks. */