X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeschednormal.c;h=eaef6f1af4798ac601ff3580cd99ee30bdcf2c73;hb=a4c23fb5fdcaf600f18b4fa7b7e104fa9b7dc514;hp=2c534ec0f1040f1a1c869ac2cd8c6a14a80bbd93;hpb=16c6fb6b6a7f1b5c11345fa29e925b4b4447a52b;p=libfirm diff --git a/ir/be/beschednormal.c b/ir/be/beschednormal.c index 2c534ec0f..eaef6f1af 100644 --- a/ir/be/beschednormal.c +++ b/ir/be/beschednormal.c @@ -39,7 +39,8 @@ // XXX there is no one time init for schedulers -#define NORMAL_DBG +//#define NORMAL_DBG +#include "irprintf.h" static int must_be_scheduled(const ir_node* const irn) @@ -93,17 +94,11 @@ 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; - if (is_irn_forking(a1->irn)) { - ret = 1; - } else if (is_irn_forking(b1->irn)) { - ret = -1; - } else { - ret = b1->cost - a1->cost; - //ret = a1->cost - b1->cost; - } + 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; } @@ -134,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; @@ -187,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); @@ -275,9 +275,20 @@ static int root_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; + int ret; + if (is_irn_forking(a1->irn)) { + ret = 1; + } else if (is_irn_forking(b1->irn)) { + ret = -1; + } else { + ret = b1->cost - a1->cost; + if (ret == 0) { + /* place live-out nodes later */ + ret = (count_result(a1->irn) != 0) - (count_result(b1->irn) != 0); + } + } #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; }