mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 13:29:14 +02:00
* fixed peephole optimizer replace lea by add even if the flags were in use
(patch by J. Gareth Moreton) git-svn-id: trunk@46213 -
This commit is contained in:
parent
3047ce71bc
commit
06a5ec5b5c
@ -2816,7 +2816,10 @@ unit aoptx86;
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if MatchInstruction(hp1,A_LEA,[S_L{$ifdef x86_64},S_Q{$endif x86_64}]) then
|
if MatchInstruction(hp1,A_LEA,[S_L{$ifdef x86_64},S_Q{$endif x86_64}]) and
|
||||||
|
{ If the flags register is in use, don't change the instruction to an
|
||||||
|
ADD otherwise this will scramble the flags. [Kit] }
|
||||||
|
not RegInUsedRegs(NR_DEFAULTFLAGS, UsedRegs) then
|
||||||
begin
|
begin
|
||||||
if MatchOpType(Taicpu(p),top_ref,top_reg) and
|
if MatchOpType(Taicpu(p),top_ref,top_reg) and
|
||||||
((MatchReference(Taicpu(hp1).oper[0]^.ref^,Taicpu(hp1).oper[1]^.reg,Taicpu(p).oper[1]^.reg) and
|
((MatchReference(Taicpu(hp1).oper[0]^.ref^,Taicpu(hp1).oper[1]^.reg,Taicpu(p).oper[1]^.reg) and
|
||||||
@ -3174,6 +3177,9 @@ unit aoptx86;
|
|||||||
(taicpu(p).oper[1]^.reg<>NR_STACK_POINTER_REG) or
|
(taicpu(p).oper[1]^.reg<>NR_STACK_POINTER_REG) or
|
||||||
(cs_opt_size in current_settings.optimizerswitches)
|
(cs_opt_size in current_settings.optimizerswitches)
|
||||||
) and
|
) and
|
||||||
|
{ If the flags register is in use, don't change the instruction
|
||||||
|
to an ADD otherwise this will scramble the flags. [Kit] }
|
||||||
|
not RegInUsedRegs(NR_DEFAULTFLAGS, UsedRegs) and
|
||||||
ConvertLEA(taicpu(p)) then
|
ConvertLEA(taicpu(p)) then
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -5370,7 +5376,12 @@ unit aoptx86;
|
|||||||
(taicpu(hp1).opcode <> A_LEA) or
|
(taicpu(hp1).opcode <> A_LEA) or
|
||||||
{ If the LEA instruction can be converted into an arithmetic instruction,
|
{ If the LEA instruction can be converted into an arithmetic instruction,
|
||||||
it may be possible to then fold it. }
|
it may be possible to then fold it. }
|
||||||
ConvertLEA(taicpu(hp1))
|
(
|
||||||
|
{ If the flags register is in use, don't change the instruction
|
||||||
|
to an ADD otherwise this will scramble the flags. [Kit] }
|
||||||
|
not RegInUsedRegs(NR_DEFAULTFLAGS, UsedRegs) and
|
||||||
|
ConvertLEA(taicpu(hp1))
|
||||||
|
)
|
||||||
) and
|
) and
|
||||||
IsFoldableArithOp(taicpu(hp1),taicpu(p).oper[1]^.reg) and
|
IsFoldableArithOp(taicpu(hp1),taicpu(p).oper[1]^.reg) and
|
||||||
GetNextInstruction(hp1,hp2) and
|
GetNextInstruction(hp1,hp2) and
|
||||||
|
Loading…
Reference in New Issue
Block a user