浏览代码

* x86: 64-bit integer division reciprocal algorithm uses IMUL
with an immediate for the modulus version where possible

J. Gareth "Curious Kit" Moreton 3 年之前
父节点
当前提交
079905654d
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      compiler/x86/nx86mat.pas

+ 4 - 1
compiler/x86/nx86mat.pas

@@ -552,13 +552,16 @@ interface
                 { Now multiply the quotient by the original denominator and
                 { Now multiply the quotient by the original denominator and
                   subtract the product from the original numerator to get
                   subtract the product from the original numerator to get
                   the remainder. }
                   the remainder. }
-                if (cgsize in [OS_64,OS_S64]) then { Cannot use 64-bit constants in IMUL }
+{$ifdef x86_64}
+                if (cgsize in [OS_64,OS_S64]) and (d > $7FFFFFFF) then { Cannot use 64-bit constants in IMUL }
                   begin
                   begin
                     hreg3:=cg.getintregister(current_asmdata.CurrAsmList,cgsize);
                     hreg3:=cg.getintregister(current_asmdata.CurrAsmList,cgsize);
                     emit_const_reg(A_MOV,opsize,aint(d),hreg3);
                     emit_const_reg(A_MOV,opsize,aint(d),hreg3);
                     emit_reg_reg(A_IMUL,opsize,hreg3,regd);
                     emit_reg_reg(A_IMUL,opsize,hreg3,regd);
                   end
                   end
                 else
                 else
+{$endif x86_64}
+{$endif x86_64}
                   emit_const_reg(A_IMUL,opsize,aint(d),regd);
                   emit_const_reg(A_IMUL,opsize,aint(d),regd);
 
 
                 emit_reg_reg(A_SUB,opsize,regd,hreg2);
                 emit_reg_reg(A_SUB,opsize,regd,hreg2);