+ TX86AsmOptimizer.OptPass1OP

git-svn-id: trunk@36365 -
This commit is contained in:
florian 2017-05-28 13:49:43 +00:00
parent 7c0f72d9af
commit 22956c4393
3 changed files with 61 additions and 0 deletions

View File

@ -1263,6 +1263,12 @@ begin
A_VADDSS:
if OptPass1VOP(p) then
continue;
A_MULSD,
A_MULSS,
A_ADDSD,
A_ADDSS:
if OptPass1OP(p) then
continue;
A_MOVAPD,
A_MOVAPS:
if OptPass1MOVAP(p) then

View File

@ -64,6 +64,7 @@ unit aoptx86;
function OptPass1Movx(var p : tai) : boolean;
function OptPass1MOVAP(var p : tai) : boolean;
function OptPass1MOVXX(var p : tai) : boolean;
function OptPass1OP(const p : tai) : boolean;
function OptPass2MOV(var p : tai) : boolean;
function OptPass2Imul(var p : tai) : boolean;
@ -1064,6 +1065,15 @@ unit aoptx86;
hp1 : tai;
begin
result:=false;
{ replace
V<Op>X %mreg1,%mreg2,%mreg3
VMovX %mreg3,%mreg4
dealloc %mreg3
by
V<Op>X %mreg1,%mreg2,%mreg4
?
}
if GetNextInstruction(p,hp1) and
{ we mix single and double opperations here because we assume that the compiler
generates vmovapd only after double operations and vmovaps only after single operations }
@ -1077,6 +1087,7 @@ unit aoptx86;
) then
begin
taicpu(p).loadoper(2,taicpu(hp1).oper[1]^);
DebugMsg('PeepHole Optimization VOpVmov2VOp done',p);
asml.Remove(hp1);
hp1.Free;
result:=true;
@ -1670,6 +1681,45 @@ unit aoptx86;
end;
function TX86AsmOptimizer.OptPass1OP(const p : tai) : boolean;
var
TmpUsedRegs : TAllUsedRegs;
hp1 : tai;
begin
result:=false;
{ replace
<Op>X %mreg1,%mreg2 // Op in [ADD,MUL]
MovX %mreg2,%mreg1
dealloc %mreg2
by
<Op>X %mreg2,%mreg1
?
}
if GetNextInstruction(p,hp1) and
{ we mix single and double opperations here because we assume that the compiler
generates vmovapd only after double operations and vmovaps only after single operations }
MatchInstruction(hp1,A_MOVAPD,A_MOVAPS,[S_NO]) and
MatchOperand(taicpu(p).oper[1]^,taicpu(hp1).oper[0]^) and
MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[1]^) and
(taicpu(p).oper[0]^.typ=top_reg) then
begin
CopyUsedRegs(TmpUsedRegs);
UpdateUsedRegs(TmpUsedRegs, tai(p.next));
if not(RegUsedAfterInstruction(taicpu(p).oper[1]^.reg,hp1,TmpUsedRegs)
) then
begin
taicpu(p).loadoper(0,taicpu(hp1).oper[0]^);
taicpu(p).loadoper(1,taicpu(hp1).oper[1]^);
DebugMsg('PeepHole Optimization OpMov2Op done',p);
asml.Remove(hp1);
hp1.Free;
result:=true;
end;
end;
end;
function TX86AsmOptimizer.OptPass2MOV(var p : tai) : boolean;
var
TmpUsedRegs : TAllUsedRegs;

View File

@ -87,6 +87,11 @@ uses
A_VADDSD,
A_VADDSS:
result:=OptPass1VOP(p);
A_MULSD,
A_MULSS,
A_ADDSD,
A_ADDSS:
result:=OptPass1OP(p);
A_VMOVSD,
A_VMOVSS,
A_MOVSD,