From 6b67c91583da5eedc02a3942ef864d1fd64a48aa Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Tue, 27 Nov 2018 18:01:23 +0000 Subject: Add an optimisation pass to combine variables if possible This optimisation re-uses variables if possible, rather than allocating new ones. --- src/bytecode_util.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/bytecode_util.ml') 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) -- cgit v1.2.3