Debian Codegraph @

modules/lsp-dsp-lib/include/private/dsp/arch/x86/sse/pmath/normalize.h

raw
1 /*
2 * Copyright (C) 2022 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2022 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-dsp-lib
6 * Created on: 6 нояб. 2022 г.
7 *
8 * lsp-dsp-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-dsp-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef PRIVATE_DSP_ARCH_X86_SSE_PMATH_NORMALIZE_H_
23 #define PRIVATE_DSP_ARCH_X86_SSE_PMATH_NORMALIZE_H_
24
25 #ifndef PRIVATE_DSP_ARCH_X86_SSE_IMPL
26 #error "This header should not be included directly"
27 #endif /* PRIVATE_DSP_ARCH_X86_SSE_IMPL */
28
29 namespace lsp
30 {
31 namespace sse
32 {
33 IF_ARCH_X86(
34 static const uint32_t normalize_const[] __lsp_aligned16 =
35 {
36 LSP_DSP_VEC4(0x7fffffff),
37 LSP_DSP_VEC4(0x3f800000) /* 1.0f */
38 };
39 );
40
41 void normalize1(float *dst, size_t count)
42 {
43 IF_ARCH_X86( size_t off, count2 );
44
45 ARCH_X86_ASM
46 (
47 __ASM_EMIT("test %[count], %[count]")
48 __ASM_EMIT("jz 2000f")
49
50 /* Search minimum */
51 __ASM_EMIT("xorps %%xmm1, %%xmm1") /* xmm1 = 0 */
52 __ASM_EMIT("movaps 0x00(%[MASK]), %%xmm2") /* xmm2 = abs mask */
53 __ASM_EMIT("xor %[off], %[off]") /* off = 0 */
54 __ASM_EMIT("mov %[count], %[count2]")
55
56 /* Perform search of absolute max value */
57 __ASM_EMIT("sub $16, %[count]")
58 __ASM_EMIT("xorps %%xmm0, %%xmm0") /* xmm0 = 0 */
59 __ASM_EMIT("movaps %%xmm2, %%xmm3") /* xmm3 = abs mask */
60 __ASM_EMIT("jb 2f")
61 /* x16 blocks */
62 __ASM_EMIT("1:")
63 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm4")
64 __ASM_EMIT("movups 0x10(%[dst], %[off]), %%xmm5")
65 __ASM_EMIT("movups 0x20(%[dst], %[off]), %%xmm6")
66 __ASM_EMIT("movups 0x30(%[dst], %[off]), %%xmm7")
67 __ASM_EMIT("andps %%xmm2, %%xmm4")
68 __ASM_EMIT("andps %%xmm3, %%xmm5")
69 __ASM_EMIT("andps %%xmm2, %%xmm6")
70 __ASM_EMIT("andps %%xmm3, %%xmm7")
71 __ASM_EMIT("maxps %%xmm4, %%xmm0")
72 __ASM_EMIT("maxps %%xmm5, %%xmm1")
73 __ASM_EMIT("maxps %%xmm6, %%xmm0")
74 __ASM_EMIT("maxps %%xmm7, %%xmm1")
75 __ASM_EMIT("add $0x40, %[off]")
76 __ASM_EMIT("sub $16, %[count]")
77 __ASM_EMIT("jae 1b")
78 /* x8 block */
79 __ASM_EMIT("2:")
80 __ASM_EMIT("add $8, %[count]")
81 __ASM_EMIT("jl 4f")
82 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm4")
83 __ASM_EMIT("movups 0x10(%[dst], %[off]), %%xmm5")
84 __ASM_EMIT("andps %%xmm2, %%xmm4")
85 __ASM_EMIT("andps %%xmm3, %%xmm5")
86 __ASM_EMIT("maxps %%xmm4, %%xmm0")
87 __ASM_EMIT("maxps %%xmm5, %%xmm1")
88 __ASM_EMIT("sub $8, %[count]")
89 __ASM_EMIT("add $0x20, %[off]")
90 /* x4 block */
91 __ASM_EMIT("4:")
92 __ASM_EMIT("add $4, %[count]")
93 __ASM_EMIT("jl 6f")
94 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm4")
95 __ASM_EMIT("andps %%xmm2, %%xmm4")
96 __ASM_EMIT("maxps %%xmm4, %%xmm1")
97 __ASM_EMIT("sub $4, %[count]")
98 __ASM_EMIT("add $0x10, %[off]")
99 /* x1 block */
100 __ASM_EMIT("6:")
101 __ASM_EMIT("maxps %%xmm0, %%xmm1")
102 __ASM_EMIT("movhlps %%xmm1, %%xmm0")
103 __ASM_EMIT("maxps %%xmm0, %%xmm1")
104 __ASM_EMIT("unpcklps %%xmm0, %%xmm1")
105 __ASM_EMIT("movhlps %%xmm1, %%xmm0")
106 __ASM_EMIT("maxss %%xmm0, %%xmm1")
107 __ASM_EMIT("add $3, %[count]")
108 __ASM_EMIT("jl 8f")
109 __ASM_EMIT("7:")
110 __ASM_EMIT("movss 0x00(%[dst], %[off]), %%xmm4")
111 __ASM_EMIT("andps %%xmm2, %%xmm4")
112 __ASM_EMIT("maxss %%xmm4, %%xmm1")
113 __ASM_EMIT("add $0x04, %[off]")
114 __ASM_EMIT("dec %[count]")
115 __ASM_EMIT("jge 7b")
116 __ASM_EMIT("8:")
117 /* xmm1 = max { abs{ src } } */
118 __ASM_EMIT("mov %[count2], %[count]") /* restore count */
119 __ASM_EMIT("xorps %%xmm0, %%xmm0") /* xmm0 = 0.0f */
120 __ASM_EMIT("xor %[off], %[off]") /* off = 0 */
121 __ASM_EMIT("ucomiss %%xmm1, %%xmm0") /* abs mask <=> 0.0f */
122 __ASM_EMIT("jle 2000f")
123 __ASM_EMIT("movaps 0x10(%[MASK]), %%xmm0") /* xmm0 = 1.0f */
124 __ASM_EMIT("shufps $0x00, %%xmm1, %%xmm1") /* xmm0 = 1.0f */
125 __ASM_EMIT("divps %%xmm1, %%xmm0") /* xmm0 = 1.0f / max { abs { src } } */
126
127 /* Scale data by the coefficient stored in xmm0 and store to destination */
128 __ASM_EMIT("sub $24, %[count]")
129 __ASM_EMIT("movaps %%xmm0, %%xmm1")
130 __ASM_EMIT("jb 2f")
131 /* x24 blocks */
132 __ASM_EMIT("1:")
133 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm2")
134 __ASM_EMIT("movups 0x10(%[dst], %[off]), %%xmm3")
135 __ASM_EMIT("movups 0x20(%[dst], %[off]), %%xmm4")
136 __ASM_EMIT("mulps %%xmm0, %%xmm2")
137 __ASM_EMIT("movups 0x30(%[dst], %[off]), %%xmm5")
138 __ASM_EMIT("mulps %%xmm1, %%xmm3")
139 __ASM_EMIT("movups 0x40(%[dst], %[off]), %%xmm6")
140 __ASM_EMIT("mulps %%xmm0, %%xmm4")
141 __ASM_EMIT("movups 0x50(%[dst], %[off]), %%xmm7")
142 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
143 __ASM_EMIT("mulps %%xmm1, %%xmm5")
144 __ASM_EMIT("movups %%xmm3, 0x10(%[dst], %[off])")
145 __ASM_EMIT("mulps %%xmm0, %%xmm6")
146 __ASM_EMIT("movups %%xmm4, 0x20(%[dst], %[off])")
147 __ASM_EMIT("mulps %%xmm1, %%xmm7")
148 __ASM_EMIT("movups %%xmm5, 0x30(%[dst], %[off])")
149 __ASM_EMIT("movups %%xmm6, 0x40(%[dst], %[off])")
150 __ASM_EMIT("movups %%xmm7, 0x50(%[dst], %[off])")
151 __ASM_EMIT("add $0x60, %[off]")
152 __ASM_EMIT("sub $24, %[count]")
153 __ASM_EMIT("jae 1b")
154 /* x16 block */
155 __ASM_EMIT("2:")
156 __ASM_EMIT("add $8, %[count]")
157 __ASM_EMIT("jl 4f")
158 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm2")
159 __ASM_EMIT("movups 0x10(%[dst], %[off]), %%xmm3")
160 __ASM_EMIT("movups 0x20(%[dst], %[off]), %%xmm4")
161 __ASM_EMIT("mulps %%xmm0, %%xmm2")
162 __ASM_EMIT("movups 0x30(%[dst], %[off]), %%xmm5")
163 __ASM_EMIT("mulps %%xmm1, %%xmm3")
164 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
165 __ASM_EMIT("mulps %%xmm0, %%xmm4")
166 __ASM_EMIT("movups %%xmm3, 0x10(%[dst], %[off])")
167 __ASM_EMIT("mulps %%xmm1, %%xmm5")
168 __ASM_EMIT("movups %%xmm4, 0x20(%[dst], %[off])")
169 __ASM_EMIT("movups %%xmm5, 0x30(%[dst], %[off])")
170 __ASM_EMIT("sub $16, %[count]")
171 __ASM_EMIT("add $0x40, %[off]")
172 /* x8 block */
173 __ASM_EMIT("4:")
174 __ASM_EMIT("add $8, %[count]")
175 __ASM_EMIT("jl 6f")
176 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm2")
177 __ASM_EMIT("movups 0x10(%[dst], %[off]), %%xmm3")
178 __ASM_EMIT("mulps %%xmm0, %%xmm2")
179 __ASM_EMIT("mulps %%xmm1, %%xmm3")
180 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
181 __ASM_EMIT("movups %%xmm3, 0x10(%[dst], %[off])")
182 __ASM_EMIT("sub $8, %[count]")
183 __ASM_EMIT("add $0x20, %[off]")
184 /* x4 block */
185 __ASM_EMIT("6:")
186 __ASM_EMIT("add $4, %[count]")
187 __ASM_EMIT("jl 8f")
188 __ASM_EMIT("movups 0x00(%[dst], %[off]), %%xmm2")
189 __ASM_EMIT("mulps %%xmm0, %%xmm2")
190 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
191 __ASM_EMIT("sub $4, %[count]")
192 __ASM_EMIT("add $0x10, %[off]")
193 /* x1 block */
194 __ASM_EMIT("8:")
195 __ASM_EMIT("add $3, %[count]")
196 __ASM_EMIT("jl 2000f")
197 __ASM_EMIT("9:")
198 __ASM_EMIT("movss 0x00(%[dst], %[off]), %%xmm2")
199 __ASM_EMIT("mulss %%xmm0, %%xmm2")
200 __ASM_EMIT("movss %%xmm2, 0x00(%[dst], %[off])")
201 __ASM_EMIT("add $0x04, %[off]")
202 __ASM_EMIT("dec %[count]")
203 __ASM_EMIT("jge 9b")
204
205 __ASM_EMIT("2000:")
206
207 : [off] "=&r" (off), [count] "+r" (count), [count2] "=&r" (count2)
208 : [dst] "r" (dst),
209 [MASK] "r" (normalize_const)
210 : "cc", "memory",
211 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
212 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
213 );
214 }
215
216 void normalize2(float *dst, const float *src, size_t count)
217 {
218 IF_ARCH_X86( size_t off, count2 );
219
220 ARCH_X86_ASM
221 (
222 __ASM_EMIT("test %[count], %[count]")
223 __ASM_EMIT("jz 2000f")
224
225 /* Search minimum */
226 __ASM_EMIT("xorps %%xmm1, %%xmm1") /* xmm1 = 0 */
227 __ASM_EMIT("movaps 0x00(%[MASK]), %%xmm2") /* xmm2 = abs mask */
228 __ASM_EMIT("xor %[off], %[off]") /* off = 0 */
229 __ASM_EMIT("mov %[count], %[count2]")
230
231 /* Perform search of absolute max value */
232 __ASM_EMIT("sub $16, %[count]")
233 __ASM_EMIT("xorps %%xmm0, %%xmm0") /* xmm0 = 0 */
234 __ASM_EMIT("movaps %%xmm2, %%xmm3") /* xmm3 = abs mask */
235 __ASM_EMIT("jb 2f")
236 /* x16 blocks */
237 __ASM_EMIT("1:")
238 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm4")
239 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm5")
240 __ASM_EMIT("movups 0x20(%[src], %[off]), %%xmm6")
241 __ASM_EMIT("movups 0x30(%[src], %[off]), %%xmm7")
242 __ASM_EMIT("andps %%xmm2, %%xmm4")
243 __ASM_EMIT("andps %%xmm3, %%xmm5")
244 __ASM_EMIT("andps %%xmm2, %%xmm6")
245 __ASM_EMIT("andps %%xmm3, %%xmm7")
246 __ASM_EMIT("maxps %%xmm4, %%xmm0")
247 __ASM_EMIT("maxps %%xmm5, %%xmm1")
248 __ASM_EMIT("maxps %%xmm6, %%xmm0")
249 __ASM_EMIT("maxps %%xmm7, %%xmm1")
250 __ASM_EMIT("add $0x40, %[off]")
251 __ASM_EMIT("sub $16, %[count]")
252 __ASM_EMIT("jae 1b")
253 /* x8 block */
254 __ASM_EMIT("2:")
255 __ASM_EMIT("add $8, %[count]")
256 __ASM_EMIT("jl 4f")
257 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm4")
258 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm5")
259 __ASM_EMIT("andps %%xmm2, %%xmm4")
260 __ASM_EMIT("andps %%xmm3, %%xmm5")
261 __ASM_EMIT("maxps %%xmm4, %%xmm0")
262 __ASM_EMIT("maxps %%xmm5, %%xmm1")
263 __ASM_EMIT("sub $8, %[count]")
264 __ASM_EMIT("add $0x20, %[off]")
265 /* x4 block */
266 __ASM_EMIT("4:")
267 __ASM_EMIT("add $4, %[count]")
268 __ASM_EMIT("jl 6f")
269 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm4")
270 __ASM_EMIT("andps %%xmm2, %%xmm4")
271 __ASM_EMIT("maxps %%xmm4, %%xmm1")
272 __ASM_EMIT("sub $4, %[count]")
273 __ASM_EMIT("add $0x10, %[off]")
274 /* x1 block */
275 __ASM_EMIT("6:")
276 __ASM_EMIT("maxps %%xmm0, %%xmm1")
277 __ASM_EMIT("movhlps %%xmm1, %%xmm0")
278 __ASM_EMIT("maxps %%xmm0, %%xmm1")
279 __ASM_EMIT("unpcklps %%xmm0, %%xmm1")
280 __ASM_EMIT("movhlps %%xmm1, %%xmm0")
281 __ASM_EMIT("maxss %%xmm0, %%xmm1")
282 __ASM_EMIT("add $3, %[count]")
283 __ASM_EMIT("jl 8f")
284 __ASM_EMIT("7:")
285 __ASM_EMIT("movss 0x00(%[src], %[off]), %%xmm4")
286 __ASM_EMIT("andps %%xmm2, %%xmm4")
287 __ASM_EMIT("maxss %%xmm4, %%xmm1")
288 __ASM_EMIT("add $0x04, %[off]")
289 __ASM_EMIT("dec %[count]")
290 __ASM_EMIT("jge 7b")
291 __ASM_EMIT("8:")
292 /* xmm1 = max { abs{ src } } */
293 __ASM_EMIT("mov %[count2], %[count]") /* restore count */
294 __ASM_EMIT("xorps %%xmm0, %%xmm0") /* xmm0 = 0.0f */
295 __ASM_EMIT("xor %[off], %[off]") /* off = 0 */
296 __ASM_EMIT("ucomiss %%xmm1, %%xmm0") /* abs mask <=> 0.0f */
297 __ASM_EMIT("jle 1000f")
298 __ASM_EMIT("movaps 0x10(%[MASK]), %%xmm0") /* xmm0 = 1.0f */
299 __ASM_EMIT("shufps $0x00, %%xmm1, %%xmm1") /* xmm0 = 1.0f */
300 __ASM_EMIT("divps %%xmm1, %%xmm0") /* xmm0 = 1.0f / max { abs { src } } */
301
302 /* Scale data by the coefficient stored in xmm0 and store to destination */
303 __ASM_EMIT("sub $24, %[count]")
304 __ASM_EMIT("movaps %%xmm0, %%xmm1")
305 __ASM_EMIT("jb 2f")
306 /* x24 blocks */
307 __ASM_EMIT("1:")
308 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm2")
309 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm3")
310 __ASM_EMIT("movups 0x20(%[src], %[off]), %%xmm4")
311 __ASM_EMIT("mulps %%xmm0, %%xmm2")
312 __ASM_EMIT("movups 0x30(%[src], %[off]), %%xmm5")
313 __ASM_EMIT("mulps %%xmm1, %%xmm3")
314 __ASM_EMIT("movups 0x40(%[src], %[off]), %%xmm6")
315 __ASM_EMIT("mulps %%xmm0, %%xmm4")
316 __ASM_EMIT("movups 0x50(%[src], %[off]), %%xmm7")
317 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
318 __ASM_EMIT("mulps %%xmm1, %%xmm5")
319 __ASM_EMIT("movups %%xmm3, 0x10(%[dst], %[off])")
320 __ASM_EMIT("mulps %%xmm0, %%xmm6")
321 __ASM_EMIT("movups %%xmm4, 0x20(%[dst], %[off])")
322 __ASM_EMIT("mulps %%xmm1, %%xmm7")
323 __ASM_EMIT("movups %%xmm5, 0x30(%[dst], %[off])")
324 __ASM_EMIT("movups %%xmm6, 0x40(%[dst], %[off])")
325 __ASM_EMIT("movups %%xmm7, 0x50(%[dst], %[off])")
326 __ASM_EMIT("add $0x60, %[off]")
327 __ASM_EMIT("sub $24, %[count]")
328 __ASM_EMIT("jae 1b")
329 /* x16 block */
330 __ASM_EMIT("2:")
331 __ASM_EMIT("add $8, %[count]")
332 __ASM_EMIT("jl 4f")
333 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm2")
334 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm3")
335 __ASM_EMIT("movups 0x20(%[src], %[off]), %%xmm4")
336 __ASM_EMIT("mulps %%xmm0, %%xmm2")
337 __ASM_EMIT("movups 0x30(%[src], %[off]), %%xmm5")
338 __ASM_EMIT("mulps %%xmm1, %%xmm3")
339 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
340 __ASM_EMIT("mulps %%xmm0, %%xmm4")
341 __ASM_EMIT("movups %%xmm3, 0x10(%[dst], %[off])")
342 __ASM_EMIT("mulps %%xmm1, %%xmm5")
343 __ASM_EMIT("movups %%xmm4, 0x20(%[dst], %[off])")
344 __ASM_EMIT("movups %%xmm5, 0x30(%[dst], %[off])")
345 __ASM_EMIT("sub $16, %[count]")
346 __ASM_EMIT("add $0x40, %[off]")
347 /* x8 block */
348 __ASM_EMIT("4:")
349 __ASM_EMIT("add $8, %[count]")
350 __ASM_EMIT("jl 6f")
351 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm2")
352 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm3")
353 __ASM_EMIT("mulps %%xmm0, %%xmm2")
354 __ASM_EMIT("mulps %%xmm1, %%xmm3")
355 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
356 __ASM_EMIT("movups %%xmm3, 0x10(%[dst], %[off])")
357 __ASM_EMIT("sub $8, %[count]")
358 __ASM_EMIT("add $0x20, %[off]")
359 /* x4 block */
360 __ASM_EMIT("6:")
361 __ASM_EMIT("add $4, %[count]")
362 __ASM_EMIT("jl 8f")
363 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm2")
364 __ASM_EMIT("mulps %%xmm0, %%xmm2")
365 __ASM_EMIT("movups %%xmm2, 0x00(%[dst], %[off])")
366 __ASM_EMIT("sub $4, %[count]")
367 __ASM_EMIT("add $0x10, %[off]")
368 /* x1 block */
369 __ASM_EMIT("8:")
370 __ASM_EMIT("add $3, %[count]")
371 __ASM_EMIT("jl 2000f")
372 __ASM_EMIT("9:")
373 __ASM_EMIT("movss 0x00(%[src], %[off]), %%xmm2")
374 __ASM_EMIT("mulss %%xmm0, %%xmm2")
375 __ASM_EMIT("movss %%xmm2, 0x00(%[dst], %[off])")
376 __ASM_EMIT("add $0x04, %[off]")
377 __ASM_EMIT("dec %[count]")
378 __ASM_EMIT("jge 9b")
379 __ASM_EMIT("jmp 2000f")
380
381 /* Copy data to destination */
382 __ASM_EMIT("1000:")
383 __ASM_EMIT("cmp %[src], %[dst]")
384 __ASM_EMIT("je 2000f")
385 __ASM_EMIT("sub $32, %[count]")
386 __ASM_EMIT("jb 2f")
387 /* x32 blocks */
388 __ASM_EMIT("1:")
389 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm0")
390 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm1")
391 __ASM_EMIT("movups 0x20(%[src], %[off]), %%xmm2")
392 __ASM_EMIT("movups 0x30(%[src], %[off]), %%xmm3")
393 __ASM_EMIT("movups 0x40(%[src], %[off]), %%xmm4")
394 __ASM_EMIT("movups 0x50(%[src], %[off]), %%xmm5")
395 __ASM_EMIT("movups 0x60(%[src], %[off]), %%xmm6")
396 __ASM_EMIT("movups 0x70(%[src], %[off]), %%xmm7")
397 __ASM_EMIT("movups %%xmm0, 0x00(%[dst], %[off])")
398 __ASM_EMIT("movups %%xmm1, 0x10(%[dst], %[off])")
399 __ASM_EMIT("movups %%xmm2, 0x20(%[dst], %[off])")
400 __ASM_EMIT("movups %%xmm3, 0x30(%[dst], %[off])")
401 __ASM_EMIT("movups %%xmm4, 0x40(%[dst], %[off])")
402 __ASM_EMIT("movups %%xmm5, 0x50(%[dst], %[off])")
403 __ASM_EMIT("movups %%xmm6, 0x60(%[dst], %[off])")
404 __ASM_EMIT("movups %%xmm7, 0x70(%[dst], %[off])")
405 __ASM_EMIT("add $0x80, %[off]")
406 __ASM_EMIT("sub $32, %[count]")
407 __ASM_EMIT("jae 1b")
408 /* x16 block */
409 __ASM_EMIT("2:")
410 __ASM_EMIT("add $16, %[count]")
411 __ASM_EMIT("jl 4f")
412 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm0")
413 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm1")
414 __ASM_EMIT("movups 0x20(%[src], %[off]), %%xmm2")
415 __ASM_EMIT("movups 0x30(%[src], %[off]), %%xmm3")
416 __ASM_EMIT("movups %%xmm0, 0x00(%[dst], %[off])")
417 __ASM_EMIT("movups %%xmm1, 0x10(%[dst], %[off])")
418 __ASM_EMIT("movups %%xmm2, 0x20(%[dst], %[off])")
419 __ASM_EMIT("movups %%xmm3, 0x30(%[dst], %[off])")
420 __ASM_EMIT("sub $16, %[count]")
421 __ASM_EMIT("add $0x40, %[off]")
422 /* x8 block */
423 __ASM_EMIT("4:")
424 __ASM_EMIT("add $8, %[count]")
425 __ASM_EMIT("jl 6f")
426 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm0")
427 __ASM_EMIT("movups 0x10(%[src], %[off]), %%xmm1")
428 __ASM_EMIT("movups %%xmm0, 0x00(%[dst], %[off])")
429 __ASM_EMIT("movups %%xmm1, 0x10(%[dst], %[off])")
430 __ASM_EMIT("sub $8, %[count]")
431 __ASM_EMIT("add $0x20, %[off]")
432 /* x4 block */
433 __ASM_EMIT("6:")
434 __ASM_EMIT("add $4, %[count]")
435 __ASM_EMIT("jl 8f")
436 __ASM_EMIT("movups 0x00(%[src], %[off]), %%xmm0")
437 __ASM_EMIT("movups %%xmm0, 0x00(%[dst], %[off])")
438 __ASM_EMIT("sub $4, %[count]")
439 __ASM_EMIT("add $0x10, %[off]")
440 /* x1 block */
441 __ASM_EMIT("8:")
442 __ASM_EMIT("add $3, %[count]")
443 __ASM_EMIT("jl 2000f")
444 __ASM_EMIT("9:")
445 __ASM_EMIT("movss 0x00(%[src], %[off]), %%xmm0")
446 __ASM_EMIT("movss %%xmm0, 0x00(%[dst], %[off])")
447 __ASM_EMIT("add $0x04, %[off]")
448 __ASM_EMIT("dec %[count]")
449 __ASM_EMIT("jge 9b")
450
451 __ASM_EMIT("2000:")
452
453 : [off] "=&r" (off), [count] "+r" (count)
454 __IF_64(, [count2] "=&r" (count2))
455 : [dst] "r" (dst), [src] "r" (src),
456 [MASK] "r" (normalize_const)
457 __IF_32(, [count2] "m" (count2))
458 : "cc", "memory",
459 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
460 "%xmm4", "%xmm5", "%xmm6", "%xmm7"
461 );
462 }
463
464 } /* namespace sse */
465 } /* namespace lsp */
466
467
468
469 #endif /* PRIVATE_DSP_ARCH_X86_SSE_PMATH_NORMALIZE_H_ */