From 72b6cca9c32e1d0495cea17fff0f254cf8c4ca20 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 30 Dec 2015 16:07:14 +0800 Subject: [PATCH] transforms.cfg_simplifier: correctly update phis. --- artiq/compiler/transforms/cfg_simplifier.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/artiq/compiler/transforms/cfg_simplifier.py b/artiq/compiler/transforms/cfg_simplifier.py index 6017212d4..22b915884 100644 --- a/artiq/compiler/transforms/cfg_simplifier.py +++ b/artiq/compiler/transforms/cfg_simplifier.py @@ -26,7 +26,10 @@ class CFGSimplifier: # Our IR doesn't tolerate branch_if %c, %b, %b insn.replace_with(ir.Branch(successor)) elif isinstance(insn, ir.Phi): + incoming_value = insn.incoming_value_for_block(block) insn.remove_incoming_block(block) + for pred in block.predecessors(): + insn.add_incoming(incoming_value, pred) block.replace_all_uses_with(successor) block.erase()