+ PushPushPopPop2MovMov optimization

git-svn-id: trunk@34934 -
This commit is contained in:
florian 2016-11-20 16:03:49 +00:00
parent cfb5ebeb23
commit e49a826837

View File

@ -628,24 +628,28 @@ Implementation
push reg1 push reg1
pop reg3 pop reg3
pop reg2 pop reg2
into into
movw reg2,reg0 movw reg2,reg0
or
mov reg3,reg1
mov reg2,reg0
} }
if (taicpu(p).ops=1) and if GetNextInstruction(p,hp1) and
(taicpu(p).oper[0]^.typ=top_reg) and MatchInstruction(hp1,A_PUSH) and
GetNextInstruction(p,hp1) and
(hp1.typ=ait_instruction) and
(taicpu(hp1).opcode=A_PUSH) and
(getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(p).oper[0]^.reg)+1) and
((getsupreg(taicpu(p).oper[0]^.reg) mod 2)=0) and
GetNextInstruction(hp1,hp2) and GetNextInstruction(hp1,hp2) and
(hp2.typ=ait_instruction) and MatchInstruction(hp2,A_POP) and
(taicpu(hp2).opcode=A_POP) and
GetNextInstruction(hp2,hp3) and GetNextInstruction(hp2,hp3) and
(hp3.typ=ait_instruction) and MatchInstruction(hp3,A_POP) then
(taicpu(hp3).opcode=A_POP) and begin
if (getsupreg(taicpu(hp1).oper[0]^.reg)=getsupreg(taicpu(p).oper[0]^.reg)+1) and
((getsupreg(taicpu(p).oper[0]^.reg) mod 2)=0) and
(getsupreg(taicpu(hp2).oper[0]^.reg)=getsupreg(taicpu(hp3).oper[0]^.reg)+1) and (getsupreg(taicpu(hp2).oper[0]^.reg)=getsupreg(taicpu(hp3).oper[0]^.reg)+1) and
((getsupreg(taicpu(hp3).oper[0]^.reg) mod 2)=0) then ((getsupreg(taicpu(hp3).oper[0]^.reg) mod 2)=0) then
begin begin
@ -665,6 +669,31 @@ Implementation
hp3.Free; hp3.Free;
result:=true; result:=true;
end
else
begin
DebugMsg('Peephole PushPushPopPop2MovMov performed', p);
taicpu(p).ops:=2;
taicpu(p).opcode:=A_MOV;
taicpu(hp1).ops:=2;
taicpu(hp1).opcode:=A_MOV;
taicpu(p).loadreg(1, taicpu(p).oper[0]^.reg);
taicpu(p).loadreg(0, taicpu(hp3).oper[0]^.reg);
taicpu(hp1).loadreg(1, taicpu(hp1).oper[0]^.reg);
taicpu(hp1).loadreg(0, taicpu(hp2).oper[0]^.reg);
asml.Remove(hp2);
hp2.Free;
asml.Remove(hp3);
hp3.Free;
result:=true;
end
end; end;
end; end;
A_MOV: A_MOV: