Browse Source

* search also nested common subexpressions on node level
* don't write stats for a release compiler

git-svn-id: trunk@14494 -

florian 15 years ago
parent
commit
1632a10305
1 changed files with 8 additions and 5 deletions
  1. 8 5
      compiler/optcse.pas

+ 8 - 5
compiler/optcse.pas

@@ -24,7 +24,7 @@ unit optcse;
 {$i fpcdefs.inc}
 {$i fpcdefs.inc}
 
 
 { $define csedebug}
 { $define csedebug}
-{$define csestats}
+{ $define csestats}
 
 
   interface
   interface
 
 
@@ -71,17 +71,19 @@ unit optcse;
 
 
     function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
     function collectnodes(var n:tnode; arg: pointer) : foreachnoderesult;
       begin
       begin
+        result:=fen_false;
         { node worth to add? }
         { node worth to add? }
         if (node_complexity(n)>1) and (tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) and
         if (node_complexity(n)>1) and (tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) and
-          { adding tempref nodes is worthless but there complexity is probably <= 1 anyways }
+          { adding tempref nodes is worthless but their complexity is probably <= 1 anyways }
           not(n.nodetype in [temprefn]) then
           not(n.nodetype in [temprefn]) then
           begin
           begin
             plists(arg)^.nodelist.Add(n);
             plists(arg)^.nodelist.Add(n);
             plists(arg)^.locationlist.Add(@n);
             plists(arg)^.locationlist.Add(@n);
-            result:=fen_false;
-          end
+          end;
+        {
         else
         else
           result:=fen_norecurse_false;
           result:=fen_norecurse_false;
+        }
       end;
       end;
 
 
 
 
@@ -110,6 +112,7 @@ unit optcse;
 {$ifdef csedebug}
 {$ifdef csedebug}
                 writeln('============ cse domain ==================');
                 writeln('============ cse domain ==================');
                 printnode(output,n);
                 printnode(output,n);
+                writeln('Complexity: ',node_complexity(n));
 {$endif csedebug}
 {$endif csedebug}
 
 
                 lists.nodelist:=tfplist.create;
                 lists.nodelist:=tfplist.create;
@@ -155,7 +158,7 @@ unit optcse;
                                     def.is_intregable or def.is_fpuregable);
                                     def.is_intregable or def.is_fpuregable);
                                   addstatement(creates,tnode(templist[i]));
                                   addstatement(creates,tnode(templist[i]));
 
 
-                                  { properties can't be passed by var }
+                                  { properties can't be passed by "var" }
                                   hp:=ttempcreatenode(templist[i]);
                                   hp:=ttempcreatenode(templist[i]);
                                   do_firstpass(tnode(hp));
                                   do_firstpass(tnode(hp));