Debian Codegraph @

mpn/x86_64/atom/aorsmul_1.asm

raw
1 dnl AMD64 mpn_addmul_1/mpn_submul_1 optimised for Intel Atom.
2
3 dnl Copyright 2003-2005, 2007, 2008, 2011-2013 Free Software Foundation, Inc.
4
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
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.
13 dnl
14 dnl or
15 dnl
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
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
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
25 dnl for more details.
26 dnl
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/.
30
31 include(`../config.m4')
32
33 C cycles/limb
34 C AMD K8,K9 4.5
35 C AMD K10 4.5
36 C AMD bull 4.73
37 C AMD pile 4.60 4.80
38 C AMD steam
39 C AMD excavator
40 C AMD bobcat 5.48
41 C AMD jaguar 5.61
42 C Intel P4 16.6
43 C Intel core2 5.09
44 C Intel NHM 4.79
45 C Intel SBR 3.88
46 C Intel IBR 3.65
47 C Intel HWL 3.53
48 C Intel BWL 2.75
49 C Intel SKL 2.76
50 C Intel atom 19.4
51 C Intel SLM 8
52 C VIA nano
53
54 C The loop of this code is the result of running a code generation and
55 C optimisation tool suite written by David Harvey and Torbjorn Granlund.
56
57 define(`rp', `%rdi') C rcx
58 define(`up', `%rsi') C rdx
59 define(`n_param', `%rdx') C r8
60 define(`v0', `%rcx') C r9
61
62 define(`n', `%rbx')
63
64 ifdef(`OPERATION_addmul_1',`
65 define(`ADDSUB', `add')
66 define(`func', `mpn_addmul_1')
67 ')
68 ifdef(`OPERATION_submul_1',`
69 define(`ADDSUB', `sub')
70 define(`func', `mpn_submul_1')
71 ')
72
73 ABI_SUPPORT(DOS64)
74 ABI_SUPPORT(STD64)
75
76 MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1)
77
78 ASM_START()
79 TEXT
80 ALIGN(16)
81 PROLOGUE(func)
82 FUNC_ENTRY(4)
83 push %rbx
84
85 mov (up), %rax
86 lea -8(up,n_param,8), up
87 lea -16(rp,n_param,8), rp
88
89 test $1, R8(n_param)
90 jnz L(bx1)
91
92 L(bx0): test $2, R8(n_param)
93 jnz L(b10)
94
95 L(b00): mov $1, R32(n)
96 sub n_param, n
97 mul v0
98 mov %rax, %r11
99 mov 8(up,n,8), %rax
100 mov %rdx, %r10
101 mul v0
102 mov %rax, %r8
103 mov 16(up,n,8), %rax
104 jmp L(lo0)
105
106 L(b10): mov $3, R32(n)
107 sub n_param, n
108 mul v0
109 mov %rax, %r11
110 mov -8(up,n,8), %rax
111 mov %rdx, %r10
112 mul v0
113 test n, n
114 jns L(cj2)
115 mov %rax, %r8
116 mov (up,n,8), %rax
117 mov %rdx, %r9
118 jmp L(lo2)
119
120 L(bx1): test $2, R8(n_param)
121 jnz L(b11)
122
123 L(b01): mov $2, R32(n)
124 sub n_param, n
125 mul v0
126 test n, n
127 jns L(cj1)
128 mov %rax, %r8
129 mov (up,n,8), %rax
130 mov %rdx, %r9
131 mul v0
132 mov %rax, %r11
133 mov 8(up,n,8), %rax
134 mov %rdx, %r10
135 jmp L(lo1)
136
137 L(b11): xor R32(n), R32(n)
138 sub n_param, n
139 mul v0
140 mov %rax, %r8
141 mov 16(up,n,8), %rax
142 mov %rdx, %r9
143 mul v0
144 mov %rax, %r11
145 mov 24(up,n,8), %rax
146 jmp L(lo3)
147
148 ALIGN(16)
149 L(top): mul v0
150 ADDSUB %r8, -16(rp,n,8)
151 mov %rax, %r8
152 mov (up,n,8), %rax
153 adc %r9, %r11
154 mov %rdx, %r9
155 adc $0, %r10
156 L(lo2): mul v0
157 ADDSUB %r11, -8(rp,n,8)
158 mov %rax, %r11
159 mov 8(up,n,8), %rax
160 adc %r10, %r8
161 mov %rdx, %r10
162 adc $0, %r9
163 L(lo1): mul v0
164 ADDSUB %r8, (rp,n,8)
165 mov %rax, %r8
166 adc %r9, %r11
167 mov 16(up,n,8), %rax
168 adc $0, %r10
169 L(lo0): mov %rdx, %r9
170 mul v0
171 ADDSUB %r11, 8(rp,n,8)
172 mov %rax, %r11
173 adc %r10, %r8
174 mov 24(up,n,8), %rax
175 adc $0, %r9
176 L(lo3): add $4, n
177 mov %rdx, %r10
178 js L(top)
179
180 L(end): mul v0
181 ADDSUB %r8, -16(rp,n,8)
182 adc %r9, %r11
183 adc $0, %r10
184 L(cj2): ADDSUB %r11, -8(rp,n,8)
185 adc %r10, %rax
186 adc $0, %rdx
187 L(cj1): ADDSUB %rax, (rp,n,8)
188 mov $0, R32(%rax)
189 adc %rdx, %rax
190 pop %rbx
191 FUNC_EXIT()
192 ret
193 EPILOGUE()
194 ASM_END()