- ir_node *block;
-
- block = get_nodes_block(irn);
-
- if(block_dominates(dominator, block)) {
- ir_node *cond = NULL;
- int i, n;
-
- /* check, if we're on a ProjX
- *
- * Further, the ProjX/Cond block must dominate the base block
- * (the block with the phi in it), otherwise, the Cond
- * is not affecting the phi so that a mux can be inserted.
- */
- if(is_Proj(irn) && get_irn_mode(irn) == mode_X) {
-
- int proj = get_Proj_proj(irn);
- cond = get_Proj_pred(irn);
-
- /* Check, if the pred of the proj is a Cond
- * with a Projb as selector.
- */
- if(get_irn_opcode(cond) == iro_Cond
- && get_irn_mode(get_Cond_selector(cond)) == mode_b) {
-
- cond_t *res, c;
-
- memset(&c, 0, sizeof(c));
- c.cond = cond;
- INIT_LIST_HEAD(&c.list);
- c.cases[0].pos = -1;
- c.cases[1].pos = -1;
-
- /* get or insert the cond info into the set. */
- res = set_insert(ci->cond_set, &c, sizeof(c), HASH_PTR(cond));
-
- if(!res->in_list) {
- res->in_list = 1;
- list_add(&res->list, &ci->roots);
- }
-
- /*
- * Link it to the cond ir_node. We need that later, since
- * one cond masks the other we want to retreive the cond_t
- * data from the masking cond ir_node.
- */
- set_irn_link(cond, res);
-
- /*
- * Set masked by (either NULL or another cond node.
- * If this cond is truly masked by another one, set
- * the position of the actually investigated branch
- * to -1. Since the cond is masked by another one,
- * there could be more ways from the start block
- * to this branch, so we choose -1.
- */
- res->cases[proj].masked_by = masked_by;
- if(!masked_by)
- res->cases[proj].pos = pos;
-
- /*
- * Since the masked_by nodes masks a cond, remove it from the
- * root list of the conf trees.
- */
- else {
- cond_t *m = get_cond(masked_by, ci->cond_set);
- struct list_head *list = &m->list;
-
- /*
- * If this cond was not removed before,
- * remove it now from the list.
- */
- if(!list_empty(list))
- list_del_init(list);
- }
-
- DBG((dbg, LEVEL_5, "%{firm:indent}found cond %n (%s branch) "
- "for pos %d in block %n reached by %n\n",
- depth, cond, get_Proj_proj(irn) ? "true" : "false", pos, block, masked_by));
- }
-
- /*
- * We set cond to NULL if the cond was an switch cond, since it is
- * passed (as the masked_by argument) to recursive calls to this
- * function. We do not consider switch conds as masking conds for
- * other conds.
- */
- else
- cond = NULL;
- }
-
- if(get_Block_block_visited(block) < visited_nr) {
-
- set_Block_block_visited(block, visited_nr);
-
- /* Search recursively from this cond. */
- for(i = 0, n = get_irn_arity(block); i < n; ++i) {
- ir_node *pred = get_irn_n(block, i);
+ ir_node* pred_block = get_nodes_block(get_irn_n(block, i));
+ int arity = get_irn_arity(block);
+ int new_pred_arity;
+ ir_node *phi, *next;
+ ir_node **ins;
+ ir_node **pred_ins;
+ int k;
+
+ DB((dbg, LEVEL_1, "Splitting predecessor %d of predecessor %d of %+F\n", j, i, block));
+
+ NEW_ARR_A(ir_node*, ins, arity + 1);
+
+ for (phi = get_Block_phis(block); phi != NULL; phi = get_Phi_next(phi)) {
+ ir_node* copy = copy_to(get_irn_n(phi, i), pred_block, j);
+
+ for (k = 0; k < i; ++k) ins[k] = get_irn_n(phi, k);
+ ins[k++] = copy;
+ for (; k < arity; ++k) ins[k] = get_irn_n(phi, k);
+ ins[k] = get_irn_n(phi, i);
+ assert(k == arity);
+ set_irn_in(phi, arity + 1, ins);
+ }