浏览代码

* do not apply node CSE to nested loads on high level cpu targets, because
their nested tree already contains the load (subscriptn) for the variable
itself and there is no clean/easy way to avoid that in a completely
portable way in ncgnstld + test

git-svn-id: trunk@22519 -

Jonas Maebe 13 年之前
父节点
当前提交
ae56841ee6
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 11 0
      compiler/optcse.pas
  2. 3 2
      tests/test/jvm/tnestproc.pp

+ 11 - 0
compiler/optcse.pas

@@ -234,6 +234,17 @@ unit optcse;
               DFASetExclude(plists(arg)^.avail,i);
             result:=fen_norecurse_false;
           end;
+{$ifdef cpuhighleveltarget}
+          { The high level targets use the functionality from ncgnstld for
+            nested accesses, and that one stores the complete location of the
+            nested variable in tloadnode.left rather than only the location of
+            the parent context containing it. This causes problems with the
+            CSE in case the nested variable is used as an lvalue, so disable
+            CSE in that case
+          }
+          if (n.nodetype=loadn) and assigned(tloadnode(n).left) then
+            result:=fen_norecurse_false;
+{$endif}
        end;
 
 

+ 3 - 2
tests/test/jvm/tnestproc.pp

@@ -34,14 +34,14 @@ procedure outer(var para: byte);
   
     procedure doubleinner;
       begin
-        b:=3;
+        b:=b+1;
       end;
       
     begin
+      b:=2;
       doubleinner;
       if b<>3 then
         raise JLException.Create('b');
-      inner;
     end;
 
   begin
@@ -52,6 +52,7 @@ procedure outer(var para: byte);
       raise JLException.Create('a2');
     if para<>3 then
       raise JLException.Create('para2');
+    inner2;
   end;
 
 var