Fix bug in register update.

This commit is contained in:
Marcel Keller
2023-05-11 13:01:51 +10:00
parent 1838683ce9
commit 8e735daab5
2 changed files with 9 additions and 10 deletions

View File

@@ -314,6 +314,7 @@ class Merger:
reg_nodes = {}
last_def = defaultdict_by_id(lambda: -1)
last_read = defaultdict_by_id(lambda: -1)
second_last_read = defaultdict_by_id(lambda: -1)
last_mem_write = []
last_mem_read = []
last_mem_write_of = defaultdict(list)
@@ -332,6 +333,8 @@ class Merger:
round_type = {}
def add_edge(i, j):
if i in (-1, j):
return
G.add_edge(i, j)
for d in (self.depths, self.real_depths):
if d[j] < d[i]:
@@ -341,15 +344,13 @@ class Merger:
for dup in reg.duplicates:
if last_def[dup] not in (-1, n):
add_edge(last_def[dup], n)
second_last_read[reg] = last_read[reg]
last_read[reg] = n
def write(reg, n):
for dup in reg.duplicates:
if last_read[dup] not in (-1, n):
add_edge(last_read[dup], n)
if id(dup) in [id(x) for x in block.instructions[n].get_used()] and \
last_read[dup] not in (-1, n):
add_edge(last_read[dup], n)
add_edge(last_read[dup], n)
add_edge(second_last_read[dup], n)
last_def[reg] = n
def handle_mem_access(addr, reg_type, last_access_this_kind,

View File

@@ -1501,11 +1501,9 @@ class Tape:
:param other: any convertible type
"""
if isinstance(other, Tape.Register) and other.block != Program.prog.curr_block:
other = type(self)(other)
else:
other = self.conv(other)
if Program.prog.curr_block in [x.block for x in self.duplicates]:
diff_block = isinstance(other, Tape.Register) and self.block != other.block
other = type(self)(other)
if not diff_block:
self.program.start_new_basicblock()
if self.program != other.program:
raise CompilerError(