Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CertiCompil
CompCert-KVX
Commits
6d4dc7ae
Commit
6d4dc7ae
authored
Apr 02, 2021
by
Cyril SIX
Browse files
Outermost loop detection works
parent
a4720c58
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/Duplicateaux.ml
View file @
6d4dc7ae
...
...
@@ -306,21 +306,25 @@ let get_loop_bodies code entrypoint =
(* Returns a PTree of either None or Some b where b determines the node in the loop body, for a cb instruction *)
let
get_loop_info
f
is_loop_header
bfs_order
code
=
let
loop_info
=
ref
(
PTree
.
map
(
fun
n
i
->
None
)
code
)
in
let
mark_
iloop
iloop
=
let
mark_
body
body
=
List
.
iter
(
fun
n
->
match
get_some
@@
PTree
.
get
n
code
with
|
Icond
(
_
,
_
,
ifso
,
ifnot
,
_
)
->
let
b1
=
List
.
mem
ifso
iloop
.
body
in
let
b2
=
List
.
mem
ifnot
iloop
.
body
in
let
b1
=
List
.
mem
ifso
body
in
let
b2
=
List
.
mem
ifnot
body
in
if
(
b1
&&
b2
)
then
()
else
if
(
b1
||
b2
)
then
begin
if
b1
then
loop_info
:=
PTree
.
set
n
(
Some
true
)
!
loop_info
else
if
b2
then
loop_info
:=
PTree
.
set
n
(
Some
false
)
!
loop_info
end
|
_
->
()
)
iloop
.
body
in
let
iloops
=
get_inner_loops
f
code
is_loop_header
in
List
.
iter
mark_iloop
iloops
;
)
body
in
let
bodymap
=
get_loop_bodies
code
f
.
fn_entrypoint
in
List
.
iter
(
fun
(
_
,
obody
)
->
match
obody
with
|
None
->
()
|
Some
body
->
mark_body
body
)
(
PTree
.
elements
bodymap
);
!
loop_info
(* Remark - compared to the original Branch Prediction for Free paper, we don't use the store heuristic *)
...
...
@@ -962,9 +966,6 @@ let loop_rotate f =
((
code
,
entrypoint
)
,
revmap
)
let
static_predict
f
=
debug_flag
:=
true
;
Printf
.
printf
"Loop bodies: %a"
print_ptree_oplist
(
get_loop_bodies
f
.
fn_code
f
.
fn_entrypoint
);
debug_flag
:=
false
;
let
entrypoint
=
f
.
fn_entrypoint
in
let
code
=
f
.
fn_code
in
let
revmap
=
make_identity_ptree
code
in
...
...
Write
Preview
Supports
Markdown
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