diff options
author | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2021-07-29 13:08:06 +0200 |
---|---|---|
committer | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2021-07-29 13:08:06 +0200 |
commit | e789b59ed87185da84c4b77ae99bf7927a312ecf (patch) | |
tree | 2391c4de228eefe8ffcd743e29f33b0972b63a46 | |
parent | 5628b922283c40b8169b68d13c5bdc43accf2366 (diff) | |
download | compcert-kvx-e789b59ed87185da84c4b77ae99bf7927a312ecf.tar.gz compcert-kvx-e789b59ed87185da84c4b77ae99bf7927a312ecf.zip |
Code may be scheduled past a path-ending Icond if it is predicted
-rw-r--r-- | scheduling/MyRTLpathScheduleraux.ml | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/scheduling/MyRTLpathScheduleraux.ml b/scheduling/MyRTLpathScheduleraux.ml index 93c3da21..3e9e6055 100644 --- a/scheduling/MyRTLpathScheduleraux.ml +++ b/scheduling/MyRTLpathScheduleraux.ml @@ -485,9 +485,6 @@ let update_liveins liveins live_renames = let replace_iconds_by_ocmps sb code ~next_free_reg = let module P = Camlcoq.P in - (* We won't replace an Icond if it is the last instruction of the superblock, then it - * cannot be moved. *) - let last_pc = sb.instructions.(Array.length sb.instructions - 1) in let (code, _previous_icond, next_free_reg) = ArrayLabels.fold_left sb.instructions ~init:(code, None, next_free_reg) @@ -502,29 +499,25 @@ let replace_iconds_by_ocmps sb code ~next_free_reg = let code' = PTree.set pc istore' code in (code', previous_icond_proxy_reg, next_free_reg) ) | Icond(cond, args, ifso, ifnot, prediction) -> - (* Don't transform the last Icond of a superblock *) - if pc = last_pc then + (match prediction with + | None -> + (* Case only happens at the very end of the path; no transformation necessary *) + assert(sb.instructions.(Array.length sb.instructions - 1) = pc); (code, None, next_free_reg) - else - (match prediction with - | None -> - (* Case only happens at the very end of the path; no transformation necessary *) - assert(sb.instructions.(Array.length sb.instructions - 1) = pc); - (code, None, next_free_reg) - | Some true -> ( - let ocmp = match previous_icond_proxy_reg with - | None -> Iop((Op.Ocmp cond), args, next_free_reg, ifso) - | Some r -> Iop((Op.Ocmp cond), r::args, next_free_reg, ifso) - in - let code' = PTree.set pc ocmp code in - (code', Some next_free_reg, P.succ next_free_reg) ) - | Some false -> ( - let ocmp = match previous_icond_proxy_reg with - | None -> Iop((Op.Ocmp cond), args, next_free_reg, ifnot) - | Some r -> Iop((Op.Ocmp cond), r::args, next_free_reg, ifnot) - in - let code' = PTree.set pc ocmp code in - (code', Some next_free_reg, P.succ next_free_reg) )) + | Some true -> ( + let ocmp = match previous_icond_proxy_reg with + | None -> Iop((Op.Ocmp cond), args, next_free_reg, ifso) + | Some r -> Iop((Op.Ocmp cond), r::args, next_free_reg, ifso) + in + let code' = PTree.set pc ocmp code in + (code', Some next_free_reg, P.succ next_free_reg) ) + | Some false -> ( + let ocmp = match previous_icond_proxy_reg with + | None -> Iop((Op.Ocmp cond), args, next_free_reg, ifnot) + | Some r -> Iop((Op.Ocmp cond), r::args, next_free_reg, ifnot) + in + let code' = PTree.set pc ocmp code in + (code', Some next_free_reg, P.succ next_free_reg) )) | Iload(trap, chunk, addr, args, dest, succ) -> ( if !Machine.config.Machine.has_non_trapping_loads then (code, previous_icond_proxy_reg, next_free_reg) |