mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 13:28:05 +02:00
+ (V)Cvtss2CvtSd(V)Cvtsd2ss2Nop optimization, resolves #39360
This commit is contained in:
parent
d5867793f6
commit
ec40db3da7
@ -228,6 +228,9 @@ unit aoptcpu;
|
||||
A_SHRX,
|
||||
A_SHLX:
|
||||
Result:=OptPass1SHXX(p);
|
||||
A_VCVTSS2SD,
|
||||
A_CVTSS2SD:
|
||||
Result:=OptPass1_V_Cvtss2sd(p);
|
||||
else
|
||||
;
|
||||
end;
|
||||
|
@ -158,6 +158,7 @@ unit aoptx86;
|
||||
function OptPass1Imul(var p : tai) : boolean;
|
||||
function OptPass1Jcc(var p : tai) : boolean;
|
||||
function OptPass1SHXX(var p: tai): boolean;
|
||||
function OptPass1_V_Cvtss2sd(var p: tai): boolean;
|
||||
|
||||
function OptPass2Movx(var p : tai): Boolean;
|
||||
function OptPass2MOV(var p : tai) : boolean;
|
||||
@ -5855,6 +5856,38 @@ unit aoptx86;
|
||||
end;
|
||||
|
||||
|
||||
function TX86AsmOptimizer.OptPass1_V_Cvtss2sd(var p: tai): boolean;
|
||||
var
|
||||
hp1: tai;
|
||||
begin
|
||||
Result:=false;
|
||||
{ get rid of
|
||||
|
||||
(v)cvtss2sd reg0,<reg1,>reg2
|
||||
(v)cvtss2sd reg2,<reg2,>reg0
|
||||
}
|
||||
if GetNextInstruction(p,hp1) and
|
||||
(((taicpu(p).opcode=A_CVTSS2SD) and MatchInstruction(hp1,A_CVTSD2SS,[taicpu(p).opsize]) and
|
||||
MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[1]^) and MatchOperand(taicpu(p).oper[1]^,taicpu(hp1).oper[0]^)) or
|
||||
((taicpu(p).opcode=A_VCVTSS2SD) and MatchInstruction(hp1,A_VCVTSD2SS,[taicpu(p).opsize]) and
|
||||
MatchOpType(taicpu(p),top_reg,top_reg,top_reg) and
|
||||
MatchOpType(taicpu(hp1),top_reg,top_reg,top_reg) and
|
||||
(getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
|
||||
(getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg)) and
|
||||
(getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[2]^.reg)) and
|
||||
(getsupreg(taicpu(p).oper[2]^.reg)=getsupreg(taicpu(hp1).oper[0]^.reg))
|
||||
)
|
||||
) then
|
||||
begin
|
||||
DebugMsg(SPeepholeOptimization + '(V)Cvtss2CvtSd(V)Cvtsd2ss2Nop done',p);
|
||||
RemoveCurrentP(p);
|
||||
RemoveInstruction(hp1);
|
||||
Result:=true;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TX86AsmOptimizer.OptPass1Jcc(var p : tai) : boolean;
|
||||
var
|
||||
hp1, hp2, hp3, hp4, hp5: tai;
|
||||
|
@ -152,6 +152,9 @@ uses
|
||||
A_SHRX,
|
||||
A_SHLX:
|
||||
Result:=OptPass1SHXX(p);
|
||||
A_VCVTSS2SD,
|
||||
A_CVTSS2SD:
|
||||
Result:=OptPass1_V_Cvtss2sd(p);
|
||||
else
|
||||
;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user