diff options
| author | Alasdair Armstrong | 2018-11-27 18:01:23 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-11-27 21:43:19 +0000 |
| commit | 6b67c91583da5eedc02a3942ef864d1fd64a48aa (patch) | |
| tree | 1d20576fa7ffd62a9cbff7f95b8084effa48cfb2 /src/bytecode_util.ml | |
| parent | d48ccd801b4d99c160f289b2efdde10aa36e7bdd (diff) | |
Add an optimisation pass to combine variables if possible
This optimisation re-uses variables if possible, rather than
allocating new ones.
Diffstat (limited to 'src/bytecode_util.ml')
| -rw-r--r-- | src/bytecode_util.ml | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bytecode_util.ml b/src/bytecode_util.ml index 783f6793..aeb1daf1 100644 --- a/src/bytecode_util.ml +++ b/src/bytecode_util.ml @@ -155,8 +155,11 @@ let rec instr_rename from_id to_id (I_aux (instr, aux)) = | I_init (ctyp, id, cval) -> I_init (ctyp, id, cval_rename from_id to_id cval) - | I_if ((frag, ctyp1), then_instrs, else_instrs, ctyp2) -> - I_if ((frag_rename from_id to_id frag, ctyp1), then_instrs, else_instrs, ctyp2) + | I_if (cval, then_instrs, else_instrs, ctyp2) -> + I_if (cval_rename from_id to_id cval, + List.map (instr_rename from_id to_id) then_instrs, + List.map (instr_rename from_id to_id) else_instrs, + ctyp2) | I_jump (cval, label) -> I_jump (cval_rename from_id to_id cval, label) |
