Browse Source

* get rid or move the allocation of the replaced register if possible

git-svn-id: trunk@22193 -
florian 13 years ago
parent
commit
3d7b603d11
1 changed files with 15 additions and 2 deletions
  1. 15 2
      compiler/arm/aoptcpu.pas

+ 15 - 2
compiler/arm/aoptcpu.pas

@@ -300,10 +300,23 @@ Implementation
           if assigned(dealloc) then
             begin
               asml.insertbefore(tai_comment.Create(strpnew('Peephole '+optimizer+' removed superfluous mov')), movp);
+
+              { taicpu(p).oper[0]^.reg is not used anymore, try to find its allocation
+                and remove it if possible }
+              GetLastInstruction(p,hp1);
+              asml.Remove(dealloc);
+              alloc:=FindRegAlloc(taicpu(p).oper[0]^.reg,tai(hp1.Next));
+              if assigned(alloc) then
+                begin
+                  asml.Remove(alloc);
+                  alloc.free;
+                  dealloc.free;
+                end
+              else
+                asml.InsertAfter(dealloc,p);
+
               taicpu(p).loadreg(0,taicpu(movp).oper[0]^.reg);
               asml.remove(movp);
-              asml.Remove(dealloc);
-              asml.InsertAfter(dealloc,p);
               movp.free;
             end;
         end;