X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeschednormal.c;h=3f30b2224459c9c60a2118d967c6573bcca9e3f0;hb=afbbc0b1ccd684c4c24bfd43d0f994123245f39f;hp=dacc5a6750a40aaabd493df161cfa11e81791659;hpb=3e73377d9f92b527766caf42bd54af4b9f398c79;p=libfirm diff --git a/ir/be/beschednormal.c b/ir/be/beschednormal.c index dacc5a675..3f30b2224 100644 --- a/ir/be/beschednormal.c +++ b/ir/be/beschednormal.c @@ -36,7 +36,7 @@ #include "irtools.h" #include "irgwalk.h" #include "benode_t.h" - +#include "array_t.h" // XXX there is no one time init for schedulers //#define NORMAL_DBG @@ -95,8 +95,10 @@ static int cost_cmp(const void* a, const void* b) const irn_cost_pair* const a1 = a; const irn_cost_pair* const b1 = b; int ret = b1->cost - a1->cost; + if (ret == 0) + ret = (int)get_irn_idx(a1->irn) - (int)get_irn_idx(b1->irn); #if defined NORMAL_DBG - ir_fprintf(stderr, "%+F %s %+F\n", a1->irn, ret < 0 ? "<" : ret > 0 ? ">" : "=", b1->irn); + ir_fprintf(stderr, "cost %+F %s %+F\n", a1->irn, ret < 0 ? "<" : ret > 0 ? ">" : "=", b1->irn); #endif return ret; } @@ -127,6 +129,7 @@ static int normal_tree_cost(ir_node* irn) flag_and_cost* fc = get_irn_link(irn); ir_node* block = get_nodes_block(irn); int arity = get_irn_arity(irn); + ir_node* last; int n_res; int cost; int n_op_res = 0; @@ -180,10 +183,14 @@ static int normal_tree_cost(ir_node* irn) } cost = 0; + last = 0; for (i = 0; i < arity; ++i) { - if (get_irn_mode(fc->costs[i].irn) == mode_M) continue; - if (arch_irn_is(cur_arch_env, fc->costs[i].irn, ignore)) continue; + ir_node* op = fc->costs[i].irn; + if (op == last) continue; + if (get_irn_mode(op) == mode_M) continue; + if (arch_irn_is(cur_arch_env, op, ignore)) continue; cost = MAX(fc->costs[i].cost + n_op_res, cost); + last = op; ++n_op_res; } n_res = count_result(irn); @@ -245,8 +252,8 @@ static ir_node** sched_node(ir_node** sched, ir_node* irn) int arity = get_irn_arity(irn); int i; - if (irn_visited(irn)) return sched; - if (is_End(irn)) return sched; + if (irn_visited_else_mark(irn)) return sched; + if (is_End(irn)) return sched; if (!is_Phi(irn) && !be_is_Keep(irn)) { for (i = 0; i < arity; ++i) { @@ -258,7 +265,6 @@ static ir_node** sched_node(ir_node** sched, ir_node* irn) } } - mark_irn_visited(irn); ARR_APP1(ir_node*, sched, irn); return sched; } @@ -281,7 +287,7 @@ static int root_cmp(const void* a, const void* b) } } #if defined NORMAL_DBG - ir_fprintf(stderr, "%+F %s %+F\n", a1->irn, ret < 0 ? "<" : ret > 0 ? ">" : "=", b1->irn); + ir_fprintf(stderr, "root %+F %s %+F\n", a1->irn, ret < 0 ? "<" : ret > 0 ? ">" : "=", b1->irn); #endif return ret; }