From 05432242ff54bbd6bd4cb04f18f126e3225b1a14 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 25 Jan 2014 21:35:59 -0800 Subject: [PATCH] Removing block continuation branches. --- src/alloy/compiler/passes/finalization_pass.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/alloy/compiler/passes/finalization_pass.cc b/src/alloy/compiler/passes/finalization_pass.cc index 668b546b8..4784eee9e 100644 --- a/src/alloy/compiler/passes/finalization_pass.cc +++ b/src/alloy/compiler/passes/finalization_pass.cc @@ -52,7 +52,16 @@ int FinalizationPass::Run(HIRBuilder* builder) { label = label->next; } - // ? remove useless jumps? + // Remove unneeded jumps. + auto tail = block->instr_tail; + if (tail && tail->opcode == &OPCODE_BRANCH_info) { + // Jump. Check target. + auto target = tail->src1.label; + if (target->block == block->next) { + // Jumping to subsequent block. Remove. + tail->Remove(); + } + } // Renumber all instructions to make liveness tracking easier. uint32_t instr_ordinal = 0;