Debian Codegraph @

mpn/x86_64/k8/addmul_2.asm

raw
1 dnl AMD64 mpn_addmul_2 -- Multiply an n-limb vector with a 2-limb vector and
2 dnl add the result to a third limb vector.
3
4 dnl Copyright 2008, 2011, 2012, 2016 Free Software Foundation, Inc.
5
6 dnl This file is part of the GNU MP Library.
7 dnl
8 dnl The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl it under the terms of either:
10 dnl
11 dnl * the GNU Lesser General Public License as published by the Free
12 dnl Software Foundation; either version 3 of the License, or (at your
13 dnl option) any later version.
14 dnl
15 dnl or
16 dnl
17 dnl * the GNU General Public License as published by the Free Software
18 dnl Foundation; either version 2 of the License, or (at your option) any
19 dnl later version.
20 dnl
21 dnl or both in parallel, as here.
22 dnl
23 dnl The GNU MP Library is distributed in the hope that it will be useful, but
24 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 dnl for more details.
27 dnl
28 dnl You should have received copies of the GNU General Public License and the
29 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
30 dnl see https://www.gnu.org/licenses/.
31
32 include(`../config.m4')
33
34 C cycles/limb cycles/limb cfg cycles/limb am1+am1
35 C AMD K8,K9 2.375
36 C AMD K10 2.375
37 C AMD bull 5.2 <- 4.6-4.75 bad
38 C AMD pile 4.96 <- 4.6-4.75 bad
39 C AMD steam ?
40 C AMD excavator ?
41 C AMD bobcat 5.75 5.0 bad
42 C AMD jaguar 5.9 5.2-5.4 bad
43 C Intel P4 15-16
44 C Intel core2 4.5 4.25-4.5 bad
45 C Intel NHM 4.33 4.55 bad
46 C Intel SBR 3.4 2.93 3.24 bad
47 C Intel IBR 3.35 2.6 2.95 bad
48 C Intel HWL 3.3 2.15 2.3 bad
49 C Intel BWL 2.33 2.33 1.65 bad
50 C Intel SKL 2.37 2.21 1.64 bad
51 C Intel atom 20 18.7
52 C Intel SLM 8 8.5
53 C VIA nano 4.4
54
55 C This code is the result of running a code generation and optimization tool
56 C suite written by David Harvey and Torbjorn Granlund.
57
58 C TODO
59 C * Tune feed-in and wind-down code.
60
61 C INPUT PARAMETERS
62 define(`rp', `%rdi')
63 define(`up', `%rsi')
64 define(`n_param',`%rdx')
65 define(`vp', `%rcx')
66
67 define(`v0', `%r8')
68 define(`v1', `%r9')
69 define(`w0', `%rbx')
70 define(`w1', `%rcx')
71 define(`w2', `%rbp')
72 define(`w3', `%r10')
73 define(`n', `%r11')
74
75 ABI_SUPPORT(DOS64)
76 ABI_SUPPORT(STD64)
77
78 ASM_START()
79 TEXT
80 ALIGN(16)
81 PROLOGUE(mpn_addmul_2)
82 FUNC_ENTRY(4)
83 mov n_param, n
84 push %rbx
85 push %rbp
86
87 mov 0(vp), v0
88 mov 8(vp), v1
89
90 mov R32(n_param), R32(%rbx)
91 mov (up), %rax
92 lea -8(up,n_param,8), up
93 lea -8(rp,n_param,8), rp
94 mul v0
95 neg n
96 and $3, R32(%rbx)
97 jz L(b0)
98 cmp $2, R32(%rbx)
99 jc L(b1)
100 jz L(b2)
101
102 L(b3): mov %rax, w1
103 mov %rdx, w2
104 xor R32(w3), R32(w3)
105 mov 8(up,n,8), %rax
106 dec n
107 jmp L(lo3)
108
109 L(b2): mov %rax, w2
110 mov 8(up,n,8), %rax
111 mov %rdx, w3
112 xor R32(w0), R32(w0)
113 add $-2, n
114 jmp L(lo2)
115
116 L(b1): mov %rax, w3
117 mov 8(up,n,8), %rax
118 mov %rdx, w0
119 xor R32(w1), R32(w1)
120 inc n
121 jmp L(lo1)
122
123 L(b0): mov $0, R32(w3)
124 mov %rax, w0
125 mov 8(up,n,8), %rax
126 mov %rdx, w1
127 xor R32(w2), R32(w2)
128 jmp L(lo0)
129
130 ALIGN(32)
131 L(top): mov $0, R32(w1)
132 mul v0
133 add %rax, w3
134 mov (up,n,8), %rax
135 adc %rdx, w0
136 adc $0, R32(w1)
137 L(lo1): mul v1
138 add w3, (rp,n,8)
139 mov $0, R32(w3)
140 adc %rax, w0
141 mov $0, R32(w2)
142 mov 8(up,n,8), %rax
143 adc %rdx, w1
144 mul v0
145 add %rax, w0
146 mov 8(up,n,8), %rax
147 adc %rdx, w1
148 adc $0, R32(w2)
149 L(lo0): mul v1
150 add w0, 8(rp,n,8)
151 adc %rax, w1
152 adc %rdx, w2
153 mov 16(up,n,8), %rax
154 mul v0
155 add %rax, w1
156 adc %rdx, w2
157 adc $0, R32(w3)
158 mov 16(up,n,8), %rax
159 L(lo3): mul v1
160 add w1, 16(rp,n,8)
161 adc %rax, w2
162 adc %rdx, w3
163 xor R32(w0), R32(w0)
164 mov 24(up,n,8), %rax
165 mul v0
166 add %rax, w2
167 mov 24(up,n,8), %rax
168 adc %rdx, w3
169 adc $0, R32(w0)
170 L(lo2): mul v1
171 add w2, 24(rp,n,8)
172 adc %rax, w3
173 adc %rdx, w0
174 mov 32(up,n,8), %rax
175 add $4, n
176 js L(top)
177
178 L(end): xor R32(w1), R32(w1)
179 mul v0
180 add %rax, w3
181 mov (up), %rax
182 adc %rdx, w0
183 adc R32(w1), R32(w1)
184 mul v1
185 add w3, (rp)
186 adc %rax, w0
187 adc %rdx, w1
188 mov w0, 8(rp)
189 mov w1, %rax
190
191 pop %rbp
192 pop %rbx
193 FUNC_EXIT()
194 ret
195 EPILOGUE()