Debian Codegraph @

modules/lsp-dsp-lib/include/private/dsp/arch/x86/avx/pmath/abs_vv.h

raw
1 /*
2 * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2024 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-dsp-lib
6 * Created on: 31 мар. 2020 г.
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_AVX_PMATH_ABS_VV_H_
23 #define PRIVATE_DSP_ARCH_X86_AVX_PMATH_ABS_VV_H_
24
25 #ifndef PRIVATE_DSP_ARCH_X86_AVX_IMPL
26 #error "This header should not be included directly"
27 #endif /* PRIVATE_DSP_ARCH_X86_AVX_IMPL */
28
29 namespace lsp
30 {
31 namespace avx
32 {
33 IF_ARCH_X86(
34 static const uint32_t abs_vv_const[] __lsp_aligned32 =
35 {
36 LSP_DSP_VEC8(0x7fffffff)
37 };
38 )
39
40 #define OP_DSEL(a, b) a
41 #define OP_RSEL(a, b) b
42
43 #define ABS_V4_CORE(DST, SRC1, SRC2, OP, SEL) \
44 __ASM_EMIT("xor %[off], %[off]") \
45 __ASM_EMIT("vmovaps %[SIGN], %%ymm0") \
46 __ASM_EMIT("sub $32, %[count]") \
47 __ASM_EMIT("vmovaps %%ymm0, %%ymm1") \
48 __ASM_EMIT("jb 2f") \
49 /* 32x blocks */ \
50 __ASM_EMIT("1:") \
51 __ASM_EMIT(SEL("vmovups 0x000(%[" SRC1 "], %[off]), %%ymm6", "")) \
52 __ASM_EMIT(SEL("vmovups 0x020(%[" SRC1 "], %[off]), %%ymm7", "")) \
53 __ASM_EMIT(SEL("vmovups 0x040(%[" SRC1 "], %[off]), %%ymm8", "")) \
54 __ASM_EMIT(SEL("vmovups 0x060(%[" SRC1 "], %[off]), %%ymm9", "")) \
55 __ASM_EMIT("vandps 0x000(%[" SRC2 "], %[off]), %%ymm0, %%ymm2") \
56 __ASM_EMIT("vandps 0x020(%[" SRC2 "], %[off]), %%ymm1, %%ymm3") \
57 __ASM_EMIT("vandps 0x040(%[" SRC2 "], %[off]), %%ymm0, %%ymm4") \
58 __ASM_EMIT("vandps 0x060(%[" SRC2 "], %[off]), %%ymm1, %%ymm5") \
59 __ASM_EMIT(OP "ps " SEL("%%ymm2", "0x000(%[" SRC1 "], %[off])") ", " SEL("%%ymm6", "%%ymm2") ", %%ymm6") \
60 __ASM_EMIT(OP "ps " SEL("%%ymm3", "0x020(%[" SRC1 "], %[off])") ", " SEL("%%ymm7", "%%ymm3") ", %%ymm7") \
61 __ASM_EMIT(OP "ps " SEL("%%ymm4", "0x040(%[" SRC1 "], %[off])") ", " SEL("%%ymm8", "%%ymm4") ", %%ymm8") \
62 __ASM_EMIT(OP "ps " SEL("%%ymm5", "0x060(%[" SRC1 "], %[off])") ", " SEL("%%ymm9", "%%ymm5") ", %%ymm9") \
63 __ASM_EMIT("vmovups %%ymm6, 0x000(%[" DST "], %[off])") \
64 __ASM_EMIT("vmovups %%ymm7, 0x020(%[" DST "], %[off])") \
65 __ASM_EMIT("vmovups %%ymm8, 0x040(%[" DST "], %[off])") \
66 __ASM_EMIT("vmovups %%ymm9, 0x060(%[" DST "], %[off])") \
67 __ASM_EMIT("add $0x80, %[off]") \
68 __ASM_EMIT("sub $32, %[count]") \
69 __ASM_EMIT("jae 1b") \
70 /* 16x block */ \
71 __ASM_EMIT("2:") \
72 __ASM_EMIT("add $16, %[count]") /* 32 - 16 */ \
73 __ASM_EMIT("jl 4f") \
74 __ASM_EMIT(SEL("vmovups 0x000(%[" SRC1 "], %[off]), %%ymm6", "")) \
75 __ASM_EMIT(SEL("vmovups 0x020(%[" SRC1 "], %[off]), %%ymm7", "")) \
76 __ASM_EMIT("vandps 0x000(%[" SRC2 "], %[off]), %%ymm0, %%ymm2") \
77 __ASM_EMIT("vandps 0x020(%[" SRC2 "], %[off]), %%ymm1, %%ymm3") \
78 __ASM_EMIT(OP "ps " SEL("%%ymm2", "0x000(%[" SRC1 "], %[off])") ", " SEL("%%ymm6", "%%ymm2") ", %%ymm6") \
79 __ASM_EMIT(OP "ps " SEL("%%ymm3", "0x020(%[" SRC1 "], %[off])") ", " SEL("%%ymm7", "%%ymm3") ", %%ymm7") \
80 __ASM_EMIT("vmovups %%ymm6, 0x000(%[" DST "], %[off])") \
81 __ASM_EMIT("vmovups %%ymm7, 0x020(%[" DST "], %[off])") \
82 __ASM_EMIT("add $0x40, %[off]") \
83 __ASM_EMIT("sub $16, %[count]") \
84 /* 8x block */ \
85 __ASM_EMIT("4:") \
86 __ASM_EMIT("add $8, %[count]") /* 16 - 8 */ \
87 __ASM_EMIT("jl 6f") \
88 __ASM_EMIT(SEL("vmovups 0x000(%[" SRC1 "], %[off]), %%ymm6", "")) \
89 __ASM_EMIT("vandps 0x000(%[" SRC2 "], %[off]), %%ymm0, %%ymm2") \
90 __ASM_EMIT(OP "ps " SEL("%%ymm2", "0x000(%[" SRC1 "], %[off])") ", " SEL("%%ymm6", "%%ymm2") ", %%ymm6") \
91 __ASM_EMIT("vmovups %%ymm6, 0x000(%[" DST "], %[off])") \
92 __ASM_EMIT("add $0x20, %[off]") \
93 __ASM_EMIT("sub $8, %[count]") \
94 \
95 /* 4x block */ \
96 __ASM_EMIT("6:") \
97 __ASM_EMIT("add $4, %[count]") /* 8 - 4 */ \
98 __ASM_EMIT("jl 8f") \
99 __ASM_EMIT(SEL("vmovups 0x000(%[" SRC1 "], %[off]), %%xmm6", "")) \
100 __ASM_EMIT("vandps 0x000(%[" SRC2 "], %[off]), %%xmm0, %%xmm2") \
101 __ASM_EMIT(OP "ps " SEL("%%xmm2", "0x000(%[" SRC1 "], %[off])") ", " SEL("%%xmm6", "%%xmm2") ", %%xmm6") \
102 __ASM_EMIT("vmovups %%xmm6, 0x000(%[" DST "], %[off])") \
103 __ASM_EMIT("add $0x10, %[off]") \
104 __ASM_EMIT("sub $4, %[count]") \
105 \
106 /* 1x blocks */ \
107 __ASM_EMIT("8:") \
108 __ASM_EMIT("add $3, %[count]") /* 8 - 4 */ \
109 __ASM_EMIT("jl 10f") \
110 __ASM_EMIT("9:") \
111 __ASM_EMIT(SEL("vmovss 0x000(%[" SRC1 "], %[off]), %%xmm6", "")) \
112 __ASM_EMIT("vandps 0x000(%[" SRC2 "], %[off]), %%xmm0, %%xmm2") \
113 __ASM_EMIT(OP "ss " SEL("%%xmm2", "0x000(%[" SRC1 "], %[off])") ", " SEL("%%xmm6", "%%xmm2") ", %%xmm6") \
114 __ASM_EMIT("vmovss %%xmm6, 0x000(%[" DST "], %[off])") \
115 __ASM_EMIT("add $0x04, %[off]") \
116 __ASM_EMIT("dec %[count]") \
117 __ASM_EMIT("jge 9b") \
118 __ASM_EMIT("10:")
119
120 void x64_abs_add2(float *dst, const float *src, size_t count)
121 {
122 IF_ARCH_X86_64(size_t off);
123 ARCH_X86_64_ASM
124 (
125 ABS_V4_CORE("dst", "dst", "src", "vadd", OP_DSEL)
126 : [off] "=&r" (off), [count] "+r" (count)
127 : [dst] "r"(dst), [src] "r"(src),
128 [SIGN] "m" (abs_vv_const)
129 : "cc", "memory",
130 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
131 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
132 "%xmm8", "%xmm9"
133 );
134 }
135
136 void x64_abs_sub2(float *dst, const float *src, size_t count)
137 {
138 IF_ARCH_X86_64(size_t off);
139 ARCH_X86_64_ASM
140 (
141 ABS_V4_CORE("dst", "dst", "src", "vsub", OP_DSEL)
142 : [off] "=&r" (off), [count] "+r" (count)
143 : [dst] "r"(dst), [src] "r"(src),
144 [SIGN] "m" (abs_vv_const)
145 : "cc", "memory",
146 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
147 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
148 "%xmm8", "%xmm9"
149 );
150 }
151
152 void x64_abs_rsub2(float *dst, const float *src, size_t count)
153 {
154 IF_ARCH_X86_64(size_t off);
155 ARCH_X86_64_ASM
156 (
157 ABS_V4_CORE("dst", "dst", "src", "vsub", OP_RSEL)
158 : [off] "=&r" (off), [count] "+r" (count)
159 : [dst] "r"(dst), [src] "r"(src),
160 [SIGN] "m" (abs_vv_const)
161 : "cc", "memory",
162 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
163 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
164 "%xmm8", "%xmm9"
165 );
166 }
167
168 void x64_abs_mul2(float *dst, const float *src, size_t count)
169 {
170 IF_ARCH_X86_64(size_t off);
171 ARCH_X86_64_ASM
172 (
173 ABS_V4_CORE("dst", "dst", "src", "vmul", OP_DSEL)
174 : [off] "=&r" (off), [count] "+r" (count)
175 : [dst] "r"(dst), [src] "r"(src),
176 [SIGN] "m" (abs_vv_const)
177 : "cc", "memory",
178 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
179 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
180 "%xmm8", "%xmm9"
181 );
182 }
183
184 void x64_abs_div2(float *dst, const float *src, size_t count)
185 {
186 IF_ARCH_X86_64(size_t off);
187 ARCH_X86_64_ASM
188 (
189 ABS_V4_CORE("dst", "dst", "src", "vdiv", OP_DSEL)
190 : [off] "=&r" (off), [count] "+r" (count)
191 : [dst] "r"(dst), [src] "r"(src),
192 [SIGN] "m" (abs_vv_const)
193 : "cc", "memory",
194 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
195 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
196 "%xmm8", "%xmm9"
197 );
198 }
199
200 void x64_abs_rdiv2(float *dst, const float *src, size_t count)
201 {
202 IF_ARCH_X86_64(size_t off);
203 ARCH_X86_64_ASM
204 (
205 ABS_V4_CORE("dst", "dst", "src", "vdiv", OP_RSEL)
206 : [off] "=&r" (off), [count] "+r" (count)
207 : [dst] "r"(dst), [src] "r"(src),
208 [SIGN] "m" (abs_vv_const)
209 : "cc", "memory",
210 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
211 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
212 "%xmm8", "%xmm9"
213 );
214 }
215
216 void x64_abs_max2(float *dst, const float *src, size_t count)
217 {
218 IF_ARCH_X86_64(size_t off);
219 ARCH_X86_64_ASM
220 (
221 ABS_V4_CORE("dst", "dst", "src", "vmax", OP_DSEL)
222 : [off] "=&r" (off), [count] "+r" (count)
223 : [dst] "r"(dst), [src] "r"(src),
224 [SIGN] "m" (abs_vv_const)
225 : "cc", "memory",
226 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
227 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
228 "%xmm8", "%xmm9"
229 );
230 }
231
232 void x64_abs_min2(float *dst, const float *src, size_t count)
233 {
234 IF_ARCH_X86_64(size_t off);
235 ARCH_X86_64_ASM
236 (
237 ABS_V4_CORE("dst", "dst", "src", "vmin", OP_DSEL)
238 : [off] "=&r" (off), [count] "+r" (count)
239 : [dst] "r"(dst), [src] "r"(src),
240 [SIGN] "m" (abs_vv_const)
241 : "cc", "memory",
242 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
243 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
244 "%xmm8", "%xmm9"
245 );
246 }
247
248 void x64_abs_add3(float *dst, const float *src1, const float *src2, size_t count)
249 {
250 IF_ARCH_X86_64(size_t off);
251 ARCH_X86_64_ASM
252 (
253 ABS_V4_CORE("dst", "src1", "src2", "vadd", OP_DSEL)
254 : [off] "=&r" (off), [count] "+r" (count)
255 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
256 [SIGN] "m" (abs_vv_const)
257 : "cc", "memory",
258 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
259 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
260 "%xmm8", "%xmm9"
261 );
262 }
263
264 void x64_abs_sub3(float *dst, const float *src1, const float *src2, size_t count)
265 {
266 IF_ARCH_X86_64(size_t off);
267 ARCH_X86_64_ASM
268 (
269 ABS_V4_CORE("dst", "src1", "src2", "vsub", OP_DSEL)
270 : [off] "=&r" (off), [count] "+r" (count)
271 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
272 [SIGN] "m" (abs_vv_const)
273 : "cc", "memory",
274 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
275 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
276 "%xmm8", "%xmm9"
277 );
278 }
279
280 void x64_abs_rsub3(float *dst, const float *src1, const float *src2, size_t count)
281 {
282 IF_ARCH_X86_64(size_t off);
283 ARCH_X86_64_ASM
284 (
285 ABS_V4_CORE("dst", "src1", "src2", "vsub", OP_RSEL)
286 : [off] "=&r" (off), [count] "+r" (count)
287 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
288 [SIGN] "m" (abs_vv_const)
289 : "cc", "memory",
290 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
291 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
292 "%xmm8", "%xmm9"
293 );
294 }
295
296 void x64_abs_mul3(float *dst, const float *src1, const float *src2, size_t count)
297 {
298 IF_ARCH_X86_64(size_t off);
299 ARCH_X86_64_ASM
300 (
301 ABS_V4_CORE("dst", "src1", "src2", "vmul", OP_DSEL)
302 : [off] "=&r" (off), [count] "+r" (count)
303 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
304 [SIGN] "m" (abs_vv_const)
305 : "cc", "memory",
306 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
307 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
308 "%xmm8", "%xmm9"
309 );
310 }
311
312 void x64_abs_div3(float *dst, const float *src1, const float *src2, size_t count)
313 {
314 IF_ARCH_X86_64(size_t off);
315 ARCH_X86_64_ASM
316 (
317 ABS_V4_CORE("dst", "src1", "src2", "vdiv", OP_DSEL)
318 : [off] "=&r" (off), [count] "+r" (count)
319 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
320 [SIGN] "m" (abs_vv_const)
321 : "cc", "memory",
322 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
323 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
324 "%xmm8", "%xmm9"
325 );
326 }
327
328 void x64_abs_rdiv3(float *dst, const float *src1, const float *src2, size_t count)
329 {
330 IF_ARCH_X86_64(size_t off);
331 ARCH_X86_64_ASM
332 (
333 ABS_V4_CORE("dst", "src1", "src2", "vdiv", OP_RSEL)
334 : [off] "=&r" (off), [count] "+r" (count)
335 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
336 [SIGN] "m" (abs_vv_const)
337 : "cc", "memory",
338 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
339 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
340 "%xmm8", "%xmm9"
341 );
342 }
343
344 void x64_abs_max3(float *dst, const float *src1, const float *src2, size_t count)
345 {
346 IF_ARCH_X86_64(size_t off);
347 ARCH_X86_64_ASM
348 (
349 ABS_V4_CORE("dst", "src1", "src2", "vmax", OP_DSEL)
350 : [off] "=&r" (off), [count] "+r" (count)
351 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
352 [SIGN] "m" (abs_vv_const)
353 : "cc", "memory",
354 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
355 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
356 "%xmm8", "%xmm9"
357 );
358 }
359
360 void x64_abs_min3(float *dst, const float *src1, const float *src2, size_t count)
361 {
362 IF_ARCH_X86_64(size_t off);
363 ARCH_X86_64_ASM
364 (
365 ABS_V4_CORE("dst", "src1", "src2", "vmin", OP_DSEL)
366 : [off] "=&r" (off), [count] "+r" (count)
367 : [dst] "r"(dst), [src1] "r" (src1), [src2] "r" (src2),
368 [SIGN] "m" (abs_vv_const)
369 : "cc", "memory",
370 "%xmm0", "%xmm1", "%xmm2", "%xmm3",
371 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
372 "%xmm8", "%xmm9"
373 );
374 }
375
376 #undef ABS_V4_CORE
377
378 #define ABS_CORE(DST, SRC) \
379 __ASM_EMIT("xor %[off], %[off]") \
380 __ASM_EMIT("vmovaps %[SIGN], %%ymm8") \
381 __ASM_EMIT("sub $64, %[count]") \
382 __ASM_EMIT("vmovaps %%ymm8, %%ymm9") \
383 __ASM_EMIT("jb 2f") \
384 /* 64x blocks */ \
385 __ASM_EMIT("1:") \
386 __ASM_EMIT("vandps 0x000(%[" SRC "], %[off]), %%ymm8, %%ymm0") \
387 __ASM_EMIT("vandps 0x020(%[" SRC "], %[off]), %%ymm9, %%ymm1") \
388 __ASM_EMIT("vandps 0x040(%[" SRC "], %[off]), %%ymm8, %%ymm2") \
389 __ASM_EMIT("vandps 0x060(%[" SRC "], %[off]), %%ymm9, %%ymm3") \
390 __ASM_EMIT("vandps 0x080(%[" SRC "], %[off]), %%ymm8, %%ymm4") \
391 __ASM_EMIT("vandps 0x0a0(%[" SRC "], %[off]), %%ymm9, %%ymm5") \
392 __ASM_EMIT("vandps 0x0c0(%[" SRC "], %[off]), %%ymm8, %%ymm6") \
393 __ASM_EMIT("vandps 0x0e0(%[" SRC "], %[off]), %%ymm9, %%ymm7") \
394 __ASM_EMIT("vmovups %%ymm0, 0x000(%[" DST "], %[off])") \
395 __ASM_EMIT("vmovups %%ymm1, 0x020(%[" DST "], %[off])") \
396 __ASM_EMIT("vmovups %%ymm2, 0x040(%[" DST "], %[off])") \
397 __ASM_EMIT("vmovups %%ymm3, 0x060(%[" DST "], %[off])") \
398 __ASM_EMIT("vmovups %%ymm4, 0x080(%[" DST "], %[off])") \
399 __ASM_EMIT("vmovups %%ymm5, 0x0a0(%[" DST "], %[off])") \
400 __ASM_EMIT("vmovups %%ymm6, 0x0c0(%[" DST "], %[off])") \
401 __ASM_EMIT("vmovups %%ymm7, 0x0e0(%[" DST "], %[off])") \
402 __ASM_EMIT("add $0x100, %[off]") \
403 __ASM_EMIT("sub $64, %[count]") \
404 __ASM_EMIT("jae 1b") \
405 /* 32x block */ \
406 __ASM_EMIT("2:") \
407 __ASM_EMIT("add $32, %[count]") \
408 __ASM_EMIT("jl 4f") \
409 __ASM_EMIT("vandps 0x000(%[" SRC "], %[off]), %%ymm8, %%ymm0") \
410 __ASM_EMIT("vandps 0x020(%[" SRC "], %[off]), %%ymm9, %%ymm1") \
411 __ASM_EMIT("vandps 0x040(%[" SRC "], %[off]), %%ymm8, %%ymm2") \
412 __ASM_EMIT("vandps 0x060(%[" SRC "], %[off]), %%ymm9, %%ymm3") \
413 __ASM_EMIT("vmovups %%ymm0, 0x000(%[" DST "], %[off])") \
414 __ASM_EMIT("vmovups %%ymm1, 0x020(%[" DST "], %[off])") \
415 __ASM_EMIT("vmovups %%ymm2, 0x040(%[" DST "], %[off])") \
416 __ASM_EMIT("vmovups %%ymm3, 0x060(%[" DST "], %[off])") \
417 __ASM_EMIT("sub $32, %[count]") \
418 __ASM_EMIT("add $0x80, %[off]") \
419 /* 16x block */ \
420 __ASM_EMIT("4:") \
421 __ASM_EMIT("add $16, %[count]") \
422 __ASM_EMIT("jl 6f") \
423 __ASM_EMIT("vandps 0x000(%[" SRC "], %[off]), %%ymm8, %%ymm0") \
424 __ASM_EMIT("vandps 0x020(%[" SRC "], %[off]), %%ymm9, %%ymm1") \
425 __ASM_EMIT("vmovups %%ymm0, 0x000(%[" DST "], %[off])") \
426 __ASM_EMIT("vmovups %%ymm1, 0x020(%[" DST "], %[off])") \
427 __ASM_EMIT("sub $16, %[count]") \
428 __ASM_EMIT("add $0x40, %[off]") \
429 /* 8x block */ \
430 __ASM_EMIT("6:") \
431 __ASM_EMIT("add $8, %[count]") \
432 __ASM_EMIT("jl 8f") \
433 __ASM_EMIT("vandps 0x000(%[" SRC "], %[off]), %%ymm8, %%ymm0") \
434 __ASM_EMIT("vmovups %%ymm0, 0x000(%[" DST "], %[off])") \
435 __ASM_EMIT("sub $8, %[count]") \
436 __ASM_EMIT("add $0x20, %[off]") \
437 /* 4x block */ \
438 __ASM_EMIT("8:") \
439 __ASM_EMIT("add $4, %[count]") \
440 __ASM_EMIT("jl 10f") \
441 __ASM_EMIT("vandps 0x000(%[" SRC "], %[off]), %%xmm8, %%xmm0") \
442 __ASM_EMIT("vmovups %%xmm0, 0x000(%[" DST "], %[off])") \
443 __ASM_EMIT("sub $4, %[count]") \
444 __ASM_EMIT("add $0x10, %[off]") \
445 /* 1x block */ \
446 __ASM_EMIT("10:") \
447 __ASM_EMIT("add $3, %[count]") \
448 __ASM_EMIT("jl 12f") \
449 __ASM_EMIT("11:") \
450 __ASM_EMIT("vmovss 0x00(%[" SRC "], %[off]), %%xmm0") \
451 __ASM_EMIT("vandps %%xmm0, %%xmm8, %%xmm0") \
452 __ASM_EMIT("vmovss %%xmm0, 0x00(%[" DST "], %[off])") \
453 __ASM_EMIT("add $0x04, %[off]") \
454 __ASM_EMIT("dec %[count]") \
455 __ASM_EMIT("jge 11b") \
456 __ASM_EMIT("12:")
457
458 void x64_abs1(float *dst, size_t count)
459 {
460 IF_ARCH_X86_64(size_t off);
461 ARCH_X86_64_ASM
462 (
463 ABS_CORE("dst", "dst")
464 : [off] "=&r" (off), [count] "+r" (count)
465 : [dst] "r" (dst),
466 [SIGN] "m" (abs_vv_const)
467 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
468 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
469 "%xmm8", "%xmm9"
470 );
471 }
472
473 void x64_abs2(float *dst, const float *src, size_t count)
474 {
475 IF_ARCH_X86_64(size_t off);
476 ARCH_X86_64_ASM
477 (
478 ABS_CORE("dst", "src")
479 : [off] "=&r" (off), [count] "+r" (count)
480 : [dst] "r" (dst), [src] "r" (src),
481 [SIGN] "m" (abs_vv_const)
482 : "%xmm0", "%xmm1", "%xmm2", "%xmm3",
483 "%xmm4", "%xmm5", "%xmm6", "%xmm7",
484 "%xmm8", "%xmm9"
485 );
486 }
487
488 #undef ABS_CORE
489
490 #undef OP_DSEL
491 #undef OP_RSEL
492 } /* namespace avx */
493 } /* namespace lsp */
494
495 #endif /* PRIVATE_DSP_ARCH_X86_AVX_PMATH_ABS_VV_H_ */