* AVR: fix TCpuAsmOptimizer.InstructionLoadsFromReg for MOVW

* simplify code for MovMov2Movw optimization
This commit is contained in:
florian 2022-04-24 22:42:09 +02:00
parent 49edb0b606
commit 9695dba4d9

View File

@ -229,7 +229,7 @@ Implementation
top_reg: top_reg:
Result := (p.oper[i]^.reg = reg) or Result := (p.oper[i]^.reg = reg) or
{ MOVW } { MOVW }
((i=1) and (p.opcode=A_MOVW) and (getsupreg(p.oper[0]^.reg)+1=getsupreg(reg))); ((i=1) and (p.opcode=A_MOVW) and (getsupreg(p.oper[i]^.reg)+1=getsupreg(reg)));
top_ref: top_ref:
Result := Result :=
(p.oper[i]^.ref^.base = reg) or (p.oper[i]^.ref^.base = reg) or
@ -1205,14 +1205,8 @@ Implementation
begin begin
DebugMsg('Peephole MovMov2Movw performed', p); DebugMsg('Peephole MovMov2Movw performed', p);
alloc:=FindRegAllocBackward(taicpu(hp1).oper[0]^.reg,tai(hp1.Previous)); AllocRegBetween(taicpu(hp1).oper[0]^.reg,p,hp1,UsedRegs);
if assigned(alloc) then AllocRegBetween(taicpu(hp1).oper[1]^.reg,p,hp1,UsedRegs);
begin
asml.Remove(alloc);
asml.InsertBefore(alloc,p);
{ proper book keeping of currently used registers }
IncludeRegInUsedRegs(taicpu(hp1).oper[0]^.reg,UsedRegs);
end;
taicpu(p).opcode:=A_MOVW; taicpu(p).opcode:=A_MOVW;
asml.remove(hp1); asml.remove(hp1);