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
d1e2fe6b
Commit
d1e2fe6b
authored
Sep 19, 2014
by
Andreas Fried
Browse files
Check that the Gauss-Jordan algorithm did not fail on the matrix.
parent
9ea8c8e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/ana/execfreq.c
View file @
d1e2fe6b
...
...
@@ -94,19 +94,14 @@ void exit_execfreq(void)
}
static
double
*
solve_lgs
(
double
*
mat
,
double
*
x
,
int
size
)
static
int
solve_lgs
(
double
*
mat
,
double
*
x
,
int
size
)
{
/* better convergence. */
double
init
=
1
.
0
/
size
;
for
(
int
i
=
0
;
i
<
size
;
++
i
)
x
[
i
]
=
init
;
double
dev
;
do
{
dev
=
firm_gaussjordansolve
(
mat
,
x
,
size
);
}
while
(
fabs
(
dev
)
>
SEIDEL_TOLERANCE
);
return
x
;
return
firm_gaussjordansolve
(
mat
,
x
,
size
);
}
static
bool
has_path_to_end
(
const
ir_node
*
block
)
...
...
@@ -345,10 +340,16 @@ void ir_estimate_execfreq(ir_graph *irg)
}
/* solve the system and delete the matrix */
double
*
x
=
XMALLOCN
(
double
,
size
);
//ir_fprintf(stderr, "%+F:\n", irg);
//gs_matrix_dump(mat, stderr);
solve_lgs
(
mat
,
x
,
size
);
double
*
x
=
XMALLOCN
(
double
,
size
);
bool
valid_freq
=
true
;
if
(
lgs_size
==
1
)
{
lgs_x
[
0
]
=
1
.
0
;
}
else
{
int
lgs_result
=
solve_lgs
(
lgs_matrix
,
lgs_x
);
valid_freq
=
!
lgs_result
;
/* solve_lgs returns -1 on error. */
}
free
(
mat
);
/* compute the normalization factor.
...
...
@@ -356,21 +357,22 @@ void ir_estimate_execfreq(ir_graph *irg)
* (note: start_idx is != 0 in strange cases involving endless loops,
* probably a misfeature/bug)
*/
double
start_freq
=
x
[
start_idx
];
double
norm
=
start_freq
!
=
0
.
0
?
1
.
0
/
start_freq
:
1
.
0
;
bool
valid
_freq
=
true
;
for
(
int
idx
=
size
-
1
;
idx
>=
0
;
--
idx
)
{
ir_node
*
bb
=
(
ir_node
*
)
dfs_get_post_num_node
(
dfs
,
size
-
idx
-
1
);
if
(
valid_freq
)
{
double
start_freq
=
x
[
start_idx
]
;
double
norm
=
start
_freq
!
=
0
.
0
?
1
.
0
/
start_freq
:
1
.
0
;
for
(
int
idx
=
size
-
1
;
idx
>=
0
;
--
idx
)
{
ir_node
*
bb
=
(
ir_node
*
)
dfs_get_post_num_node
(
dfs
,
size
-
idx
-
1
);
/* take abs because it sometimes can be -0 in case of endless loops */
double
freq
=
fabs
(
x
[
idx
])
*
norm
;
/* take abs because it sometimes can be -0 in case of endless loops */
double
freq
=
fabs
(
x
[
idx
])
*
norm
;
/* Check for inf, nan and negative values. */
if
(
isinf
(
freq
)
||
!
(
freq
>=
0
))
{
valid_freq
=
false
;
break
;
/* Check for inf, nan and negative values. */
if
(
isinf
(
freq
)
||
!
(
freq
>=
0
))
{
valid_freq
=
false
;
break
;
}
set_block_execfreq
(
bb
,
freq
);
}
set_block_execfreq
(
bb
,
freq
);
}
/* Fallback solution: Use loop weight. */
...
...
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