* x86: Fixed inefficiency in the long-range MOV optimisations

This commit is contained in:
J. Gareth "Curious Kit" Moreton 2023-10-29 01:55:11 +01:00 committed by FPK
parent 736f5edf98
commit af1eb33a75

View File

@ -4369,10 +4369,11 @@ unit aoptx86;
if (taicpu(hp2).oper[1]^.typ = top_ref) then if (taicpu(hp2).oper[1]^.typ = top_ref) then
ReplaceRegisterInRef(taicpu(hp2).oper[1]^.ref^, p_TargetReg, p_SourceReg); ReplaceRegisterInRef(taicpu(hp2).oper[1]^.ref^, p_TargetReg, p_SourceReg);
{ Don't remove the first instruction if the temporary register is in use }
if not TempRegUsed and
{ ReplaceRegisterInRef won't actually replace the register if it's a different size } { ReplaceRegisterInRef won't actually replace the register if it's a different size }
not RegInOp(p_TargetReg, taicpu(hp2).oper[1]^) then if not RegInOp(p_TargetReg, taicpu(hp2).oper[1]^) then
begin
{ Don't remove the first instruction if the temporary register is in use }
if not TempRegUsed then
begin begin
DebugMsg(SPeepholeOptimization + 'MovMov2Mov 6 done',p); DebugMsg(SPeepholeOptimization + 'MovMov2Mov 6 done',p);
RemoveCurrentP(p, hp1); RemoveCurrentP(p, hp1);
@ -4384,6 +4385,9 @@ unit aoptx86;
{ No need to set Result to True here. If there's another instruction later { No need to set Result to True here. If there's another instruction later
on that can be optimised, it will be detected when the main Pass 1 loop on that can be optimised, it will be detected when the main Pass 1 loop
reaches what is now hp2 and passes it through OptPass1MOV. [Kit] } reaches what is now hp2 and passes it through OptPass1MOV. [Kit] }
hp3 := hp2;
Continue;
end;
end; end;
end; end;
top_const: top_const: