+ in[0] = get_Block_cfgpred(block, pos);
+ new_block = new_r_Block(irg, 1, in);
+ new_jmp = new_r_Jmp(irg, new_block);
+ set_Block_cfgpred(block, pos, new_jmp);
+}
+
+typedef struct condeval_env_t {
+ ir_node *true_block;
+ ir_node *cmp; /**< The Compare node that might be partial evaluated */
+ pn_Cmp pnc; /**< The Compare mode of the Compare node. */
+ ir_node *cnst;
+ tarval *tv;
+ unsigned long visited_nr;
+
+ ir_node *cnst_pred; /**< the block before the constant */
+ int cnst_pos; /**< the pos to the constant block (needed to
+ kill that edge later) */
+} condeval_env_t;
+
+static ir_node *copy_and_fix_node(const condeval_env_t *env, ir_node *block,
+ ir_node *copy_block, int j, ir_node *node) {
+ int i, arity;
+ ir_node *copy;
+
+ /* we can evaluate Phis right now, all other nodes get copied */
+ if (is_Phi(node)) {
+ copy = get_Phi_pred(node, j);
+ /* we might have to evaluate a Phi-cascade */
+ if(get_irn_visited(copy) >= env->visited_nr) {
+ copy = get_irn_link(copy);
+ }
+ } else {
+ copy = exact_copy(node);
+ set_nodes_block(copy, copy_block);
+
+ assert(get_irn_mode(copy) != mode_X);
+
+ arity = get_irn_arity(copy);
+ for(i = 0; i < arity; ++i) {
+ ir_node *pred = get_irn_n(copy, i);
+ ir_node *new_pred;
+
+ if(get_nodes_block(pred) != block)
+ continue;
+
+ if(get_irn_visited(pred) >= env->visited_nr) {
+ new_pred = get_irn_link(pred);
+ } else {
+ new_pred = copy_and_fix_node(env, block, copy_block, j, pred);
+ }
+ set_irn_n(copy, i, new_pred);
+ }
+ }
+
+ set_irn_link(node, copy);
+ set_irn_visited(node, env->visited_nr);
+
+ return copy;