瀏覽代碼

* handle for-loops correctly if the limits contain the counter variable

git-svn-id: trunk@19918 -
florian 13 年之前
父節點
當前提交
5defdf86ba
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      compiler/optdfa.pas

+ 6 - 2
compiler/optdfa.pas

@@ -276,7 +276,7 @@ unit optdfa;
                     foreachnodestatic(pm_postprocess,twhilerepeatnode(node).left,@AddDefUse,@dfainfo);
                     foreachnodestatic(pm_postprocess,twhilerepeatnode(node).left,@AddDefUse,@dfainfo);
                   end;
                   end;
 
 
-                { NB: this node should typically have empty def set }                  
+                { NB: this node should typically have empty def set }
                 if assigned(node.successor) then
                 if assigned(node.successor) then
                   DFASetDiff(l,node.successor.optinfo^.life,node.optinfo^.def)
                   DFASetDiff(l,node.successor.optinfo^.life,node.optinfo^.def)
                 else if assigned(resultnode) then
                 else if assigned(resultnode) then
@@ -344,10 +344,14 @@ unit optdfa;
                 { update for node }
                 { update for node }
                 { life:=life+use+body }
                 { life:=life+use+body }
                 l:=copy(node.optinfo^.life);
                 l:=copy(node.optinfo^.life);
-                DFASetIncludeSet(l,node.optinfo^.use);
                 DFASetIncludeSet(l,tfornode(node).t2.optinfo^.life);
                 DFASetIncludeSet(l,tfornode(node).t2.optinfo^.life);
                 { the for loop always updates its control variable }
                 { the for loop always updates its control variable }
                 DFASetDiff(l,l,node.optinfo^.def);
                 DFASetDiff(l,l,node.optinfo^.def);
+
+                { ... but it could be that left/right use it, so do it after
+                  removing def }
+                DFASetIncludeSet(l,node.optinfo^.use);
+
                 UpdateLifeInfo(node,l);
                 UpdateLifeInfo(node,l);
 
 
                 { ... and a second iteration for fast convergence }
                 { ... and a second iteration for fast convergence }