4 * @author Sebastian Hack
6 * Insert duplicates for phi operands which interfere with the phi.
8 * Copyright (C) 2005 Universitaet Karlsruhe
9 * Released under the GPL
13 #include "irgraph_t.h"
20 #include "besched_t.h"
22 static void eliminate_phi_int_walker(ir_node *irn, void *data)
24 const be_main_session_env_t *env = data;
25 const arch_register_class_t *cls =
26 arch_get_irn_reg_class(env->main_env->arch_env, irn, arch_pos_make_out(0));
28 if(is_Phi(irn) && cls != NULL) {
30 ir_node *phi_bl = get_nodes_block(irn);
32 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
33 ir_node *operand = get_irn_n(irn, i);
34 ir_node *bl = get_Block_cfgpred_block(phi_bl, i);
36 if(is_live_in(phi_bl, irn)) { // values_interfere(irn, operand)) {
37 ir_node *copy = new_Copy(env->main_env->node_factory, cls, env->irg, bl, operand);
38 set_irn_n(irn, i, copy);
39 sched_add_after(sched_last(bl), copy);
45 void be_eliminate_phi_interferences(const be_main_session_env_t *env)
47 irg_walk_graph(env->irg, eliminate_phi_int_walker, NULL, (void *) env);