mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 14:47:55 +02:00
+ SHXXMov2SHXX optimization
git-svn-id: trunk@49579 -
This commit is contained in:
parent
9377d9a029
commit
7d6b01bfc4
@ -223,6 +223,9 @@ unit aoptcpu;
|
||||
A_MOVSD,
|
||||
A_MOVSS:
|
||||
Result:=OptPass1MOVXX(p);
|
||||
A_SHRX,
|
||||
A_SHLX:
|
||||
Result:=OptPass1SHXX(p);
|
||||
else
|
||||
;
|
||||
end;
|
||||
|
@ -147,6 +147,7 @@ unit aoptx86;
|
||||
function OptPass1VPXor(var p: tai): boolean;
|
||||
function OptPass1Imul(var p : tai) : boolean;
|
||||
function OptPass1Jcc(var p : tai) : boolean;
|
||||
function OptPass1SHXX(var p: tai): boolean;
|
||||
|
||||
function OptPass2Movx(var p : tai): Boolean;
|
||||
function OptPass2MOV(var p : tai) : boolean;
|
||||
@ -4884,6 +4885,37 @@ unit aoptx86;
|
||||
end;
|
||||
|
||||
|
||||
function TX86AsmOptimizer.OptPass1SHXX(var p: tai): boolean;
|
||||
var
|
||||
hp1 : tai;
|
||||
begin
|
||||
result:=false;
|
||||
{ replace
|
||||
IMul %reg0,%reg1,%reg2
|
||||
Mov %reg2,%reg3
|
||||
dealloc %reg2
|
||||
|
||||
by
|
||||
Imul %reg0,%reg1,%reg3
|
||||
}
|
||||
if 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 + 'SHXXMov2SHXX done',p);
|
||||
RemoveInstruction(hp1);
|
||||
result:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TX86AsmOptimizer.OptPass1Jcc(var p : tai) : boolean;
|
||||
var
|
||||
hp1, hp2, hp3, hp4, hp5: tai;
|
||||
|
@ -147,6 +147,9 @@ uses
|
||||
Result:=OptPass1Test(p);
|
||||
A_Jcc:
|
||||
Result:=OptPass1Jcc(p);
|
||||
A_SHRX,
|
||||
A_SHLX:
|
||||
Result:=OptPass1SHXX(p);
|
||||
else
|
||||
;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user