X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Floop_unrolling.c;h=564d44a6471f7cd38bdbb145f947eed18eca14d4;hb=8eb0a1256d88d68e762c1f087bffadca68dc5c12;hp=142b94cf05778e8003ec9075144a9c99f92d4730;hpb=7ebd71f224d304813e574a95b1cafd2d6370dd92;p=libfirm diff --git a/ir/opt/loop_unrolling.c b/ir/opt/loop_unrolling.c index 142b94cf0..564d44a64 100644 --- a/ir/opt/loop_unrolling.c +++ b/ir/opt/loop_unrolling.c @@ -35,6 +35,7 @@ # include "irgopt_t.h" # include "irnode_t.h" # include "irouts.h" +# include "trouts.h" # include "hashptr.h" # include "pset.h" # include "strength_red.h" @@ -814,10 +815,11 @@ set_loop_outs(set *l_n, set *loop_outs, set *loop_endblock_outs, induct_var_info * Called from a post walker. * * @param n An IR node. - * @param env Free environment pointer. + * @param env points to a result */ static void do_loop_unroll(ir_node *n, void *env) { + int *unroll_done = env; induct_var_info info; copies_t *value; set *loop_nodes, *loop_outs, *loop_endblock_outs; @@ -887,7 +889,9 @@ static void do_loop_unroll(ir_node *n, void *env) if (get_firm_verbosity()) printf("\nloop unrolling with factor %d \n", unroll_factor); - //DDMG(get_irn_irg(n)); + + /* ok, we will do unrolling */ + *unroll_done += 1; /* The unroll factor must be less than 4. */ assert(unroll_factor <= MAX_UNROLL); @@ -922,10 +926,8 @@ static void do_loop_unroll(ir_node *n, void *env) /* Set the backedge of the loop head. */ for (value = set_first(loop_nodes); value != NULL; value = set_next(loop_nodes)) { - if(value->irn == backedge_jmp){ - + if (value->irn == backedge_jmp) set_Block_cfgpred(loop_head, backedge_pos, value->copy[unroll_factor-2]); - } } set_loop_outs(loop_nodes, loop_outs, loop_endblock_outs, &info, unroll_factor); } @@ -934,6 +936,7 @@ static void do_loop_unroll(ir_node *n, void *env) void optimize_loop_unrolling(ir_graph *irg /* unroll factor, max body size */) { ir_graph *rem; + int unroll_done = 0; if ( !get_opt_loop_unrolling()) return; @@ -954,7 +957,16 @@ void optimize_loop_unrolling(ir_graph *irg /* unroll factor, max body size */) collect_phiprojs(irg); /* -- Search expressions that can be optimized -- */ - irg_walk_graph(irg, NULL, do_loop_unroll, NULL); + irg_walk_graph(irg, NULL, do_loop_unroll, &unroll_done); + + if (unroll_done) { + /* unrolling was done, all info is invalid */ + set_irg_dom_inconsistent(irg); + set_irg_outs_inconsistent(irg); + set_irg_loopinfo_state(current_ir_graph, loopinfo_cf_inconsistent); + set_trouts_inconsistent(); + set_irg_callee_info_state(irg, irg_callee_info_inconsistent); + } current_ir_graph = rem; }