瀏覽代碼

+ enable constant propagation across 2-parameter inc()/dec() calls

git-svn-id: trunk@35962 -
nickysn 8 年之前
父節點
當前提交
8512f8240e
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      compiler/optconstprop.pas

+ 3 - 2
compiler/optconstprop.pas

@@ -197,8 +197,9 @@ unit optconstprop;
             { constant inc'ed/dec'ed? }
             { constant inc'ed/dec'ed? }
             if (tinlinenode(n).inlinenumber=in_dec_x) or (tinlinenode(n).inlinenumber=in_inc_x) then
             if (tinlinenode(n).inlinenumber=in_dec_x) or (tinlinenode(n).inlinenumber=in_inc_x) then
               begin
               begin
-                if not(assigned(tcallparanode(tinlinenode(n).left).right)) and
-                  tnode(tassignmentnode(arg).left).isequal(tcallparanode(tinlinenode(n).left).left) then
+                if tnode(tassignmentnode(arg).left).isequal(tcallparanode(tinlinenode(n).left).left) and
+                   (not(assigned(tcallparanode(tinlinenode(n).left).right)) or
+                       (tcallparanode(tcallparanode(tinlinenode(n).left).right).left.nodetype=ordconstn)) then
                   begin
                   begin
                     { if the node just being searched is inc'ed/dec'ed then replace the inc/dec
                     { if the node just being searched is inc'ed/dec'ed then replace the inc/dec
                       by add/sub and force a second replacement pass }
                       by add/sub and force a second replacement pass }