mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 08:30:28 +02:00
* x86: Improvements to JccMov2CMov to catch Jcc @Lbl; <movs>; JMP @Lbl
This commit is contained in:
parent
82df643b74
commit
696b7b6f68
@ -10335,6 +10335,15 @@ unit aoptx86;
|
|||||||
jCC xxx
|
jCC xxx
|
||||||
<several movs>
|
<several movs>
|
||||||
xxx:
|
xxx:
|
||||||
|
|
||||||
|
Also spot:
|
||||||
|
Jcc xxx
|
||||||
|
<several movs>
|
||||||
|
jmp xxx
|
||||||
|
|
||||||
|
Change to:
|
||||||
|
<several cmovs with inverted condition>
|
||||||
|
jmp xxx
|
||||||
}
|
}
|
||||||
l:=0;
|
l:=0;
|
||||||
while assigned(hp1) and
|
while assigned(hp1) and
|
||||||
@ -10349,7 +10358,12 @@ unit aoptx86;
|
|||||||
if assigned(hp1) then
|
if assigned(hp1) then
|
||||||
begin
|
begin
|
||||||
TransferUsedRegs(TmpUsedRegs);
|
TransferUsedRegs(TmpUsedRegs);
|
||||||
if FindLabel(tasmlabel(symbol),hp1) then
|
if (
|
||||||
|
MatchInstruction(hp1, A_JMP, []) and
|
||||||
|
(JumpTargetOp(taicpu(hp1))^.typ=top_ref) and
|
||||||
|
(JumpTargetOp(taicpu(hp1))^.ref^.symbol=symbol)
|
||||||
|
) or
|
||||||
|
FindLabel(tasmlabel(symbol),hp1) then
|
||||||
begin
|
begin
|
||||||
if (l<=4) and (l>0) then
|
if (l<=4) and (l>0) then
|
||||||
begin
|
begin
|
||||||
@ -10385,6 +10399,14 @@ unit aoptx86;
|
|||||||
hp2 := tai(hp2.Next);
|
hp2 := tai(hp2.Next);
|
||||||
Continue;
|
Continue;
|
||||||
end;
|
end;
|
||||||
|
ait_instruction:
|
||||||
|
begin
|
||||||
|
if taicpu(hp2).opcode<>A_JMP then
|
||||||
|
InternalError(2018062912);
|
||||||
|
|
||||||
|
{ This is the Jcc @Lbl; <several movs>; JMP @Lbl variant }
|
||||||
|
Break;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{ Might be a comment or temporary allocation entry }
|
{ Might be a comment or temporary allocation entry }
|
||||||
@ -10406,15 +10428,21 @@ unit aoptx86;
|
|||||||
{ Remove the original jump }
|
{ Remove the original jump }
|
||||||
RemoveInstruction(p); { Note, the choice to not use RemoveCurrentp is deliberate }
|
RemoveInstruction(p); { Note, the choice to not use RemoveCurrentp is deliberate }
|
||||||
|
|
||||||
UpdateUsedRegs(tai(hp2.next));
|
if hp2.typ=ait_instruction then
|
||||||
GetNextInstruction(hp2, p); { Instruction after the label }
|
begin
|
||||||
|
p:=hp2;
|
||||||
|
Result:=True;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
UpdateUsedRegs(tai(hp2.next));
|
||||||
|
Result:=GetNextInstruction(hp2, p); { Instruction after the label }
|
||||||
|
|
||||||
{ Remove the label if this is its final reference }
|
{ Remove the label if this is its final reference }
|
||||||
if (tasmlabel(symbol).getrefs=0) then
|
if (tasmlabel(symbol).getrefs=0) then
|
||||||
StripLabelFast(hp1);
|
StripLabelFast(hp1);
|
||||||
|
end;
|
||||||
|
|
||||||
if Assigned(p) then
|
|
||||||
result:=true;
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user