mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 03:39:33 +02:00
* RemoveSuperfluousMove uses FindRegDeAlloc to find out if the register used in the move can be removed
* RemoveSuperfluousMove fixes partially the register allocation changes caused by the mov git-svn-id: trunk@22192 -
This commit is contained in:
parent
6e62fbc3d2
commit
77e579f59f
@ -277,7 +277,9 @@ Implementation
|
|||||||
|
|
||||||
procedure TCpuAsmOptimizer.RemoveSuperfluousMove(const p: tai; movp: tai; const optimizer: string);
|
procedure TCpuAsmOptimizer.RemoveSuperfluousMove(const p: tai; movp: tai; const optimizer: string);
|
||||||
var
|
var
|
||||||
TmpUsedRegs: TAllUsedRegs;
|
alloc,
|
||||||
|
dealloc : tai_regalloc;
|
||||||
|
hp1 : tai;
|
||||||
begin
|
begin
|
||||||
if MatchInstruction(movp, A_MOV, [taicpu(p).condition], [PF_None]) and
|
if MatchInstruction(movp, A_MOV, [taicpu(p).condition], [PF_None]) and
|
||||||
(taicpu(movp).ops=2) and {We can't optimize if there is a shiftop}
|
(taicpu(movp).ops=2) and {We can't optimize if there is a shiftop}
|
||||||
@ -294,16 +296,16 @@ Implementation
|
|||||||
(taicpu(p).oper[1]^.reg = taicpu(movp).oper[0]^.reg)
|
(taicpu(p).oper[1]^.reg = taicpu(movp).oper[0]^.reg)
|
||||||
) then
|
) then
|
||||||
begin
|
begin
|
||||||
CopyUsedRegs(TmpUsedRegs);
|
dealloc:=FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(movp.Next));
|
||||||
UpdateUsedRegs(TmpUsedRegs, tai(p.next));
|
if assigned(dealloc) then
|
||||||
if not(RegUsedAfterInstruction(taicpu(p).oper[0]^.reg,movp,TmpUsedRegs)) then
|
|
||||||
begin
|
begin
|
||||||
asml.insertbefore(tai_comment.Create(strpnew('Peephole '+optimizer+' removed superfluous mov')), movp);
|
asml.insertbefore(tai_comment.Create(strpnew('Peephole '+optimizer+' removed superfluous mov')), movp);
|
||||||
taicpu(p).loadreg(0,taicpu(movp).oper[0]^.reg);
|
taicpu(p).loadreg(0,taicpu(movp).oper[0]^.reg);
|
||||||
asml.remove(movp);
|
asml.remove(movp);
|
||||||
|
asml.Remove(dealloc);
|
||||||
|
asml.InsertAfter(dealloc,p);
|
||||||
movp.free;
|
movp.free;
|
||||||
end;
|
end;
|
||||||
ReleaseUsedRegs(TmpUsedRegs);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user