* do prefetching correctly

* more prefetching inserted
  * unnecessary/wrong UpdateUsedRegs removed

git-svn-id: trunk@43878 -
This commit is contained in:
florian 2020-01-06 20:59:24 +00:00
parent 3dd6a8e24e
commit 872c22842e
4 changed files with 25 additions and 9 deletions

View File

@ -148,6 +148,7 @@ Unit aopt;
p := BlockStart;
While (P <> BlockEnd) Do
Begin
prefetch(pointer(p.Next)^);
Case p.typ Of
ait_Label:
begin
@ -346,6 +347,7 @@ Unit aopt;
p:=BlockStart;
while p<>BlockEnd Do
begin
prefetch(pointer(p.Next)^);
if SchedulerPass1Cpu(p) then
continue;
p:=tai(p.next);

View File

@ -195,7 +195,12 @@ unit aoptbase;
{$endif cpudelayslot}
((Current.typ = ait_label) And
labelCanBeSkipped(Tai_Label(Current)))) Do
Current := tai(Current.Next);
begin
{ this won't help the current loop, but it helps when returning from GetNextInstruction
as the next entry is probably already in the cache }
prefetch(pointer(Current.Next)^);
Current := Tai(Current.Next);
end;
If Assigned(Current) And
(Current.typ = ait_Marker) And
(Tai_Marker(Current).Kind = mark_NoPropInfoStart) Then
@ -203,7 +208,12 @@ unit aoptbase;
While Assigned(Current) And
((Current.typ <> ait_Marker) Or
(Tai_Marker(Current).Kind <> mark_NoPropInfoEnd)) Do
Current := Tai(Current.Next);
begin
{ this won't help the current loop, but it helps when returning from GetNextInstruction
as the next entry is probably already in the cache }
prefetch(pointer(Current.Next)^);
Current := Tai(Current.Next);
end;
End;
Until Not(Assigned(Current)) Or
(Current.typ <> ait_Marker) Or

View File

@ -1016,6 +1016,7 @@ Unit AoptObj;
((p.typ = ait_marker) and
(tai_Marker(p).Kind in [mark_AsmBlockEnd,mark_NoLineInfoStart,mark_NoLineInfoEnd]))) do
begin
prefetch(pointer(p.Next)^);
{ Here's the optimise part }
if (p.typ in [ait_align, ait_label]) then
begin
@ -1040,6 +1041,7 @@ Unit AoptObj;
while assigned(p) and
(p.typ=ait_RegAlloc) Do
begin
prefetch(pointer(p.Next)^);
case tai_regalloc(p).ratype of
ra_alloc :
Include(UsedRegs[getregtype(tai_regalloc(p).reg)].UsedRegs, getsupreg(tai_regalloc(p).reg));
@ -1074,6 +1076,7 @@ Unit AoptObj;
while assigned(p) and
(p.typ=ait_RegAlloc) Do
begin
prefetch(pointer(p.Next)^);
case tai_regalloc(p).ratype of
ra_alloc :
Include(UsedRegs[getregtype(tai_regalloc(p).reg)].UsedRegs, getsupreg(tai_regalloc(p).reg));
@ -1693,6 +1696,7 @@ Unit AoptObj;
{ Stop if hp is an instruction, for example }
while (hp1 <> BlockEnd) and (hp1.typ in [ait_label,ait_align]) do
begin
prefetch(pointer(hp1.Next)^);
case hp1.typ of
ait_label:
begin
@ -2396,13 +2400,13 @@ Unit AoptObj;
ClearUsedRegs;
while (p <> BlockEnd) Do
begin
UpdateUsedRegs(tai(p.next));
prefetch(pointer(p.Next)^);
if PrePeepHoleOptsCpu(p) then
continue;
if assigned(p) then
begin
UpdateUsedRegs(p);
p:=tai(p.next);
UpdateUsedRegs(p);
end;
end;
end;
@ -2425,7 +2429,7 @@ Unit AoptObj;
while Assigned(p) and (p <> BlockEnd) Do
begin
prefetch(p.Next);
prefetch(pointer(p.Next)^);
{ I'am not sure why this is done, UsedRegs should reflect the register usage before the instruction
If an instruction needs the information of this, it can easily create a TempUsedRegs (FK)
@ -2439,7 +2443,6 @@ Unit AoptObj;
{ Handle jump optimizations first }
if JumpOptsAvailable and DoJumpOptimizations(p, stoploop) then
begin
UpdateUsedRegs(p);
if FirstInstruction then
{ Update StartPoint, since the old p was removed;
don't set FirstInstruction to False though, as
@ -2481,6 +2484,7 @@ Unit AoptObj;
ClearUsedRegs;
while (p <> BlockEnd) Do
begin
prefetch(pointer(p.Next)^);
if PeepHoleOptPass2Cpu(p) then
continue;
if assigned(p) then
@ -2497,13 +2501,13 @@ Unit AoptObj;
ClearUsedRegs;
while (p <> BlockEnd) Do
begin
UpdateUsedRegs(tai(p.next));
prefetch(pointer(p.Next)^);
if PostPeepHoleOptsCpu(p) then
continue;
if assigned(p) then
begin
UpdateUsedRegs(p);
p:=tai(p.next);
UpdateUsedRegs(p);
end;
end;
end;

View File

@ -2190,7 +2190,7 @@ end;
while assigned(NewNode) do
begin
Next:=NewNode.Next;
prefetch(next.next);
prefetch(pointer(Next)^);
NewNode.Free;
NewNode:=Next;
end;