|
@@ -1101,13 +1101,16 @@ Implementation
|
|
mov rX,...
|
|
mov rX,...
|
|
mov rX,...
|
|
mov rX,...
|
|
}
|
|
}
|
|
- else if GetNextInstruction(p,hp1) and MatchInstruction(hp1,A_MOV) then
|
|
|
|
|
|
+ else if GetNextInstruction(p,hp1) and MatchInstruction(hp1,A_MOV) and
|
|
|
|
+ { test condition here already instead in the while loop only, else MovMov2Mov 2 might be oversight }
|
|
|
|
+ MatchInstruction(hp1,A_MOV) and
|
|
|
|
+ MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) then
|
|
while MatchInstruction(hp1,A_MOV) and
|
|
while MatchInstruction(hp1,A_MOV) and
|
|
MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
|
|
MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
|
|
{ don't remove the first mov if the second is a mov rX,rX }
|
|
{ don't remove the first mov if the second is a mov rX,rX }
|
|
not(MatchOperand(taicpu(hp1).oper[0]^,taicpu(hp1).oper[1]^)) do
|
|
not(MatchOperand(taicpu(hp1).oper[0]^,taicpu(hp1).oper[1]^)) do
|
|
begin
|
|
begin
|
|
- DebugMsg('Peephole MovMov2Mov performed', p);
|
|
|
|
|
|
+ DebugMsg('Peephole MovMov2Mov 1 performed', p);
|
|
|
|
|
|
RemoveCurrentP(p,hp1);
|
|
RemoveCurrentP(p,hp1);
|
|
Result := True;
|
|
Result := True;
|
|
@@ -1115,7 +1118,28 @@ Implementation
|
|
GetNextInstruction(hp1,hp1);
|
|
GetNextInstruction(hp1,hp1);
|
|
if not assigned(hp1) then
|
|
if not assigned(hp1) then
|
|
break;
|
|
break;
|
|
- end;
|
|
|
|
|
|
+ end
|
|
|
|
+ {
|
|
|
|
+ This removes the second mov from
|
|
|
|
+ mov rX,rY
|
|
|
|
+
|
|
|
|
+ ...
|
|
|
|
+
|
|
|
|
+ mov rX,rY
|
|
|
|
+
|
|
|
|
+ if rX and rY are not modified in-between
|
|
|
|
+ }
|
|
|
|
+ else if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[1]^.reg) and
|
|
|
|
+ MatchInstruction(hp1,A_MOV) and
|
|
|
|
+ MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
|
|
|
|
+ MatchOperand(taicpu(p).oper[1]^, taicpu(hp1).oper[1]^) and
|
|
|
|
+ not(RegModifiedBetween(taicpu(p).oper[0]^.reg,p,hp1)) then
|
|
|
|
+ begin
|
|
|
|
+ DebugMsg('Peephole MovMov2Mov 2 performed', p);
|
|
|
|
+ AllocRegBetween(taicpu(p).oper[0]^.reg,p,hp1,UsedRegs);
|
|
|
|
+ RemoveInstruction(hp1);
|
|
|
|
+ Result := True;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
A_SBIC,
|
|
A_SBIC,
|
|
A_SBIS:
|
|
A_SBIS:
|