aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-11 12:21:30 +0200
committerJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-11 12:21:30 +0200
commitb807e528c9fe45c15ddb4c87b44099a1aac6b768 (patch)
tree9062c5cea2876efcf259231eee6fc56ad13e5add
parent511fd79173174df1f9c19a37751ebe7967c052c9 (diff)
downloadcompcert-kvx-b807e528c9fe45c15ddb4c87b44099a1aac6b768.tar.gz
compcert-kvx-b807e528c9fe45c15ddb4c87b44099a1aac6b768.zip
Do not restore unnecessary instructions before a predicted Icond
If the Icond is the last instruction of the path, the live_renames includes all the live renames for all successors (s_output_regs). However not all of those need to be stricly restored before the Icond. Some can be restored afterwards.
-rw-r--r--scheduling/MyRTLpathScheduleraux.ml26
1 files changed, 16 insertions, 10 deletions
diff --git a/scheduling/MyRTLpathScheduleraux.ml b/scheduling/MyRTLpathScheduleraux.ml
index 212867f4..547019a9 100644
--- a/scheduling/MyRTLpathScheduleraux.ml
+++ b/scheduling/MyRTLpathScheduleraux.ml
@@ -392,19 +392,25 @@ let restoration_instructions sb code live_renames =
| Icond _ -> false
| _ -> true
in
+ let open Either in
let to_insert =
PTree.fold
(fun to_insert side_exit_pc renames ->
- let insts = ListLabels.map renames
- ~f:(fun {old_name; new_name} ->
- Iop (Op.Omove, [new_name], old_name, Camlcoq.P.one))
- in
- let pos = if last_inst_is_basic
- then InsertPosition.Below side_exit_pc
- else InsertPosition.Above side_exit_pc
- in
-
- InsertPositionMap.add pos insts to_insert)
+ let live_regs_opt = PTree.get side_exit_pc sb.liveins in
+ let (above, below) =
+ ListLabels.partition_map renames
+ ~f:(fun {old_name; new_name} ->
+ let inst = Iop (Op.Omove, [new_name], old_name, Camlcoq.P.one) in
+ match last_inst_is_basic, live_regs_opt with
+ | true, _ -> Right inst
+ | false, None -> Left inst
+ | false, Some live_regs ->
+ if Regset.mem old_name live_regs then
+ Left inst
+ else Right inst)
+ in
+ InsertPositionMap.add (InsertPosition.Above side_exit_pc) above to_insert
+ |> InsertPositionMap.add (InsertPosition.Below side_exit_pc) below)
live_renames
InsertPositionMap.empty
in