diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2020-07-13 18:00:40 +0200 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2020-07-13 18:00:40 +0200 |
commit | ba42f656e78e9ef7d3de699bd8a8e9a032de9b60 (patch) | |
tree | b08a1a881449bd26ad8ecbf3600b082caddce6c2 /kvx | |
parent | 5b756533e3fbd51b8b824e9ed87d2be3feff8f36 (diff) | |
download | compcert-kvx-ba42f656e78e9ef7d3de699bd8a8e9a032de9b60.tar.gz compcert-kvx-ba42f656e78e9ef7d3de699bd8a8e9a032de9b60.zip |
Fix switching basic instruction with Icond
Diffstat (limited to 'kvx')
-rw-r--r-- | kvx/lib/RTLpathScheduleraux.ml | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/kvx/lib/RTLpathScheduleraux.ml b/kvx/lib/RTLpathScheduleraux.ml index 08cda134..6c1d4b11 100644 --- a/kvx/lib/RTLpathScheduleraux.ml +++ b/kvx/lib/RTLpathScheduleraux.ml @@ -153,7 +153,7 @@ let schedule_superblock sb code = end *) (* stub: identity function *) -let change_successors i = function +let rec change_successors i = function | [] -> ( match i with | Itailcall _ | Ireturn _ -> i @@ -178,7 +178,7 @@ let change_successors i = function match i with | Icond (a,b,n1,n2,p) -> Icond (a,b,s1,s2,p) | Ijumptable (a, [n1; n2]) -> Ijumptable (a, [s1; s2]) - | _ -> failwith "Wrong instruction (3)") + | _ -> change_successors i [s1]) | ls -> ( match i with | Ijumptable (a, ln) -> begin @@ -221,11 +221,21 @@ let check_order code old_order new_order = begin | _ -> () end +let successors_inst_with_prediction = function +| Icond (_,_,n1,n2,p) -> ( + match p with + | Some true -> [n1; n2] + | Some false -> [n2; n1] + | None -> [n1; n2] + ) +| i -> successors_inst i + let apply_schedule code sb new_order = let tc = ref code in let old_order = sb.instructions in let last_node = Array.get old_order (Array.length old_order - 1) in - let last_successors = successors_inst @@ get_some @@ PTree.get last_node code in + let last_successors = successors_inst_with_prediction + @@ get_some @@ PTree.get last_node code in begin check_order code old_order new_order; Array.iteri (fun i n' -> |