+ n_jpreds = get_Block_n_cfgpreds(jmp_block);
+ /**
+ * If the jmp block has only one predecessor this is straightforward.
+ * However, if there are more predecessors, we only handle this,
+ * if block has no Phis.
+ */
+ if (n_jpreds == 1) {
+ ir_node *pred = get_Block_cfgpred(jmp_block, 0);
+ ir_node *pred_block = get_nodes_block(pred);
+ if (has_operations(&env->block_infos,jmp_block)) {
+ if (get_irg_start_block(get_irn_irg(pred_block)) == pred_block)
+ continue; /* must not merge operations into start block */
+ if (!is_Jmp(pred))
+ continue; /* must not create partially dead code, especially when it is mode_M */
+ }
+
+ /* skip jmp block by rerouting its predecessor to block
+ *
+ * A A
+ * | |
+ * jmp_block => |
+ * | |
+ * block block
+ */
+ exchange(jmp, pred);
+
+ /* cleanup: jmp_block might have a Keep edge! */
+ exchange(jmp_block, pred_block);
+ env->changed = true;
+ } else if ( !has_phis(&env->block_infos, block) &&
+ !has_operations(&env->block_infos,jmp_block))
+ {
+ /* all predecessors can skip the jmp block, so block gets some new
+ * predecessors
+ *
+ * A B A B
+ * \ / | |
+ * jmp_block C => Bad C | |
+ * \ / \ | | /
+ * block block
+ */
+ ir_node **ins = ALLOCAN(ir_node*, n_preds+n_jpreds);
+ int j;
+ /* first copy the old predecessors, because the outer loop (i)
+ * still walks over them */
+ for (j = 0; j < n_preds; ++j) {
+ ins[j] = get_Block_cfgpred(block, j);
+ }
+ /* now append the new predecessors */
+ for (j = 0; j < n_jpreds; ++j) {
+ ir_node *pred = get_Block_cfgpred(jmp_block, j);
+ ins[n_preds+j] = pred;
+ }
+ set_irn_in(block, n_preds+n_jpreds, ins);
+ /* convert the jmp_block to Bad */
+ ir_graph *irg = get_irn_irg(block);
+ exchange(jmp_block, new_r_Bad(irg, mode_BB));
+ exchange(jmp, new_r_Bad(irg, mode_X));
+ /* let the outer loop walk over the new predecessors as well */
+ n_preds += n_jpreds;
+ env->changed = true;
+ // TODO What if jmp_block had a KeepAlive edge?
+ } else {
+ /* This would involve Phis ... */
+ }