Debian Codegraph @

gmp4/mpn/x86_64/fastsse/copyd.asm

raw
1 dnl AMD64 mpn_copyd optimised for CPUs with fast SSE.
2
3 dnl Copyright 2003, 2005, 2007, 2011, 2012 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
34 C cycles/limb good for cpu?
35 C AMD K8,K9
36 C AMD K10 0.85 Y
37 C AMD bd1 0.8 Y
38 C AMD bobcat
39 C Intel P4 2.28 Y
40 C Intel core2 1
41 C Intel NHM 0.5 Y
42 C Intel SBR 0.5 Y
43 C Intel atom
44 C VIA nano 1.1 Y
45
46 C We try to do as many 16-byte operations as possible. The top-most and
47 C bottom-most writes might need 8-byte operations. We can always write using
48 C aligned 16-byte operations, we read with both aligned and unaligned 16-byte
49 C operations.
50
51 C Instead of having separate loops for reading aligned and unaligned, we read
52 C using MOVDQU. This seems to work great except for core2; there performance
53 C doubles when reading using MOVDQA (for aligned source). It is unclear how to
54 C best handle the unaligned case there.
55
56 C INPUT PARAMETERS
57 define(`rp', `%rdi')
58 define(`up', `%rsi')
59 define(`n', `%rdx')
60
61 ABI_SUPPORT(DOS64)
62 ABI_SUPPORT(STD64)
63
64 ASM_START()
65 TEXT
66 ALIGN(16)
67 PROLOGUE(mpn_copyd)
68 FUNC_ENTRY(3)
69
70 test n, n
71 jz L(don)
72
73 lea -16(rp,n,8), rp
74 lea -16(up,n,8), up
75
76 test $8, R8(rp) C is rp 16-byte aligned?
77 jz L(ali) C jump if rp aligned
78 mov 8(up), %rax
79 lea -8(up), up
80 mov %rax, 8(rp)
81 lea -8(rp), rp
82 dec n
83
84 sub $16, n
85 jc L(sma)
86
87 ALIGN(16)
88 L(top): movdqu (up), %xmm0
89 movdqu -16(up), %xmm1
90 movdqu -32(up), %xmm2
91 movdqu -48(up), %xmm3
92 movdqu -64(up), %xmm4
93 movdqu -80(up), %xmm5
94 movdqu -96(up), %xmm6
95 movdqu -112(up), %xmm7
96 lea -128(up), up
97 movdqa %xmm0, (rp)
98 movdqa %xmm1, -16(rp)
99 movdqa %xmm2, -32(rp)
100 movdqa %xmm3, -48(rp)
101 movdqa %xmm4, -64(rp)
102 movdqa %xmm5, -80(rp)
103 movdqa %xmm6, -96(rp)
104 movdqa %xmm7, -112(rp)
105 lea -128(rp), rp
106 L(ali): sub $16, n
107 jnc L(top)
108
109 L(sma): test $8, R8(n)
110 jz 1f
111 movdqu (up), %xmm0
112 movdqu -16(up), %xmm1
113 movdqu -32(up), %xmm2
114 movdqu -48(up), %xmm3
115 lea -64(up), up
116 movdqa %xmm0, (rp)
117 movdqa %xmm1, -16(rp)
118 movdqa %xmm2, -32(rp)
119 movdqa %xmm3, -48(rp)
120 lea -64(rp), rp
121 1:
122 test $4, R8(n)
123 jz 1f
124 movdqu (up), %xmm0
125 movdqu -16(up), %xmm1
126 lea -32(up), up
127 movdqa %xmm0, (rp)
128 movdqa %xmm1, -16(rp)
129 lea -32(rp), rp
130 1:
131 test $2, R8(n)
132 jz 1f
133 movdqu (up), %xmm0
134 lea -16(up), up
135 movdqa %xmm0, (rp)
136 lea -16(rp), rp
137 1:
138 test $1, R8(n)
139 jz 1f
140 mov 8(up), %r8
141 mov %r8, 8(rp)
142 1:
143 L(don): FUNC_EXIT()
144 ret
145 EPILOGUE()