* ARM: optimize mov rX,#0 .... mul/mla/umull ...,rX,...

git-svn-id: trunk@44242 -
This commit is contained in:
florian 2020-02-24 21:10:55 +00:00
parent 9bdfbc2473
commit 684ef3008f

View File

@ -1243,6 +1243,33 @@ Implementation
GetNextInstruction(p,hp1) and
(tai(hp1).typ = ait_instruction) then
begin
{
This removes the mul from
mov rX,0
...
mul ...,rX,...
}
if (taicpu(p).oper[1]^.typ = top_const) and
(taicpu(p).oper[1]^.val=0) and
MatchInstruction(hp1, [A_MUL,A_MLA], [taicpu(p).condition], [taicpu(p).oppostfix]) and
(((taicpu(hp1).oper[1]^.typ=top_reg) and MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[1]^)) or
((taicpu(hp1).oper[2]^.typ=top_reg) and MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[2]^))) then
begin
TransferUsedRegs(TmpUsedRegs);
UpdateUsedRegs(TmpUsedRegs, tai(p.next));
UpdateUsedRegs(TmpUsedRegs, tai(hp1.next));
DebugMsg('Peephole Mul0 done', p);
if taicpu(hp1).opcode=A_MUL then
taicpu(hp1).loadconst(1,0)
else
taicpu(hp1).loadreg(1,taicpu(hp1).oper[3]^.reg);
taicpu(hp1).ops:=2;
taicpu(hp1).opcode:=A_MOV;
if not(RegUsedAfterInstruction(taicpu(hp1).oper[0]^.reg,hp1,TmpUsedRegs)) then
RemoveCurrentP(p);
Result:=true;
exit;
end
{
This changes the very common
mov r0, #0
@ -1252,7 +1279,7 @@ Implementation
and removes all superfluous mov instructions
}
if (taicpu(p).oper[1]^.typ = top_const) and
else if (taicpu(p).oper[1]^.typ = top_const) and
(taicpu(hp1).opcode=A_STR) then
while MatchInstruction(hp1, A_STR, [taicpu(p).condition], []) and
MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and