瀏覽代碼

* handle Movzl/Op/Mov optimization correctly, resolves #23431

git-svn-id: trunk@23128 -
florian 12 年之前
父節點
當前提交
2ea6979277
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      compiler/i386/popt386.pas

+ 10 - 1
compiler/i386/popt386.pas

@@ -1304,7 +1304,16 @@ begin
                          (hp2.typ = ait_instruction) and
                          (taicpu(hp2).opcode = A_MOV) and
                          (taicpu(hp2).oper[0]^.typ = top_reg) and
-                         OpsEqual(taicpu(hp2).oper[1]^,taicpu(p).oper[0]^) then
+                         OpsEqual(taicpu(hp2).oper[1]^,taicpu(p).oper[0]^) and
+                         (((taicpu(hp1).ops=2) and
+                           (getsupreg(taicpu(hp2).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg))) or
+                           ((taicpu(hp1).ops=1) and
+                           (getsupreg(taicpu(hp2).oper[0]^.reg)=getsupreg(taicpu(hp1).oper[0]^.reg)))) and
+                         { reg2 must not be used after the sequence considered, so
+                           it must be either deallocated or loaded with a new value }
+                         (GetNextInstruction(hp2,hp3) and
+                          (FindRegDealloc(getsupreg(taicpu(hp2).oper[0]^.reg),tai(hp3)) or
+                          RegLoadedWithNewValue(getsupreg(taicpu(hp2).oper[0]^.reg), false, hp3))) then
                       { change   movsX/movzX    reg/ref, reg2             }
                       {          add/sub/or/... reg3/$const, reg2         }
                       {          mov            reg2 reg/ref              }