some more code I played around with lately
[libfirm] / ir / opt / reassoc.c
index 1890716..de5b6dd 100644 (file)
@@ -735,6 +735,7 @@ void optimize_reassociation(ir_graph *irg)
 {
        walker_t env;
        irg_loopinfo_state state;
+       ir_graph *rem;
 
        assert(get_irg_phase_state(irg) != phase_building);
        assert(get_irg_pinned(irg) != op_pin_state_floats &&
@@ -744,6 +745,9 @@ void optimize_reassociation(ir_graph *irg)
        if (!get_opt_reassociation() || !get_opt_constant_folding())
                return;
 
+       rem = current_ir_graph;
+       current_ir_graph = irg;
+
        /* we use dominance to detect dead blocks */
        assure_doms(irg);
 
@@ -762,7 +766,7 @@ void optimize_reassociation(ir_graph *irg)
        env.wq      = new_waitq();
 
        /* disable some optimizations while reassoc is running to prevent endless loops */
-       set_opt_reassoc_running(1);
+       set_reassoc_running(1);
        {
                /* now we have collected enough information, optimize */
                irg_walk_graph(irg, NULL, wq_walker, &env);
@@ -771,7 +775,7 @@ void optimize_reassociation(ir_graph *irg)
                /* reverse those rules that do not result in collapsed constants */
                irg_walk_graph(irg, NULL, reverse_rules, &env);
        }
-       set_opt_reassoc_running(0);
+       set_reassoc_running(0);
 
        /* Handle graph state */
        if (env.changes) {
@@ -780,6 +784,7 @@ void optimize_reassociation(ir_graph *irg)
        }
 
        del_waitq(env.wq);
+       current_ir_graph = rem;
 }  /* optimize_reassociation */
 
 /* Sets the default reassociation operation for an ir_op_ops. */