mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 15:50:36 +02:00
* i386: more clean up of TCPUAsmOPtimizer.PeepHoleOptPass1Cpu
git-svn-id: trunk@43465 -
This commit is contained in:
parent
632f13c47a
commit
87b3b089d6
@ -245,85 +245,6 @@ unit aoptcpu;
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
{ Handle Jmp Optimizations }
|
||||
if taicpu(p).is_jmp then
|
||||
begin
|
||||
{ the following if-block removes all code between a jmp and the next label,
|
||||
because it can never be executed }
|
||||
if (taicpu(p).opcode = A_JMP) then
|
||||
begin
|
||||
hp2:=p;
|
||||
while GetNextInstruction(hp2, hp1) and
|
||||
(hp1.typ <> ait_label) do
|
||||
if not(hp1.typ in ([ait_label]+skipinstr)) then
|
||||
begin
|
||||
{ don't kill start/end of assembler block,
|
||||
no-line-info-start/end, cfi end, etc }
|
||||
if not(hp1.typ in [ait_align,ait_marker]) and
|
||||
((hp1.typ<>ait_cfi) or
|
||||
(tai_cfi_base(hp1).cfityp<>cfi_endproc)) then
|
||||
begin
|
||||
asml.remove(hp1);
|
||||
hp1.free;
|
||||
end
|
||||
else
|
||||
hp2:=hp1;
|
||||
end
|
||||
else break;
|
||||
end;
|
||||
{ remove jumps to a label coming right after them }
|
||||
if GetNextInstruction(p, hp1) then
|
||||
begin
|
||||
if FindLabel(tasmlabel(taicpu(p).oper[0]^.ref^.symbol), hp1) and
|
||||
{ TODO: FIXME removing the first instruction fails}
|
||||
(p<>blockstart) then
|
||||
begin
|
||||
hp2:=tai(hp1.next);
|
||||
asml.remove(p);
|
||||
p.free;
|
||||
p:=hp2;
|
||||
Result:=true;
|
||||
exit;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if hp1.typ = ait_label then
|
||||
SkipLabels(hp1,hp1);
|
||||
if (tai(hp1).typ=ait_instruction) and
|
||||
(taicpu(hp1).opcode=A_JMP) and
|
||||
GetNextInstruction(hp1, hp2) and
|
||||
FindLabel(tasmlabel(taicpu(p).oper[0]^.ref^.symbol), hp2) then
|
||||
begin
|
||||
if taicpu(p).opcode=A_Jcc then
|
||||
begin
|
||||
taicpu(p).condition:=inverse_cond(taicpu(p).condition);
|
||||
tai_label(hp2).labsym.decrefs;
|
||||
taicpu(p).oper[0]^.ref^.symbol:=taicpu(hp1).oper[0]^.ref^.symbol;
|
||||
{ when free'ing hp1, the ref. isn't decresed, so we don't
|
||||
increase it (FK)
|
||||
|
||||
taicpu(p).oper[0]^.ref^.symbol.increfs;
|
||||
}
|
||||
asml.remove(hp1);
|
||||
hp1.free;
|
||||
GetFinalDestination(asml, taicpu(p),0);
|
||||
end
|
||||
else
|
||||
begin
|
||||
GetFinalDestination(asml, taicpu(p),0);
|
||||
p:=tai(p.next);
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
GetFinalDestination(asml, taicpu(p),0);
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else
|
||||
{ All other optimizes }
|
||||
begin
|
||||
case taicpu(p).opcode Of
|
||||
A_AND:
|
||||
Result:=OptPass1And(p);
|
||||
@ -417,7 +338,7 @@ unit aoptcpu;
|
||||
A_MOVSX,
|
||||
A_MOVZX :
|
||||
Result:=OptPass1Movx(p);
|
||||
(* should not be generated anymore by the current code generator
|
||||
(* should not be generated anymore by the current code generator
|
||||
A_POP:
|
||||
begin
|
||||
if target_info.system=system_i386_go32v2 then
|
||||
@ -501,7 +422,7 @@ unit aoptcpu;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
*)
|
||||
A_PUSH:
|
||||
begin
|
||||
if (taicpu(p).opsize = S_W) and
|
||||
@ -562,7 +483,6 @@ unit aoptcpu;
|
||||
else
|
||||
;
|
||||
end;
|
||||
end; { if is_jmp }
|
||||
end;
|
||||
else
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user