* x86: Fixes to GetInt/MMRegisterBetween assignments

This commit is contained in:
J. Gareth "Curious Kit" Moreton 2022-01-06 22:03:14 +00:00 committed by FPK
parent fb14bc8459
commit f4e28ab357

View File

@ -6868,6 +6868,11 @@ unit aoptx86;
if (NewReg <> NR_NO) and if (NewReg <> NR_NO) and
{ RegUsedAfterInstruction modifies TmpUsedRegs } { RegUsedAfterInstruction modifies TmpUsedRegs }
not RegUsedAfterInstruction(NR_DEFAULTFLAGS, p_dist, TmpUsedRegs) then not RegUsedAfterInstruction(NR_DEFAULTFLAGS, p_dist, TmpUsedRegs) then
begin
{ Register can appear in p if it's not used afterwards, so only
allocate between hp1 and hp1_dist }
NewReg := GetIntRegisterBetween(R_SUBL, TmpUsedRegs, hp1, p_dist);
if NewReg <> NR_NO then
begin begin
DebugMsg(SPeepholeOptimization + 'CMP/JE/CMP/@Lbl/SETE -> CMP/SETE/CMP/SETE/OR, removing conditional branch', p); DebugMsg(SPeepholeOptimization + 'CMP/JE/CMP/@Lbl/SETE -> CMP/SETE/CMP/SETE/OR, removing conditional branch', p);
@ -6879,16 +6884,19 @@ unit aoptx86;
{ This is now a dead label } { This is now a dead label }
tai_label(p_label).labsym.decrefs; tai_label(p_label).labsym.decrefs;
{ Prefer adding before the next instruction so the FLAGS
register is deallocated first }
hp2 := taicpu.op_reg_reg(A_OR, S_B, NewReg, taicpu(p_dist).oper[0]^.reg); hp2 := taicpu.op_reg_reg(A_OR, S_B, NewReg, taicpu(p_dist).oper[0]^.reg);
{ Try to add the instruction right after the flags get deallocated, since AsmL.InsertBefore(
the flags may become allocated again before the next instruction hp2,
(reuse p_dist, not hp1, since that needs to remain as the hp1_dist
instruction immediately after p) } );
if SetAndTest(FindRegDealloc(NR_DEFAULTFLAGS, tai(p_dist.Next)), p_dist) then
AsmL.InsertAfter(hp2, p_dist) { Make sure the new register is in use over the new instruction
else (long-winded, but things work best when the FLAGS register
AsmL.InsertBefore(hp2, hp1_dist); is not allocated here) }
AllocRegBetween(NewReg, p_dist, hp2, TmpUsedRegs);
Result := True; Result := True;
{ Don't exit yet, as p wasn't changed and hp1, while { Don't exit yet, as p wasn't changed and hp1, while
@ -6896,6 +6904,7 @@ unit aoptx86;
SETcc optimisation below } SETcc optimisation below }
end; end;
end; end;
end;
if taicpu(p).oper[0]^.typ = top_const then if taicpu(p).oper[0]^.typ = top_const then
begin begin