Browse Source

* ARM: fix for Merge Add/Sub optimization

git-svn-id: trunk@49520 -
florian 4 years ago
parent
commit
bbcc396644
1 changed files with 11 additions and 1 deletions
  1. 11 1
      compiler/arm/aoptcpu.pas

+ 11 - 1
compiler/arm/aoptcpu.pas

@@ -640,6 +640,10 @@ Implementation
         into
         into
 
 
         add/sub rx,ry,const1+/-const
         add/sub rx,ry,const1+/-const
+        or
+        mov rx,ry if const1+/-const=0
+        or
+        remove it, if rx=ry and const1+/-const=0
 
 
         check if the first operation has no postfix and condition
         check if the first operation has no postfix and condition
       }
       }
@@ -664,7 +668,13 @@ Implementation
               Result:=true;
               Result:=true;
               if newvalue=0 then
               if newvalue=0 then
                 begin
                 begin
-                  RemoveCurrentP(p);
+                  if MatchOperand(taicpu(p).oper[0]^,taicpu(p).oper[1]^) then
+                    RemoveCurrentP(p)
+                  else
+                    begin
+                      taicpu(p).opcode:=A_MOV;
+                      taicpu(p).ops:=2;
+                    end;
                   Exit;
                   Exit;
                 end;
                 end;
             end;
             end;