From d91c1df685eb821f0d4429c29b52e41c733d3294 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Mon, 25 Nov 2024 22:16:20 +0100 Subject: [PATCH] TP05b : Don't do unnecessary moves, that breaks everything --- MiniC/TP05/SequentializeMoves.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MiniC/TP05/SequentializeMoves.py b/MiniC/TP05/SequentializeMoves.py index d4df776..88f9cfe 100644 --- a/MiniC/TP05/SequentializeMoves.py +++ b/MiniC/TP05/SequentializeMoves.py @@ -22,8 +22,7 @@ def generate_smart_move(dest: DataLocation, src: DataLocation) -> List[BlockInst match dest, src: case Register(), Register(): - if dest != src: - instr.append(RiscV.mv(dest, src)) + instr.append(RiscV.mv(dest, src)) case Register(), Offset(): instr.append(RiscV.ld(dest, src)) case Offset(), Register(): @@ -70,6 +69,8 @@ def sequentialize_moves(parallel_moves: Set[Tuple[DataLocation, DataLocation]] # Then handle the cycles cycles: List = move_graph.connected_components() for cycle in cycles: + if len(cycle) == 1: + continue previous = tmp for var in reversed(cycle): moves.append((previous, var))