Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ac3a170c8fc1
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 72b6cca9c32e
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 30, 2015

  1. ir: fix incoming_{blocks,values,value_for_block}.

    whitequark committed Dec 30, 2015
    Copy the full SHA
    2a474b7 View commit details
  2. transforms.cfg_simplifier: correctly update phis.

    whitequark committed Dec 30, 2015
    Copy the full SHA
    72b6cca View commit details
Showing with 8 additions and 3 deletions.
  1. +5 −3 artiq/compiler/ir.py
  2. +3 −0 artiq/compiler/transforms/cfg_simplifier.py
8 changes: 5 additions & 3 deletions artiq/compiler/ir.py
Original file line number Diff line number Diff line change
@@ -242,13 +242,13 @@ def incoming(self):
return

def incoming_blocks(self):
return (block for (block, value) in self.incoming())
return (block for (value, block) in self.incoming())

def incoming_values(self):
return (value for (block, value) in self.incoming())
return (value for (value, block) in self.incoming())

def incoming_value_for_block(self, target_block):
for (block, value) in self.incoming():
for (value, block) in self.incoming():
if block == target_block:
return value
assert False
@@ -262,12 +262,14 @@ def add_incoming(self, value, block):

def remove_incoming_value(self, value):
index = self.operands.index(value)
assert index % 2 == 0
self.operands[index].uses.remove(self)
self.operands[index + 1].uses.remove(self)
del self.operands[index:index + 2]

def remove_incoming_block(self, block):
index = self.operands.index(block)
assert index % 2 == 1
self.operands[index - 1].uses.remove(self)
self.operands[index].uses.remove(self)
del self.operands[index - 1:index + 1]
3 changes: 3 additions & 0 deletions artiq/compiler/transforms/cfg_simplifier.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,10 @@ def process_function(self, func):
# 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()