aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-02 19:16:04 +0200
committerJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-02 19:16:04 +0200
commit21128117e0ff886891822ced917497c7fbe9dc92 (patch)
tree6386eb04b7c77bd2866d73d74a6c83a9bfe43b90
parent5efd95e03b8a8101dd971a01543e23aefbb07eb3 (diff)
downloadcompcert-kvx-21128117e0ff886891822ced917497c7fbe9dc92.tar.gz
compcert-kvx-21128117e0ff886891822ced917497c7fbe9dc92.zip
Rename less registers when pmSSA is turned off but code motion past side
exits is turned on
-rw-r--r--scheduling/MyRTLpathScheduleraux.ml29
1 files changed, 28 insertions, 1 deletions
diff --git a/scheduling/MyRTLpathScheduleraux.ml b/scheduling/MyRTLpathScheduleraux.ml
index 23d5d339..39c77f53 100644
--- a/scheduling/MyRTLpathScheduleraux.ml
+++ b/scheduling/MyRTLpathScheduleraux.ml
@@ -1379,8 +1379,35 @@ let scheduler f =
((sb, to_compensate, live_renames)::sbs, code, next_free_reg)
) else (
assert (PTree.elements live_renames |> List.for_all (fun (_, l) -> l = []));
+ let dup_count = InsertPositionMap.fold
+ (fun _pos (pcs : Camlcoq.P.t list) acc ->
+ let acc = ListLabels.fold_left pcs
+ ~init:acc
+ ~f:(fun acc pc ->
+ let old = ptree_get_or_default acc pc 0 in
+ PTree.set pc (old + 1) acc)
+ in
+ acc )
+ to_compensate_pcs
+ PTree.empty
+ in
+ let pcs_dupd_twice_or_more =
+ PTree.filter1 (fun n -> n > 1) dup_count
+ |> PTree.elements
+ |> List.map fst
+ in
+ let arg_regs = ListLabels.fold_left pcs_dupd_twice_or_more
+ ~init:(Regset.empty)
+ ~f:(fun acc pc ->
+ let inst = get_some @@ PTree.get pc code in
+ RTL.instr_uses inst
+ |> List.fold_left
+ (fun acc reg -> Regset.add reg acc)
+ acc
+ )
+ in
let pi = get_some @@ PTree.get sb.instructions.(0) pm in
- let (code, live_renames, next_free_reg) = local_single_assignment sb code pi.input_regs ~next_free_reg in
+ let (code, live_renames, next_free_reg) = rename_regs ~only_rename:arg_regs sb code ~liveatentry:pi.input_regs ~next_free_reg in
let to_compensate = InsertPositionMap.map (fun pcs ->
let insts = List.map (fun pc -> get_some @@ PTree.get pc code) pcs in
insts)