Commit 2b0fed0d authored by Matthias Braun's avatar Matthias Braun
Browse files

improv execfreq estimation if a loop outedge leaves multiple loops

[r26458]
parent 00d79195
......@@ -182,24 +182,38 @@ get_cf_probability(ir_node *bb, int pos, double loop_weight)
{
double sum = 0.0;
double cur = 0.0;
double inv_loop_weight = 1./loop_weight;
const ir_node *pred = get_Block_cfgpred_block(bb, pos);
const ir_loop *pred_loop;
int pred_depth;
const ir_edge_t *edge;
const ir_loop *loop;
int depth;
int d;
if (is_Bad(pred))
return 0;
loop = get_irn_loop(bb);
depth = get_loop_depth(loop);
pred_loop = get_irn_loop(pred);
pred_depth = get_loop_depth(pred_loop);
cur = get_loop_depth(get_irn_loop(bb)) < get_loop_depth(get_irn_loop(pred)) ? 1.0 : loop_weight;
cur = 1.0;
for (d = depth; d < pred_depth; ++d) {
cur *= inv_loop_weight;
}
foreach_block_succ(pred, edge) {
const ir_node *block = get_edge_src_irn(edge);
const ir_loop *loop = get_irn_loop(block);
int depth = get_loop_depth(loop);
sum += depth < pred_depth ? 1.0 : loop_weight;
const ir_node *succ = get_edge_src_irn(edge);
const ir_loop *succ_loop = get_irn_loop(succ);
int succ_depth = get_loop_depth(succ_loop);
double fac = 1.0;
for (d = succ_depth; d < pred_depth; ++d) {
fac *= inv_loop_weight;
}
sum += fac;
}
return cur/sum;
......
......@@ -190,8 +190,6 @@ int get_loop_loop_nr(const ir_loop *loop) {
#endif
}
/** A field to connect additional information to a loop. Only valid
if libfirm_debug is set. */
void set_loop_link(ir_loop *loop, void *link) {
assert(loop && loop->kind == k_ir_loop);
loop->link = link;
......
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