Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
41ca8262
Commit
41ca8262
authored
Sep 04, 2009
by
yb9976
Browse files
Added some comments.
[r26492]
parent
871d475c
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/ana/execfreq.c
View file @
41ca8262
...
...
@@ -177,11 +177,14 @@ solve_lgs(gs_matrix_t *mat, double *x, int size)
return
x
;
}
/*
* Determine probability that predecessor pos takes this cf edge.
*/
static
double
get_cf_probability
(
ir_node
*
bb
,
int
pos
,
double
loop_weight
)
{
double
sum
=
0
.
0
;
double
cur
=
0
.
0
;
double
cur
=
1
.
0
;
double
inv_loop_weight
=
1
.
/
loop_weight
;
const
ir_node
*
pred
=
get_Block_cfgpred_block
(
bb
,
pos
);
const
ir_loop
*
pred_loop
;
...
...
@@ -199,7 +202,6 @@ get_cf_probability(ir_node *bb, int pos, double loop_weight)
pred_loop
=
get_irn_loop
(
pred
);
pred_depth
=
get_loop_depth
(
pred_loop
);
cur
=
1
.
0
;
for
(
d
=
depth
;
d
<
pred_depth
;
++
d
)
{
cur
*=
inv_loop_weight
;
}
...
...
@@ -299,19 +301,21 @@ compute_execfreq(ir_graph * irg, double loop_weight)
freq
=
set_insert_freq
(
freqs
,
bb
);
freq
->
idx
=
idx
;
/* Sum of (execution frequency of predecessor * probability of cf edge) ... */
for
(
i
=
get_Block_n_cfgpreds
(
bb
)
-
1
;
i
>=
0
;
--
i
)
{
ir_node
*
pred
=
get_Block_cfgpred_block
(
bb
,
i
);
int
pred_idx
=
size
-
dfs_get_post_num
(
dfs
,
pred
)
-
1
;
gs_matrix_set
(
mat
,
idx
,
pred_idx
,
get_cf_probability
(
bb
,
i
,
loop_weight
));
}
/* ... equals my execution frequency */
gs_matrix_set
(
mat
,
idx
,
idx
,
-
1
.
0
);
}
dfs_free
(
dfs
);
/*
* Add a
loop
from end to start.
* Add a
n edge
from end to start.
* The problem is then an eigenvalue problem:
* Solve A*x = 1*x => (A-I)x = 0
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment