Bugfix
[libfirm] / ir / be / becopyilp.c
index 4ff9f25..c2c518c 100644 (file)
@@ -381,10 +381,6 @@ static INLINE int get_costs(problem_instance_t *pi, ir_node *phi, ir_node *irn)
        return 0;
 }
 
-/*
- * TODO: Because this here uses a phi-walker and not the ou's,
- * it is possible, that the interfering args of a phi will cause a bug ??!!
- */
 static void M_constr_walker(ir_node *block, void *env) {
        problem_instance_t *pi = env;
        int count, arity, row, col, other_row, *costs;
@@ -410,8 +406,14 @@ static void M_constr_walker(ir_node *block, void *env) {
        phi = sched_first(block);
        for (row=0; row<count; ++row) {
                phis[row] = phi;
-               for (col=0; col<arity; ++col)
-                       phi_matrix[row*arity + col] = get_irn_n(phi, col);
+               for (col=0; col<arity; ++col) {
+                       ir_node *arg = get_irn_n(phi, col);
+                       /* Sort out all arguments interfering with its phi */
+                       if (nodes_interfere(pi->co->chordal_env, phi, arg)) {
+                               phi_matrix[row*arity + col] =  NULL;
+                       } else
+                               phi_matrix[row*arity + col] =  arg;
+               }
                phi = sched_next(phi);
        }
 
@@ -422,8 +424,11 @@ static void M_constr_walker(ir_node *block, void *env) {
                done = pset_new_ptr_default();
                for (row=0; row<count; ++row) {
                        irn = phi_matrix[row*arity + col];
-                       /* has the irn already been processed in this col? */
-                       if (pset_find_ptr(done, irn))
+                       /*
+                        * is this an interfering arg (NULL)
+                        * or has the irn already been processed in this col?
+                        */
+                       if (!irn || pset_find_ptr(done, irn))
                                continue;
                        else
                                pset_insert_ptr(done, irn);
@@ -611,8 +616,8 @@ static void pi_apply_solution(problem_instance_t *pi) {
        DBG((dbg, LEVEL_2, "Applying solution...\n"));
 
 #ifdef DO_STAT
-       curr_vals[I_ILP_ITER] += lpp_get_iter_cnt(pi->curr_lp);
-       curr_vals[I_ILP_TIME] += lpp_get_sol_time(pi->curr_lp);
+       copystat_add_ilp_time(lpp_get_sol_time(pi->curr_lp));
+       copystat_add_ilp_iter(lpp_get_iter_cnt(pi->curr_lp));
 #endif
 
        sol = xmalloc((pi->last_x_var+1) * sizeof(*sol));