aboutsummaryrefslogtreecommitdiffstats
path: root/backend/Duplicateaux.ml
diff options
context:
space:
mode:
Diffstat (limited to 'backend/Duplicateaux.ml')
-rw-r--r--backend/Duplicateaux.ml24
1 files changed, 11 insertions, 13 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml
index 8ca6c6ab..22bee067 100644
--- a/backend/Duplicateaux.ml
+++ b/backend/Duplicateaux.ml
@@ -49,13 +49,11 @@ let stats_nb_overpredict = ref 0
let wrong_opcode = ref 0
let wrong_return = ref 0
let wrong_loop2 = ref 0
-let wrong_loop = ref 0
let wrong_call = ref 0
let right_opcode = ref 0
let right_return = ref 0
let right_loop2 = ref 0
-let right_loop = ref 0
let right_call = ref 0
let reset_stats () = begin
@@ -67,12 +65,10 @@ let reset_stats () = begin
wrong_opcode := 0;
wrong_return := 0;
wrong_loop2 := 0;
- wrong_loop := 0;
wrong_call := 0;
right_opcode := 0;
right_return := 0;
right_loop2 := 0;
- right_loop := 0;
right_call := 0;
end
@@ -86,11 +82,11 @@ let write_stats_oc () =
match !stats_oc with
| None -> ()
| Some oc -> begin
- Printf.fprintf oc "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n" !stats_nb_total
+ Printf.fprintf oc "%d %d %d %d %d %d %d %d %d %d %d %d %d\n" !stats_nb_total
!stats_nb_correct_predicts !stats_nb_mispredicts !stats_nb_missed_opportunities
!stats_nb_overpredict
- !wrong_opcode !wrong_return !wrong_loop2 !wrong_loop !wrong_call
- !right_opcode !right_return !right_loop2 !right_loop !right_call
+ !wrong_opcode !wrong_return !wrong_loop2 !wrong_call
+ !right_opcode !right_return !right_loop2 !right_call
;
close_out oc
end
@@ -417,7 +413,7 @@ let get_directions f code entrypoint = begin
if stats_oc_recording () || not @@ has_some pred then
(* debug "Analyzing %d.." (P.to_int n); *)
let heuristics = [ do_opcode_heuristic;
- do_return_heuristic; do_loop2_heuristic loop_info n; do_loop_heuristic; do_call_heuristic;
+ do_return_heuristic; do_loop2_heuristic loop_info n; (* do_loop_heuristic; *) do_call_heuristic;
(* do_store_heuristic *) ] in
let preferred = ref None in
let current_heuristic = ref 0 in
@@ -438,8 +434,7 @@ let get_directions f code entrypoint = begin
| 0 -> incr wrong_opcode
| 1 -> incr wrong_return
| 2 -> incr wrong_loop2
- | 3 -> incr wrong_loop
- | 4 -> incr wrong_call
+ | 3 -> incr wrong_call
| _ -> failwith "Shouldn't happen"
end
| Some false, Some false
@@ -448,8 +443,7 @@ let get_directions f code entrypoint = begin
| 0 -> incr right_opcode
| 1 -> incr right_return
| 2 -> incr right_loop2
- | 3 -> incr right_loop
- | 4 -> incr right_call
+ | 3 -> incr right_call
| _ -> failwith "Shouldn't happen"
end
| _ -> ()
@@ -1050,9 +1044,13 @@ let extract_upto_icond f code head =
let rotate_inner_loop f code revmap iloop =
let header = extract_upto_icond f code iloop.head in
let limit = !Clflags.option_flooprotate in
- if count_ignore_nops code header > limit then begin
+ let nb_duplicated = count_ignore_nops code header in
+ if nb_duplicated > limit then begin
debug "Loop Rotate: too many nodes to duplicate (%d > %d)" (List.length header) limit;
(code, revmap)
+ end else if nb_duplicated == count_ignore_nops code iloop.body then begin
+ debug "The conditional branch is already at the end! No need to rotate.";
+ (code, revmap)
end else
let (code2, revmap2, dupheader, fwmap) = clone code revmap header in
let code' = ref code2 in