1 dnl AMD64 mpn_addlsh_n
and mpn_rsblsh_n. R
= V2^k
+- U.
3 dnl Copyright
2006, 2010-2012 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
')
35 C AMD K8,K9 3.1 < 3.85 for lshift + add_n
36 C AMD K10 3.1 < 3.85 for lshift + add_n
37 C Intel P4 14.6 > 7.33 for lshift + add_n
38 C Intel core2 3.87 > 3.27 for lshift + add_n
39 C Intel NHM 4 > 3.75 for lshift + add_n
40 C Intel SBR (5.8) > 3.46 for lshift + add_n
41 C Intel atom (7.75) < 8.75 for lshift + add_n
42 C VIA nano 4.7 < 6.25 for lshift + add_n
44 C This was written quickly and not optimized at all. Surely one could get
45 C closer to 3 c/l or perhaps even under 3 c/l. Ideas:
46 C 1) Use indexing to save the 3 LEA
47 C 2) Write reasonable feed-in code
48 C 3) Be more clever about register usage
49 C 4) Unroll more, handling CL negation, carry save/restore cost much now
59 ifdef(`OPERATION_addlsh_n',`
61 define(func, mpn_addlsh_n)
63 ifdef
(`OPERATION_rsblsh_n
',`
65 define
(func
, mpn_rsblsh_n
)
68 MULFUNC_PROLOGUE(mpn_addlsh_n mpn_rsblsh_n)
78 IFDOS(` mov 56(%rsp), %r8d ')
86 xor R32
(%rbx
), R32
(%rbx
) C clear carry save register
87 mov R32
(%r8
), R32
(%rcx
) C shift count
88 xor R32
(%rbp
), R32
(%rbp
) C limb carry
90 mov R32
(%rax
), R32
(%r11
)
103 add R32
(%rbx
), R32
(%rbx
)
106 sbb R32
(%rbx
), R32
(%rbx
)
117 L
(top
): mov (vp
), %r8
137 shr R8
(%rcx
), %rbp C used next iteration
145 add R32
(%rbx
), R32
(%rbx
) C restore carry flag
157 sbb R32
(%rbx
), R32
(%rbx
) C save carry flag
166 L
(end): add R32
(%rbx
), R32
(%rbx
)