1 dnl AMD64 mpn_mulmid_basecase
3 dnl Contributed by David Harvey.
5 dnl Copyright
2011, 2012 Free Software Foundation
, Inc.
7 dnl
This file is part of the GNU MP Library.
9 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
10 dnl it under the terms of
either:
12 dnl
* the GNU Lesser General
Public License as published by the Free
13 dnl Software Foundation
; either version 3 of the License, or (at your
14 dnl option
) any later version.
18 dnl
* the GNU General
Public License as published by the Free Software
19 dnl Foundation
; either version 2 of the License, or (at your option) any
22 dnl
or both
in parallel
, as here.
24 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
25 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
26 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
29 dnl You should have received copies of the GNU General
Public License
and the
30 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
31 dnl see
https://www.gnu.
org/licenses
/.
34 include(`..
/config.m4
')
37 C K8,K9: 2.375 (2.5 when un - vn is "small")
45 define(`un_param',`
%rdx
')
46 define(`vp_param',`
%rcx
')
58 define(`outer_addr', `
%r14
')
62 define(`vp_inner', `
%r10
')
70 PROLOGUE(mpn_mulmid_basecase)
72 IFDOS(` mov 56(%rsp), %r8d ')
82 C use un for row
length (= un_param
- vn
+ 1)
88 cmp $4, un C
TODO: needs tuning
91 lea (up
,un_param
,8), up
96 C
===========================================================
97 C mul_1 for vp
[0] if vn is odd
107 and $
-4, un C round down to multiple of
4
111 jz L
(mul_1_prologue_0
)
113 jc L
(mul_1_prologue_1
)
114 jz L
(mul_1_prologue_2
)
119 lea L
(addmul_prologue_3
)(%rip
), outer_addr
125 mov %rdx
, w3 C note already w0
== 0
126 lea L
(addmul_prologue_0
)(%rip
), outer_addr
136 lea L
(addmul_prologue_1
)(%rip
), outer_addr
146 lea L
(addmul_prologue_2
)(%rip
), outer_addr
150 C
this loop is
10 c
/loop = 2.5 c
/l on K8
174 mov $0, R32
(w2
) C zero
188 mov w2
, 8(rp
) C zero last limb of output
204 C
===========================================================
205 C mul_2 for vp
[0], vp
[1] if vn is even
212 mov -8(up
,un
,8), %rax
217 and $
-4, un C round down to multiple of
4
221 jz L
(mul_2_prologue_0
)
223 jc L
(mul_2_prologue_1
)
224 jz L
(mul_2_prologue_2
)
229 lea L
(addmul_prologue_3
)(%rip
), outer_addr
236 lea L
(addmul_prologue_0
)(%rip
), outer_addr
244 lea L
(addmul_prologue_1
)(%rip
), outer_addr
253 lea L
(addmul_prologue_2
)(%rip
), outer_addr
257 C
this loop is
18 c
/loop = 2.25 c
/l on K8
327 C
===========================================================
328 C addmul_2 for remaining vp
's
331 L(addmul_prologue_0):
337 jmp L(addmul_entry_0)
340 L(addmul_prologue_1):
347 jmp L(addmul_entry_1)
350 L(addmul_prologue_2):
356 jmp L(addmul_entry_2)
359 L(addmul_prologue_3):
366 jmp L(addmul_entry_3)
368 C this loop is 19 c/loop = 2.375 c/l on K8
444 C
===========================================================
445 C accumulate along diagonals if un
- vn is
small
457 jz L
(diag_prologue_0
)
459 jc L
(diag_prologue_1
)
460 jz L
(diag_prologue_2
)
467 lea L
(diag_entry_3
)(%rip
), outer_addr
473 lea 0(%rip
), outer_addr
482 lea 0(%rip
), outer_addr
483 mov -8(vp_inner
), %rax
491 lea 0(%rip
), outer_addr
492 mov 16(vp_inner
), %rax
496 C
this loop is
10 c
/loop = 2.5 c
/l on K8
510 mov -16(up
,n
,8), %rax
513 mov 16(vp_inner
), %rax
519 mov 24(vp_inner
), %rax
521 lea 32(vp_inner
), vp_inner