1 dnl AMD64 mpn_mullo_basecase optimised for Conroe
/Wolfdale
/Nehalem
/Westmere.
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright
2008, 2009, 2011-2013 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
/.
33 include(`..
/config.m4
')
35 C cycles/limb mul_2 addmul_2
44 C Intel core 4.0 4.18-4.25
45 C Intel NHM 3.75 4.06-4.2
53 C The inner loops of this code are the result of running a code generation and
54 C optimisation tool suite written by David Harvey and Torbjörn Granlund.
57 C * Implement proper cor2, replacing current cor0.
58 C * Offset n by 2 in order to avoid the outer loop cmp. (And sqr_basecase?)
61 C When playing with pointers, set this to $2 to fall back to conservative
62 C indexing in wind-down code.
67 define(`vp_param', `
%rdx
')
68 define(`n_param', `
%rcx
')
83 C rax rbx rcx rdx rdi rsi rbp r8 r9 r10 r11 r12 r13 r14 r15
88 define(`ALIGNx', `
ALIGN(16)')
91 ifdef
(`N
',,`define(`N',0)')
92 define(`MOV', `ifelse
(eval
(N
& $3),0,`
mov $1, $2',`lea ($1), $2')')
97 PROLOGUE(mpn_mullo_basecase)
108 lea (rp,n_param,8), rp C point rp at R[un]
110 lea (up,n_param,8), up C point up right after U's
end
112 mov $0, R32
(n
) C FIXME
121 L
(m2x0
):test $2, R8
(n_param
)
138 L
(m2x1
):test $2, R8
(n_param
)
195 mov $0, R32
(w1
) C
FIXME: dead
in last iteration
199 adc %rdx
, w0 C
FIXME: dead
in last iteration
203 L
(m2ed
):imul v0
, %rax
205 mov %rax
, I
(-8(rp
),-8(rp
,i
,8))
284 L
(lo1
): mov (up
,i
,8), %rax
298 L
(lo0
): mov 8(up
,i
,8), %rax
324 L
(end): imul v1
, %rax
327 mov I
(-8(up
),-8(up
,i
,8)), %rax
330 mov X1
, I
(-16(rp
),-16(rp
,i
,8))
332 mov I
(-8(rp
),-8(rp
,i
,8)), w1
335 mov %rax
, I
(-8(rp
),-8(rp
,i
,8))
352 add -16(rp
), %rax C
FIXME: rp
[0] still available
in reg
?
353 adc -8(rp
), %rdx C
FIXME: rp
[1] still available
in reg
?
369 L
(cor0
):mov (vp
), %r11
384 L
(n1
): imul
(vp_param
), %rax
389 L
(n2
): mov (vp_param
), %r9
403 L
(n3
): mov (vp_param
), %r9
409 imul
16(up
), %r9 C u2 x v0
417 imul
8(up
), %r11 C u1 x v1
422 imul
%rax
, %r10 C u0 x v2