mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-01-05 00:12:13 +01:00
+ ARM/Aarch64: *xt*Op2Op optimizations
This commit is contained in:
parent
cebb47fe9a
commit
c1db756617
@ -622,6 +622,7 @@ Implementation
|
||||
function TARMAsmOptimizer.OptPass1UXTB(var p : tai) : Boolean;
|
||||
var
|
||||
hp1, hp2: tai;
|
||||
so: tshifterop;
|
||||
begin
|
||||
Result:=false;
|
||||
if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) then
|
||||
@ -720,6 +721,25 @@ Implementation
|
||||
taicpu(hp1).loadReg(1,taicpu(p).oper[1]^.reg);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if MatchInstruction(hp1, [A_ADD,A_SUB], [C_None], [PF_None,PF_S]) and
|
||||
(taicpu(p).ops=2) and
|
||||
(taicpu(hp1).ops=3) and
|
||||
MatchOperand(taicpu(hp1).oper[2]^, taicpu(p).oper[0]^.reg) and
|
||||
not(MatchOperand(taicpu(hp1).oper[1]^, taicpu(p).oper[0]^.reg)) and
|
||||
RegEndofLife(taicpu(p).oper[0]^.reg,taicpu(hp1)) and
|
||||
{ reg1 might not be modified inbetween }
|
||||
not(RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) then
|
||||
begin
|
||||
DebugMsg('Peephole UxtbOp2Op done', p);
|
||||
AllocRegBetween(taicpu(p).oper[1]^.reg,p,hp1,UsedRegs);
|
||||
taicpu(hp1).loadReg(2,taicpu(p).oper[1]^.reg);
|
||||
taicpu(hp1).ops:=4;
|
||||
shifterop_reset(so);
|
||||
so.shiftmode:=SM_UXTB;
|
||||
so.shiftimm:=0;
|
||||
taicpu(hp1).loadshifterop(3,so);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if RemoveSuperfluousMove(p, hp1, 'UxtbMov2Uxtb') then
|
||||
Result:=true;
|
||||
end;
|
||||
@ -729,6 +749,7 @@ Implementation
|
||||
function TARMAsmOptimizer.OptPass1UXTH(var p : tai) : Boolean;
|
||||
var
|
||||
hp1: tai;
|
||||
so: tshifterop;
|
||||
begin
|
||||
Result:=false;
|
||||
if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) then
|
||||
@ -802,6 +823,25 @@ Implementation
|
||||
taicpu(hp1).loadReg(1,taicpu(p).oper[1]^.reg);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if MatchInstruction(hp1, [A_ADD,A_SUB], [C_None], [PF_None,PF_S]) and
|
||||
(taicpu(p).ops=2) and
|
||||
(taicpu(hp1).ops=3) and
|
||||
MatchOperand(taicpu(hp1).oper[2]^, taicpu(p).oper[0]^.reg) and
|
||||
not(MatchOperand(taicpu(hp1).oper[1]^, taicpu(p).oper[0]^.reg)) and
|
||||
RegEndofLife(taicpu(p).oper[0]^.reg,taicpu(hp1)) and
|
||||
{ reg1 might not be modified inbetween }
|
||||
not(RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) then
|
||||
begin
|
||||
DebugMsg('Peephole UxthOp2Op done', p);
|
||||
AllocRegBetween(taicpu(p).oper[1]^.reg,p,hp1,UsedRegs);
|
||||
taicpu(hp1).loadReg(2,taicpu(p).oper[1]^.reg);
|
||||
taicpu(hp1).ops:=4;
|
||||
shifterop_reset(so);
|
||||
so.shiftmode:=SM_UXTH;
|
||||
so.shiftimm:=0;
|
||||
taicpu(hp1).loadshifterop(3,so);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if RemoveSuperfluousMove(p, hp1, 'UxthMov2Data') then
|
||||
Result:=true;
|
||||
end;
|
||||
@ -811,6 +851,7 @@ Implementation
|
||||
function TARMAsmOptimizer.OptPass1SXTB(var p : tai) : Boolean;
|
||||
var
|
||||
hp1, hp2: tai;
|
||||
so: tshifterop;
|
||||
begin
|
||||
Result:=false;
|
||||
if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) then
|
||||
@ -909,6 +950,25 @@ Implementation
|
||||
taicpu(hp1).loadReg(1,taicpu(p).oper[1]^.reg);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if MatchInstruction(hp1, [A_ADD,A_SUB], [C_None], [PF_None,PF_S]) and
|
||||
(taicpu(p).ops=2) and
|
||||
(taicpu(hp1).ops=3) and
|
||||
MatchOperand(taicpu(hp1).oper[2]^, taicpu(p).oper[0]^.reg) and
|
||||
not(MatchOperand(taicpu(hp1).oper[1]^, taicpu(p).oper[0]^.reg)) and
|
||||
RegEndofLife(taicpu(p).oper[0]^.reg,taicpu(hp1)) and
|
||||
{ reg1 might not be modified inbetween }
|
||||
not(RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) then
|
||||
begin
|
||||
DebugMsg('Peephole SxtbOp2Op done', p);
|
||||
AllocRegBetween(taicpu(p).oper[1]^.reg,p,hp1,UsedRegs);
|
||||
taicpu(hp1).loadReg(2,taicpu(p).oper[1]^.reg);
|
||||
taicpu(hp1).ops:=4;
|
||||
shifterop_reset(so);
|
||||
so.shiftmode:=SM_SXTB;
|
||||
so.shiftimm:=0;
|
||||
taicpu(hp1).loadshifterop(3,so);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) and
|
||||
RemoveSuperfluousMove(p, hp1, 'SxtbMov2Sxtb') then
|
||||
Result:=true;
|
||||
@ -919,6 +979,7 @@ Implementation
|
||||
function TARMAsmOptimizer.OptPass1SXTH(var p : tai) : Boolean;
|
||||
var
|
||||
hp1: tai;
|
||||
so: tshifterop;
|
||||
begin
|
||||
Result:=false;
|
||||
if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) then
|
||||
@ -1017,6 +1078,25 @@ Implementation
|
||||
taicpu(hp1).loadReg(1,taicpu(p).oper[1]^.reg);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if MatchInstruction(hp1, [A_ADD,A_SUB], [C_None], [PF_None,PF_S]) and
|
||||
(taicpu(p).ops=2) and
|
||||
(taicpu(hp1).ops=3) and
|
||||
MatchOperand(taicpu(hp1).oper[2]^, taicpu(p).oper[0]^.reg) and
|
||||
not(MatchOperand(taicpu(hp1).oper[1]^, taicpu(p).oper[0]^.reg)) and
|
||||
RegEndofLife(taicpu(p).oper[0]^.reg,taicpu(hp1)) and
|
||||
{ reg1 might not be modified inbetween }
|
||||
not(RegModifiedBetween(taicpu(p).oper[1]^.reg,p,hp1)) then
|
||||
begin
|
||||
DebugMsg('Peephole SxthOp2Op done', p);
|
||||
AllocRegBetween(taicpu(p).oper[1]^.reg,p,hp1,UsedRegs);
|
||||
taicpu(hp1).loadReg(2,taicpu(p).oper[1]^.reg);
|
||||
taicpu(hp1).ops:=4;
|
||||
shifterop_reset(so);
|
||||
so.shiftmode:=SM_SXTH;
|
||||
so.shiftimm:=0;
|
||||
taicpu(hp1).loadshifterop(3,so);
|
||||
result:=RemoveCurrentP(p);
|
||||
end
|
||||
else if GetNextInstructionUsingReg(p, hp1, taicpu(p).oper[0]^.reg) and
|
||||
RemoveSuperfluousMove(p, hp1, 'SxthMov2Sxth') then
|
||||
Result:=true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user