mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 16:48:12 +02:00
* x86: Fixes to GetInt/MMRegisterBetween assignments
This commit is contained in:
parent
fb14bc8459
commit
f4e28ab357
@ -6869,7 +6869,12 @@ unit aoptx86;
|
|||||||
{ RegUsedAfterInstruction modifies TmpUsedRegs }
|
{ RegUsedAfterInstruction modifies TmpUsedRegs }
|
||||||
not RegUsedAfterInstruction(NR_DEFAULTFLAGS, p_dist, TmpUsedRegs) then
|
not RegUsedAfterInstruction(NR_DEFAULTFLAGS, p_dist, TmpUsedRegs) then
|
||||||
begin
|
begin
|
||||||
DebugMsg(SPeepholeOptimization + 'CMP/JE/CMP/@Lbl/SETE -> CMP/SETE/CMP/SETE/OR, removing conditional branch', p);
|
{ 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
|
||||||
|
DebugMsg(SPeepholeOptimization + 'CMP/JE/CMP/@Lbl/SETE -> CMP/SETE/CMP/SETE/OR, removing conditional branch', p);
|
||||||
|
|
||||||
{ Change the jump instruction into a SETcc instruction }
|
{ Change the jump instruction into a SETcc instruction }
|
||||||
taicpu(hp1).opcode := A_SETcc;
|
taicpu(hp1).opcode := A_SETcc;
|
||||||
@ -6879,21 +6884,25 @@ 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;
|
||||||
|
|
||||||
hp2 := taicpu.op_reg_reg(A_OR, S_B, NewReg, taicpu(p_dist).oper[0]^.reg);
|
{ 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);
|
||||||
|
|
||||||
{ 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)
|
|
||||||
else
|
|
||||||
AsmL.InsertBefore(hp2, hp1_dist);
|
|
||||||
|
|
||||||
Result := True;
|
{ Make sure the new register is in use over the new instruction
|
||||||
{ Don't exit yet, as p wasn't changed and hp1, while
|
(long-winded, but things work best when the FLAGS register
|
||||||
modified, is still intact and might be optimised by the
|
is not allocated here) }
|
||||||
SETcc optimisation below }
|
AllocRegBetween(NewReg, p_dist, hp2, TmpUsedRegs);
|
||||||
|
|
||||||
|
Result := True;
|
||||||
|
{ Don't exit yet, as p wasn't changed and hp1, while
|
||||||
|
modified, is still intact and might be optimised by the
|
||||||
|
SETcc optimisation below }
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user