monitor/qmp: Update comment for commit 4eaca8de268
[qemu/armbru.git] / accel / tcg / tcg-runtime-gvec.c
blob51cb29ca791a560210f0c9b1f223b7662765c490
1 /*
2 * Generic vectorized operation runtime
4 * Copyright (c) 2018 Linaro
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "qemu/host-utils.h"
22 #include "cpu.h"
23 #include "exec/helper-proto.h"
24 #include "tcg-gvec-desc.h"
27 /* Virtually all hosts support 16-byte vectors. Those that don't can emulate
28 * them via GCC's generic vector extension. This turns out to be simpler and
29 * more reliable than getting the compiler to autovectorize.
31 * In tcg-op-gvec.c, we asserted that both the size and alignment of the data
32 * are multiples of 16.
34 * When the compiler does not support all of the operations we require, the
35 * loops are written so that we can always fall back on the base types.
37 #ifdef CONFIG_VECTOR16
38 typedef uint8_t vec8 __attribute__((vector_size(16)));
39 typedef uint16_t vec16 __attribute__((vector_size(16)));
40 typedef uint32_t vec32 __attribute__((vector_size(16)));
41 typedef uint64_t vec64 __attribute__((vector_size(16)));
43 typedef int8_t svec8 __attribute__((vector_size(16)));
44 typedef int16_t svec16 __attribute__((vector_size(16)));
45 typedef int32_t svec32 __attribute__((vector_size(16)));
46 typedef int64_t svec64 __attribute__((vector_size(16)));
48 #define DUP16(X) { X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X }
49 #define DUP8(X) { X, X, X, X, X, X, X, X }
50 #define DUP4(X) { X, X, X, X }
51 #define DUP2(X) { X, X }
52 #else
53 typedef uint8_t vec8;
54 typedef uint16_t vec16;
55 typedef uint32_t vec32;
56 typedef uint64_t vec64;
58 typedef int8_t svec8;
59 typedef int16_t svec16;
60 typedef int32_t svec32;
61 typedef int64_t svec64;
63 #define DUP16(X) X
64 #define DUP8(X) X
65 #define DUP4(X) X
66 #define DUP2(X) X
67 #endif /* CONFIG_VECTOR16 */
69 static inline void clear_high(void *d, intptr_t oprsz, uint32_t desc)
71 intptr_t maxsz = simd_maxsz(desc);
72 intptr_t i;
74 if (unlikely(maxsz > oprsz)) {
75 for (i = oprsz; i < maxsz; i += sizeof(uint64_t)) {
76 *(uint64_t *)(d + i) = 0;
81 void HELPER(gvec_add8)(void *d, void *a, void *b, uint32_t desc)
83 intptr_t oprsz = simd_oprsz(desc);
84 intptr_t i;
86 for (i = 0; i < oprsz; i += sizeof(vec8)) {
87 *(vec8 *)(d + i) = *(vec8 *)(a + i) + *(vec8 *)(b + i);
89 clear_high(d, oprsz, desc);
92 void HELPER(gvec_add16)(void *d, void *a, void *b, uint32_t desc)
94 intptr_t oprsz = simd_oprsz(desc);
95 intptr_t i;
97 for (i = 0; i < oprsz; i += sizeof(vec16)) {
98 *(vec16 *)(d + i) = *(vec16 *)(a + i) + *(vec16 *)(b + i);
100 clear_high(d, oprsz, desc);
103 void HELPER(gvec_add32)(void *d, void *a, void *b, uint32_t desc)
105 intptr_t oprsz = simd_oprsz(desc);
106 intptr_t i;
108 for (i = 0; i < oprsz; i += sizeof(vec32)) {
109 *(vec32 *)(d + i) = *(vec32 *)(a + i) + *(vec32 *)(b + i);
111 clear_high(d, oprsz, desc);
114 void HELPER(gvec_add64)(void *d, void *a, void *b, uint32_t desc)
116 intptr_t oprsz = simd_oprsz(desc);
117 intptr_t i;
119 for (i = 0; i < oprsz; i += sizeof(vec64)) {
120 *(vec64 *)(d + i) = *(vec64 *)(a + i) + *(vec64 *)(b + i);
122 clear_high(d, oprsz, desc);
125 void HELPER(gvec_adds8)(void *d, void *a, uint64_t b, uint32_t desc)
127 intptr_t oprsz = simd_oprsz(desc);
128 vec8 vecb = (vec8)DUP16(b);
129 intptr_t i;
131 for (i = 0; i < oprsz; i += sizeof(vec8)) {
132 *(vec8 *)(d + i) = *(vec8 *)(a + i) + vecb;
134 clear_high(d, oprsz, desc);
137 void HELPER(gvec_adds16)(void *d, void *a, uint64_t b, uint32_t desc)
139 intptr_t oprsz = simd_oprsz(desc);
140 vec16 vecb = (vec16)DUP8(b);
141 intptr_t i;
143 for (i = 0; i < oprsz; i += sizeof(vec16)) {
144 *(vec16 *)(d + i) = *(vec16 *)(a + i) + vecb;
146 clear_high(d, oprsz, desc);
149 void HELPER(gvec_adds32)(void *d, void *a, uint64_t b, uint32_t desc)
151 intptr_t oprsz = simd_oprsz(desc);
152 vec32 vecb = (vec32)DUP4(b);
153 intptr_t i;
155 for (i = 0; i < oprsz; i += sizeof(vec32)) {
156 *(vec32 *)(d + i) = *(vec32 *)(a + i) + vecb;
158 clear_high(d, oprsz, desc);
161 void HELPER(gvec_adds64)(void *d, void *a, uint64_t b, uint32_t desc)
163 intptr_t oprsz = simd_oprsz(desc);
164 vec64 vecb = (vec64)DUP2(b);
165 intptr_t i;
167 for (i = 0; i < oprsz; i += sizeof(vec64)) {
168 *(vec64 *)(d + i) = *(vec64 *)(a + i) + vecb;
170 clear_high(d, oprsz, desc);
173 void HELPER(gvec_sub8)(void *d, void *a, void *b, uint32_t desc)
175 intptr_t oprsz = simd_oprsz(desc);
176 intptr_t i;
178 for (i = 0; i < oprsz; i += sizeof(vec8)) {
179 *(vec8 *)(d + i) = *(vec8 *)(a + i) - *(vec8 *)(b + i);
181 clear_high(d, oprsz, desc);
184 void HELPER(gvec_sub16)(void *d, void *a, void *b, uint32_t desc)
186 intptr_t oprsz = simd_oprsz(desc);
187 intptr_t i;
189 for (i = 0; i < oprsz; i += sizeof(vec16)) {
190 *(vec16 *)(d + i) = *(vec16 *)(a + i) - *(vec16 *)(b + i);
192 clear_high(d, oprsz, desc);
195 void HELPER(gvec_sub32)(void *d, void *a, void *b, uint32_t desc)
197 intptr_t oprsz = simd_oprsz(desc);
198 intptr_t i;
200 for (i = 0; i < oprsz; i += sizeof(vec32)) {
201 *(vec32 *)(d + i) = *(vec32 *)(a + i) - *(vec32 *)(b + i);
203 clear_high(d, oprsz, desc);
206 void HELPER(gvec_sub64)(void *d, void *a, void *b, uint32_t desc)
208 intptr_t oprsz = simd_oprsz(desc);
209 intptr_t i;
211 for (i = 0; i < oprsz; i += sizeof(vec64)) {
212 *(vec64 *)(d + i) = *(vec64 *)(a + i) - *(vec64 *)(b + i);
214 clear_high(d, oprsz, desc);
217 void HELPER(gvec_subs8)(void *d, void *a, uint64_t b, uint32_t desc)
219 intptr_t oprsz = simd_oprsz(desc);
220 vec8 vecb = (vec8)DUP16(b);
221 intptr_t i;
223 for (i = 0; i < oprsz; i += sizeof(vec8)) {
224 *(vec8 *)(d + i) = *(vec8 *)(a + i) - vecb;
226 clear_high(d, oprsz, desc);
229 void HELPER(gvec_subs16)(void *d, void *a, uint64_t b, uint32_t desc)
231 intptr_t oprsz = simd_oprsz(desc);
232 vec16 vecb = (vec16)DUP8(b);
233 intptr_t i;
235 for (i = 0; i < oprsz; i += sizeof(vec16)) {
236 *(vec16 *)(d + i) = *(vec16 *)(a + i) - vecb;
238 clear_high(d, oprsz, desc);
241 void HELPER(gvec_subs32)(void *d, void *a, uint64_t b, uint32_t desc)
243 intptr_t oprsz = simd_oprsz(desc);
244 vec32 vecb = (vec32)DUP4(b);
245 intptr_t i;
247 for (i = 0; i < oprsz; i += sizeof(vec32)) {
248 *(vec32 *)(d + i) = *(vec32 *)(a + i) - vecb;
250 clear_high(d, oprsz, desc);
253 void HELPER(gvec_subs64)(void *d, void *a, uint64_t b, uint32_t desc)
255 intptr_t oprsz = simd_oprsz(desc);
256 vec64 vecb = (vec64)DUP2(b);
257 intptr_t i;
259 for (i = 0; i < oprsz; i += sizeof(vec64)) {
260 *(vec64 *)(d + i) = *(vec64 *)(a + i) - vecb;
262 clear_high(d, oprsz, desc);
265 void HELPER(gvec_mul8)(void *d, void *a, void *b, uint32_t desc)
267 intptr_t oprsz = simd_oprsz(desc);
268 intptr_t i;
270 for (i = 0; i < oprsz; i += sizeof(vec8)) {
271 *(vec8 *)(d + i) = *(vec8 *)(a + i) * *(vec8 *)(b + i);
273 clear_high(d, oprsz, desc);
276 void HELPER(gvec_mul16)(void *d, void *a, void *b, uint32_t desc)
278 intptr_t oprsz = simd_oprsz(desc);
279 intptr_t i;
281 for (i = 0; i < oprsz; i += sizeof(vec16)) {
282 *(vec16 *)(d + i) = *(vec16 *)(a + i) * *(vec16 *)(b + i);
284 clear_high(d, oprsz, desc);
287 void HELPER(gvec_mul32)(void *d, void *a, void *b, uint32_t desc)
289 intptr_t oprsz = simd_oprsz(desc);
290 intptr_t i;
292 for (i = 0; i < oprsz; i += sizeof(vec32)) {
293 *(vec32 *)(d + i) = *(vec32 *)(a + i) * *(vec32 *)(b + i);
295 clear_high(d, oprsz, desc);
298 void HELPER(gvec_mul64)(void *d, void *a, void *b, uint32_t desc)
300 intptr_t oprsz = simd_oprsz(desc);
301 intptr_t i;
303 for (i = 0; i < oprsz; i += sizeof(vec64)) {
304 *(vec64 *)(d + i) = *(vec64 *)(a + i) * *(vec64 *)(b + i);
306 clear_high(d, oprsz, desc);
309 void HELPER(gvec_muls8)(void *d, void *a, uint64_t b, uint32_t desc)
311 intptr_t oprsz = simd_oprsz(desc);
312 vec8 vecb = (vec8)DUP16(b);
313 intptr_t i;
315 for (i = 0; i < oprsz; i += sizeof(vec8)) {
316 *(vec8 *)(d + i) = *(vec8 *)(a + i) * vecb;
318 clear_high(d, oprsz, desc);
321 void HELPER(gvec_muls16)(void *d, void *a, uint64_t b, uint32_t desc)
323 intptr_t oprsz = simd_oprsz(desc);
324 vec16 vecb = (vec16)DUP8(b);
325 intptr_t i;
327 for (i = 0; i < oprsz; i += sizeof(vec16)) {
328 *(vec16 *)(d + i) = *(vec16 *)(a + i) * vecb;
330 clear_high(d, oprsz, desc);
333 void HELPER(gvec_muls32)(void *d, void *a, uint64_t b, uint32_t desc)
335 intptr_t oprsz = simd_oprsz(desc);
336 vec32 vecb = (vec32)DUP4(b);
337 intptr_t i;
339 for (i = 0; i < oprsz; i += sizeof(vec32)) {
340 *(vec32 *)(d + i) = *(vec32 *)(a + i) * vecb;
342 clear_high(d, oprsz, desc);
345 void HELPER(gvec_muls64)(void *d, void *a, uint64_t b, uint32_t desc)
347 intptr_t oprsz = simd_oprsz(desc);
348 vec64 vecb = (vec64)DUP2(b);
349 intptr_t i;
351 for (i = 0; i < oprsz; i += sizeof(vec64)) {
352 *(vec64 *)(d + i) = *(vec64 *)(a + i) * vecb;
354 clear_high(d, oprsz, desc);
357 void HELPER(gvec_neg8)(void *d, void *a, uint32_t desc)
359 intptr_t oprsz = simd_oprsz(desc);
360 intptr_t i;
362 for (i = 0; i < oprsz; i += sizeof(vec8)) {
363 *(vec8 *)(d + i) = -*(vec8 *)(a + i);
365 clear_high(d, oprsz, desc);
368 void HELPER(gvec_neg16)(void *d, void *a, uint32_t desc)
370 intptr_t oprsz = simd_oprsz(desc);
371 intptr_t i;
373 for (i = 0; i < oprsz; i += sizeof(vec16)) {
374 *(vec16 *)(d + i) = -*(vec16 *)(a + i);
376 clear_high(d, oprsz, desc);
379 void HELPER(gvec_neg32)(void *d, void *a, uint32_t desc)
381 intptr_t oprsz = simd_oprsz(desc);
382 intptr_t i;
384 for (i = 0; i < oprsz; i += sizeof(vec32)) {
385 *(vec32 *)(d + i) = -*(vec32 *)(a + i);
387 clear_high(d, oprsz, desc);
390 void HELPER(gvec_neg64)(void *d, void *a, uint32_t desc)
392 intptr_t oprsz = simd_oprsz(desc);
393 intptr_t i;
395 for (i = 0; i < oprsz; i += sizeof(vec64)) {
396 *(vec64 *)(d + i) = -*(vec64 *)(a + i);
398 clear_high(d, oprsz, desc);
401 void HELPER(gvec_abs8)(void *d, void *a, uint32_t desc)
403 intptr_t oprsz = simd_oprsz(desc);
404 intptr_t i;
406 for (i = 0; i < oprsz; i += sizeof(int8_t)) {
407 int8_t aa = *(int8_t *)(a + i);
408 *(int8_t *)(d + i) = aa < 0 ? -aa : aa;
410 clear_high(d, oprsz, desc);
413 void HELPER(gvec_abs16)(void *d, void *a, uint32_t desc)
415 intptr_t oprsz = simd_oprsz(desc);
416 intptr_t i;
418 for (i = 0; i < oprsz; i += sizeof(int16_t)) {
419 int16_t aa = *(int16_t *)(a + i);
420 *(int16_t *)(d + i) = aa < 0 ? -aa : aa;
422 clear_high(d, oprsz, desc);
425 void HELPER(gvec_abs32)(void *d, void *a, uint32_t desc)
427 intptr_t oprsz = simd_oprsz(desc);
428 intptr_t i;
430 for (i = 0; i < oprsz; i += sizeof(int32_t)) {
431 int32_t aa = *(int32_t *)(a + i);
432 *(int32_t *)(d + i) = aa < 0 ? -aa : aa;
434 clear_high(d, oprsz, desc);
437 void HELPER(gvec_abs64)(void *d, void *a, uint32_t desc)
439 intptr_t oprsz = simd_oprsz(desc);
440 intptr_t i;
442 for (i = 0; i < oprsz; i += sizeof(int64_t)) {
443 int64_t aa = *(int64_t *)(a + i);
444 *(int64_t *)(d + i) = aa < 0 ? -aa : aa;
446 clear_high(d, oprsz, desc);
449 void HELPER(gvec_mov)(void *d, void *a, uint32_t desc)
451 intptr_t oprsz = simd_oprsz(desc);
453 memcpy(d, a, oprsz);
454 clear_high(d, oprsz, desc);
457 void HELPER(gvec_dup64)(void *d, uint32_t desc, uint64_t c)
459 intptr_t oprsz = simd_oprsz(desc);
460 intptr_t i;
462 if (c == 0) {
463 oprsz = 0;
464 } else {
465 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
466 *(uint64_t *)(d + i) = c;
469 clear_high(d, oprsz, desc);
472 void HELPER(gvec_dup32)(void *d, uint32_t desc, uint32_t c)
474 intptr_t oprsz = simd_oprsz(desc);
475 intptr_t i;
477 if (c == 0) {
478 oprsz = 0;
479 } else {
480 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
481 *(uint32_t *)(d + i) = c;
484 clear_high(d, oprsz, desc);
487 void HELPER(gvec_dup16)(void *d, uint32_t desc, uint32_t c)
489 HELPER(gvec_dup32)(d, desc, 0x00010001 * (c & 0xffff));
492 void HELPER(gvec_dup8)(void *d, uint32_t desc, uint32_t c)
494 HELPER(gvec_dup32)(d, desc, 0x01010101 * (c & 0xff));
497 void HELPER(gvec_not)(void *d, void *a, uint32_t desc)
499 intptr_t oprsz = simd_oprsz(desc);
500 intptr_t i;
502 for (i = 0; i < oprsz; i += sizeof(vec64)) {
503 *(vec64 *)(d + i) = ~*(vec64 *)(a + i);
505 clear_high(d, oprsz, desc);
508 void HELPER(gvec_and)(void *d, void *a, void *b, uint32_t desc)
510 intptr_t oprsz = simd_oprsz(desc);
511 intptr_t i;
513 for (i = 0; i < oprsz; i += sizeof(vec64)) {
514 *(vec64 *)(d + i) = *(vec64 *)(a + i) & *(vec64 *)(b + i);
516 clear_high(d, oprsz, desc);
519 void HELPER(gvec_or)(void *d, void *a, void *b, uint32_t desc)
521 intptr_t oprsz = simd_oprsz(desc);
522 intptr_t i;
524 for (i = 0; i < oprsz; i += sizeof(vec64)) {
525 *(vec64 *)(d + i) = *(vec64 *)(a + i) | *(vec64 *)(b + i);
527 clear_high(d, oprsz, desc);
530 void HELPER(gvec_xor)(void *d, void *a, void *b, uint32_t desc)
532 intptr_t oprsz = simd_oprsz(desc);
533 intptr_t i;
535 for (i = 0; i < oprsz; i += sizeof(vec64)) {
536 *(vec64 *)(d + i) = *(vec64 *)(a + i) ^ *(vec64 *)(b + i);
538 clear_high(d, oprsz, desc);
541 void HELPER(gvec_andc)(void *d, void *a, void *b, uint32_t desc)
543 intptr_t oprsz = simd_oprsz(desc);
544 intptr_t i;
546 for (i = 0; i < oprsz; i += sizeof(vec64)) {
547 *(vec64 *)(d + i) = *(vec64 *)(a + i) &~ *(vec64 *)(b + i);
549 clear_high(d, oprsz, desc);
552 void HELPER(gvec_orc)(void *d, void *a, void *b, uint32_t desc)
554 intptr_t oprsz = simd_oprsz(desc);
555 intptr_t i;
557 for (i = 0; i < oprsz; i += sizeof(vec64)) {
558 *(vec64 *)(d + i) = *(vec64 *)(a + i) |~ *(vec64 *)(b + i);
560 clear_high(d, oprsz, desc);
563 void HELPER(gvec_nand)(void *d, void *a, void *b, uint32_t desc)
565 intptr_t oprsz = simd_oprsz(desc);
566 intptr_t i;
568 for (i = 0; i < oprsz; i += sizeof(vec64)) {
569 *(vec64 *)(d + i) = ~(*(vec64 *)(a + i) & *(vec64 *)(b + i));
571 clear_high(d, oprsz, desc);
574 void HELPER(gvec_nor)(void *d, void *a, void *b, uint32_t desc)
576 intptr_t oprsz = simd_oprsz(desc);
577 intptr_t i;
579 for (i = 0; i < oprsz; i += sizeof(vec64)) {
580 *(vec64 *)(d + i) = ~(*(vec64 *)(a + i) | *(vec64 *)(b + i));
582 clear_high(d, oprsz, desc);
585 void HELPER(gvec_eqv)(void *d, void *a, void *b, uint32_t desc)
587 intptr_t oprsz = simd_oprsz(desc);
588 intptr_t i;
590 for (i = 0; i < oprsz; i += sizeof(vec64)) {
591 *(vec64 *)(d + i) = ~(*(vec64 *)(a + i) ^ *(vec64 *)(b + i));
593 clear_high(d, oprsz, desc);
596 void HELPER(gvec_ands)(void *d, void *a, uint64_t b, uint32_t desc)
598 intptr_t oprsz = simd_oprsz(desc);
599 vec64 vecb = (vec64)DUP2(b);
600 intptr_t i;
602 for (i = 0; i < oprsz; i += sizeof(vec64)) {
603 *(vec64 *)(d + i) = *(vec64 *)(a + i) & vecb;
605 clear_high(d, oprsz, desc);
608 void HELPER(gvec_xors)(void *d, void *a, uint64_t b, uint32_t desc)
610 intptr_t oprsz = simd_oprsz(desc);
611 vec64 vecb = (vec64)DUP2(b);
612 intptr_t i;
614 for (i = 0; i < oprsz; i += sizeof(vec64)) {
615 *(vec64 *)(d + i) = *(vec64 *)(a + i) ^ vecb;
617 clear_high(d, oprsz, desc);
620 void HELPER(gvec_ors)(void *d, void *a, uint64_t b, uint32_t desc)
622 intptr_t oprsz = simd_oprsz(desc);
623 vec64 vecb = (vec64)DUP2(b);
624 intptr_t i;
626 for (i = 0; i < oprsz; i += sizeof(vec64)) {
627 *(vec64 *)(d + i) = *(vec64 *)(a + i) | vecb;
629 clear_high(d, oprsz, desc);
632 void HELPER(gvec_shl8i)(void *d, void *a, uint32_t desc)
634 intptr_t oprsz = simd_oprsz(desc);
635 int shift = simd_data(desc);
636 intptr_t i;
638 for (i = 0; i < oprsz; i += sizeof(vec8)) {
639 *(vec8 *)(d + i) = *(vec8 *)(a + i) << shift;
641 clear_high(d, oprsz, desc);
644 void HELPER(gvec_shl16i)(void *d, void *a, uint32_t desc)
646 intptr_t oprsz = simd_oprsz(desc);
647 int shift = simd_data(desc);
648 intptr_t i;
650 for (i = 0; i < oprsz; i += sizeof(vec16)) {
651 *(vec16 *)(d + i) = *(vec16 *)(a + i) << shift;
653 clear_high(d, oprsz, desc);
656 void HELPER(gvec_shl32i)(void *d, void *a, uint32_t desc)
658 intptr_t oprsz = simd_oprsz(desc);
659 int shift = simd_data(desc);
660 intptr_t i;
662 for (i = 0; i < oprsz; i += sizeof(vec32)) {
663 *(vec32 *)(d + i) = *(vec32 *)(a + i) << shift;
665 clear_high(d, oprsz, desc);
668 void HELPER(gvec_shl64i)(void *d, void *a, uint32_t desc)
670 intptr_t oprsz = simd_oprsz(desc);
671 int shift = simd_data(desc);
672 intptr_t i;
674 for (i = 0; i < oprsz; i += sizeof(vec64)) {
675 *(vec64 *)(d + i) = *(vec64 *)(a + i) << shift;
677 clear_high(d, oprsz, desc);
680 void HELPER(gvec_shr8i)(void *d, void *a, uint32_t desc)
682 intptr_t oprsz = simd_oprsz(desc);
683 int shift = simd_data(desc);
684 intptr_t i;
686 for (i = 0; i < oprsz; i += sizeof(vec8)) {
687 *(vec8 *)(d + i) = *(vec8 *)(a + i) >> shift;
689 clear_high(d, oprsz, desc);
692 void HELPER(gvec_shr16i)(void *d, void *a, uint32_t desc)
694 intptr_t oprsz = simd_oprsz(desc);
695 int shift = simd_data(desc);
696 intptr_t i;
698 for (i = 0; i < oprsz; i += sizeof(vec16)) {
699 *(vec16 *)(d + i) = *(vec16 *)(a + i) >> shift;
701 clear_high(d, oprsz, desc);
704 void HELPER(gvec_shr32i)(void *d, void *a, uint32_t desc)
706 intptr_t oprsz = simd_oprsz(desc);
707 int shift = simd_data(desc);
708 intptr_t i;
710 for (i = 0; i < oprsz; i += sizeof(vec32)) {
711 *(vec32 *)(d + i) = *(vec32 *)(a + i) >> shift;
713 clear_high(d, oprsz, desc);
716 void HELPER(gvec_shr64i)(void *d, void *a, uint32_t desc)
718 intptr_t oprsz = simd_oprsz(desc);
719 int shift = simd_data(desc);
720 intptr_t i;
722 for (i = 0; i < oprsz; i += sizeof(vec64)) {
723 *(vec64 *)(d + i) = *(vec64 *)(a + i) >> shift;
725 clear_high(d, oprsz, desc);
728 void HELPER(gvec_sar8i)(void *d, void *a, uint32_t desc)
730 intptr_t oprsz = simd_oprsz(desc);
731 int shift = simd_data(desc);
732 intptr_t i;
734 for (i = 0; i < oprsz; i += sizeof(vec8)) {
735 *(svec8 *)(d + i) = *(svec8 *)(a + i) >> shift;
737 clear_high(d, oprsz, desc);
740 void HELPER(gvec_sar16i)(void *d, void *a, uint32_t desc)
742 intptr_t oprsz = simd_oprsz(desc);
743 int shift = simd_data(desc);
744 intptr_t i;
746 for (i = 0; i < oprsz; i += sizeof(vec16)) {
747 *(svec16 *)(d + i) = *(svec16 *)(a + i) >> shift;
749 clear_high(d, oprsz, desc);
752 void HELPER(gvec_sar32i)(void *d, void *a, uint32_t desc)
754 intptr_t oprsz = simd_oprsz(desc);
755 int shift = simd_data(desc);
756 intptr_t i;
758 for (i = 0; i < oprsz; i += sizeof(vec32)) {
759 *(svec32 *)(d + i) = *(svec32 *)(a + i) >> shift;
761 clear_high(d, oprsz, desc);
764 void HELPER(gvec_sar64i)(void *d, void *a, uint32_t desc)
766 intptr_t oprsz = simd_oprsz(desc);
767 int shift = simd_data(desc);
768 intptr_t i;
770 for (i = 0; i < oprsz; i += sizeof(vec64)) {
771 *(svec64 *)(d + i) = *(svec64 *)(a + i) >> shift;
773 clear_high(d, oprsz, desc);
776 void HELPER(gvec_shl8v)(void *d, void *a, void *b, uint32_t desc)
778 intptr_t oprsz = simd_oprsz(desc);
779 intptr_t i;
781 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
782 uint8_t sh = *(uint8_t *)(b + i) & 7;
783 *(uint8_t *)(d + i) = *(uint8_t *)(a + i) << sh;
785 clear_high(d, oprsz, desc);
788 void HELPER(gvec_shl16v)(void *d, void *a, void *b, uint32_t desc)
790 intptr_t oprsz = simd_oprsz(desc);
791 intptr_t i;
793 for (i = 0; i < oprsz; i += sizeof(uint16_t)) {
794 uint8_t sh = *(uint16_t *)(b + i) & 15;
795 *(uint16_t *)(d + i) = *(uint16_t *)(a + i) << sh;
797 clear_high(d, oprsz, desc);
800 void HELPER(gvec_shl32v)(void *d, void *a, void *b, uint32_t desc)
802 intptr_t oprsz = simd_oprsz(desc);
803 intptr_t i;
805 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
806 uint8_t sh = *(uint32_t *)(b + i) & 31;
807 *(uint32_t *)(d + i) = *(uint32_t *)(a + i) << sh;
809 clear_high(d, oprsz, desc);
812 void HELPER(gvec_shl64v)(void *d, void *a, void *b, uint32_t desc)
814 intptr_t oprsz = simd_oprsz(desc);
815 intptr_t i;
817 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
818 uint8_t sh = *(uint64_t *)(b + i) & 63;
819 *(uint64_t *)(d + i) = *(uint64_t *)(a + i) << sh;
821 clear_high(d, oprsz, desc);
824 void HELPER(gvec_shr8v)(void *d, void *a, void *b, uint32_t desc)
826 intptr_t oprsz = simd_oprsz(desc);
827 intptr_t i;
829 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
830 uint8_t sh = *(uint8_t *)(b + i) & 7;
831 *(uint8_t *)(d + i) = *(uint8_t *)(a + i) >> sh;
833 clear_high(d, oprsz, desc);
836 void HELPER(gvec_shr16v)(void *d, void *a, void *b, uint32_t desc)
838 intptr_t oprsz = simd_oprsz(desc);
839 intptr_t i;
841 for (i = 0; i < oprsz; i += sizeof(uint16_t)) {
842 uint8_t sh = *(uint16_t *)(b + i) & 15;
843 *(uint16_t *)(d + i) = *(uint16_t *)(a + i) >> sh;
845 clear_high(d, oprsz, desc);
848 void HELPER(gvec_shr32v)(void *d, void *a, void *b, uint32_t desc)
850 intptr_t oprsz = simd_oprsz(desc);
851 intptr_t i;
853 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
854 uint8_t sh = *(uint32_t *)(b + i) & 31;
855 *(uint32_t *)(d + i) = *(uint32_t *)(a + i) >> sh;
857 clear_high(d, oprsz, desc);
860 void HELPER(gvec_shr64v)(void *d, void *a, void *b, uint32_t desc)
862 intptr_t oprsz = simd_oprsz(desc);
863 intptr_t i;
865 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
866 uint8_t sh = *(uint64_t *)(b + i) & 63;
867 *(uint64_t *)(d + i) = *(uint64_t *)(a + i) >> sh;
869 clear_high(d, oprsz, desc);
872 void HELPER(gvec_sar8v)(void *d, void *a, void *b, uint32_t desc)
874 intptr_t oprsz = simd_oprsz(desc);
875 intptr_t i;
877 for (i = 0; i < oprsz; i += sizeof(int8_t)) {
878 uint8_t sh = *(uint8_t *)(b + i) & 7;
879 *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh;
881 clear_high(d, oprsz, desc);
884 void HELPER(gvec_sar16v)(void *d, void *a, void *b, uint32_t desc)
886 intptr_t oprsz = simd_oprsz(desc);
887 intptr_t i;
889 for (i = 0; i < oprsz; i += sizeof(int16_t)) {
890 uint8_t sh = *(uint16_t *)(b + i) & 15;
891 *(int16_t *)(d + i) = *(int16_t *)(a + i) >> sh;
893 clear_high(d, oprsz, desc);
896 void HELPER(gvec_sar32v)(void *d, void *a, void *b, uint32_t desc)
898 intptr_t oprsz = simd_oprsz(desc);
899 intptr_t i;
901 for (i = 0; i < oprsz; i += sizeof(int32_t)) {
902 uint8_t sh = *(uint32_t *)(b + i) & 31;
903 *(int32_t *)(d + i) = *(int32_t *)(a + i) >> sh;
905 clear_high(d, oprsz, desc);
908 void HELPER(gvec_sar64v)(void *d, void *a, void *b, uint32_t desc)
910 intptr_t oprsz = simd_oprsz(desc);
911 intptr_t i;
913 for (i = 0; i < oprsz; i += sizeof(int64_t)) {
914 uint8_t sh = *(uint64_t *)(b + i) & 63;
915 *(int64_t *)(d + i) = *(int64_t *)(a + i) >> sh;
917 clear_high(d, oprsz, desc);
920 /* If vectors are enabled, the compiler fills in -1 for true.
921 Otherwise, we must take care of this by hand. */
922 #ifdef CONFIG_VECTOR16
923 # define DO_CMP0(X) X
924 #else
925 # define DO_CMP0(X) -(X)
926 #endif
928 #define DO_CMP1(NAME, TYPE, OP) \
929 void HELPER(NAME)(void *d, void *a, void *b, uint32_t desc) \
931 intptr_t oprsz = simd_oprsz(desc); \
932 intptr_t i; \
933 for (i = 0; i < oprsz; i += sizeof(TYPE)) { \
934 *(TYPE *)(d + i) = DO_CMP0(*(TYPE *)(a + i) OP *(TYPE *)(b + i)); \
936 clear_high(d, oprsz, desc); \
939 #define DO_CMP2(SZ) \
940 DO_CMP1(gvec_eq##SZ, vec##SZ, ==) \
941 DO_CMP1(gvec_ne##SZ, vec##SZ, !=) \
942 DO_CMP1(gvec_lt##SZ, svec##SZ, <) \
943 DO_CMP1(gvec_le##SZ, svec##SZ, <=) \
944 DO_CMP1(gvec_ltu##SZ, vec##SZ, <) \
945 DO_CMP1(gvec_leu##SZ, vec##SZ, <=)
947 DO_CMP2(8)
948 DO_CMP2(16)
949 DO_CMP2(32)
950 DO_CMP2(64)
952 #undef DO_CMP0
953 #undef DO_CMP1
954 #undef DO_CMP2
956 void HELPER(gvec_ssadd8)(void *d, void *a, void *b, uint32_t desc)
958 intptr_t oprsz = simd_oprsz(desc);
959 intptr_t i;
961 for (i = 0; i < oprsz; i += sizeof(int8_t)) {
962 int r = *(int8_t *)(a + i) + *(int8_t *)(b + i);
963 if (r > INT8_MAX) {
964 r = INT8_MAX;
965 } else if (r < INT8_MIN) {
966 r = INT8_MIN;
968 *(int8_t *)(d + i) = r;
970 clear_high(d, oprsz, desc);
973 void HELPER(gvec_ssadd16)(void *d, void *a, void *b, uint32_t desc)
975 intptr_t oprsz = simd_oprsz(desc);
976 intptr_t i;
978 for (i = 0; i < oprsz; i += sizeof(int16_t)) {
979 int r = *(int16_t *)(a + i) + *(int16_t *)(b + i);
980 if (r > INT16_MAX) {
981 r = INT16_MAX;
982 } else if (r < INT16_MIN) {
983 r = INT16_MIN;
985 *(int16_t *)(d + i) = r;
987 clear_high(d, oprsz, desc);
990 void HELPER(gvec_ssadd32)(void *d, void *a, void *b, uint32_t desc)
992 intptr_t oprsz = simd_oprsz(desc);
993 intptr_t i;
995 for (i = 0; i < oprsz; i += sizeof(int32_t)) {
996 int32_t ai = *(int32_t *)(a + i);
997 int32_t bi = *(int32_t *)(b + i);
998 int32_t di = ai + bi;
999 if (((di ^ ai) &~ (ai ^ bi)) < 0) {
1000 /* Signed overflow. */
1001 di = (di < 0 ? INT32_MAX : INT32_MIN);
1003 *(int32_t *)(d + i) = di;
1005 clear_high(d, oprsz, desc);
1008 void HELPER(gvec_ssadd64)(void *d, void *a, void *b, uint32_t desc)
1010 intptr_t oprsz = simd_oprsz(desc);
1011 intptr_t i;
1013 for (i = 0; i < oprsz; i += sizeof(int64_t)) {
1014 int64_t ai = *(int64_t *)(a + i);
1015 int64_t bi = *(int64_t *)(b + i);
1016 int64_t di = ai + bi;
1017 if (((di ^ ai) &~ (ai ^ bi)) < 0) {
1018 /* Signed overflow. */
1019 di = (di < 0 ? INT64_MAX : INT64_MIN);
1021 *(int64_t *)(d + i) = di;
1023 clear_high(d, oprsz, desc);
1026 void HELPER(gvec_sssub8)(void *d, void *a, void *b, uint32_t desc)
1028 intptr_t oprsz = simd_oprsz(desc);
1029 intptr_t i;
1031 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
1032 int r = *(int8_t *)(a + i) - *(int8_t *)(b + i);
1033 if (r > INT8_MAX) {
1034 r = INT8_MAX;
1035 } else if (r < INT8_MIN) {
1036 r = INT8_MIN;
1038 *(uint8_t *)(d + i) = r;
1040 clear_high(d, oprsz, desc);
1043 void HELPER(gvec_sssub16)(void *d, void *a, void *b, uint32_t desc)
1045 intptr_t oprsz = simd_oprsz(desc);
1046 intptr_t i;
1048 for (i = 0; i < oprsz; i += sizeof(int16_t)) {
1049 int r = *(int16_t *)(a + i) - *(int16_t *)(b + i);
1050 if (r > INT16_MAX) {
1051 r = INT16_MAX;
1052 } else if (r < INT16_MIN) {
1053 r = INT16_MIN;
1055 *(int16_t *)(d + i) = r;
1057 clear_high(d, oprsz, desc);
1060 void HELPER(gvec_sssub32)(void *d, void *a, void *b, uint32_t desc)
1062 intptr_t oprsz = simd_oprsz(desc);
1063 intptr_t i;
1065 for (i = 0; i < oprsz; i += sizeof(int32_t)) {
1066 int32_t ai = *(int32_t *)(a + i);
1067 int32_t bi = *(int32_t *)(b + i);
1068 int32_t di = ai - bi;
1069 if (((di ^ ai) & (ai ^ bi)) < 0) {
1070 /* Signed overflow. */
1071 di = (di < 0 ? INT32_MAX : INT32_MIN);
1073 *(int32_t *)(d + i) = di;
1075 clear_high(d, oprsz, desc);
1078 void HELPER(gvec_sssub64)(void *d, void *a, void *b, uint32_t desc)
1080 intptr_t oprsz = simd_oprsz(desc);
1081 intptr_t i;
1083 for (i = 0; i < oprsz; i += sizeof(int64_t)) {
1084 int64_t ai = *(int64_t *)(a + i);
1085 int64_t bi = *(int64_t *)(b + i);
1086 int64_t di = ai - bi;
1087 if (((di ^ ai) & (ai ^ bi)) < 0) {
1088 /* Signed overflow. */
1089 di = (di < 0 ? INT64_MAX : INT64_MIN);
1091 *(int64_t *)(d + i) = di;
1093 clear_high(d, oprsz, desc);
1096 void HELPER(gvec_usadd8)(void *d, void *a, void *b, uint32_t desc)
1098 intptr_t oprsz = simd_oprsz(desc);
1099 intptr_t i;
1101 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
1102 unsigned r = *(uint8_t *)(a + i) + *(uint8_t *)(b + i);
1103 if (r > UINT8_MAX) {
1104 r = UINT8_MAX;
1106 *(uint8_t *)(d + i) = r;
1108 clear_high(d, oprsz, desc);
1111 void HELPER(gvec_usadd16)(void *d, void *a, void *b, uint32_t desc)
1113 intptr_t oprsz = simd_oprsz(desc);
1114 intptr_t i;
1116 for (i = 0; i < oprsz; i += sizeof(uint16_t)) {
1117 unsigned r = *(uint16_t *)(a + i) + *(uint16_t *)(b + i);
1118 if (r > UINT16_MAX) {
1119 r = UINT16_MAX;
1121 *(uint16_t *)(d + i) = r;
1123 clear_high(d, oprsz, desc);
1126 void HELPER(gvec_usadd32)(void *d, void *a, void *b, uint32_t desc)
1128 intptr_t oprsz = simd_oprsz(desc);
1129 intptr_t i;
1131 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
1132 uint32_t ai = *(uint32_t *)(a + i);
1133 uint32_t bi = *(uint32_t *)(b + i);
1134 uint32_t di = ai + bi;
1135 if (di < ai) {
1136 di = UINT32_MAX;
1138 *(uint32_t *)(d + i) = di;
1140 clear_high(d, oprsz, desc);
1143 void HELPER(gvec_usadd64)(void *d, void *a, void *b, uint32_t desc)
1145 intptr_t oprsz = simd_oprsz(desc);
1146 intptr_t i;
1148 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
1149 uint64_t ai = *(uint64_t *)(a + i);
1150 uint64_t bi = *(uint64_t *)(b + i);
1151 uint64_t di = ai + bi;
1152 if (di < ai) {
1153 di = UINT64_MAX;
1155 *(uint64_t *)(d + i) = di;
1157 clear_high(d, oprsz, desc);
1160 void HELPER(gvec_ussub8)(void *d, void *a, void *b, uint32_t desc)
1162 intptr_t oprsz = simd_oprsz(desc);
1163 intptr_t i;
1165 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
1166 int r = *(uint8_t *)(a + i) - *(uint8_t *)(b + i);
1167 if (r < 0) {
1168 r = 0;
1170 *(uint8_t *)(d + i) = r;
1172 clear_high(d, oprsz, desc);
1175 void HELPER(gvec_ussub16)(void *d, void *a, void *b, uint32_t desc)
1177 intptr_t oprsz = simd_oprsz(desc);
1178 intptr_t i;
1180 for (i = 0; i < oprsz; i += sizeof(uint16_t)) {
1181 int r = *(uint16_t *)(a + i) - *(uint16_t *)(b + i);
1182 if (r < 0) {
1183 r = 0;
1185 *(uint16_t *)(d + i) = r;
1187 clear_high(d, oprsz, desc);
1190 void HELPER(gvec_ussub32)(void *d, void *a, void *b, uint32_t desc)
1192 intptr_t oprsz = simd_oprsz(desc);
1193 intptr_t i;
1195 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
1196 uint32_t ai = *(uint32_t *)(a + i);
1197 uint32_t bi = *(uint32_t *)(b + i);
1198 uint32_t di = ai - bi;
1199 if (ai < bi) {
1200 di = 0;
1202 *(uint32_t *)(d + i) = di;
1204 clear_high(d, oprsz, desc);
1207 void HELPER(gvec_ussub64)(void *d, void *a, void *b, uint32_t desc)
1209 intptr_t oprsz = simd_oprsz(desc);
1210 intptr_t i;
1212 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
1213 uint64_t ai = *(uint64_t *)(a + i);
1214 uint64_t bi = *(uint64_t *)(b + i);
1215 uint64_t di = ai - bi;
1216 if (ai < bi) {
1217 di = 0;
1219 *(uint64_t *)(d + i) = di;
1221 clear_high(d, oprsz, desc);
1224 void HELPER(gvec_smin8)(void *d, void *a, void *b, uint32_t desc)
1226 intptr_t oprsz = simd_oprsz(desc);
1227 intptr_t i;
1229 for (i = 0; i < oprsz; i += sizeof(int8_t)) {
1230 int8_t aa = *(int8_t *)(a + i);
1231 int8_t bb = *(int8_t *)(b + i);
1232 int8_t dd = aa < bb ? aa : bb;
1233 *(int8_t *)(d + i) = dd;
1235 clear_high(d, oprsz, desc);
1238 void HELPER(gvec_smin16)(void *d, void *a, void *b, uint32_t desc)
1240 intptr_t oprsz = simd_oprsz(desc);
1241 intptr_t i;
1243 for (i = 0; i < oprsz; i += sizeof(int16_t)) {
1244 int16_t aa = *(int16_t *)(a + i);
1245 int16_t bb = *(int16_t *)(b + i);
1246 int16_t dd = aa < bb ? aa : bb;
1247 *(int16_t *)(d + i) = dd;
1249 clear_high(d, oprsz, desc);
1252 void HELPER(gvec_smin32)(void *d, void *a, void *b, uint32_t desc)
1254 intptr_t oprsz = simd_oprsz(desc);
1255 intptr_t i;
1257 for (i = 0; i < oprsz; i += sizeof(int32_t)) {
1258 int32_t aa = *(int32_t *)(a + i);
1259 int32_t bb = *(int32_t *)(b + i);
1260 int32_t dd = aa < bb ? aa : bb;
1261 *(int32_t *)(d + i) = dd;
1263 clear_high(d, oprsz, desc);
1266 void HELPER(gvec_smin64)(void *d, void *a, void *b, uint32_t desc)
1268 intptr_t oprsz = simd_oprsz(desc);
1269 intptr_t i;
1271 for (i = 0; i < oprsz; i += sizeof(int64_t)) {
1272 int64_t aa = *(int64_t *)(a + i);
1273 int64_t bb = *(int64_t *)(b + i);
1274 int64_t dd = aa < bb ? aa : bb;
1275 *(int64_t *)(d + i) = dd;
1277 clear_high(d, oprsz, desc);
1280 void HELPER(gvec_smax8)(void *d, void *a, void *b, uint32_t desc)
1282 intptr_t oprsz = simd_oprsz(desc);
1283 intptr_t i;
1285 for (i = 0; i < oprsz; i += sizeof(int8_t)) {
1286 int8_t aa = *(int8_t *)(a + i);
1287 int8_t bb = *(int8_t *)(b + i);
1288 int8_t dd = aa > bb ? aa : bb;
1289 *(int8_t *)(d + i) = dd;
1291 clear_high(d, oprsz, desc);
1294 void HELPER(gvec_smax16)(void *d, void *a, void *b, uint32_t desc)
1296 intptr_t oprsz = simd_oprsz(desc);
1297 intptr_t i;
1299 for (i = 0; i < oprsz; i += sizeof(int16_t)) {
1300 int16_t aa = *(int16_t *)(a + i);
1301 int16_t bb = *(int16_t *)(b + i);
1302 int16_t dd = aa > bb ? aa : bb;
1303 *(int16_t *)(d + i) = dd;
1305 clear_high(d, oprsz, desc);
1308 void HELPER(gvec_smax32)(void *d, void *a, void *b, uint32_t desc)
1310 intptr_t oprsz = simd_oprsz(desc);
1311 intptr_t i;
1313 for (i = 0; i < oprsz; i += sizeof(int32_t)) {
1314 int32_t aa = *(int32_t *)(a + i);
1315 int32_t bb = *(int32_t *)(b + i);
1316 int32_t dd = aa > bb ? aa : bb;
1317 *(int32_t *)(d + i) = dd;
1319 clear_high(d, oprsz, desc);
1322 void HELPER(gvec_smax64)(void *d, void *a, void *b, uint32_t desc)
1324 intptr_t oprsz = simd_oprsz(desc);
1325 intptr_t i;
1327 for (i = 0; i < oprsz; i += sizeof(int64_t)) {
1328 int64_t aa = *(int64_t *)(a + i);
1329 int64_t bb = *(int64_t *)(b + i);
1330 int64_t dd = aa > bb ? aa : bb;
1331 *(int64_t *)(d + i) = dd;
1333 clear_high(d, oprsz, desc);
1336 void HELPER(gvec_umin8)(void *d, void *a, void *b, uint32_t desc)
1338 intptr_t oprsz = simd_oprsz(desc);
1339 intptr_t i;
1341 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
1342 uint8_t aa = *(uint8_t *)(a + i);
1343 uint8_t bb = *(uint8_t *)(b + i);
1344 uint8_t dd = aa < bb ? aa : bb;
1345 *(uint8_t *)(d + i) = dd;
1347 clear_high(d, oprsz, desc);
1350 void HELPER(gvec_umin16)(void *d, void *a, void *b, uint32_t desc)
1352 intptr_t oprsz = simd_oprsz(desc);
1353 intptr_t i;
1355 for (i = 0; i < oprsz; i += sizeof(uint16_t)) {
1356 uint16_t aa = *(uint16_t *)(a + i);
1357 uint16_t bb = *(uint16_t *)(b + i);
1358 uint16_t dd = aa < bb ? aa : bb;
1359 *(uint16_t *)(d + i) = dd;
1361 clear_high(d, oprsz, desc);
1364 void HELPER(gvec_umin32)(void *d, void *a, void *b, uint32_t desc)
1366 intptr_t oprsz = simd_oprsz(desc);
1367 intptr_t i;
1369 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
1370 uint32_t aa = *(uint32_t *)(a + i);
1371 uint32_t bb = *(uint32_t *)(b + i);
1372 uint32_t dd = aa < bb ? aa : bb;
1373 *(uint32_t *)(d + i) = dd;
1375 clear_high(d, oprsz, desc);
1378 void HELPER(gvec_umin64)(void *d, void *a, void *b, uint32_t desc)
1380 intptr_t oprsz = simd_oprsz(desc);
1381 intptr_t i;
1383 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
1384 uint64_t aa = *(uint64_t *)(a + i);
1385 uint64_t bb = *(uint64_t *)(b + i);
1386 uint64_t dd = aa < bb ? aa : bb;
1387 *(uint64_t *)(d + i) = dd;
1389 clear_high(d, oprsz, desc);
1392 void HELPER(gvec_umax8)(void *d, void *a, void *b, uint32_t desc)
1394 intptr_t oprsz = simd_oprsz(desc);
1395 intptr_t i;
1397 for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
1398 uint8_t aa = *(uint8_t *)(a + i);
1399 uint8_t bb = *(uint8_t *)(b + i);
1400 uint8_t dd = aa > bb ? aa : bb;
1401 *(uint8_t *)(d + i) = dd;
1403 clear_high(d, oprsz, desc);
1406 void HELPER(gvec_umax16)(void *d, void *a, void *b, uint32_t desc)
1408 intptr_t oprsz = simd_oprsz(desc);
1409 intptr_t i;
1411 for (i = 0; i < oprsz; i += sizeof(uint16_t)) {
1412 uint16_t aa = *(uint16_t *)(a + i);
1413 uint16_t bb = *(uint16_t *)(b + i);
1414 uint16_t dd = aa > bb ? aa : bb;
1415 *(uint16_t *)(d + i) = dd;
1417 clear_high(d, oprsz, desc);
1420 void HELPER(gvec_umax32)(void *d, void *a, void *b, uint32_t desc)
1422 intptr_t oprsz = simd_oprsz(desc);
1423 intptr_t i;
1425 for (i = 0; i < oprsz; i += sizeof(uint32_t)) {
1426 uint32_t aa = *(uint32_t *)(a + i);
1427 uint32_t bb = *(uint32_t *)(b + i);
1428 uint32_t dd = aa > bb ? aa : bb;
1429 *(uint32_t *)(d + i) = dd;
1431 clear_high(d, oprsz, desc);
1434 void HELPER(gvec_umax64)(void *d, void *a, void *b, uint32_t desc)
1436 intptr_t oprsz = simd_oprsz(desc);
1437 intptr_t i;
1439 for (i = 0; i < oprsz; i += sizeof(uint64_t)) {
1440 uint64_t aa = *(uint64_t *)(a + i);
1441 uint64_t bb = *(uint64_t *)(b + i);
1442 uint64_t dd = aa > bb ? aa : bb;
1443 *(uint64_t *)(d + i) = dd;
1445 clear_high(d, oprsz, desc);
1448 void HELPER(gvec_bitsel)(void *d, void *a, void *b, void *c, uint32_t desc)
1450 intptr_t oprsz = simd_oprsz(desc);
1451 intptr_t i;
1453 for (i = 0; i < oprsz; i += sizeof(vec64)) {
1454 vec64 aa = *(vec64 *)(a + i);
1455 vec64 bb = *(vec64 *)(b + i);
1456 vec64 cc = *(vec64 *)(c + i);
1457 *(vec64 *)(d + i) = (bb & aa) | (cc & ~aa);
1459 clear_high(d, oprsz, desc);