* Fixed issue where OptPass2CMP and OptPass2TEST didn't drop out on labels etc.

This commit is contained in:
J. Gareth "Curious Kit" Moreton 2024-01-25 22:39:17 +00:00 committed by FPK
parent 2e441609be
commit b514e979bd
2 changed files with 52 additions and 46 deletions

View File

@ -11838,6 +11838,9 @@ unit aoptx86;
hp2 := hp1;
while GetNextInstruction(hp2, hp2) and (hp2 <> BlockEnd) do
begin
if (hp2.typ <> ait_instruction) then
Exit;
case taicpu(hp2).opcode of
A_MOV:
begin
@ -11987,29 +11990,32 @@ unit aoptx86;
while GetNextInstruction(hp1, hp1) and (hp1 <> BlockEnd) do
begin
if (hp1.typ = ait_instruction) then
begin
case taicpu(hp1).opcode of
A_MOV:
{ Ignore regular MOVs unless they are obviously not related
to a CMOV block }
if taicpu(hp1).oper[1]^.typ <> top_reg then
Break;
A_CMOVcc:
if TryCmpCMovOpts(pCond, hp1) then
begin
hp1 := hp2;
if (hp1.typ <> ait_instruction) then
{ Break out on markers and labels etc. }
Break;
{ p itself isn't changed, and we're still inside a
while loop to catch subsequent CMOVs, so just flag
a new iteration }
Include(OptsToCheck, aoc_ForceNewIteration);
Continue;
end;
else
Break;
end;
end;
case taicpu(hp1).opcode of
A_MOV:
{ Ignore regular MOVs unless they are obviously not related
to a CMOV block }
if taicpu(hp1).oper[1]^.typ <> top_reg then
Break;
A_CMOVcc:
if TryCmpCMovOpts(pCond, hp1) then
begin
hp1 := hp2;
{ p itself isn't changed, and we're still inside a
while loop to catch subsequent CMOVs, so just flag
a new iteration }
Include(OptsToCheck, aoc_ForceNewIteration);
Continue;
end;
else
{ Drop out if we find anything else }
Break;
end;
hp2 := hp1;
end;
@ -12039,29 +12045,31 @@ unit aoptx86;
while GetNextInstruction(hp1, hp1) and (hp1 <> BlockEnd) do
begin
if (hp1.typ = ait_instruction) then
begin
case taicpu(hp1).opcode of
A_MOV:
{ Ignore regular MOVs unless they are obviously not related
to a CMOV block }
if taicpu(hp1).oper[1]^.typ <> top_reg then
Break;
A_CMOVcc:
if TryCmpCMovOpts(pCond, hp1) then
begin
hp1 := hp2;
if (hp1.typ <> ait_instruction) then
{ Break out on markers and labels etc. }
Break;
{ p itself isn't changed, and we're still inside a
while loop to catch subsequent CMOVs, so just flag
a new iteration }
Include(OptsToCheck, aoc_ForceNewIteration);
Continue;
end;
else
Break;
end;
end;
case taicpu(hp1).opcode of
A_MOV:
{ Ignore regular MOVs unless they are obviously not related
to a CMOV block }
if taicpu(hp1).oper[1]^.typ <> top_reg then
Break;
A_CMOVcc:
if TryCmpCMovOpts(pCond, hp1) then
begin
hp1 := hp2;
{ p itself isn't changed, and we're still inside a
while loop to catch subsequent CMOVs, so just flag
a new iteration }
Include(OptsToCheck, aoc_ForceNewIteration);
Continue;
end;
else
{ Drop out if we find anything else }
Break;
end;
hp2 := hp1;
end;

View File

@ -228,12 +228,10 @@ uses
Result:=OptPass2ADD(p);
A_SETcc:
result:=OptPass2SETcc(p);
{ disable for now as the it seems to cause buggy code
A_CMP:
Result:=OptPass2CMP(p);
A_TEST:
Result:=OptPass2TEST(p);
}
else
;
end;