Selaa lähdekoodia

+ cse across assignment operator fixed and enabled

git-svn-id: trunk@22017 -
florian 13 vuotta sitten
vanhempi
commit
405a80066e
1 muutettua tiedostoa jossa 14 lisäystä ja 2 poistoa
  1. 14 2
      compiler/optcse.pas

+ 14 - 2
compiler/optcse.pas

@@ -65,7 +65,7 @@ unit optcse;
       cseinvariant : set of tnodetype = [addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn,
       cseinvariant : set of tnodetype = [addn,muln,subn,divn,slashn,modn,andn,orn,xorn,notn,vecn,
         derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn,
         derefn,equaln,unequaln,ltn,gtn,lten,gten,typeconvn,subscriptn,
         inn,symdifn,shrn,shln,ordconstn,realconstn,unaryminusn,pointerconstn,stringconstn,setconstn,
         inn,symdifn,shrn,shln,ordconstn,realconstn,unaryminusn,pointerconstn,stringconstn,setconstn,
-        isn,asn,starstarn,nothingn,temprefn,loadparentfpn {,callparan}];
+        isn,asn,starstarn,nothingn,temprefn,loadparentfpn {,callparan},assignn];
 
 
     function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult;
     function searchsubdomain(var n:tnode; arg: pointer) : foreachnoderesult;
       begin
       begin
@@ -109,6 +109,14 @@ unit optcse;
     function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
     function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
       var
       var
         i,j : longint;
         i,j : longint;
+
+      function is_written(node : tnode) : boolean;
+        begin
+          while node.nodetype in [typeconvn] do
+            node:=ttypeconvnode(node).left;
+          result:=(node.flags*[nf_write,nf_modify]<>[])
+        end;
+
       begin
       begin
         result:=fen_false;
         result:=fen_false;
         { don't add the tree below an untyped const parameter: there is
         { don't add the tree below an untyped const parameter: there is
@@ -122,10 +130,12 @@ unit optcse;
             exit;
             exit;
           end;
           end;
         { so far, we can handle only nodes being read }
         { so far, we can handle only nodes being read }
-        if (n.flags*[nf_write,nf_modify]=[]) and
+        if
           { node possible to add? }
           { node possible to add? }
           assigned(n.resultdef) and
           assigned(n.resultdef) and
           (
           (
+            { regable expressions }
+            not(is_written(n)) and
             ((tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) and
             ((tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) and
             { is_int/fpuregable allows arrays and records to be in registers, cse cannot handle this }
             { is_int/fpuregable allows arrays and records to be in registers, cse cannot handle this }
             (not(n.resultdef.typ in [arraydef,recorddef])) and
             (not(n.resultdef.typ in [arraydef,recorddef])) and
@@ -160,6 +170,8 @@ unit optcse;
             (not(is_constnode(n)) or (node_complexity(n)>1)))
             (not(is_constnode(n)) or (node_complexity(n)>1)))
 {$ifndef x86}
 {$ifndef x86}
             or
             or
+            { store reference of expression? }
+
             { loading the address of a global symbol takes typically more than
             { loading the address of a global symbol takes typically more than
               one instruction on every platform except x86
               one instruction on every platform except x86
               so consider in this case loading the address of the data
               so consider in this case loading the address of the data