forked from M-Labs/artiq
transforms.cfg_simplifier: handle phi and branch_if properly.
This commit is contained in:
parent
04b0db1a91
commit
14484216ec
@ -18,5 +18,15 @@ class CFGSimplifier:
|
||||
if len(block.instructions) == 1 and \
|
||||
isinstance(block.terminator(), ir.Branch):
|
||||
successor, = block.successors()
|
||||
|
||||
for insn in set(block.uses):
|
||||
if isinstance(insn, ir.BranchIf) and \
|
||||
((insn.if_true() == block and insn.if_false() == successor) or
|
||||
(insn.if_true() == successor and insn.if_false() == block)):
|
||||
# Our IR doesn't tolerate branch_if %c, %b, %b
|
||||
insn.replace_with(ir.Branch(successor))
|
||||
elif isinstance(insn, ir.Phi):
|
||||
insn.remove_incoming_block(block)
|
||||
|
||||
block.replace_all_uses_with(successor)
|
||||
block.erase()
|
||||
|
Loading…
Reference in New Issue
Block a user