Browse Source

* improved node complexity calculation: 64 bit operations are more expensive, ord. const nodes on arm can be expensive

git-svn-id: trunk@14486 -
florian 15 years ago
parent
commit
1583907ac4
1 changed files with 18 additions and 3 deletions
  1. 18 3
      compiler/nutils.pas

+ 18 - 3
compiler/nutils.pas

@@ -630,6 +630,9 @@ implementation
     { at will, probably best mainly in terms of required memory      }
     { at will, probably best mainly in terms of required memory      }
     { accesses                                                       }
     { accesses                                                       }
     function node_complexity(p: tnode): cardinal;
     function node_complexity(p: tnode): cardinal;
+      var
+        correction,
+        dummy : byte;
       begin
       begin
         result := 0;
         result := 0;
         while assigned(p) do
         while assigned(p) do
@@ -705,9 +708,14 @@ implementation
               equaln,unequaln,gtn,gten,ltn,lten,
               equaln,unequaln,gtn,gten,ltn,lten,
               assignn:
               assignn:
                 begin
                 begin
-                  inc(result,node_complexity(tbinarynode(p).left)+1);
+{$ifdef CPU64BITALU}
+                  correction:=1;
+{$else CPU64BITALU}
+                  correction:=2;
+{$endif CPU64BITALU}
+                  inc(result,node_complexity(tbinarynode(p).left)+1*correction);
                   if (p.nodetype in [muln,divn,modn]) then
                   if (p.nodetype in [muln,divn,modn]) then
-                    inc(result,5);
+                    inc(result,5*correction*correction);
                   if (result >= NODE_COMPLEXITY_INF) then
                   if (result >= NODE_COMPLEXITY_INF) then
                     begin
                     begin
                       result := NODE_COMPLEXITY_INF;
                       result := NODE_COMPLEXITY_INF;
@@ -715,10 +723,17 @@ implementation
                     end;
                     end;
                   p := tbinarynode(p).right;
                   p := tbinarynode(p).right;
                 end;
                 end;
+              ordconstn:
+                begin
+{$ifdef ARM}
+                  if not(is_shifter_const(tordconstnode(p).value.svalue,dummy)) then
+                    result:=2;
+{$endif ARM}
+                  exit;
+                end;
               stringconstn,
               stringconstn,
               tempcreaten,
               tempcreaten,
               tempdeleten,
               tempdeleten,
-              ordconstn,
               pointerconstn,
               pointerconstn,
               nothingn,
               nothingn,
               niln:
               niln: