Debian Codegraph @

mpn/x86_64/fastavx/copyi.asm

raw
1 dnl AMD64 mpn_copyi 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_copyi)
81 FUNC_ENTRY(3)
82
83 cmp $7, n
84 jbe L(bc)
85
86 test $8, R8(rp) C is rp 16-byte aligned?
87 jz L(a2) C jump if rp aligned
88 mov (up), %rax
89 lea 8(up), up
90 mov %rax, (rp)
91 lea 8(rp), rp
92 dec n
93 L(a2): test $16, R8(rp) C is rp 32-byte aligned?
94 jz L(a3) C jump if rp aligned
95 vmovdqu (up), %xmm0
96 lea 16(up), up
97 vmovdqa %xmm0, (rp)
98 lea 16(rp), rp
99 sub $2, n
100 L(a3): sub $16, n
101 jc L(sma)
102
103 ALIGN(16)
104 L(top): vmovdqu (up), %ymm0
105 vmovdqu 32(up), %ymm1
106 vmovdqu 64(up), %ymm2
107 vmovdqu 96(up), %ymm3
108 lea 128(up), up
109 vmovdqa %ymm0, (rp)
110 vmovdqa %ymm1, 32(rp)
111 vmovdqa %ymm2, 64(rp)
112 vmovdqa %ymm3, 96(rp)
113 lea 128(rp), rp
114 L(ali): sub $16, n
115 jnc L(top)
116
117 L(sma): test $8, R8(n)
118 jz 1f
119 vmovdqu (up), %ymm0
120 vmovdqu 32(up), %ymm1
121 lea 64(up), up
122 vmovdqa %ymm0, (rp)
123 vmovdqa %ymm1, 32(rp)
124 lea 64(rp), rp
125 1:
126 test $4, R8(n)
127 jz 1f
128 vmovdqu (up), %ymm0
129 lea 32(up), up
130 vmovdqa %ymm0, (rp)
131 lea 32(rp), rp
132 1:
133 test $2, R8(n)
134 jz 1f
135 vmovdqu (up), %xmm0
136 lea 16(up), up
137 vmovdqa %xmm0, (rp)
138 lea 16(rp), rp
139 1:
140 L(end): test $1, R8(n)
141 jz 1f
142 mov (up), %r8
143 mov %r8, (rp)
144 1:
145 FUNC_EXIT()
146 ret
147
148 ALIGN(16)
149 L(bc): test $4, R8(n)
150 jz 1f
151 mov (up), %rax
152 mov 8(up), %rcx
153 mov 16(up), %r8
154 mov 24(up), %r9
155 lea 32(up), up
156 mov %rax, (rp)
157 mov %rcx, 8(rp)
158 mov %r8, 16(rp)
159 mov %r9, 24(rp)
160 lea 32(rp), rp
161 1:
162 test $2, R8(n)
163 jz 1f
164 mov (up), %rax
165 mov 8(up), %rcx
166 lea 16(up), up
167 mov %rax, (rp)
168 mov %rcx, 8(rp)
169 lea 16(rp), rp
170 1:
171 test $1, R8(n)
172 jz 1f
173 mov (up), %rax
174 mov %rax, (rp)
175 1:
176 FUNC_EXIT()
177 ret
178 EPILOGUE()