From 9faa0b9eb03e37facaf77366d703bb20f4af9461 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 28 Apr 2021 12:34:44 +0200 Subject: Heuristic counter update --- backend/Duplicateaux.ml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'backend/Duplicateaux.ml') diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index d55da64a..425947ce 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -48,13 +48,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 @@ -66,12 +64,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 @@ -85,11 +81,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 | _ -> () -- cgit From 8b649e6898afeb243a992ab81092c4fd431410d7 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 28 Apr 2021 12:44:30 +0200 Subject: Do not rotate if the CB was already at the end. --- backend/Duplicateaux.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'backend/Duplicateaux.ml') diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index 425947ce..324acd99 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -1044,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 -- cgit