Commit cf90c48d authored by Matthias Braun's avatar Matthias Braun
Browse files

- make liveness computation ignore end node (to avoid unnecessary...

- make liveness computation ignore end node (to avoid unnecessary interferences because of keepalive edges)
parent ac17fa4d
...@@ -25,7 +25,15 @@ ...@@ -25,7 +25,15 @@
static INLINE int is_liveness_node(const ir_node *irn) static INLINE int is_liveness_node(const ir_node *irn)
{ {
return !is_Block(irn) && !is_Bad(irn); switch(get_irn_opcode(irn)) {
case iro_Block:
case iro_Bad:
case iro_End:
return 0;
default:;
}
return 1;
} }
int (be_lv_next_irn)(const struct _be_lv_t *lv, const ir_node *bl, unsigned flags, int i) int (be_lv_next_irn)(const struct _be_lv_t *lv, const ir_node *bl, unsigned flags, int i)
...@@ -351,9 +359,9 @@ static void liveness_for_node(ir_node *irn, void *data) ...@@ -351,9 +359,9 @@ static void liveness_for_node(ir_node *irn, void *data)
ir_node *use_block; ir_node *use_block;
/* /*
* If the usage is no data node, skip this use, since it does not * If the usage is no data node, skip this use, since it does not
* affect the liveness of the node. * affect the liveness of the node.
*/ */
if(!is_liveness_node(use)) if(!is_liveness_node(use))
continue; continue;
...@@ -361,19 +369,19 @@ static void liveness_for_node(ir_node *irn, void *data) ...@@ -361,19 +369,19 @@ static void liveness_for_node(ir_node *irn, void *data)
use_block = get_nodes_block(use); use_block = get_nodes_block(use);
/* /*
* If the use is a phi function, determine the corresponding block * If the use is a phi function, determine the corresponding block
* through which the value reaches the phi function and mark the * through which the value reaches the phi function and mark the
* value as live out of that block. * value as live out of that block.
*/ */
if(is_Phi(use)) { if(is_Phi(use)) {
ir_node *pred_block = get_Block_cfgpred_block(use_block, edge->pos); ir_node *pred_block = get_Block_cfgpred_block(use_block, edge->pos);
live_end_at_block(lv, irn, pred_block, visited, 0); live_end_at_block(lv, irn, pred_block, visited, 0);
} }
/* /*
* Else, the value is live in at this block. Mark it and call live * Else, the value is live in at this block. Mark it and call live
* out on the predecessors. * out on the predecessors.
*/ */
else if(def_block != use_block) { else if(def_block != use_block) {
int i, n; int i, n;
......
...@@ -218,6 +218,7 @@ typedef struct _spill_t { ...@@ -218,6 +218,7 @@ typedef struct _spill_t {
} spill_t; } spill_t;
typedef struct { typedef struct {
be_lv_t *lv;
ir_graph *irg; ir_graph *irg;
set *spills; set *spills;
ir_node **reloads; ir_node **reloads;
...@@ -373,6 +374,8 @@ static void check_spillslot_interference(be_verify_spillslots_env_t *env) { ...@@ -373,6 +374,8 @@ static void check_spillslot_interference(be_verify_spillslots_env_t *env) {
sp1->spill, get_nodes_block(sp1->spill), get_irg_dump_name(env->irg), sp1->spill, get_nodes_block(sp1->spill), get_irg_dump_name(env->irg),
sp2->spill, get_nodes_block(sp2->spill), get_irg_dump_name(env->irg)); sp2->spill, get_nodes_block(sp2->spill), get_irg_dump_name(env->irg));
env->problem_found = 1; env->problem_found = 1;
my_values_interfere(sp1->spill, sp2->spill);
printf("Intf: %d\n", values_interfere(env->lv, sp1->spill, sp2->spill));
} }
} }
} }
...@@ -386,11 +389,13 @@ int be_verify_spillslots(ir_graph *irg) ...@@ -386,11 +389,13 @@ int be_verify_spillslots(ir_graph *irg)
env.spills = new_set(cmp_spill, 10); env.spills = new_set(cmp_spill, 10);
env.reloads = NEW_ARR_F(ir_node*, 0); env.reloads = NEW_ARR_F(ir_node*, 0);
env.problem_found = 0; env.problem_found = 0;
env.lv = be_liveness(irg);
irg_walk_graph(irg, collect_spills_walker, NULL, &env); irg_walk_graph(irg, collect_spills_walker, NULL, &env);
check_spillslot_interference(&env); check_spillslot_interference(&env);
be_liveness_free(env.lv);
DEL_ARR_F(env.reloads); DEL_ARR_F(env.reloads);
del_set(env.spills); del_set(env.spills);
...@@ -403,39 +408,6 @@ int be_verify_spillslots(ir_graph *irg) ...@@ -403,39 +408,6 @@ int be_verify_spillslots(ir_graph *irg)
static sched_timestep_t get_time_step(const ir_node *irn)
{
if(is_Phi(irn))
return 0;
return sched_get_time_step(irn);
}
static int my_value_dominates(const ir_node *a, const ir_node *b)
{
int res = 0;
const ir_node *ba = get_block(a);
const ir_node *bb = get_block(b);
/*
* a and b are not in the same block,
* so dominance is determined by the dominance of the blocks.
*/
if(ba != bb) {
res = block_dominates(ba, bb);
/*
* Dominance is determined by the time steps of the schedule.
*/
} else {
sched_timestep_t as = get_time_step(a);
sched_timestep_t bs = get_time_step(b);
res = as <= bs;
}
return res;
}
/** /**
* Check, if two values interfere. * Check, if two values interfere.
* @param a The first value. * @param a The first value.
...@@ -446,8 +418,8 @@ static int my_values_interfere(const ir_node *a, const ir_node *b) ...@@ -446,8 +418,8 @@ static int my_values_interfere(const ir_node *a, const ir_node *b)
{ {
const ir_edge_t *edge; const ir_edge_t *edge;
ir_node *bb; ir_node *bb;
int a2b = my_value_dominates(a, b); int a2b = value_dominates(a, b);
int b2a = my_value_dominates(b, a); int b2a = value_dominates(b, a);
/* If there is no dominance relation, they do not interfere. */ /* If there is no dominance relation, they do not interfere. */
if(!a2b && !b2a) if(!a2b && !b2a)
...@@ -481,13 +453,18 @@ static int my_values_interfere(const ir_node *a, const ir_node *b) ...@@ -481,13 +453,18 @@ static int my_values_interfere(const ir_node *a, const ir_node *b)
if(b == user) if(b == user)
continue; continue;
if(get_irn_opcode(user) == iro_End)
continue;
// in case of phi arguments we compare with the block the value comes from // in case of phi arguments we compare with the block the value comes from
if(is_Phi(user)) { if(is_Phi(user)) {
ir_node *phiblock = get_nodes_block(user); ir_node *phiblock = get_nodes_block(user);
if(phiblock == bb)
continue;
user = get_irn_n(phiblock, get_edge_src_pos(edge)); user = get_irn_n(phiblock, get_edge_src_pos(edge));
} }
if(my_value_dominates(b, user)) if(value_dominates(b, user))
return 1; return 1;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment