X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FRegAllocLinear.hs;h=d761bae3c0ae88fd889780683339f9856033c9b1;hb=4839f119310cd82dec679239e0897e4a2a26ee92;hp=d9ff1214bc508a85980b7dba737844c293ff475d;hpb=f2cd56cf9fc310c9b587ecb5dfaee4ad6b580355;p=ghc-hetmet.git diff --git a/compiler/nativeGen/RegAllocLinear.hs b/compiler/nativeGen/RegAllocLinear.hs index d9ff121..d761bae 100644 --- a/compiler/nativeGen/RegAllocLinear.hs +++ b/compiler/nativeGen/RegAllocLinear.hs @@ -498,7 +498,15 @@ genRaInsn block_live new_instrs instr r_dying w_dying = -- (j) free up stack slots for dead spilled regs -- TODO (can't be bothered right now) - return (patched_instr : w_spills ++ reverse r_spills + -- erase reg->reg moves where the source and destination are the same. + -- If the src temp didn't die in this instr but happened to be allocated + -- to the same real reg as the destination, then we can erase the move anyway. + squashed_instr = case isRegRegMove patched_instr of + Just (src, dst) + | src == dst -> [] + _ -> [patched_instr] + + return (squashed_instr ++ w_spills ++ reverse r_spills ++ clobber_saves ++ new_instrs, fixup_blocks) }}