Browse Source

* check constant for being a valid offset

git-svn-id: trunk@22230 -
florian 13 years ago
parent
commit
6b73bc45c5
1 changed files with 9 additions and 0 deletions
  1. 9 0
      compiler/arm/aoptcpu.pas

+ 9 - 0
compiler/arm/aoptcpu.pas

@@ -378,6 +378,15 @@ Implementation
          MatchInstruction(hp1, A_SUB, [C_None], [PF_None])) and
          MatchInstruction(hp1, A_SUB, [C_None], [PF_None])) and
         (taicpu(hp1).oper[0]^.reg=p.oper[1]^.ref^.base) and
         (taicpu(hp1).oper[0]^.reg=p.oper[1]^.ref^.base) and
         (taicpu(hp1).oper[1]^.reg=p.oper[1]^.ref^.base) and
         (taicpu(hp1).oper[1]^.reg=p.oper[1]^.ref^.base) and
+        (
+         (taicpu(hp1).oper[2]^.typ=top_reg) or
+         { valid offset? }
+         ((taicpu(hp1).oper[2]^.typ=top_const) and
+          ((abs(taicpu(hp1).oper[2]^.val)<256) or
+           ((abs(taicpu(hp1).oper[2]^.val)<4096) and (p.oppostfix in [PF_None,PF_B]))
+          )
+         )
+        ) and
         { don't apply the optimization if the base register is loaded }
         { don't apply the optimization if the base register is loaded }
         (p.oper[0]^.reg<>p.oper[1]^.ref^.base) and
         (p.oper[0]^.reg<>p.oper[1]^.ref^.base) and
         not(RegModifiedBetween(taicpu(hp1).oper[0]^.reg,p,hp1)) and
         not(RegModifiedBetween(taicpu(hp1).oper[0]^.reg,p,hp1)) and