Browse Source

* improved TX86AsmOptimizer.OptPass1MOVXX

florian 3 years ago
parent
commit
10fcae34a9
1 changed files with 4 additions and 2 deletions
  1. 4 2
      compiler/x86/aoptx86.pas

+ 4 - 2
compiler/x86/aoptx86.pas

@@ -4094,7 +4094,8 @@ unit aoptx86;
         Result:=false;
         if taicpu(p).ops <> 2 then
           exit;
-        if GetNextInstruction(p,hp1) then
+        if ((taicpu(p).oper[1]^.typ=top_reg) and GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[1]^.reg)) or
+          GetNextInstruction(p,hp1) then
           begin
             if MatchInstruction(hp1,taicpu(p).opcode,[taicpu(p).opsize]) and
             (taicpu(hp1).ops = 2) then
@@ -4129,7 +4130,8 @@ unit aoptx86;
                               Result:=true;
                               exit;
                             end
-                          else if (taicpu(hp1).oper[1]^.typ<>top_ref) or (not(vol_write in taicpu(hp1).oper[1]^.ref^.volatility)) then
+                          else if (taicpu(hp1).oper[1]^.typ<>top_ref) or (not(vol_write in taicpu(hp1).oper[1]^.ref^.volatility)) and
+                            (taicpu(hp1).oper[0]^.typ<>top_ref) or (not(vol_read in taicpu(hp1).oper[0]^.ref^.volatility)) then
                             begin
                               DebugMsg(SPeepholeOptimization + 'MovXXMovXX2MoVXX 1 done',p);
                               RemoveInstruction(hp1);