* x86: New "aoc_DoPass2JccOpts" option to catch branch and

STC/CLC optimisations that only manifest in Pass 2
This commit is contained in:
J. Gareth "Curious Kit" Moreton 2024-01-29 01:11:06 +00:00 committed by FPK
parent 2055ef4e88
commit 62495c964a
3 changed files with 26 additions and 2 deletions

View File

@ -316,6 +316,9 @@ unit aoptcpu;
Result:=OptPass2SUB(p);
A_SETcc:
Result:=OptPass2SETcc(p);
A_CLC,
A_STC:
Result:=OptPass2STCCLC(p);
else
;
end;

View File

@ -41,7 +41,8 @@ unit aoptx86;
type
TOptsToCheck = (
aoc_MovAnd2Mov_3,
aoc_ForceNewIteration
aoc_ForceNewIteration,
aoc_DoPass2JccOpts
);
TX86AsmOptimizer = class(TAsmOptimizer)
@ -188,6 +189,7 @@ unit aoptx86;
function OptPass1_V_Cvtss2sd(var p: tai): boolean;
function OptPass1STCCLC(var p: tai): Boolean;
function OptPass2STCCLC(var p: tai): Boolean;
function OptPass2Movx(var p : tai): Boolean;
function OptPass2MOV(var p : tai) : boolean;
function OptPass2Imul(var p : tai) : boolean;
@ -9643,6 +9645,13 @@ unit aoptx86;
end;
function TX86AsmOptimizer.OptPass2STCCLC(var p: tai): Boolean;
begin
{ This generally only executes under -O3 and above }
Result := (aoc_DoPass2JccOpts in OptsToCheck) and OptPass1STCCLC(p);
end;
function TX86AsmOptimizer.OptPass2MOV(var p : tai) : boolean;
function IsXCHGAcceptable: Boolean; inline;
@ -11893,7 +11902,11 @@ unit aoptx86;
if taicpu(hp2).opcode = A_SETcc then
DebugMsg(SPeepholeOptimization + 'SETcc/TEST/SETcc -> SETcc',p)
else
DebugMsg(SPeepholeOptimization + 'SETcc/TEST/Jcc -> Jcc',p);
begin
DebugMsg(SPeepholeOptimization + 'SETcc/TEST/Jcc -> Jcc',p);
if (cs_opt_level3 in current_settings.optimizerswitches) then
Include(OptsToCheck, aoc_DoPass2JccOpts);
end;
end
else
if taicpu(hp2).opcode = A_SETcc then
@ -13236,8 +13249,13 @@ unit aoptx86;
CMOVTracking: PCMOVTracking;
hp3,hp4,hp5: tai;
{$endif i8086}
TempBool: Boolean;
begin
if (aoc_DoPass2JccOpts in OptsToCheck) and
DoJumpOptimizations(p, TempBool) then
Exit(True);
result:=false;
if GetNextInstruction(p,hp1) then
begin

View File

@ -235,6 +235,9 @@ uses
Result:=OptPass2CMP(p);
A_TEST:
Result:=OptPass2TEST(p);
A_CLC,
A_STC:
Result:=OptPass2STCCLC(p);
else
;
end;