Explorar o código

+ perform unsigned modulus by power of 2 constant by using an AND instruction (instead of DIV) on x86

git-svn-id: trunk@36756 -
nickysn %!s(int64=8) %!d(string=hai) anos
pai
achega
7c306f18e3
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      compiler/x86/nx86mat.pas

+ 8 - 0
compiler/x86/nx86mat.pas

@@ -510,6 +510,14 @@ interface
                   end;
               end;
           end
+        { unsigned modulus by a power-of-2 constant? }
+        else if (nodetype=modn) and (right.nodetype=ordconstn) and
+                ispowerof2(tordconstnode(right).value,power) and
+                not(is_signed(left.resultdef)) then
+          begin
+            emit_const_reg(A_AND,opsize,(aint(1) shl power)-1,hreg1);
+            location.register:=hreg1;
+          end
         else
           begin
             {Bring denominator to a register.}