1 dnl AMD64 mpn_addmul_1
and mpn_submul_1 optimised for Intel Haswell.
3 dnl Contributed to the GNU project by Torbjörn Granlund.
5 dnl Copyright
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
')
53 C The loop of this code is the result of running a code generation and
54 C optimisation tool suite written by David Harvey and Torbjörn Granlund.
57 C * Handle small n separately, for lower overhead.
59 define(`rp', `
%rdi
') C rcx
60 define(`up', `
%rsi
') C rdx
61 define(`n_param', `
%rdx
') C r8
62 define(`v0_param',`
%rcx
') C r9
67 ifdef(`OPERATION_addmul_1',`
68 define
(`ADDSUB
', `add')
69 define
(`ADCSBB
', `adc')
70 define
(`func
', `mpn_addmul_1')
72 ifdef(`OPERATION_submul_1',`
73 define
(`ADDSUB
', `sub')
74 define
(`ADCSBB
', `sbb')
75 define
(`func
', `mpn_submul_1')
81 MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1)
102 L(b00): mulx( (up), %r13, %r12)
103 mulx( 8,(up), %rbx, %rax)
108 mulx( 16,(up), %r9, %r8)
117 L(b01): mulx( (up), %r11, %r10)
119 L(n1): ADDSUB %r11, (rp)
124 L(gt1): mulx( 8,(up), %r13, %r12)
125 mulx( 16,(up), %rbx, %rax)
137 L(b11): mulx( (up), %rbx, %rax)
139 mulx( 8,(up), %r9, %r8)
146 L(b10): mulx( (up), %r9, %r8)
147 mulx( 8,(up), %r11, %r10)
151 jz L(end) C depends on old shift
154 L(top): adc %rax, %r9
157 mulx( 16,(up), %r13, %r12)
159 mulx( 24,(up), %rbx, %rax)
170 L(lo1): mulx( (up), %r9, %r8)
173 L(lo0): mov %r12, 16(rp)
175 L(lo3): mulx( 8,(up), %r11, %r10)
180 L(end): adc %rax, %r9