* x86: ImulMov2Imul optimization

* x86: apply OptPass1VOP also to vsqrts*

git-svn-id: trunk@46955 -
This commit is contained in:
florian 2020-09-25 20:06:27 +00:00
parent 61da70bb72
commit 1fb7603f61
3 changed files with 39 additions and 0 deletions

View File

@ -139,6 +139,8 @@ unit aoptcpu;
case taicpu(p).opcode Of
A_AND:
Result:=OptPass1And(p);
A_IMUL:
Result:=OptPass1Imul(p);
A_CMP:
Result:=OptPass1Cmp(p);
A_VPXOR:

View File

@ -138,6 +138,7 @@ unit aoptx86;
function OptPass1Cmp(var p : tai) : boolean;
function OptPass1PXor(var p : tai) : boolean;
function OptPass1VPXor(var p: tai): boolean;
function OptPass1Imul(var p : tai) : boolean;
function OptPass2MOV(var p : tai) : boolean;
function OptPass2Imul(var p : tai) : boolean;
@ -4194,6 +4195,38 @@ unit aoptx86;
end;
end;
function TX86AsmOptimizer.OptPass1Imul(var p: tai): boolean;
var
hp1 : tai;
begin
result:=false;
{ replace
IMul const,%mreg1,%mreg2
Mov %reg2,%mreg3
dealloc %mreg3
by
Imul const,%mreg1,%mreg23
}
if (taicpu(p).ops=3) and
GetNextInstruction(p,hp1) and
MatchInstruction(hp1,A_MOV,[taicpu(p).opsize]) and
MatchOperand(taicpu(p).oper[2]^,taicpu(hp1).oper[0]^) and
(taicpu(hp1).oper[1]^.typ=top_reg) then
begin
TransferUsedRegs(TmpUsedRegs);
UpdateUsedRegs(TmpUsedRegs, tai(p.next));
if not(RegUsedAfterInstruction(taicpu(hp1).oper[0]^.reg,hp1,TmpUsedRegs)) then
begin
taicpu(p).loadoper(2,taicpu(hp1).oper[1]^);
DebugMsg(SPeepholeOptimization + 'ImulMov2Imul done',p);
RemoveInstruction(hp1);
result:=true;
end;
end;
end;
function TX86AsmOptimizer.OptPass2MOV(var p : tai) : boolean;

View File

@ -73,6 +73,8 @@ uses
case taicpu(p).opcode of
A_AND:
Result:=OptPass1AND(p);
A_IMUL:
Result:=OptPass1Imul(p);
A_MOV:
Result:=OptPass1MOV(p);
A_MOVSX,
@ -88,6 +90,8 @@ uses
A_VMOVUPS,
A_VMOVUPD:
result:=OptPass1_V_MOVAP(p);
A_VSQRTSD,
A_VSQRTSS,
A_VDIVSD,
A_VDIVSS,
A_VSUBSD,