forked from M-Labs/artiq
1
0
Fork 0

transforms.cfg_simplifier: correctly update phis.

This commit is contained in:
whitequark 2015-12-30 16:07:14 +08:00
parent 2a474b7166
commit 72b6cca9c3
1 changed files with 3 additions and 0 deletions

View File

@ -26,7 +26,10 @@ class CFGSimplifier:
# Our IR doesn't tolerate branch_if %c, %b, %b # Our IR doesn't tolerate branch_if %c, %b, %b
insn.replace_with(ir.Branch(successor)) insn.replace_with(ir.Branch(successor))
elif isinstance(insn, ir.Phi): elif isinstance(insn, ir.Phi):
incoming_value = insn.incoming_value_for_block(block)
insn.remove_incoming_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.replace_all_uses_with(successor)
block.erase() block.erase()