Debian Codegraph @

mpn/x86_64/fastavx/copyd.asm

raw
1 dnl AMD64 mpn_copyd optimised for CPUs with fast AVX.
2
3 dnl Copyright 2003, 2005, 2007, 2011-2013, 2015 Free Software Foundation, Inc.
4
5 dnl Contributed to the GNU project by Torbjörn Granlund.
6
7 dnl This file is part of the GNU MP Library.
8 dnl
9 dnl The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl it under the terms of either:
11 dnl
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.
15 dnl
16 dnl or
17 dnl
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
20 dnl later version.
21 dnl
22 dnl or both in parallel, as here.
23 dnl
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
27 dnl for more details.
28 dnl
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/.
32
33 include(`../config.m4')
34
35 C cycles/limb cycles/limb cycles/limb good
36 C aligned unaligned best seen for cpu?
37 C AMD K8,K9 n/a
38 C AMD K10 n/a
39 C AMD bd1 n/a
40 C AMD bd2 4.87 4.87 N
41 C AMD bd3 ? ?
42 C AMD bd4 0.53 ?
43 C AMD zn1 0.51 ?
44 C AMD zn2 0.25 ? Y
45 C AMD zn3 0.25 ? Y
46 C AMD bt1 n/a
47 C AMD bt2 n/a
48 C Intel P4 n/a
49 C Intel CNR n/a
50 C Intel PNR n/a
51 C Intel NHM n/a
52 C Intel WSM n/a
53 C Intel SBR 0.50 0.91 N
54 C Intel IBR 0.50 0.65 N
55 C Intel HWL 0.25 0.30 Y
56 C Intel BWL 0.28 0.37 Y
57 C Intel SKL 0.27 ? Y
58 C Intel atom n/a
59 C Intel SLM n/a
60 C Intel GLM n/a
61 C VIA nano n/a
62
63 C We try to do as many 32-byte operations as possible. The top-most and
64 C bottom-most writes might need 8-byte operations. For the bulk copying, we
65 C write using aligned 32-byte operations, but we read with both aligned and
66 C unaligned 32-byte operations.
67
68 define(`rp', `%rdi')
69 define(`up', `%rsi')
70 define(`n', `%rdx')
71
72 ABI_SUPPORT(DOS64)
73 ABI_SUPPORT(STD64)
74
75 dnl define(`vmovdqu', vlddqu)
76
77 ASM_START()
78 TEXT
79 ALIGN(32)
80 PROLOGUE(mpn_copyd)
81 FUNC_ENTRY(3)
82
83 lea -32(rp,n,8), rp
84 lea -32(up,n,8), up
85
86 cmp $7, n C basecase needed for correctness
87 jbe L(bc)
88
89 test $8, R8(rp) C is rp 16-byte aligned?
90 jz L(a2) C jump if rp aligned
91 mov 24(up), %rax
92 lea -8(up), up
93 mov %rax, 24(rp)
94 lea -8(rp), rp
95 dec n
96 L(a2): test $16, R8(rp) C is rp 32-byte aligned?
97 jz L(a3) C jump if rp aligned
98 vmovdqu 16(up), %xmm0
99 lea -16(up), up
100 vmovdqa %xmm0, 16(rp)
101 lea -16(rp), rp
102 sub $2, n
103 L(a3): sub $16, n
104 jc L(sma)
105
106 ALIGN(16)
107 L(top): vmovdqu (up), %ymm0
108 vmovdqu -32(up), %ymm1
109 vmovdqu -64(up), %ymm2
110 vmovdqu -96(up), %ymm3
111 lea -128(up), up
112 vmovdqa %ymm0, (rp)
113 vmovdqa %ymm1, -32(rp)
114 vmovdqa %ymm2, -64(rp)
115 vmovdqa %ymm3, -96(rp)
116 lea -128(rp), rp
117 L(ali): sub $16, n
118 jnc L(top)
119
120 L(sma): test $8, R8(n)
121 jz 1f
122 vmovdqu (up), %ymm0
123 vmovdqu -32(up), %ymm1
124 lea -64(up), up
125 vmovdqa %ymm0, (rp)
126 vmovdqa %ymm1, -32(rp)
127 lea -64(rp), rp
128 1:
129 test $4, R8(n)
130 jz 1f
131 vmovdqu (up), %ymm0
132 lea -32(up), up
133 vmovdqa %ymm0, (rp)
134 lea -32(rp), rp
135 1:
136 test $2, R8(n)
137 jz 1f
138 vmovdqu 16(up), %xmm0
139 lea -16(up), up
140 vmovdqa %xmm0, 16(rp)
141 lea -16(rp), rp
142 1:
143 test $1, R8(n)
144 jz 1f
145 mov 24(up), %r8
146 mov %r8, 24(rp)
147 1:
148 FUNC_EXIT()
149 ret
150
151 ALIGN(16)
152 L(bc): test $4, R8(n)
153 jz 1f
154 mov 24(up), %rax
155 mov 16(up), %rcx
156 mov 8(up), %r8
157 mov (up), %r9
158 lea -32(up), up
159 mov %rax, 24(rp)
160 mov %rcx, 16(rp)
161 mov %r8, 8(rp)
162 mov %r9, (rp)
163 lea -32(rp), rp
164 1:
165 test $2, R8(n)
166 jz 1f
167 mov 24(up), %rax
168 mov 16(up), %rcx
169 lea -16(up), up
170 mov %rax, 24(rp)
171 mov %rcx, 16(rp)
172 lea -16(rp), rp
173 1:
174 test $1, R8(n)
175 jz 1f
176 mov 24(up), %rax
177 mov %rax, 24(rp)
178 1:
179 FUNC_EXIT()
180 ret
181 EPILOGUE()