From eb1b7367a5b5296c5a6a82042e047a2d493a4716 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Wed, 14 Oct 2020 11:54:38 +0200 Subject: Ignoring Inops for counting number of instructions --- backend/Duplicateaux.ml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml index 4355ab5c..e5b36710 100644 --- a/backend/Duplicateaux.ml +++ b/backend/Duplicateaux.ml @@ -543,6 +543,11 @@ let is_empty = function let next_free_pc code = maxint (List.map (fun e -> let (n, _) = e in P.to_int n) (PTree.elements code)) + 1 +let is_a_nop code n = + match get_some @@ PTree.get n code with + | Inop _ -> true + | _ -> false + (* code: RTL code * preds: mapping node -> predecessors * ptree: the revmap @@ -571,7 +576,7 @@ let tail_duplicate code preds ptree trace = in let (newc, newp) = duplicate code ptree !last_node n final_node_preds (P.of_int n') in begin next_int := !next_int + 1; - nb_duplicated := !nb_duplicated + 1; + (if not @@ is_a_nop code n then nb_duplicated := !nb_duplicated + 1); last_duplicate := Some (P.of_int n'); (newc, newp) end @@ -743,18 +748,22 @@ let clone code revmap ln = begin (!code', revmap', ln', fwmap) end +let rec count_ignore_nops code = function + | [] -> 0 + | n::ln -> + let inst = get_some @@ PTree.get n code in + match inst with + | Inop _ -> count_ignore_nops code ln + | _ -> 1 + count_ignore_nops code ln + (* Unrolls a single interation of the inner loop * 1) Clones the body into body' * 2) Links the preds to the first instruction of body' * 3) Links the last instruction of body' into the first instruction of body *) -(** FIXME - we expect a list, not a hashed PSet! - * Either we need a notion of first element / last element - * Or we need to explicitly label the head and final instructions of the inner loop - *) let unroll_inner_loop_single code revmap iloop = let body = HashedSet.PSet.elements (iloop.body) in - if List.length body > !Clflags.option_funrollsingle then begin + if count_ignore_nops code body > !Clflags.option_funrollsingle then begin debug "Too many nodes in the loop body (%d > %d)" (List.length body) !Clflags.option_funrollsingle; (code, revmap) end else -- cgit