Browse Source

* x86: "MovMov2Mov 1" now removes the first instruction if the intermediate register is not in use afterwards.

J. Gareth "Curious Kit" Moreton 1 month ago
parent
commit
6548dd0211
1 changed files with 12 additions and 0 deletions
  1. 12 0
      compiler/x86/aoptx86.pas

+ 12 - 0
compiler/x86/aoptx86.pas

@@ -4589,6 +4589,18 @@ unit aoptx86;
                         DebugMsg(SPeepholeOptimization + 'MovMov2Mov 1',p);
                         DebugMsg(SPeepholeOptimization + 'MovMov2Mov 1',p);
                         RemoveInstruction(hp1);
                         RemoveInstruction(hp1);
                         Result:=true;
                         Result:=true;
+
+                        if (taicpu(p).oper[1]^.typ = top_reg) then
+                          begin
+                            TransferUsedRegs(TmpUsedRegs);
+                            if not RegUsedAfterInstruction(taicpu(p).oper[1]^.reg, p, TmpUsedRegs) then
+                              begin
+                                { reg2 is no longer in use }
+                                DebugMsg(SPeepholeOptimization + 'Mov2Nop 6 done',p);
+                                RemoveCurrentP(p);
+                              end;
+                          end;
+
                         exit;
                         exit;
                       end
                       end
                     else
                     else