瀏覽代碼

* patch by J. Gareth Moreton: x86: Lea2Nop for stack pointer, resolves #39225

git-svn-id: trunk@49612 -
florian 4 年之前
父節點
當前提交
2629bd7ba9
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9 2
      compiler/x86/aoptx86.pas

+ 9 - 2
compiler/x86/aoptx86.pas

@@ -3742,8 +3742,15 @@ unit aoptx86;
         { changes "lea (%reg1), %reg2" into "mov %reg1, %reg2" }
         if (taicpu(p).oper[0]^.ref^.base <> NR_NO) and
            (taicpu(p).oper[0]^.ref^.index = NR_NO) and
-           { do not mess with leas acessing the stack pointer }
-           (taicpu(p).oper[1]^.reg <> NR_STACK_POINTER_REG) and
+           (
+             { do not mess with leas accessing the stack pointer
+               unless it's a null operation }
+             (taicpu(p).oper[1]^.reg <> NR_STACK_POINTER_REG) or
+             (
+               (taicpu(p).oper[0]^.ref^.base = NR_STACK_POINTER_REG) and
+               (taicpu(p).oper[0]^.ref^.offset = 0)
+             )
+           ) and
            (not(Assigned(taicpu(p).oper[0]^.ref^.Symbol))) then
           begin
             if (taicpu(p).oper[0]^.ref^.offset = 0) then