From b96a48de58e1969535865b7b345514a24f7178a6 Mon Sep 17 00:00:00 2001 From: "nicolas.nardino" Date: Mon, 28 Jun 2021 16:04:44 +0200 Subject: Change temporary solution (see prev commits), and add option for it --- driver/Clflags.ml | 1 + driver/Driver.ml | 2 ++ scheduling/InstructionScheduler.ml | 21 +++++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/driver/Clflags.ml b/driver/Clflags.ml index c90fdb8c..d01b57f0 100644 --- a/driver/Clflags.ml +++ b/driver/Clflags.ml @@ -116,4 +116,5 @@ let option_profile_arcs = ref false let option_fbranch_probabilities = ref true let option_debug_compcert = ref 0 let option_regpres_threshold = ref 2 +let option_regpres_temp = ref false let main_function_name = ref "main" diff --git a/driver/Driver.ml b/driver/Driver.ml index 4f43d7c9..22c75f44 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -212,6 +212,7 @@ Processing options: -fprepass= Perform postpass scheduling with the specified optimization [list] (=list: list scheduling, =revlist: reverse list scheduling, =regpres: list scheduling aware of register pressure, =regpres_bis: variant of regpres, =zigzag: zigzag scheduling, =ilp: ILP, =greedy: just packing bundles) -regpres-threshold n With `-fprepass= regpres`, set threshold value for number of free registers before trying to decrease register pressure + -fregpres-temp use the temporary solution (default no) -fpostpass Perform postpass scheduling (only for K1 architecture) [on] -fpostpass= Perform postpass scheduling with the specified optimization [list] (=list: list scheduling, =ilp: ILP, =greedy: just packing bundles) @@ -426,6 +427,7 @@ let cmdline_actions = @ f_opt "redundancy" option_fredundancy @ [ Exact "-mtune", String (fun s -> option_mtune := s) ] @ f_opt "prepass" option_fprepass + @ f_opt "regpres-temp" option_regpres_temp @ f_opt "postpass" option_fpostpass @ [ Exact "-ftailduplicate", Integer (fun n -> option_ftailduplicate := n) ] @ f_opt "predict" option_fpredict diff --git a/scheduling/InstructionScheduler.ml b/scheduling/InstructionScheduler.ml index e2413bc0..a881df68 100644 --- a/scheduling/InstructionScheduler.ml +++ b/scheduling/InstructionScheduler.ml @@ -486,7 +486,7 @@ let reg_pres_scheduler (problem : problem) : solution option = (* ALL MENTIONS TO cnt ARE PLACEHOLDERS *) let cnt = ref 0 in - + let attempt_scheduling ready usages = let result = ref (-1) in try @@ -500,7 +500,7 @@ let reg_pres_scheduler (problem : problem) : solution option = * print_int (Hashtbl.length live_regs); * print_newline (); * flush stdout; *) - if !cnt < 5 && avlregs <= regs_thresholds.(i) + if avlregs <= regs_thresholds.(i) then ( let maybe = InstrSet.sched_CSR i ready usages in (* print_string "maybe\n"; @@ -518,7 +518,19 @@ let reg_pres_scheduler (problem : problem) : solution option = then (vector_subtract usages.(maybe) current_resources; result := maybe) - else incr cnt); + else + if not !Clflags.option_regpres_temp + then + (InstrSet.iter (fun ins -> + if vector_less_equal usages.(ins) current_resources && + List.fold_left (fold_delta i) 0 mentions.(maybe) >= 0 + then result := ins + ) ready; + if !result <> -1 then + vector_subtract usages.(!result) current_resources) + else + (incr cnt) + ); raise Exit)) available_regs; InstrSet.iter (fun i -> if vector_less_equal usages.(i) current_resources @@ -543,7 +555,8 @@ let reg_pres_scheduler (problem : problem) : solution option = * print_int i; * print_newline (); * flush stdout; *) - cnt := 0; + if !Clflags.option_regpres_temp then + cnt := 0; List.iter (fun (r,b) -> if b then (match Hashtbl.find_opt counts r with -- cgit