瀏覽代碼

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

J. Gareth "Curious Kit" Moreton 1 月之前
父節點
當前提交
6548dd0211
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      compiler/x86/aoptx86.pas

+ 12 - 0
compiler/x86/aoptx86.pas

@@ -4589,6 +4589,18 @@ unit aoptx86;
                         DebugMsg(SPeepholeOptimization + 'MovMov2Mov 1',p);
                         RemoveInstruction(hp1);
                         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;
                       end
                     else