1 dnl AMD64 mpn_addmul_1 optimised for Intel Broadwell.
3 dnl Copyright
2015 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
')
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 Torbjorn Granlund.
57 C * Put an initial mulx before switching, targeting some free registers.
58 C * Tune feed-in code.
59 C * Trim nop execution after L(f2).
60 C * Port to DOS64, not forgetting nop execution.
62 define(`rp', `
%rdi
') C rcx
63 define(`up', `
%rsi
') C rdx
64 define(`n_param', `
%rdx
') C r8
65 define(`v0_param',`
%rcx
') C r9
69 dnl ABI_SUPPORT(DOS64)
72 dnl IFDOS(` define(`up', ``
%rsi
'') ') dnl
73 dnl IFDOS(` define(`rp', ``
%rcx
'') ') dnl
74 dnl IFDOS(` define(`vl', ``
%r9
'') ') dnl
75 dnl IFDOS(` define(`r9', ``rdi
'') ') dnl
76 dnl IFDOS(` define(`n', ``
%r8
'') ') dnl
77 dnl IFDOS(` define(`r8', ``r11
'') ') dnl
82 PROLOGUE(mpn_addmul_1)
86 mov R32(n_param), R32(%r8)
88 and $7, R32(%r8) C clear OF, CF as side-effect
90 lea L(tab)(%rip), %r10
92 ` movslq
(%r10
,%r8
,4), %r8
100 L
(tab
): JMPENT
( L
(f0
), L
(tab
))
101 JMPENT
( L
(f1
), L
(tab
))
102 JMPENT
( L
(f2
), L
(tab
))
103 JMPENT
( L
(f3
), L
(tab
))
104 JMPENT
( L
(f4
), L
(tab
))
105 JMPENT
( L
(f5
), L
(tab
))
106 JMPENT
( L
(f6
), L
(tab
))
107 JMPENT
( L
(f7
), L
(tab
))
110 L
(f0
): mulx
( (up
), %r10
, %r8
)
116 L
(f3
): mulx
( (up
), %r9
, %rax
)
121 L
(f4
): mulx
( (up
), %r10
, %r8
)
126 L
(f5
): mulx
( (up
), %r9
, %rax
)
131 L
(f6
): mulx
( (up
), %r10
, %r8
)
136 L
(f1
): mulx
( (up
), %r9
, %rax
)
141 adc %rcx
, %rax C relies on rcx
= 0
144 L
(end): adox
( (rp
), %r9
)
146 adox
( %rcx
, %rax
) C relies on rcx
= 0
147 adc %rcx
, %rax C relies on rcx
= 0
152 `
nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop')
154 L
(f2
): mulx
( (up
), %r10
, %r8
)
157 mulx
( (up
), %r9
, %rax
)
160 L
(top
): adox
( -8,(rp
), %r10
)
164 L
(b1
): mulx
( 8,(up
), %r10
, %r8
)
169 L
(b0
): mulx
( 16,(up
), %r9
, %rax
)
173 L
(b7
): mulx
( 24,(up
), %r10
, %r8
)
178 L
(b6
): mulx
( -32,(up
), %r9
, %rax
)
182 L
(b5
): mulx
( -24,(up
), %r10
, %r8
)
186 L
(b4
): mulx
( -16,(up
), %r9
, %rax
)
190 L
(b3
): adox
( 48,(rp
), %r9
)
191 mulx
( -8,(up
), %r10
, %r8
)
195 mulx
( (up
), %r9
, %rax
)
198 L
(f7
): mulx
( (up
), %r9
, %rax
)