Răsfoiți Sursa

* AVR: fix TCpuAsmOptimizer.InstructionLoadsFromReg for MOVW
* simplify code for MovMov2Movw optimization

florian 3 ani în urmă
părinte
comite
9695dba4d9
1 a modificat fișierele cu 3 adăugiri și 9 ștergeri
  1. 3 9
      compiler/avr/aoptcpu.pas

+ 3 - 9
compiler/avr/aoptcpu.pas

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