Explorar el Código

+ get_max_value in defutil
* use a linear cmp list instead of subtractions on ppc if low >=
low(smallint) and high <= high(word), because a compare does not
introduce any dependencies (and in those cases using subtractions
does not save any instructions or bytes either)

git-svn-id: trunk@3065 -

Jonas Maebe hace 19 años
padre
commit
6c62d6a647
Se han modificado 2 ficheros con 23 adiciones y 0 borrados
  1. 17 0
      compiler/defutil.pas
  2. 6 0
      compiler/powerpc/nppcset.pas

+ 17 - 0
compiler/defutil.pas

@@ -46,6 +46,9 @@ interface
     {# Returns the minimal integer value of the type }
     function get_min_value(def : tdef) : TConstExprInt;
 
+    {# Returns the maximal integer value of the type }
+    function get_max_value(def : tdef) : TConstExprInt;
+
     {# Returns basetype of the specified integer range }
     function range_to_basetype(l,h:TConstExprInt):tbasetype;
 
@@ -349,6 +352,20 @@ implementation
       end;
 
 
+    { returns the max. value of the type }
+    function get_max_value(def : tdef) : TConstExprInt;
+      begin
+         case def.deftype of
+           orddef:
+             get_max_value:=torddef(def).high;
+           enumdef:
+             get_max_value:=tenumdef(def).max;
+           else
+             get_max_value:=0;
+         end;
+      end;
+
+
     { true if p is an integer }
     function is_integer(def : tdef) : boolean;
       begin

+ 6 - 0
compiler/powerpc/nppcset.pas

@@ -144,6 +144,12 @@ implementation
           end;
 
         begin
+           if (get_min_value(left.resulttype.def) >= low(smallint)) and
+              (get_max_value(left.resulttype.def) <= high(word)) then
+             begin
+               genlinearcmplist(hp);
+               exit;
+             end;
            if assigned(t^.less) then
              genitem(t^.less);
            { need we to test the first value }