From 8805e4fb65465abb2ed0ccde2377097c8f9d48c9 Mon Sep 17 00:00:00 2001 From: Daniel Grund Date: Thu, 18 Aug 2005 21:21:54 +0000 Subject: [PATCH] bugfixes. added 3 stats. added asserts. disabled generation of M_constraints in certain cases. --- ir/be/bearch_firm.c | 7 +++---- ir/be/becopyilp.c | 14 ++++++++++---- ir/be/becopyoptmain.c | 10 +++++++++- ir/be/becopystat.c | 27 ++++++++++++++++++++------- ir/be/becopystat.h | 11 +++++++++-- ir/be/bemain.c | 5 +---- ir/be/bespillilp.c | 29 +++++++++++++++++------------ 7 files changed, 69 insertions(+), 34 deletions(-) diff --git a/ir/be/bearch_firm.c b/ir/be/bearch_firm.c index 3779dd6e2..2f9eccd97 100644 --- a/ir/be/bearch_firm.c +++ b/ir/be/bearch_firm.c @@ -21,7 +21,7 @@ #include "irreflect.h" -#define N_REGS 6 +#define N_REGS 8 static arch_register_t datab_regs[N_REGS]; @@ -339,7 +339,6 @@ static void prepare_walker(ir_node *irn, void *data) set_irn_link(nc, nc); } } - } static void localize_const_walker(ir_node *irn, void *data) @@ -352,14 +351,14 @@ static void localize_const_walker(ir_node *irn, void *data) ir_node *op = get_irn_n(irn, i); opcode opc = get_irn_opcode(op); - if(opc == iro_Const || opc == iro_SymConst) { + if(opc == iro_Const + || (opc == iro_SymConst && get_SymConst_kind(op) == symconst_addr_ent)) { ir_graph *irg = get_irn_irg(bl); ir_node *imm_bl = is_Phi(irn) ? get_Block_cfgpred_block(bl, i) : bl; ir_node *imm = new_Imm(irg, imm_bl, op); set_irn_n(irn, i, imm); } - } } } diff --git a/ir/be/becopyilp.c b/ir/be/becopyilp.c index f8e02a8a8..ad481fe3f 100644 --- a/ir/be/becopyilp.c +++ b/ir/be/becopyilp.c @@ -574,16 +574,20 @@ static void M_constr_walker(ir_node *block, void *env) { } minimal_costs = sum - max; + int gen_cst = 1; if (assert_costs != -1) { - bitset_foreach(candidates, phi_nr) - assert(costs[phi_nr] == assert_costs); + bitset_foreach(candidates, phi_nr) { + /* possible, if argument of a OU are joined */ + if (costs[phi_nr] != assert_costs) + gen_cst = 0; + } } /* generate an unequation finally. * phis are indexed in the bitset, * shared argument is irn * rhs is minimal_costs */ - { + if (gen_cst) { char buf[32]; ir_node *root; int pos, irnnr, rootnr, cst_idx, y_idx, cst_counter = 0; @@ -809,7 +813,9 @@ static void pi_apply_solution(problem_instance_t *pi) { DBG((dbg, LEVEL_2, "Applying solution...\n")); #ifdef DO_STAT - copystat_add_ilp_time(lpp_get_sol_time(pi->curr_lp)); + copystat_add_ilp_time((int)(1000.0*lpp_get_sol_time(pi->curr_lp))); //new we have ms + copystat_add_ilp_vars(lpp_get_var_count(pi->curr_lp)); + copystat_add_ilp_csts(lpp_get_cst_count(pi->curr_lp)); copystat_add_ilp_iter(lpp_get_iter_cnt(pi->curr_lp)); #endif diff --git a/ir/be/becopyoptmain.c b/ir/be/becopyoptmain.c index 6451c547b..3483174db 100644 --- a/ir/be/becopyoptmain.c +++ b/ir/be/becopyoptmain.c @@ -12,6 +12,8 @@ #include "config.h" #endif + +#include #include "debug.h" #include "irouts.h" #include "becopyopt.h" @@ -19,7 +21,7 @@ #include "becopyoptmain.h" #define DO_HEUR -#undef DO_ILP +#define DO_ILP #define DEBUG_LVL SET_LEVEL_1 static firm_dbg_module_t *dbg = NULL; @@ -54,7 +56,11 @@ void be_copy_opt(be_chordal_env_t *chordal_env) { #endif #ifdef DO_HEUR + lc_timer_t *timer = lc_timer_register("heur", NULL); + lc_timer_start(timer); co_heur_opt(co); + lc_timer_stop(timer); + copystat_add_heur_time(lc_timer_elapsed_msec(timer)); #ifdef DO_STAT costs = co_get_copy_costs(co); costs_heur = costs; @@ -72,6 +78,8 @@ void be_copy_opt(be_chordal_env_t *chordal_env) { DBG((dbg, LEVEL_1, "Opt costs: %3d\n", costs_ilp)); #endif #endif + assert(lower_bound <= costs_ilp); + assert(costs_ilp <= costs_heur); free_copy_opt(co); } diff --git a/ir/be/becopystat.c b/ir/be/becopystat.c index dae30f585..4be454229 100644 --- a/ir/be/becopystat.c +++ b/ir/be/becopystat.c @@ -58,17 +58,21 @@ enum vals_t { I_CLS_PHIS_E = I_CLS_PHIS_S+MAX_CLS_PHIS, /* FROM HERE: RESULT VLAUES */ + /* all of them are external set */ /* ilp values */ - I_ILP_TIME, /* !external set! solving time in seconds */ - I_ILP_ITER, /* !external set! number of simplex iterations */ + I_HEUR_TIME, /* solving time in milli seconds */ + I_ILP_TIME, /* solving time in milli seconds */ + I_ILP_VARS, + I_ILP_CSTR, + I_ILP_ITER, /* number of simplex iterations */ /* copy instructions */ - I_COPIES_MAX, /* !external set! max possible costs of copies*/ - I_COPIES_INIT, /* !external set! number of copies in initial allocation */ - I_COPIES_HEUR, /* !external set! number of copies after heuristic */ - I_COPIES_OPT, /* !external set! number of copies after ilp */ - I_COPIES_IF, /* !external set! number of copies inevitable due to root-arg-interf */ + I_COPIES_MAX, /* max possible costs of copies*/ + I_COPIES_INIT, /* number of copies in initial allocation */ + I_COPIES_HEUR, /* number of copies after heuristic */ + I_COPIES_OPT, /* number of copies after ilp */ + I_COPIES_IF, /* number of copies inevitable due to root-arg-interf */ ASIZE }; @@ -280,9 +284,18 @@ void copystat_add_heur_costs(int costs) { void copystat_add_opt_costs(int costs) { curr_vals[I_COPIES_OPT] += costs; } +void copystat_add_heur_time(int time) { + curr_vals[I_HEUR_TIME] += time; +} void copystat_add_ilp_time(int time) { curr_vals[I_ILP_TIME] += time; } +void copystat_add_ilp_vars(int vars) { + curr_vals[I_ILP_VARS] += vars; +} +void copystat_add_ilp_csts(int csts) { + curr_vals[I_ILP_CSTR] += csts; +} void copystat_add_ilp_iter(int iters) { curr_vals[I_ILP_ITER] += iters; } diff --git a/ir/be/becopystat.h b/ir/be/becopystat.h index 8f465afc0..3674ee211 100644 --- a/ir/be/becopystat.h +++ b/ir/be/becopystat.h @@ -24,11 +24,15 @@ void copystat_add_inevit_costs(int costs); void copystat_add_init_costs(int costs); void copystat_add_heur_costs(int costs); void copystat_add_opt_costs(int costs); +void copystat_add_heur_time(int time); void copystat_add_ilp_time(int time); +void copystat_add_ilp_vars(int vars); +void copystat_add_ilp_csts(int csts); void copystat_add_ilp_iter(int iters); void copystat_dump(ir_graph *irg); void copystat_dump_pretty(ir_graph *irg); + #else /* DO_STAT */ #define copy_copystat_init(); @@ -40,8 +44,11 @@ void copystat_dump_pretty(ir_graph *irg); #define copystat_add_init_costs(costs); #define copystat_add_heur_costs(costs); #define copystat_add_opt_costs(costs); -#define copystat_add_ilp_time(int time); -#define copystat_add_ilp_iter(int iters); +#define copystat_add_heur_time(time); +#define copystat_add_ilp_time(time); +#define copystat_add_ilp_vars(vars); +#define copystat_add_ilp_csts(csts); +#define copystat_add_ilp_iter(iters); #define copystat_dump(irg); #define copystat_dump(irg); #define copystat_dump_pretty(irg); diff --git a/ir/be/bemain.c b/ir/be/bemain.c index b5a35be34..7283ebf77 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -162,7 +162,7 @@ static void be_main_loop(void) DBG((env.dbg, LEVEL_1, "----> Reg class: %s\n", cls->name)); - be_spill_ilp(&session, cls); + be_spill_ilp(&session, cls); dump_ir_block_graph_sched(session.irg, "-spill"); be_liveness(irg); @@ -186,14 +186,12 @@ static void be_main_loop(void) #ifdef DUMP_ALLOCATED dump_allocated_irg(env.arch_env, irg, ""); #endif -#if 0 copystat_collect_cls(chordal_env); be_copy_opt(chordal_env); be_ssa_destruction(chordal_env); be_ssa_destruction_check(chordal_env); -#endif be_ra_chordal_check(chordal_env); be_ra_chordal_done(chordal_env); @@ -202,7 +200,6 @@ static void be_main_loop(void) dump_ir_block_graph_sched(session.irg, "-post"); copystat_dump(irg); - copystat_dump_pretty(irg); } } diff --git a/ir/be/bespillilp.c b/ir/be/bespillilp.c index a2a245c8c..fa9731e4d 100644 --- a/ir/be/bespillilp.c +++ b/ir/be/bespillilp.c @@ -387,6 +387,9 @@ static void process_block(ir_node *bl, void *data) step++; } + if(bl == get_irg_start_block(get_irn_irg(bl))) + goto end; + /* * Here, only the phis in the block and the values live in are in the * live set. @@ -433,6 +436,8 @@ static void process_block(ir_node *bl, void *data) } } +end: + del_pset(live); } @@ -623,21 +628,10 @@ void be_spill_ilp(const be_main_session_env_t *session_env, si.enable_store = 0; firm_dbg_set_mask(si.dbg, DBG_LEVEL); - irg_block_walk_graph(session_env->irg, process_block, NULL, &si); + irg_block_walk_graph(session_env->irg, process_block, NULL, &si); if(si.enable_store) add_store_costs(&si); - DBG((si.dbg, LEVEL_1, "%F\n", session_env->irg)); - lpp_solve_net(si.lpp, LPP_SERVER, LPP_SOLVER); - assert(lpp_is_sol_valid(si.lpp) && "ILP not feasible"); - - // assert(lpp_is_sol_valid(si.lpp) && "solution of ILP must be valid"); - - DBG((si.dbg, LEVEL_1, "\tnodes: %d, vars: %d, csts: %d\n", - set_count(si.irn_use_heads), si.lpp->var_next, si.lpp->cst_next)); - DBG((si.dbg, LEVEL_1, "\titerations: %d, solution time: %g\n", - si.lpp->iterations, si.lpp->sol_time)); - #ifdef DUMP_ILP { FILE *f; @@ -650,6 +644,17 @@ void be_spill_ilp(const be_main_session_env_t *session_env, } #endif + DBG((si.dbg, LEVEL_1, "%F\n", session_env->irg)); + lpp_solve_net(si.lpp, LPP_SERVER, LPP_SOLVER); + assert(lpp_is_sol_valid(si.lpp) && "ILP not feasible"); + + assert(lpp_is_sol_valid(si.lpp) && "solution of ILP must be valid"); + + DBG((si.dbg, LEVEL_1, "\tnodes: %d, vars: %d, csts: %d\n", + set_count(si.irn_use_heads), si.lpp->var_next, si.lpp->cst_next)); + DBG((si.dbg, LEVEL_1, "\titerations: %d, solution time: %g\n", + si.lpp->iterations, si.lpp->sol_time)); + #ifdef DUMP_SOLUTION { FILE *f; -- 2.20.1