mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 22:45:16 +02:00
+ Aarch64: FMovFMov2FMov 2 optimization
This commit is contained in:
parent
968d00fedf
commit
a18a6b4391
@ -549,6 +549,7 @@ Implementation
|
|||||||
function TCpuAsmOptimizer.OptPass1FMov(var p: tai): Boolean;
|
function TCpuAsmOptimizer.OptPass1FMov(var p: tai): Boolean;
|
||||||
var
|
var
|
||||||
hp1: tai;
|
hp1: tai;
|
||||||
|
alloc, dealloc: tai_regalloc;
|
||||||
begin
|
begin
|
||||||
{
|
{
|
||||||
change
|
change
|
||||||
@ -565,9 +566,48 @@ Implementation
|
|||||||
begin
|
begin
|
||||||
asml.Remove(hp1);
|
asml.Remove(hp1);
|
||||||
hp1.free;
|
hp1.free;
|
||||||
DebugMsg(SPeepholeOptimization + 'FMovFMov2FMov done', p);
|
DebugMsg(SPeepholeOptimization + 'FMovFMov2FMov 1 done', p);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ change
|
||||||
|
fmov reg0,const
|
||||||
|
fmov reg1,reg0
|
||||||
|
dealloc reg0
|
||||||
|
into
|
||||||
|
fmov reg1,const
|
||||||
|
}
|
||||||
|
if MatchOpType(taicpu(p),top_reg,top_realconst) and
|
||||||
|
GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and
|
||||||
|
(not RegModifiedBetween(taicpu(p).oper[1]^.reg, p, hp1)) and
|
||||||
|
MatchInstruction(hp1,A_FMOV,[taicpu(p).condition],[taicpu(p).oppostfix]) and
|
||||||
|
MatchOpType(taicpu(hp1),top_reg,top_reg) and
|
||||||
|
MatchOperand(taicpu(p).oper[0]^,taicpu(hp1).oper[1]^.reg) and
|
||||||
|
(not RegModifiedByInstruction(taicpu(p).oper[0]^.reg, hp1)) and
|
||||||
|
assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next)))
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
DebugMsg('Peephole FMovFMov2FMov 2 done', p);
|
||||||
|
|
||||||
|
taicpu(hp1).loadrealconst(1,taicpu(p).oper[1]^.val_real);
|
||||||
|
|
||||||
|
alloc:=FindRegAllocBackward(taicpu(p).oper[0]^.reg,tai(p.Previous));
|
||||||
|
dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next));
|
||||||
|
|
||||||
|
if assigned(alloc) and assigned(dealloc) then
|
||||||
|
begin
|
||||||
|
asml.Remove(alloc);
|
||||||
|
alloc.Free;
|
||||||
|
asml.Remove(dealloc);
|
||||||
|
dealloc.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ p will be removed, update used register as we continue
|
||||||
|
with the next instruction after p }
|
||||||
|
|
||||||
|
result:=RemoveCurrentP(p);
|
||||||
|
end;
|
||||||
|
|
||||||
{ not enabled as apparently not happening
|
{ not enabled as apparently not happening
|
||||||
if MatchOpType(taicpu(p),top_reg,top_reg) and
|
if MatchOpType(taicpu(p),top_reg,top_reg) and
|
||||||
GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and
|
GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[0]^.reg) and
|
||||||
|
@ -1373,6 +1373,8 @@ Implementation
|
|||||||
A_SBIC,
|
A_SBIC,
|
||||||
A_SBIS:
|
A_SBIS:
|
||||||
Result:=OptPass1SBI(p);
|
Result:=OptPass1SBI(p);
|
||||||
|
A_FMOV:
|
||||||
|
Result:=OptPass1FMOV;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user