#define DUMP_SOLUTION
#define DUMP_ILP
-//#define KEEPALIVE /* keep alive all inserted remats and dump graph with remats */
+#define KEEPALIVE /* keep alive all inserted remats and dump graph with remats */
#define COLLECT_REMATS /* enable rematerialization */
#define COLLECT_INVERSE_REMATS /* enable placement of inverse remats */
#define REMAT_WHILE_LIVE /* only remat values that are live */
//#define KEEPALIVE_RELOADS
#define GOODWIN_REDUCTION
//#define NO_MEMCOPIES
+//#define VERIFY_DOMINANCE
#define SOLVE
//#define SOLVE_LOCAL
{
ir_edge_t *edge;
op_t *op = get_irn_link(irn);
+ pset *visited_users = pset_new_ptr_default();
if(op->is_remat) return;
if(is_Phi(irn)) {
int n;
+ pset *visited_operands = pset_new_ptr(get_irn_arity(irn));
/* visit all operands */
for(n=get_irn_arity(irn)-1; n>=0; --n) {
ilp_var_t copy = op->attr.live_range.args.copies[n];
if(!has_reg_class(si, arg)) continue;
+ if(pset_find_ptr(visited_operands, arg)) continue;
+ pset_insert_ptr(visited_operands, arg);
if(arg == target) {
pset_insert(copies, INT_TO_PTR(copy), copy);
write_copy_path_cst(si, copies, any_interfere);
pset_remove(copies, INT_TO_PTR(copy), copy);
- } else {
- if(!pset_find_ptr(visited, arg)) {
- pset_insert(copies, INT_TO_PTR(copy), copy);
- find_copy_path(si, arg, target, any_interfere, copies, visited);
- pset_remove(copies, INT_TO_PTR(copy), copy);
- }
+ } else if(!pset_find_ptr(visited, arg)) {
+ pset_insert(copies, INT_TO_PTR(copy), copy);
+ find_copy_path(si, arg, target, any_interfere, copies, visited);
+ pset_remove(copies, INT_TO_PTR(copy), copy);
}
}
+
+ del_pset(visited_operands);
}
/* visit all uses which are phis */
if(!is_Phi(user)) continue;
if(!has_reg_class(si, user)) continue;
+ if(pset_find_ptr(visited_users, user)) continue;
+ pset_insert_ptr(visited_users, user);
copy = op->attr.live_range.args.copies[pos];
pset_insert(copies, INT_TO_PTR(copy), copy);
write_copy_path_cst(si, copies, any_interfere);
pset_remove(copies, INT_TO_PTR(copy), copy);
- } else {
- if(!pset_find_ptr(visited, user)) {
- pset_insert(copies, INT_TO_PTR(copy), copy);
- find_copy_path(si, user, target, any_interfere, copies, visited);
- pset_remove(copies, INT_TO_PTR(copy), copy);
- }
+ } else if(!pset_find_ptr(visited, user)) {
+ pset_insert(copies, INT_TO_PTR(copy), copy);
+ find_copy_path(si, user, target, any_interfere, copies, visited);
+ pset_remove(copies, INT_TO_PTR(copy), copy);
}
}
+ del_pset(visited_users);
pset_remove_ptr(visited, irn);
}
}
}
+static void
+dump_phi_class(spill_ilp_t * si, pset * phiclass, const char * file)
+{
+ FILE *f = fopen(file, "w");
+ ir_node *irn;
+ interference_t *interference;
+
+ pset_break(phiclass);
+ set_break(si->interferences);
+
+ ir_fprintf(f, "digraph phiclass {\n");
+
+ pset_foreach(phiclass, irn) {
+ if(is_Phi(irn))
+ ir_fprintf(f, " %F%N [shape=box]\n",irn,irn);
+ }
+
+ pset_foreach(phiclass, irn) {
+ int n;
+
+ if(!is_Phi(irn)) continue;
+
+ for(n=get_irn_arity(irn)-1; n>=0; --n) {
+ ir_node *arg = get_irn_n(irn, n);
+
+ ir_fprintf(f, " %F%N -> %F%N\n",irn,irn,arg,arg);
+ }
+ }
+
+ set_foreach(si->interferences, interference) {
+ const ir_node *a = interference->a;
+ const ir_node *b = interference->b;
+ if(get_phi_class(a) == phiclass) {
+ ir_fprintf(f, " %F%N -> %F%N [color=red,dir=none,style=bold]\n",a,a,b,b);
+ }
+ }
+
+ ir_fprintf(f, "}");
+ fclose(f);
+}
+
static void
rewire_uses(spill_ilp_t * si)
{
FIRM_DBG_REGISTER(si.dbg, "firm.be.ra.spillremat");
DBG((si.dbg, LEVEL_1, "\n\n\t\t===== Processing %s =====\n\n", problem_name));
+#ifdef VERIFY_DOMINANCE
be_check_dominance(chordal_env->irg);
+#endif
obstack_init(&obst);
si.chordal_env = chordal_env;
be_analyze_regpressure(chordal_env, "-post");
+#ifdef VERIFY_DOMINANCE
be_check_dominance(chordal_env->irg);
+#endif
free_dom(chordal_env->irg);
del_set(si.interferences);