TP05b : Don't do unnecessary moves, that breaks everything

This commit is contained in:
augustin64 2024-11-25 22:16:20 +01:00
parent d668ab98aa
commit d91c1df685

View File

@ -22,8 +22,7 @@ def generate_smart_move(dest: DataLocation, src: DataLocation) -> List[BlockInst
match dest, src: match dest, src:
case Register(), Register(): case Register(), Register():
if dest != src: instr.append(RiscV.mv(dest, src))
instr.append(RiscV.mv(dest, src))
case Register(), Offset(): case Register(), Offset():
instr.append(RiscV.ld(dest, src)) instr.append(RiscV.ld(dest, src))
case Offset(), Register(): case Offset(), Register():
@ -70,6 +69,8 @@ def sequentialize_moves(parallel_moves: Set[Tuple[DataLocation, DataLocation]]
# Then handle the cycles # Then handle the cycles
cycles: List = move_graph.connected_components() cycles: List = move_graph.connected_components()
for cycle in cycles: for cycle in cycles:
if len(cycle) == 1:
continue
previous = tmp previous = tmp
for var in reversed(cycle): for var in reversed(cycle):
moves.append((previous, var)) moves.append((previous, var))