1 dnl x86
-64 mpn_divrem_1
-- mpn by limb division.
3 dnl Copyright
2004, 2005, 2007-2010, 2012, 2014 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
10 dnl
* the GNU Lesser General
Public License as published by the Free
11 dnl Software Foundation
; either version 3 of the License, or (at your
12 dnl option
) any later version.
16 dnl
* the GNU General
Public License as published by the Free Software
17 dnl Foundation
; either version 2 of the License, or (at your option) any
20 dnl
or both
in parallel
, as here.
22 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
23 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
24 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
27 dnl You should have received copies of the GNU General
Public License
and the
28 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
29 dnl see
https://www.gnu.
org/licenses
/.
31 include(`..
/config.m4
')
38 C Intel core2 24 24 19.5
39 C Intel corei 19 19 18
44 C mpn_divrem_1 (mp_ptr qp, mp_size_t fn,
45 C mp_srcptr np, mp_size_t nn, mp_limb_t d)
48 C mpn_preinv_divrem_1 (mp_ptr qp, mp_size_t fn,
49 C mp_srcptr np, mp_size_t nn, mp_limb_t d,
50 C mp_limb_t dinv, int cnt)
54 define(`fn_param', `
%rsi
')
55 define(`up_param', `
%rdx
')
56 define(`un_param', `
%rcx
')
58 define(`dinv', `
%r9
') C only for mpn_preinv_divrem_1
59 C shift passed on stack C only for mpn_preinv_divrem_1
67 C rax rbx rcx rdx rsi rdi rbp r8 r9 r10 r11 r12 r13 r14 r15
73 IFSTD(`define(`CNTOFF', `
40($1)')')
74 IFDOS
(`define
(`CNTOFF
', `104($1)')')
79 PROLOGUE(mpn_preinv_divrem_1)
81 IFDOS(` mov 56(%rsp), %r8 ')
82 IFDOS
(`
mov 64(%rsp
), %r9
')
83 xor R32(%rax), R32(%rax)
91 add fn_param, un_param
94 lea -8(qp,un_param,8), qp
96 mov CNTOFF(%rsp), R8(cnt)
102 PROLOGUE(mpn_divrem_1)
104 IFDOS(` mov 56(%rsp), %r8 ')
105 xor R32
(%rax
), R32
(%rax
)
113 add fn_param
, un_param
117 lea -8(qp
,un_param
,8), qp
118 xor R32
(%rbp
), R32
(%rbp
)
123 mov -8(up
,un
,8), %rax
141 IFSTD
(`
sub $8, %rsp
')
142 IFSTD(` mov d, %rdi ')
143 IFDOS
(`
sub $40, %rsp
')
144 IFDOS(` mov d, %rcx ')
145 ASSERT
(nz
, `
test $15, %rsp
')
146 CALL( mpn_invert_limb)
147 IFSTD(` add $8, %rsp ')
148 IFDOS
(`
add $40, %rsp
')
159 L(ent): mov -8(up,un,8), %rbp
161 shld R8(%rcx), %rbp, %rax
166 L(top): lea 1(%rax), %r11
169 shld R8(%rcx), %r10, %rbp
188 L(end): lea 1(%rax), %r11
204 L(eok): mov %r13, (qp)
219 ALIGN(16) C K8-K10 P6-CNR P6-NHM P4
220 L(ftop):mul dinv C 0,12 0,17 0,17
221 add %r11, %rdx C 5 8 10
222 mov %rax, %r11 C 4 8 3
223 mov %rdx, %r13 C 6 9 11
224 imul %rbp, %rdx C 6 9 11
226 add %rdx, %rax C 10 14 14
227 cmp %r11, %rdx C 10 14 14
228 cmovc %rdx, %rax C 11 15 15
232 L(fent):lea 1(%rax), %r11 C