blob: fa9100a2639dba14b31b9fe9950ed2214be5dee6 [file] [log] [blame]
Logan Chien2833ffb2018-10-09 10:03:24 +08001/*===---- altivec.h - Standard header for type generic math ---------------===*\
2 *
Logan Chiendf4f7662019-09-04 16:45:23 -07003 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Logan Chien2833ffb2018-10-09 10:03:24 +08006 *
7\*===----------------------------------------------------------------------===*/
8
9#ifndef __ALTIVEC_H
10#define __ALTIVEC_H
11
12#ifndef __ALTIVEC__
13#error "AltiVec support not enabled"
14#endif
15
16/* Constants for mapping CR6 bits to predicate result. */
17
18#define __CR6_EQ 0
19#define __CR6_EQ_REV 1
20#define __CR6_LT 2
21#define __CR6_LT_REV 3
22
Logan Chien55afb0a2018-10-15 10:42:14 +080023/* Constants for vec_test_data_class */
24#define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0)
25#define __VEC_CLASS_FP_SUBNORMAL_P (1 << 1)
26#define __VEC_CLASS_FP_SUBNORMAL (__VEC_CLASS_FP_SUBNORMAL_P | \
27 __VEC_CLASS_FP_SUBNORMAL_N)
28#define __VEC_CLASS_FP_ZERO_N (1<<2)
29#define __VEC_CLASS_FP_ZERO_P (1<<3)
30#define __VEC_CLASS_FP_ZERO (__VEC_CLASS_FP_ZERO_P | \
31 __VEC_CLASS_FP_ZERO_N)
32#define __VEC_CLASS_FP_INFINITY_N (1<<4)
33#define __VEC_CLASS_FP_INFINITY_P (1<<5)
34#define __VEC_CLASS_FP_INFINITY (__VEC_CLASS_FP_INFINITY_P | \
35 __VEC_CLASS_FP_INFINITY_N)
36#define __VEC_CLASS_FP_NAN (1<<6)
37#define __VEC_CLASS_FP_NOT_NORMAL (__VEC_CLASS_FP_NAN | \
38 __VEC_CLASS_FP_SUBNORMAL | \
39 __VEC_CLASS_FP_ZERO | \
40 __VEC_CLASS_FP_INFINITY)
41
Logan Chien2833ffb2018-10-09 10:03:24 +080042#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
43
Logan Chien55afb0a2018-10-15 10:42:14 +080044#include <stddef.h>
Logan Chien55afb0a2018-10-15 10:42:14 +080045
Logan Chien2833ffb2018-10-09 10:03:24 +080046static __inline__ vector signed char __ATTRS_o_ai vec_perm(
47 vector signed char __a, vector signed char __b, vector unsigned char __c);
48
49static __inline__ vector unsigned char __ATTRS_o_ai
50vec_perm(vector unsigned char __a, vector unsigned char __b,
51 vector unsigned char __c);
52
53static __inline__ vector bool char __ATTRS_o_ai
54vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c);
55
56static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a,
57 vector signed short __b,
58 vector unsigned char __c);
59
60static __inline__ vector unsigned short __ATTRS_o_ai
61vec_perm(vector unsigned short __a, vector unsigned short __b,
62 vector unsigned char __c);
63
64static __inline__ vector bool short __ATTRS_o_ai vec_perm(
65 vector bool short __a, vector bool short __b, vector unsigned char __c);
66
67static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a,
68 vector pixel __b,
69 vector unsigned char __c);
70
71static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a,
72 vector signed int __b,
73 vector unsigned char __c);
74
75static __inline__ vector unsigned int __ATTRS_o_ai vec_perm(
76 vector unsigned int __a, vector unsigned int __b, vector unsigned char __c);
77
78static __inline__ vector bool int __ATTRS_o_ai
79vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c);
80
81static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a,
82 vector float __b,
83 vector unsigned char __c);
84
85#ifdef __VSX__
86static __inline__ vector long long __ATTRS_o_ai
87vec_perm(vector signed long long __a, vector signed long long __b,
88 vector unsigned char __c);
89
90static __inline__ vector unsigned long long __ATTRS_o_ai
91vec_perm(vector unsigned long long __a, vector unsigned long long __b,
92 vector unsigned char __c);
93
94static __inline__ vector bool long long __ATTRS_o_ai
95vec_perm(vector bool long long __a, vector bool long long __b,
96 vector unsigned char __c);
97
98static __inline__ vector double __ATTRS_o_ai vec_perm(vector double __a,
99 vector double __b,
100 vector unsigned char __c);
101#endif
102
103static __inline__ vector unsigned char __ATTRS_o_ai
104vec_xor(vector unsigned char __a, vector unsigned char __b);
105
106/* vec_abs */
107
108#define __builtin_altivec_abs_v16qi vec_abs
109#define __builtin_altivec_abs_v8hi vec_abs
110#define __builtin_altivec_abs_v4si vec_abs
111
112static __inline__ vector signed char __ATTRS_o_ai
113vec_abs(vector signed char __a) {
114 return __builtin_altivec_vmaxsb(__a, -__a);
115}
116
117static __inline__ vector signed short __ATTRS_o_ai
118vec_abs(vector signed short __a) {
119 return __builtin_altivec_vmaxsh(__a, -__a);
120}
121
122static __inline__ vector signed int __ATTRS_o_ai
123vec_abs(vector signed int __a) {
124 return __builtin_altivec_vmaxsw(__a, -__a);
125}
126
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800127#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800128static __inline__ vector signed long long __ATTRS_o_ai
129vec_abs(vector signed long long __a) {
130 return __builtin_altivec_vmaxsd(__a, -__a);
131}
132#endif
133
134static __inline__ vector float __ATTRS_o_ai vec_abs(vector float __a) {
135#ifdef __VSX__
136 return __builtin_vsx_xvabssp(__a);
137#else
138 vector unsigned int __res =
139 (vector unsigned int)__a & (vector unsigned int)(0x7FFFFFFF);
140 return (vector float)__res;
141#endif
142}
143
Logan Chien55afb0a2018-10-15 10:42:14 +0800144#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +0800145static __inline__ vector double __ATTRS_o_ai vec_abs(vector double __a) {
146 return __builtin_vsx_xvabsdp(__a);
147}
148#endif
149
150/* vec_abss */
151#define __builtin_altivec_abss_v16qi vec_abss
152#define __builtin_altivec_abss_v8hi vec_abss
153#define __builtin_altivec_abss_v4si vec_abss
154
155static __inline__ vector signed char __ATTRS_o_ai
156vec_abss(vector signed char __a) {
157 return __builtin_altivec_vmaxsb(
158 __a, __builtin_altivec_vsubsbs((vector signed char)(0), __a));
159}
160
161static __inline__ vector signed short __ATTRS_o_ai
162vec_abss(vector signed short __a) {
163 return __builtin_altivec_vmaxsh(
164 __a, __builtin_altivec_vsubshs((vector signed short)(0), __a));
165}
166
167static __inline__ vector signed int __ATTRS_o_ai
168vec_abss(vector signed int __a) {
169 return __builtin_altivec_vmaxsw(
170 __a, __builtin_altivec_vsubsws((vector signed int)(0), __a));
171}
172
Logan Chien55afb0a2018-10-15 10:42:14 +0800173/* vec_absd */
174#if defined(__POWER9_VECTOR__)
175
176static __inline__ vector unsigned char __ATTRS_o_ai
177vec_absd(vector unsigned char __a, vector unsigned char __b) {
178 return __builtin_altivec_vabsdub(__a, __b);
179}
180
181static __inline__ vector unsigned short __ATTRS_o_ai
182vec_absd(vector unsigned short __a, vector unsigned short __b) {
183 return __builtin_altivec_vabsduh(__a, __b);
184}
185
186static __inline__ vector unsigned int __ATTRS_o_ai
187vec_absd(vector unsigned int __a, vector unsigned int __b) {
188 return __builtin_altivec_vabsduw(__a, __b);
189}
190
191#endif /* End __POWER9_VECTOR__ */
192
Logan Chien2833ffb2018-10-09 10:03:24 +0800193/* vec_add */
194
195static __inline__ vector signed char __ATTRS_o_ai
196vec_add(vector signed char __a, vector signed char __b) {
197 return __a + __b;
198}
199
200static __inline__ vector signed char __ATTRS_o_ai
201vec_add(vector bool char __a, vector signed char __b) {
202 return (vector signed char)__a + __b;
203}
204
205static __inline__ vector signed char __ATTRS_o_ai
206vec_add(vector signed char __a, vector bool char __b) {
207 return __a + (vector signed char)__b;
208}
209
210static __inline__ vector unsigned char __ATTRS_o_ai
211vec_add(vector unsigned char __a, vector unsigned char __b) {
212 return __a + __b;
213}
214
215static __inline__ vector unsigned char __ATTRS_o_ai
216vec_add(vector bool char __a, vector unsigned char __b) {
217 return (vector unsigned char)__a + __b;
218}
219
220static __inline__ vector unsigned char __ATTRS_o_ai
221vec_add(vector unsigned char __a, vector bool char __b) {
222 return __a + (vector unsigned char)__b;
223}
224
225static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a,
226 vector short __b) {
227 return __a + __b;
228}
229
230static __inline__ vector short __ATTRS_o_ai vec_add(vector bool short __a,
231 vector short __b) {
232 return (vector short)__a + __b;
233}
234
235static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a,
236 vector bool short __b) {
237 return __a + (vector short)__b;
238}
239
240static __inline__ vector unsigned short __ATTRS_o_ai
241vec_add(vector unsigned short __a, vector unsigned short __b) {
242 return __a + __b;
243}
244
245static __inline__ vector unsigned short __ATTRS_o_ai
246vec_add(vector bool short __a, vector unsigned short __b) {
247 return (vector unsigned short)__a + __b;
248}
249
250static __inline__ vector unsigned short __ATTRS_o_ai
251vec_add(vector unsigned short __a, vector bool short __b) {
252 return __a + (vector unsigned short)__b;
253}
254
255static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a,
256 vector int __b) {
257 return __a + __b;
258}
259
260static __inline__ vector int __ATTRS_o_ai vec_add(vector bool int __a,
261 vector int __b) {
262 return (vector int)__a + __b;
263}
264
265static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a,
266 vector bool int __b) {
267 return __a + (vector int)__b;
268}
269
270static __inline__ vector unsigned int __ATTRS_o_ai
271vec_add(vector unsigned int __a, vector unsigned int __b) {
272 return __a + __b;
273}
274
275static __inline__ vector unsigned int __ATTRS_o_ai
276vec_add(vector bool int __a, vector unsigned int __b) {
277 return (vector unsigned int)__a + __b;
278}
279
280static __inline__ vector unsigned int __ATTRS_o_ai
281vec_add(vector unsigned int __a, vector bool int __b) {
282 return __a + (vector unsigned int)__b;
283}
284
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800285#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800286static __inline__ vector signed long long __ATTRS_o_ai
287vec_add(vector signed long long __a, vector signed long long __b) {
288 return __a + __b;
289}
290
291static __inline__ vector unsigned long long __ATTRS_o_ai
292vec_add(vector unsigned long long __a, vector unsigned long long __b) {
293 return __a + __b;
294}
295
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700296#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800297static __inline__ vector signed __int128 __ATTRS_o_ai
298vec_add(vector signed __int128 __a, vector signed __int128 __b) {
299 return __a + __b;
300}
301
302static __inline__ vector unsigned __int128 __ATTRS_o_ai
303vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) {
304 return __a + __b;
305}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700306#endif
307
308static __inline__ vector unsigned char __attribute__((__always_inline__))
309vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
310 return __builtin_altivec_vadduqm(__a, __b);
311}
312#elif defined(__VSX__)
313static __inline__ vector signed long long __ATTRS_o_ai
314vec_add(vector signed long long __a, vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800315#ifdef __LITTLE_ENDIAN__
316 // Little endian systems on CPU's prior to Power8 don't really exist
317 // so scalarizing is fine.
318 return __a + __b;
319#else
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700320 vector unsigned int __res =
321 (vector unsigned int)__a + (vector unsigned int)__b;
322 vector unsigned int __carry = __builtin_altivec_vaddcuw(
323 (vector unsigned int)__a, (vector unsigned int)__b);
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800324 __carry = __builtin_shufflevector((vector unsigned char)__carry,
325 (vector unsigned char)__carry, 0, 0, 0, 7,
326 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700327 return (vector signed long long)(__res + __carry);
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800328#endif
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700329}
330
331static __inline__ vector unsigned long long __ATTRS_o_ai
332vec_add(vector unsigned long long __a, vector unsigned long long __b) {
333 return (vector unsigned long long)vec_add((vector signed long long)__a,
334 (vector signed long long)__b);
335}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800336#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800337
338static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
339 vector float __b) {
340 return __a + __b;
341}
342
343#ifdef __VSX__
344static __inline__ vector double __ATTRS_o_ai vec_add(vector double __a,
345 vector double __b) {
346 return __a + __b;
347}
348#endif // __VSX__
349
350/* vec_adde */
351
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800352#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700353#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800354static __inline__ vector signed __int128 __ATTRS_o_ai
355vec_adde(vector signed __int128 __a, vector signed __int128 __b,
356 vector signed __int128 __c) {
357 return __builtin_altivec_vaddeuqm(__a, __b, __c);
358}
359
360static __inline__ vector unsigned __int128 __ATTRS_o_ai
361vec_adde(vector unsigned __int128 __a, vector unsigned __int128 __b,
362 vector unsigned __int128 __c) {
363 return __builtin_altivec_vaddeuqm(__a, __b, __c);
364}
365#endif
366
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700367static __inline__ vector unsigned char __attribute__((__always_inline__))
368vec_adde_u128(vector unsigned char __a, vector unsigned char __b,
369 vector unsigned char __c) {
370 return (vector unsigned char)__builtin_altivec_vaddeuqm(__a, __b, __c);
371}
372#endif
373
Logan Chien55afb0a2018-10-15 10:42:14 +0800374static __inline__ vector signed int __ATTRS_o_ai
375vec_adde(vector signed int __a, vector signed int __b,
376 vector signed int __c) {
377 vector signed int __mask = {1, 1, 1, 1};
378 vector signed int __carry = __c & __mask;
379 return vec_add(vec_add(__a, __b), __carry);
380}
381
382static __inline__ vector unsigned int __ATTRS_o_ai
383vec_adde(vector unsigned int __a, vector unsigned int __b,
384 vector unsigned int __c) {
385 vector unsigned int __mask = {1, 1, 1, 1};
386 vector unsigned int __carry = __c & __mask;
387 return vec_add(vec_add(__a, __b), __carry);
388}
389
Logan Chien2833ffb2018-10-09 10:03:24 +0800390/* vec_addec */
391
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800392#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700393#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800394static __inline__ vector signed __int128 __ATTRS_o_ai
395vec_addec(vector signed __int128 __a, vector signed __int128 __b,
396 vector signed __int128 __c) {
397 return __builtin_altivec_vaddecuq(__a, __b, __c);
398}
399
400static __inline__ vector unsigned __int128 __ATTRS_o_ai
401vec_addec(vector unsigned __int128 __a, vector unsigned __int128 __b,
402 vector unsigned __int128 __c) {
403 return __builtin_altivec_vaddecuq(__a, __b, __c);
404}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700405#endif
406
407static __inline__ vector unsigned char __attribute__((__always_inline__))
408vec_addec_u128(vector unsigned char __a, vector unsigned char __b,
409 vector unsigned char __c) {
410 return (vector unsigned char)__builtin_altivec_vaddecuq(__a, __b, __c);
411}
Logan Chien55afb0a2018-10-15 10:42:14 +0800412
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800413#ifdef __powerpc64__
Logan Chien55afb0a2018-10-15 10:42:14 +0800414static __inline__ vector signed int __ATTRS_o_ai
415vec_addec(vector signed int __a, vector signed int __b,
416 vector signed int __c) {
417
418 signed int __result[4];
419 for (int i = 0; i < 4; i++) {
420 unsigned int __tempa = (unsigned int) __a[i];
421 unsigned int __tempb = (unsigned int) __b[i];
422 unsigned int __tempc = (unsigned int) __c[i];
423 __tempc = __tempc & 0x00000001;
424 unsigned long long __longa = (unsigned long long) __tempa;
425 unsigned long long __longb = (unsigned long long) __tempb;
426 unsigned long long __longc = (unsigned long long) __tempc;
427 unsigned long long __sum = __longa + __longb + __longc;
428 unsigned long long __res = (__sum >> 32) & 0x01;
429 unsigned long long __tempres = (unsigned int) __res;
430 __result[i] = (signed int) __tempres;
431 }
432
433 vector signed int ret = { __result[0], __result[1], __result[2], __result[3] };
434 return ret;
435}
436
437static __inline__ vector unsigned int __ATTRS_o_ai
438vec_addec(vector unsigned int __a, vector unsigned int __b,
439 vector unsigned int __c) {
440
441 unsigned int __result[4];
442 for (int i = 0; i < 4; i++) {
443 unsigned int __tempc = __c[i] & 1;
444 unsigned long long __longa = (unsigned long long) __a[i];
445 unsigned long long __longb = (unsigned long long) __b[i];
446 unsigned long long __longc = (unsigned long long) __tempc;
447 unsigned long long __sum = __longa + __longb + __longc;
448 unsigned long long __res = (__sum >> 32) & 0x01;
449 unsigned long long __tempres = (unsigned int) __res;
450 __result[i] = (signed int) __tempres;
451 }
452
453 vector unsigned int ret = { __result[0], __result[1], __result[2], __result[3] };
454 return ret;
455}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800456#endif // __powerpc64__
457#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800458
459/* vec_vaddubm */
460
461#define __builtin_altivec_vaddubm vec_vaddubm
462
463static __inline__ vector signed char __ATTRS_o_ai
464vec_vaddubm(vector signed char __a, vector signed char __b) {
465 return __a + __b;
466}
467
468static __inline__ vector signed char __ATTRS_o_ai
469vec_vaddubm(vector bool char __a, vector signed char __b) {
470 return (vector signed char)__a + __b;
471}
472
473static __inline__ vector signed char __ATTRS_o_ai
474vec_vaddubm(vector signed char __a, vector bool char __b) {
475 return __a + (vector signed char)__b;
476}
477
478static __inline__ vector unsigned char __ATTRS_o_ai
479vec_vaddubm(vector unsigned char __a, vector unsigned char __b) {
480 return __a + __b;
481}
482
483static __inline__ vector unsigned char __ATTRS_o_ai
484vec_vaddubm(vector bool char __a, vector unsigned char __b) {
485 return (vector unsigned char)__a + __b;
486}
487
488static __inline__ vector unsigned char __ATTRS_o_ai
489vec_vaddubm(vector unsigned char __a, vector bool char __b) {
490 return __a + (vector unsigned char)__b;
491}
492
493/* vec_vadduhm */
494
495#define __builtin_altivec_vadduhm vec_vadduhm
496
497static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
498 vector short __b) {
499 return __a + __b;
500}
501
502static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector bool short __a,
503 vector short __b) {
504 return (vector short)__a + __b;
505}
506
507static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
508 vector bool short __b) {
509 return __a + (vector short)__b;
510}
511
512static __inline__ vector unsigned short __ATTRS_o_ai
513vec_vadduhm(vector unsigned short __a, vector unsigned short __b) {
514 return __a + __b;
515}
516
517static __inline__ vector unsigned short __ATTRS_o_ai
518vec_vadduhm(vector bool short __a, vector unsigned short __b) {
519 return (vector unsigned short)__a + __b;
520}
521
522static __inline__ vector unsigned short __ATTRS_o_ai
523vec_vadduhm(vector unsigned short __a, vector bool short __b) {
524 return __a + (vector unsigned short)__b;
525}
526
527/* vec_vadduwm */
528
529#define __builtin_altivec_vadduwm vec_vadduwm
530
531static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
532 vector int __b) {
533 return __a + __b;
534}
535
536static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector bool int __a,
537 vector int __b) {
538 return (vector int)__a + __b;
539}
540
541static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
542 vector bool int __b) {
543 return __a + (vector int)__b;
544}
545
546static __inline__ vector unsigned int __ATTRS_o_ai
547vec_vadduwm(vector unsigned int __a, vector unsigned int __b) {
548 return __a + __b;
549}
550
551static __inline__ vector unsigned int __ATTRS_o_ai
552vec_vadduwm(vector bool int __a, vector unsigned int __b) {
553 return (vector unsigned int)__a + __b;
554}
555
556static __inline__ vector unsigned int __ATTRS_o_ai
557vec_vadduwm(vector unsigned int __a, vector bool int __b) {
558 return __a + (vector unsigned int)__b;
559}
560
561/* vec_vaddfp */
562
563#define __builtin_altivec_vaddfp vec_vaddfp
564
565static __inline__ vector float __attribute__((__always_inline__))
566vec_vaddfp(vector float __a, vector float __b) {
567 return __a + __b;
568}
569
570/* vec_addc */
571
572static __inline__ vector signed int __ATTRS_o_ai
573vec_addc(vector signed int __a, vector signed int __b) {
574 return (vector signed int)__builtin_altivec_vaddcuw((vector unsigned int)__a,
575 (vector unsigned int)__b);
576}
577
578static __inline__ vector unsigned int __ATTRS_o_ai
579vec_addc(vector unsigned int __a, vector unsigned int __b) {
580 return __builtin_altivec_vaddcuw(__a, __b);
581}
582
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800583#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700584#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800585static __inline__ vector signed __int128 __ATTRS_o_ai
586vec_addc(vector signed __int128 __a, vector signed __int128 __b) {
587 return (vector signed __int128)__builtin_altivec_vaddcuq(
588 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
589}
590
591static __inline__ vector unsigned __int128 __ATTRS_o_ai
592vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
593 return __builtin_altivec_vaddcuq(__a, __b);
594}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700595#endif
596
597static __inline__ vector unsigned char __attribute__((__always_inline__))
598vec_addc_u128(vector unsigned char __a, vector unsigned char __b) {
599 return (vector unsigned char)__builtin_altivec_vaddcuq(__a, __b);
600}
Logan Chien2833ffb2018-10-09 10:03:24 +0800601#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
602
603/* vec_vaddcuw */
604
605static __inline__ vector unsigned int __attribute__((__always_inline__))
606vec_vaddcuw(vector unsigned int __a, vector unsigned int __b) {
607 return __builtin_altivec_vaddcuw(__a, __b);
608}
609
610/* vec_adds */
611
612static __inline__ vector signed char __ATTRS_o_ai
613vec_adds(vector signed char __a, vector signed char __b) {
614 return __builtin_altivec_vaddsbs(__a, __b);
615}
616
617static __inline__ vector signed char __ATTRS_o_ai
618vec_adds(vector bool char __a, vector signed char __b) {
619 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
620}
621
622static __inline__ vector signed char __ATTRS_o_ai
623vec_adds(vector signed char __a, vector bool char __b) {
624 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
625}
626
627static __inline__ vector unsigned char __ATTRS_o_ai
628vec_adds(vector unsigned char __a, vector unsigned char __b) {
629 return __builtin_altivec_vaddubs(__a, __b);
630}
631
632static __inline__ vector unsigned char __ATTRS_o_ai
633vec_adds(vector bool char __a, vector unsigned char __b) {
634 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
635}
636
637static __inline__ vector unsigned char __ATTRS_o_ai
638vec_adds(vector unsigned char __a, vector bool char __b) {
639 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
640}
641
642static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
643 vector short __b) {
644 return __builtin_altivec_vaddshs(__a, __b);
645}
646
647static __inline__ vector short __ATTRS_o_ai vec_adds(vector bool short __a,
648 vector short __b) {
649 return __builtin_altivec_vaddshs((vector short)__a, __b);
650}
651
652static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
653 vector bool short __b) {
654 return __builtin_altivec_vaddshs(__a, (vector short)__b);
655}
656
657static __inline__ vector unsigned short __ATTRS_o_ai
658vec_adds(vector unsigned short __a, vector unsigned short __b) {
659 return __builtin_altivec_vadduhs(__a, __b);
660}
661
662static __inline__ vector unsigned short __ATTRS_o_ai
663vec_adds(vector bool short __a, vector unsigned short __b) {
664 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
665}
666
667static __inline__ vector unsigned short __ATTRS_o_ai
668vec_adds(vector unsigned short __a, vector bool short __b) {
669 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
670}
671
672static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
673 vector int __b) {
674 return __builtin_altivec_vaddsws(__a, __b);
675}
676
677static __inline__ vector int __ATTRS_o_ai vec_adds(vector bool int __a,
678 vector int __b) {
679 return __builtin_altivec_vaddsws((vector int)__a, __b);
680}
681
682static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
683 vector bool int __b) {
684 return __builtin_altivec_vaddsws(__a, (vector int)__b);
685}
686
687static __inline__ vector unsigned int __ATTRS_o_ai
688vec_adds(vector unsigned int __a, vector unsigned int __b) {
689 return __builtin_altivec_vadduws(__a, __b);
690}
691
692static __inline__ vector unsigned int __ATTRS_o_ai
693vec_adds(vector bool int __a, vector unsigned int __b) {
694 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
695}
696
697static __inline__ vector unsigned int __ATTRS_o_ai
698vec_adds(vector unsigned int __a, vector bool int __b) {
699 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
700}
701
702/* vec_vaddsbs */
703
704static __inline__ vector signed char __ATTRS_o_ai
705vec_vaddsbs(vector signed char __a, vector signed char __b) {
706 return __builtin_altivec_vaddsbs(__a, __b);
707}
708
709static __inline__ vector signed char __ATTRS_o_ai
710vec_vaddsbs(vector bool char __a, vector signed char __b) {
711 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
712}
713
714static __inline__ vector signed char __ATTRS_o_ai
715vec_vaddsbs(vector signed char __a, vector bool char __b) {
716 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
717}
718
719/* vec_vaddubs */
720
721static __inline__ vector unsigned char __ATTRS_o_ai
722vec_vaddubs(vector unsigned char __a, vector unsigned char __b) {
723 return __builtin_altivec_vaddubs(__a, __b);
724}
725
726static __inline__ vector unsigned char __ATTRS_o_ai
727vec_vaddubs(vector bool char __a, vector unsigned char __b) {
728 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
729}
730
731static __inline__ vector unsigned char __ATTRS_o_ai
732vec_vaddubs(vector unsigned char __a, vector bool char __b) {
733 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
734}
735
736/* vec_vaddshs */
737
738static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
739 vector short __b) {
740 return __builtin_altivec_vaddshs(__a, __b);
741}
742
743static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector bool short __a,
744 vector short __b) {
745 return __builtin_altivec_vaddshs((vector short)__a, __b);
746}
747
748static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
749 vector bool short __b) {
750 return __builtin_altivec_vaddshs(__a, (vector short)__b);
751}
752
753/* vec_vadduhs */
754
755static __inline__ vector unsigned short __ATTRS_o_ai
756vec_vadduhs(vector unsigned short __a, vector unsigned short __b) {
757 return __builtin_altivec_vadduhs(__a, __b);
758}
759
760static __inline__ vector unsigned short __ATTRS_o_ai
761vec_vadduhs(vector bool short __a, vector unsigned short __b) {
762 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
763}
764
765static __inline__ vector unsigned short __ATTRS_o_ai
766vec_vadduhs(vector unsigned short __a, vector bool short __b) {
767 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
768}
769
770/* vec_vaddsws */
771
772static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
773 vector int __b) {
774 return __builtin_altivec_vaddsws(__a, __b);
775}
776
777static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector bool int __a,
778 vector int __b) {
779 return __builtin_altivec_vaddsws((vector int)__a, __b);
780}
781
782static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
783 vector bool int __b) {
784 return __builtin_altivec_vaddsws(__a, (vector int)__b);
785}
786
787/* vec_vadduws */
788
789static __inline__ vector unsigned int __ATTRS_o_ai
790vec_vadduws(vector unsigned int __a, vector unsigned int __b) {
791 return __builtin_altivec_vadduws(__a, __b);
792}
793
794static __inline__ vector unsigned int __ATTRS_o_ai
795vec_vadduws(vector bool int __a, vector unsigned int __b) {
796 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
797}
798
799static __inline__ vector unsigned int __ATTRS_o_ai
800vec_vadduws(vector unsigned int __a, vector bool int __b) {
801 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
802}
803
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700804#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
805 defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +0800806/* vec_vadduqm */
807
808static __inline__ vector signed __int128 __ATTRS_o_ai
809vec_vadduqm(vector signed __int128 __a, vector signed __int128 __b) {
810 return __a + __b;
811}
812
813static __inline__ vector unsigned __int128 __ATTRS_o_ai
814vec_vadduqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
815 return __a + __b;
816}
817
818/* vec_vaddeuqm */
819
820static __inline__ vector signed __int128 __ATTRS_o_ai
821vec_vaddeuqm(vector signed __int128 __a, vector signed __int128 __b,
822 vector signed __int128 __c) {
823 return __builtin_altivec_vaddeuqm(__a, __b, __c);
824}
825
826static __inline__ vector unsigned __int128 __ATTRS_o_ai
827vec_vaddeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
828 vector unsigned __int128 __c) {
829 return __builtin_altivec_vaddeuqm(__a, __b, __c);
830}
831
832/* vec_vaddcuq */
833
834static __inline__ vector signed __int128 __ATTRS_o_ai
835vec_vaddcuq(vector signed __int128 __a, vector signed __int128 __b) {
836 return __builtin_altivec_vaddcuq(__a, __b);
837}
838
839static __inline__ vector unsigned __int128 __ATTRS_o_ai
840vec_vaddcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
841 return __builtin_altivec_vaddcuq(__a, __b);
842}
843
844/* vec_vaddecuq */
845
846static __inline__ vector signed __int128 __ATTRS_o_ai
847vec_vaddecuq(vector signed __int128 __a, vector signed __int128 __b,
848 vector signed __int128 __c) {
849 return __builtin_altivec_vaddecuq(__a, __b, __c);
850}
851
852static __inline__ vector unsigned __int128 __ATTRS_o_ai
853vec_vaddecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
854 vector unsigned __int128 __c) {
855 return __builtin_altivec_vaddecuq(__a, __b, __c);
856}
857#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
858
859/* vec_and */
860
861#define __builtin_altivec_vand vec_and
862
863static __inline__ vector signed char __ATTRS_o_ai
864vec_and(vector signed char __a, vector signed char __b) {
865 return __a & __b;
866}
867
868static __inline__ vector signed char __ATTRS_o_ai
869vec_and(vector bool char __a, vector signed char __b) {
870 return (vector signed char)__a & __b;
871}
872
873static __inline__ vector signed char __ATTRS_o_ai
874vec_and(vector signed char __a, vector bool char __b) {
875 return __a & (vector signed char)__b;
876}
877
878static __inline__ vector unsigned char __ATTRS_o_ai
879vec_and(vector unsigned char __a, vector unsigned char __b) {
880 return __a & __b;
881}
882
883static __inline__ vector unsigned char __ATTRS_o_ai
884vec_and(vector bool char __a, vector unsigned char __b) {
885 return (vector unsigned char)__a & __b;
886}
887
888static __inline__ vector unsigned char __ATTRS_o_ai
889vec_and(vector unsigned char __a, vector bool char __b) {
890 return __a & (vector unsigned char)__b;
891}
892
893static __inline__ vector bool char __ATTRS_o_ai vec_and(vector bool char __a,
894 vector bool char __b) {
895 return __a & __b;
896}
897
898static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
899 vector short __b) {
900 return __a & __b;
901}
902
903static __inline__ vector short __ATTRS_o_ai vec_and(vector bool short __a,
904 vector short __b) {
905 return (vector short)__a & __b;
906}
907
908static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
909 vector bool short __b) {
910 return __a & (vector short)__b;
911}
912
913static __inline__ vector unsigned short __ATTRS_o_ai
914vec_and(vector unsigned short __a, vector unsigned short __b) {
915 return __a & __b;
916}
917
918static __inline__ vector unsigned short __ATTRS_o_ai
919vec_and(vector bool short __a, vector unsigned short __b) {
920 return (vector unsigned short)__a & __b;
921}
922
923static __inline__ vector unsigned short __ATTRS_o_ai
924vec_and(vector unsigned short __a, vector bool short __b) {
925 return __a & (vector unsigned short)__b;
926}
927
928static __inline__ vector bool short __ATTRS_o_ai
929vec_and(vector bool short __a, vector bool short __b) {
930 return __a & __b;
931}
932
933static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
934 vector int __b) {
935 return __a & __b;
936}
937
938static __inline__ vector int __ATTRS_o_ai vec_and(vector bool int __a,
939 vector int __b) {
940 return (vector int)__a & __b;
941}
942
943static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
944 vector bool int __b) {
945 return __a & (vector int)__b;
946}
947
948static __inline__ vector unsigned int __ATTRS_o_ai
949vec_and(vector unsigned int __a, vector unsigned int __b) {
950 return __a & __b;
951}
952
953static __inline__ vector unsigned int __ATTRS_o_ai
954vec_and(vector bool int __a, vector unsigned int __b) {
955 return (vector unsigned int)__a & __b;
956}
957
958static __inline__ vector unsigned int __ATTRS_o_ai
959vec_and(vector unsigned int __a, vector bool int __b) {
960 return __a & (vector unsigned int)__b;
961}
962
963static __inline__ vector bool int __ATTRS_o_ai vec_and(vector bool int __a,
964 vector bool int __b) {
965 return __a & __b;
966}
967
968static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
969 vector float __b) {
970 vector unsigned int __res =
971 (vector unsigned int)__a & (vector unsigned int)__b;
972 return (vector float)__res;
973}
974
975static __inline__ vector float __ATTRS_o_ai vec_and(vector bool int __a,
976 vector float __b) {
977 vector unsigned int __res =
978 (vector unsigned int)__a & (vector unsigned int)__b;
979 return (vector float)__res;
980}
981
982static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
983 vector bool int __b) {
984 vector unsigned int __res =
985 (vector unsigned int)__a & (vector unsigned int)__b;
986 return (vector float)__res;
987}
988
989#ifdef __VSX__
990static __inline__ vector double __ATTRS_o_ai vec_and(vector bool long long __a,
991 vector double __b) {
992 vector unsigned long long __res =
993 (vector unsigned long long)__a & (vector unsigned long long)__b;
994 return (vector double)__res;
995}
996
997static __inline__ vector double __ATTRS_o_ai
998vec_and(vector double __a, vector bool long long __b) {
999 vector unsigned long long __res =
1000 (vector unsigned long long)__a & (vector unsigned long long)__b;
1001 return (vector double)__res;
1002}
1003
1004static __inline__ vector double __ATTRS_o_ai vec_and(vector double __a,
1005 vector double __b) {
1006 vector unsigned long long __res =
1007 (vector unsigned long long)__a & (vector unsigned long long)__b;
1008 return (vector double)__res;
1009}
1010
1011static __inline__ vector signed long long __ATTRS_o_ai
1012vec_and(vector signed long long __a, vector signed long long __b) {
1013 return __a & __b;
1014}
1015
1016static __inline__ vector signed long long __ATTRS_o_ai
1017vec_and(vector bool long long __a, vector signed long long __b) {
1018 return (vector signed long long)__a & __b;
1019}
1020
1021static __inline__ vector signed long long __ATTRS_o_ai
1022vec_and(vector signed long long __a, vector bool long long __b) {
1023 return __a & (vector signed long long)__b;
1024}
1025
1026static __inline__ vector unsigned long long __ATTRS_o_ai
1027vec_and(vector unsigned long long __a, vector unsigned long long __b) {
1028 return __a & __b;
1029}
1030
1031static __inline__ vector unsigned long long __ATTRS_o_ai
1032vec_and(vector bool long long __a, vector unsigned long long __b) {
1033 return (vector unsigned long long)__a & __b;
1034}
1035
1036static __inline__ vector unsigned long long __ATTRS_o_ai
1037vec_and(vector unsigned long long __a, vector bool long long __b) {
1038 return __a & (vector unsigned long long)__b;
1039}
1040
1041static __inline__ vector bool long long __ATTRS_o_ai
1042vec_and(vector bool long long __a, vector bool long long __b) {
1043 return __a & __b;
1044}
1045#endif
1046
1047/* vec_vand */
1048
1049static __inline__ vector signed char __ATTRS_o_ai
1050vec_vand(vector signed char __a, vector signed char __b) {
1051 return __a & __b;
1052}
1053
1054static __inline__ vector signed char __ATTRS_o_ai
1055vec_vand(vector bool char __a, vector signed char __b) {
1056 return (vector signed char)__a & __b;
1057}
1058
1059static __inline__ vector signed char __ATTRS_o_ai
1060vec_vand(vector signed char __a, vector bool char __b) {
1061 return __a & (vector signed char)__b;
1062}
1063
1064static __inline__ vector unsigned char __ATTRS_o_ai
1065vec_vand(vector unsigned char __a, vector unsigned char __b) {
1066 return __a & __b;
1067}
1068
1069static __inline__ vector unsigned char __ATTRS_o_ai
1070vec_vand(vector bool char __a, vector unsigned char __b) {
1071 return (vector unsigned char)__a & __b;
1072}
1073
1074static __inline__ vector unsigned char __ATTRS_o_ai
1075vec_vand(vector unsigned char __a, vector bool char __b) {
1076 return __a & (vector unsigned char)__b;
1077}
1078
1079static __inline__ vector bool char __ATTRS_o_ai vec_vand(vector bool char __a,
1080 vector bool char __b) {
1081 return __a & __b;
1082}
1083
1084static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
1085 vector short __b) {
1086 return __a & __b;
1087}
1088
1089static __inline__ vector short __ATTRS_o_ai vec_vand(vector bool short __a,
1090 vector short __b) {
1091 return (vector short)__a & __b;
1092}
1093
1094static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
1095 vector bool short __b) {
1096 return __a & (vector short)__b;
1097}
1098
1099static __inline__ vector unsigned short __ATTRS_o_ai
1100vec_vand(vector unsigned short __a, vector unsigned short __b) {
1101 return __a & __b;
1102}
1103
1104static __inline__ vector unsigned short __ATTRS_o_ai
1105vec_vand(vector bool short __a, vector unsigned short __b) {
1106 return (vector unsigned short)__a & __b;
1107}
1108
1109static __inline__ vector unsigned short __ATTRS_o_ai
1110vec_vand(vector unsigned short __a, vector bool short __b) {
1111 return __a & (vector unsigned short)__b;
1112}
1113
1114static __inline__ vector bool short __ATTRS_o_ai
1115vec_vand(vector bool short __a, vector bool short __b) {
1116 return __a & __b;
1117}
1118
1119static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
1120 vector int __b) {
1121 return __a & __b;
1122}
1123
1124static __inline__ vector int __ATTRS_o_ai vec_vand(vector bool int __a,
1125 vector int __b) {
1126 return (vector int)__a & __b;
1127}
1128
1129static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
1130 vector bool int __b) {
1131 return __a & (vector int)__b;
1132}
1133
1134static __inline__ vector unsigned int __ATTRS_o_ai
1135vec_vand(vector unsigned int __a, vector unsigned int __b) {
1136 return __a & __b;
1137}
1138
1139static __inline__ vector unsigned int __ATTRS_o_ai
1140vec_vand(vector bool int __a, vector unsigned int __b) {
1141 return (vector unsigned int)__a & __b;
1142}
1143
1144static __inline__ vector unsigned int __ATTRS_o_ai
1145vec_vand(vector unsigned int __a, vector bool int __b) {
1146 return __a & (vector unsigned int)__b;
1147}
1148
1149static __inline__ vector bool int __ATTRS_o_ai vec_vand(vector bool int __a,
1150 vector bool int __b) {
1151 return __a & __b;
1152}
1153
1154static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1155 vector float __b) {
1156 vector unsigned int __res =
1157 (vector unsigned int)__a & (vector unsigned int)__b;
1158 return (vector float)__res;
1159}
1160
1161static __inline__ vector float __ATTRS_o_ai vec_vand(vector bool int __a,
1162 vector float __b) {
1163 vector unsigned int __res =
1164 (vector unsigned int)__a & (vector unsigned int)__b;
1165 return (vector float)__res;
1166}
1167
1168static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1169 vector bool int __b) {
1170 vector unsigned int __res =
1171 (vector unsigned int)__a & (vector unsigned int)__b;
1172 return (vector float)__res;
1173}
1174
1175#ifdef __VSX__
1176static __inline__ vector signed long long __ATTRS_o_ai
1177vec_vand(vector signed long long __a, vector signed long long __b) {
1178 return __a & __b;
1179}
1180
1181static __inline__ vector signed long long __ATTRS_o_ai
1182vec_vand(vector bool long long __a, vector signed long long __b) {
1183 return (vector signed long long)__a & __b;
1184}
1185
1186static __inline__ vector signed long long __ATTRS_o_ai
1187vec_vand(vector signed long long __a, vector bool long long __b) {
1188 return __a & (vector signed long long)__b;
1189}
1190
1191static __inline__ vector unsigned long long __ATTRS_o_ai
1192vec_vand(vector unsigned long long __a, vector unsigned long long __b) {
1193 return __a & __b;
1194}
1195
1196static __inline__ vector unsigned long long __ATTRS_o_ai
1197vec_vand(vector bool long long __a, vector unsigned long long __b) {
1198 return (vector unsigned long long)__a & __b;
1199}
1200
1201static __inline__ vector unsigned long long __ATTRS_o_ai
1202vec_vand(vector unsigned long long __a, vector bool long long __b) {
1203 return __a & (vector unsigned long long)__b;
1204}
1205
1206static __inline__ vector bool long long __ATTRS_o_ai
1207vec_vand(vector bool long long __a, vector bool long long __b) {
1208 return __a & __b;
1209}
1210#endif
1211
1212/* vec_andc */
1213
1214#define __builtin_altivec_vandc vec_andc
1215
1216static __inline__ vector signed char __ATTRS_o_ai
1217vec_andc(vector signed char __a, vector signed char __b) {
1218 return __a & ~__b;
1219}
1220
1221static __inline__ vector signed char __ATTRS_o_ai
1222vec_andc(vector bool char __a, vector signed char __b) {
1223 return (vector signed char)__a & ~__b;
1224}
1225
1226static __inline__ vector signed char __ATTRS_o_ai
1227vec_andc(vector signed char __a, vector bool char __b) {
1228 return __a & ~(vector signed char)__b;
1229}
1230
1231static __inline__ vector unsigned char __ATTRS_o_ai
1232vec_andc(vector unsigned char __a, vector unsigned char __b) {
1233 return __a & ~__b;
1234}
1235
1236static __inline__ vector unsigned char __ATTRS_o_ai
1237vec_andc(vector bool char __a, vector unsigned char __b) {
1238 return (vector unsigned char)__a & ~__b;
1239}
1240
1241static __inline__ vector unsigned char __ATTRS_o_ai
1242vec_andc(vector unsigned char __a, vector bool char __b) {
1243 return __a & ~(vector unsigned char)__b;
1244}
1245
1246static __inline__ vector bool char __ATTRS_o_ai vec_andc(vector bool char __a,
1247 vector bool char __b) {
1248 return __a & ~__b;
1249}
1250
1251static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1252 vector short __b) {
1253 return __a & ~__b;
1254}
1255
1256static __inline__ vector short __ATTRS_o_ai vec_andc(vector bool short __a,
1257 vector short __b) {
1258 return (vector short)__a & ~__b;
1259}
1260
1261static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1262 vector bool short __b) {
1263 return __a & ~(vector short)__b;
1264}
1265
1266static __inline__ vector unsigned short __ATTRS_o_ai
1267vec_andc(vector unsigned short __a, vector unsigned short __b) {
1268 return __a & ~__b;
1269}
1270
1271static __inline__ vector unsigned short __ATTRS_o_ai
1272vec_andc(vector bool short __a, vector unsigned short __b) {
1273 return (vector unsigned short)__a & ~__b;
1274}
1275
1276static __inline__ vector unsigned short __ATTRS_o_ai
1277vec_andc(vector unsigned short __a, vector bool short __b) {
1278 return __a & ~(vector unsigned short)__b;
1279}
1280
1281static __inline__ vector bool short __ATTRS_o_ai
1282vec_andc(vector bool short __a, vector bool short __b) {
1283 return __a & ~__b;
1284}
1285
1286static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1287 vector int __b) {
1288 return __a & ~__b;
1289}
1290
1291static __inline__ vector int __ATTRS_o_ai vec_andc(vector bool int __a,
1292 vector int __b) {
1293 return (vector int)__a & ~__b;
1294}
1295
1296static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1297 vector bool int __b) {
1298 return __a & ~(vector int)__b;
1299}
1300
1301static __inline__ vector unsigned int __ATTRS_o_ai
1302vec_andc(vector unsigned int __a, vector unsigned int __b) {
1303 return __a & ~__b;
1304}
1305
1306static __inline__ vector unsigned int __ATTRS_o_ai
1307vec_andc(vector bool int __a, vector unsigned int __b) {
1308 return (vector unsigned int)__a & ~__b;
1309}
1310
1311static __inline__ vector unsigned int __ATTRS_o_ai
1312vec_andc(vector unsigned int __a, vector bool int __b) {
1313 return __a & ~(vector unsigned int)__b;
1314}
1315
1316static __inline__ vector bool int __ATTRS_o_ai vec_andc(vector bool int __a,
1317 vector bool int __b) {
1318 return __a & ~__b;
1319}
1320
1321static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1322 vector float __b) {
1323 vector unsigned int __res =
1324 (vector unsigned int)__a & ~(vector unsigned int)__b;
1325 return (vector float)__res;
1326}
1327
1328static __inline__ vector float __ATTRS_o_ai vec_andc(vector bool int __a,
1329 vector float __b) {
1330 vector unsigned int __res =
1331 (vector unsigned int)__a & ~(vector unsigned int)__b;
1332 return (vector float)__res;
1333}
1334
1335static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1336 vector bool int __b) {
1337 vector unsigned int __res =
1338 (vector unsigned int)__a & ~(vector unsigned int)__b;
1339 return (vector float)__res;
1340}
1341
1342#ifdef __VSX__
1343static __inline__ vector double __ATTRS_o_ai vec_andc(vector bool long long __a,
1344 vector double __b) {
1345 vector unsigned long long __res =
1346 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1347 return (vector double)__res;
1348}
1349
1350static __inline__ vector double __ATTRS_o_ai
1351vec_andc(vector double __a, vector bool long long __b) {
1352 vector unsigned long long __res =
1353 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1354 return (vector double)__res;
1355}
1356
1357static __inline__ vector double __ATTRS_o_ai vec_andc(vector double __a,
1358 vector double __b) {
1359 vector unsigned long long __res =
1360 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1361 return (vector double)__res;
1362}
1363
1364static __inline__ vector signed long long __ATTRS_o_ai
1365vec_andc(vector signed long long __a, vector signed long long __b) {
1366 return __a & ~__b;
1367}
1368
1369static __inline__ vector signed long long __ATTRS_o_ai
1370vec_andc(vector bool long long __a, vector signed long long __b) {
1371 return (vector signed long long)__a & ~__b;
1372}
1373
1374static __inline__ vector signed long long __ATTRS_o_ai
1375vec_andc(vector signed long long __a, vector bool long long __b) {
1376 return __a & ~(vector signed long long)__b;
1377}
1378
1379static __inline__ vector unsigned long long __ATTRS_o_ai
1380vec_andc(vector unsigned long long __a, vector unsigned long long __b) {
1381 return __a & ~__b;
1382}
1383
1384static __inline__ vector unsigned long long __ATTRS_o_ai
1385vec_andc(vector bool long long __a, vector unsigned long long __b) {
1386 return (vector unsigned long long)__a & ~__b;
1387}
1388
1389static __inline__ vector unsigned long long __ATTRS_o_ai
1390vec_andc(vector unsigned long long __a, vector bool long long __b) {
1391 return __a & ~(vector unsigned long long)__b;
1392}
1393
1394static __inline__ vector bool long long __ATTRS_o_ai
1395vec_andc(vector bool long long __a, vector bool long long __b) {
1396 return __a & ~__b;
1397}
1398#endif
1399
1400/* vec_vandc */
1401
1402static __inline__ vector signed char __ATTRS_o_ai
1403vec_vandc(vector signed char __a, vector signed char __b) {
1404 return __a & ~__b;
1405}
1406
1407static __inline__ vector signed char __ATTRS_o_ai
1408vec_vandc(vector bool char __a, vector signed char __b) {
1409 return (vector signed char)__a & ~__b;
1410}
1411
1412static __inline__ vector signed char __ATTRS_o_ai
1413vec_vandc(vector signed char __a, vector bool char __b) {
1414 return __a & ~(vector signed char)__b;
1415}
1416
1417static __inline__ vector unsigned char __ATTRS_o_ai
1418vec_vandc(vector unsigned char __a, vector unsigned char __b) {
1419 return __a & ~__b;
1420}
1421
1422static __inline__ vector unsigned char __ATTRS_o_ai
1423vec_vandc(vector bool char __a, vector unsigned char __b) {
1424 return (vector unsigned char)__a & ~__b;
1425}
1426
1427static __inline__ vector unsigned char __ATTRS_o_ai
1428vec_vandc(vector unsigned char __a, vector bool char __b) {
1429 return __a & ~(vector unsigned char)__b;
1430}
1431
1432static __inline__ vector bool char __ATTRS_o_ai
1433vec_vandc(vector bool char __a, vector bool char __b) {
1434 return __a & ~__b;
1435}
1436
1437static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1438 vector short __b) {
1439 return __a & ~__b;
1440}
1441
1442static __inline__ vector short __ATTRS_o_ai vec_vandc(vector bool short __a,
1443 vector short __b) {
1444 return (vector short)__a & ~__b;
1445}
1446
1447static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1448 vector bool short __b) {
1449 return __a & ~(vector short)__b;
1450}
1451
1452static __inline__ vector unsigned short __ATTRS_o_ai
1453vec_vandc(vector unsigned short __a, vector unsigned short __b) {
1454 return __a & ~__b;
1455}
1456
1457static __inline__ vector unsigned short __ATTRS_o_ai
1458vec_vandc(vector bool short __a, vector unsigned short __b) {
1459 return (vector unsigned short)__a & ~__b;
1460}
1461
1462static __inline__ vector unsigned short __ATTRS_o_ai
1463vec_vandc(vector unsigned short __a, vector bool short __b) {
1464 return __a & ~(vector unsigned short)__b;
1465}
1466
1467static __inline__ vector bool short __ATTRS_o_ai
1468vec_vandc(vector bool short __a, vector bool short __b) {
1469 return __a & ~__b;
1470}
1471
1472static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1473 vector int __b) {
1474 return __a & ~__b;
1475}
1476
1477static __inline__ vector int __ATTRS_o_ai vec_vandc(vector bool int __a,
1478 vector int __b) {
1479 return (vector int)__a & ~__b;
1480}
1481
1482static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1483 vector bool int __b) {
1484 return __a & ~(vector int)__b;
1485}
1486
1487static __inline__ vector unsigned int __ATTRS_o_ai
1488vec_vandc(vector unsigned int __a, vector unsigned int __b) {
1489 return __a & ~__b;
1490}
1491
1492static __inline__ vector unsigned int __ATTRS_o_ai
1493vec_vandc(vector bool int __a, vector unsigned int __b) {
1494 return (vector unsigned int)__a & ~__b;
1495}
1496
1497static __inline__ vector unsigned int __ATTRS_o_ai
1498vec_vandc(vector unsigned int __a, vector bool int __b) {
1499 return __a & ~(vector unsigned int)__b;
1500}
1501
1502static __inline__ vector bool int __ATTRS_o_ai vec_vandc(vector bool int __a,
1503 vector bool int __b) {
1504 return __a & ~__b;
1505}
1506
1507static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1508 vector float __b) {
1509 vector unsigned int __res =
1510 (vector unsigned int)__a & ~(vector unsigned int)__b;
1511 return (vector float)__res;
1512}
1513
1514static __inline__ vector float __ATTRS_o_ai vec_vandc(vector bool int __a,
1515 vector float __b) {
1516 vector unsigned int __res =
1517 (vector unsigned int)__a & ~(vector unsigned int)__b;
1518 return (vector float)__res;
1519}
1520
1521static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1522 vector bool int __b) {
1523 vector unsigned int __res =
1524 (vector unsigned int)__a & ~(vector unsigned int)__b;
1525 return (vector float)__res;
1526}
1527
1528#ifdef __VSX__
1529static __inline__ vector signed long long __ATTRS_o_ai
1530vec_vandc(vector signed long long __a, vector signed long long __b) {
1531 return __a & ~__b;
1532}
1533
1534static __inline__ vector signed long long __ATTRS_o_ai
1535vec_vandc(vector bool long long __a, vector signed long long __b) {
1536 return (vector signed long long)__a & ~__b;
1537}
1538
1539static __inline__ vector signed long long __ATTRS_o_ai
1540vec_vandc(vector signed long long __a, vector bool long long __b) {
1541 return __a & ~(vector signed long long)__b;
1542}
1543
1544static __inline__ vector unsigned long long __ATTRS_o_ai
1545vec_vandc(vector unsigned long long __a, vector unsigned long long __b) {
1546 return __a & ~__b;
1547}
1548
1549static __inline__ vector unsigned long long __ATTRS_o_ai
1550vec_vandc(vector bool long long __a, vector unsigned long long __b) {
1551 return (vector unsigned long long)__a & ~__b;
1552}
1553
1554static __inline__ vector unsigned long long __ATTRS_o_ai
1555vec_vandc(vector unsigned long long __a, vector bool long long __b) {
1556 return __a & ~(vector unsigned long long)__b;
1557}
1558
1559static __inline__ vector bool long long __ATTRS_o_ai
1560vec_vandc(vector bool long long __a, vector bool long long __b) {
1561 return __a & ~__b;
1562}
1563#endif
1564
1565/* vec_avg */
1566
1567static __inline__ vector signed char __ATTRS_o_ai
1568vec_avg(vector signed char __a, vector signed char __b) {
1569 return __builtin_altivec_vavgsb(__a, __b);
1570}
1571
1572static __inline__ vector unsigned char __ATTRS_o_ai
1573vec_avg(vector unsigned char __a, vector unsigned char __b) {
1574 return __builtin_altivec_vavgub(__a, __b);
1575}
1576
1577static __inline__ vector short __ATTRS_o_ai vec_avg(vector short __a,
1578 vector short __b) {
1579 return __builtin_altivec_vavgsh(__a, __b);
1580}
1581
1582static __inline__ vector unsigned short __ATTRS_o_ai
1583vec_avg(vector unsigned short __a, vector unsigned short __b) {
1584 return __builtin_altivec_vavguh(__a, __b);
1585}
1586
1587static __inline__ vector int __ATTRS_o_ai vec_avg(vector int __a,
1588 vector int __b) {
1589 return __builtin_altivec_vavgsw(__a, __b);
1590}
1591
1592static __inline__ vector unsigned int __ATTRS_o_ai
1593vec_avg(vector unsigned int __a, vector unsigned int __b) {
1594 return __builtin_altivec_vavguw(__a, __b);
1595}
1596
1597/* vec_vavgsb */
1598
1599static __inline__ vector signed char __attribute__((__always_inline__))
1600vec_vavgsb(vector signed char __a, vector signed char __b) {
1601 return __builtin_altivec_vavgsb(__a, __b);
1602}
1603
1604/* vec_vavgub */
1605
1606static __inline__ vector unsigned char __attribute__((__always_inline__))
1607vec_vavgub(vector unsigned char __a, vector unsigned char __b) {
1608 return __builtin_altivec_vavgub(__a, __b);
1609}
1610
1611/* vec_vavgsh */
1612
1613static __inline__ vector short __attribute__((__always_inline__))
1614vec_vavgsh(vector short __a, vector short __b) {
1615 return __builtin_altivec_vavgsh(__a, __b);
1616}
1617
1618/* vec_vavguh */
1619
1620static __inline__ vector unsigned short __attribute__((__always_inline__))
1621vec_vavguh(vector unsigned short __a, vector unsigned short __b) {
1622 return __builtin_altivec_vavguh(__a, __b);
1623}
1624
1625/* vec_vavgsw */
1626
1627static __inline__ vector int __attribute__((__always_inline__))
1628vec_vavgsw(vector int __a, vector int __b) {
1629 return __builtin_altivec_vavgsw(__a, __b);
1630}
1631
1632/* vec_vavguw */
1633
1634static __inline__ vector unsigned int __attribute__((__always_inline__))
1635vec_vavguw(vector unsigned int __a, vector unsigned int __b) {
1636 return __builtin_altivec_vavguw(__a, __b);
1637}
1638
1639/* vec_ceil */
1640
1641static __inline__ vector float __ATTRS_o_ai vec_ceil(vector float __a) {
1642#ifdef __VSX__
1643 return __builtin_vsx_xvrspip(__a);
1644#else
1645 return __builtin_altivec_vrfip(__a);
1646#endif
1647}
1648
1649#ifdef __VSX__
1650static __inline__ vector double __ATTRS_o_ai vec_ceil(vector double __a) {
1651 return __builtin_vsx_xvrdpip(__a);
1652}
1653#endif
1654
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001655/* vec_roundp */
1656static __inline__ vector float __ATTRS_o_ai vec_roundp(vector float __a) {
1657 return vec_ceil(__a);
1658}
1659
1660#ifdef __VSX__
1661static __inline__ vector double __ATTRS_o_ai vec_roundp(vector double __a) {
1662 return vec_ceil(__a);
1663}
1664#endif
1665
Logan Chien2833ffb2018-10-09 10:03:24 +08001666/* vec_vrfip */
1667
1668static __inline__ vector float __attribute__((__always_inline__))
1669vec_vrfip(vector float __a) {
1670 return __builtin_altivec_vrfip(__a);
1671}
1672
1673/* vec_cmpb */
1674
1675static __inline__ vector int __attribute__((__always_inline__))
1676vec_cmpb(vector float __a, vector float __b) {
1677 return __builtin_altivec_vcmpbfp(__a, __b);
1678}
1679
1680/* vec_vcmpbfp */
1681
1682static __inline__ vector int __attribute__((__always_inline__))
1683vec_vcmpbfp(vector float __a, vector float __b) {
1684 return __builtin_altivec_vcmpbfp(__a, __b);
1685}
1686
1687/* vec_cmpeq */
1688
1689static __inline__ vector bool char __ATTRS_o_ai
1690vec_cmpeq(vector signed char __a, vector signed char __b) {
1691 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1692 (vector char)__b);
1693}
1694
1695static __inline__ vector bool char __ATTRS_o_ai
1696vec_cmpeq(vector unsigned char __a, vector unsigned char __b) {
1697 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1698 (vector char)__b);
1699}
1700
Logan Chien55afb0a2018-10-15 10:42:14 +08001701static __inline__ vector bool char __ATTRS_o_ai
1702vec_cmpeq(vector bool char __a, vector bool char __b) {
1703 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1704 (vector char)__b);
1705}
1706
Logan Chien2833ffb2018-10-09 10:03:24 +08001707static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
1708 vector short __b) {
1709 return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
1710}
1711
1712static __inline__ vector bool short __ATTRS_o_ai
1713vec_cmpeq(vector unsigned short __a, vector unsigned short __b) {
1714 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1715 (vector short)__b);
1716}
1717
Logan Chien55afb0a2018-10-15 10:42:14 +08001718static __inline__ vector bool short __ATTRS_o_ai
1719vec_cmpeq(vector bool short __a, vector bool short __b) {
1720 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1721 (vector short)__b);
1722}
1723
Logan Chien2833ffb2018-10-09 10:03:24 +08001724static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
1725 vector int __b) {
1726 return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
1727}
1728
1729static __inline__ vector bool int __ATTRS_o_ai
1730vec_cmpeq(vector unsigned int __a, vector unsigned int __b) {
1731 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1732 (vector int)__b);
1733}
1734
Logan Chien55afb0a2018-10-15 10:42:14 +08001735static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
1736 vector bool int __b) {
1737 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1738 (vector int)__b);
1739}
1740
Logan Chien2833ffb2018-10-09 10:03:24 +08001741#ifdef __POWER8_VECTOR__
1742static __inline__ vector bool long long __ATTRS_o_ai
1743vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1744 return (vector bool long long)__builtin_altivec_vcmpequd(__a, __b);
1745}
1746
1747static __inline__ vector bool long long __ATTRS_o_ai
1748vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1749 return (vector bool long long)__builtin_altivec_vcmpequd(
1750 (vector long long)__a, (vector long long)__b);
1751}
Logan Chien55afb0a2018-10-15 10:42:14 +08001752
1753static __inline__ vector bool long long __ATTRS_o_ai
1754vec_cmpeq(vector bool long long __a, vector bool long long __b) {
1755 return (vector bool long long)__builtin_altivec_vcmpequd(
1756 (vector long long)__a, (vector long long)__b);
1757}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001758#elif defined(__VSX__)
1759static __inline__ vector bool long long __ATTRS_o_ai
1760vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1761 vector bool int __wordcmp =
1762 vec_cmpeq((vector signed int)__a, (vector signed int)__b);
1763#ifdef __LITTLE_ENDIAN__
1764 __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
1765 return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 1,
1766 1, 3, 3);
1767#else
1768 __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
1769 return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 0,
1770 0, 2, 2);
1771#endif
1772}
Logan Chien55afb0a2018-10-15 10:42:14 +08001773
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001774static __inline__ vector bool long long __ATTRS_o_ai
1775vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1776 return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
1777}
1778
1779static __inline__ vector bool long long __ATTRS_o_ai
1780vec_cmpeq(vector bool long long __a, vector bool long long __b) {
1781 return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
1782}
Logan Chien2833ffb2018-10-09 10:03:24 +08001783#endif
1784
1785static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
1786 vector float __b) {
1787#ifdef __VSX__
1788 return (vector bool int)__builtin_vsx_xvcmpeqsp(__a, __b);
1789#else
1790 return (vector bool int)__builtin_altivec_vcmpeqfp(__a, __b);
1791#endif
1792}
1793
1794#ifdef __VSX__
1795static __inline__ vector bool long long __ATTRS_o_ai
1796vec_cmpeq(vector double __a, vector double __b) {
1797 return (vector bool long long)__builtin_vsx_xvcmpeqdp(__a, __b);
1798}
1799#endif
1800
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001801#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001802static __inline__ vector bool __int128 __ATTRS_o_ai
1803vec_cmpeq(vector signed __int128 __a, vector signed __int128 __b) {
1804 return (vector bool __int128)__builtin_altivec_vcmpequq(
1805 (vector bool __int128)__a, (vector bool __int128)__b);
1806}
1807
1808static __inline__ vector bool __int128 __ATTRS_o_ai
1809vec_cmpeq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
1810 return (vector bool __int128)__builtin_altivec_vcmpequq(
1811 (vector bool __int128)__a, (vector bool __int128)__b);
1812}
1813#endif
1814
Logan Chien55afb0a2018-10-15 10:42:14 +08001815#ifdef __POWER9_VECTOR__
1816/* vec_cmpne */
1817
1818static __inline__ vector bool char __ATTRS_o_ai
1819vec_cmpne(vector bool char __a, vector bool char __b) {
1820 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1821 (vector char)__b);
1822}
1823
1824static __inline__ vector bool char __ATTRS_o_ai
1825vec_cmpne(vector signed char __a, vector signed char __b) {
1826 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1827 (vector char)__b);
1828}
1829
1830static __inline__ vector bool char __ATTRS_o_ai
1831vec_cmpne(vector unsigned char __a, vector unsigned char __b) {
1832 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1833 (vector char)__b);
1834}
1835
1836static __inline__ vector bool short __ATTRS_o_ai
1837vec_cmpne(vector bool short __a, vector bool short __b) {
1838 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1839 (vector short)__b);
1840}
1841
1842static __inline__ vector bool short __ATTRS_o_ai
1843vec_cmpne(vector signed short __a, vector signed short __b) {
1844 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1845 (vector short)__b);
1846}
1847
1848static __inline__ vector bool short __ATTRS_o_ai
1849vec_cmpne(vector unsigned short __a, vector unsigned short __b) {
1850 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1851 (vector short)__b);
1852}
1853
1854static __inline__ vector bool int __ATTRS_o_ai
1855vec_cmpne(vector bool int __a, vector bool int __b) {
1856 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1857 (vector int)__b);
1858}
1859
1860static __inline__ vector bool int __ATTRS_o_ai
1861vec_cmpne(vector signed int __a, vector signed int __b) {
1862 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1863 (vector int)__b);
1864}
1865
1866static __inline__ vector bool int __ATTRS_o_ai
1867vec_cmpne(vector unsigned int __a, vector unsigned int __b) {
1868 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1869 (vector int)__b);
1870}
1871
Logan Chien55afb0a2018-10-15 10:42:14 +08001872static __inline__ vector bool int __ATTRS_o_ai
1873vec_cmpne(vector float __a, vector float __b) {
1874 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1875 (vector int)__b);
1876}
1877
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001878#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001879static __inline__ vector bool __int128 __ATTRS_o_ai
1880vec_cmpne(vector unsigned __int128 __a, vector unsigned __int128 __b) {
1881 return (vector bool __int128) ~(__builtin_altivec_vcmpequq(
1882 (vector bool __int128)__a, (vector bool __int128)__b));
Logan Chien55afb0a2018-10-15 10:42:14 +08001883}
1884
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001885static __inline__ vector bool __int128 __ATTRS_o_ai
1886vec_cmpne(vector signed __int128 __a, vector signed __int128 __b) {
1887 return (vector bool __int128) ~(__builtin_altivec_vcmpequq(
1888 (vector bool __int128)__a, (vector bool __int128)__b));
1889}
1890#endif
1891
Logan Chien55afb0a2018-10-15 10:42:14 +08001892/* vec_cmpnez */
1893
1894static __inline__ vector bool char __ATTRS_o_ai
1895vec_cmpnez(vector signed char __a, vector signed char __b) {
1896 return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a,
1897 (vector char)__b);
1898}
1899
1900static __inline__ vector bool char __ATTRS_o_ai
1901vec_cmpnez(vector unsigned char __a, vector unsigned char __b) {
1902 return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a,
1903 (vector char)__b);
1904}
1905
1906static __inline__ vector bool short __ATTRS_o_ai
1907vec_cmpnez(vector signed short __a, vector signed short __b) {
1908 return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a,
1909 (vector short)__b);
1910}
1911
1912static __inline__ vector bool short __ATTRS_o_ai
1913vec_cmpnez(vector unsigned short __a, vector unsigned short __b) {
1914 return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a,
1915 (vector short)__b);
1916}
1917
1918static __inline__ vector bool int __ATTRS_o_ai
1919vec_cmpnez(vector signed int __a, vector signed int __b) {
1920 return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a,
1921 (vector int)__b);
1922}
1923
1924static __inline__ vector bool int __ATTRS_o_ai
1925vec_cmpnez(vector unsigned int __a, vector unsigned int __b) {
1926 return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a,
1927 (vector int)__b);
1928}
1929
1930static __inline__ signed int __ATTRS_o_ai
1931vec_cntlz_lsbb(vector signed char __a) {
1932#ifdef __LITTLE_ENDIAN__
1933 return __builtin_altivec_vctzlsbb(__a);
1934#else
1935 return __builtin_altivec_vclzlsbb(__a);
1936#endif
1937}
1938
1939static __inline__ signed int __ATTRS_o_ai
1940vec_cntlz_lsbb(vector unsigned char __a) {
1941#ifdef __LITTLE_ENDIAN__
1942 return __builtin_altivec_vctzlsbb(__a);
1943#else
1944 return __builtin_altivec_vclzlsbb(__a);
1945#endif
1946}
1947
1948static __inline__ signed int __ATTRS_o_ai
1949vec_cnttz_lsbb(vector signed char __a) {
1950#ifdef __LITTLE_ENDIAN__
1951 return __builtin_altivec_vclzlsbb(__a);
1952#else
1953 return __builtin_altivec_vctzlsbb(__a);
1954#endif
1955}
1956
1957static __inline__ signed int __ATTRS_o_ai
1958vec_cnttz_lsbb(vector unsigned char __a) {
1959#ifdef __LITTLE_ENDIAN__
1960 return __builtin_altivec_vclzlsbb(__a);
1961#else
1962 return __builtin_altivec_vctzlsbb(__a);
1963#endif
1964}
1965
1966static __inline__ vector unsigned int __ATTRS_o_ai
1967vec_parity_lsbb(vector unsigned int __a) {
1968 return __builtin_altivec_vprtybw(__a);
1969}
1970
1971static __inline__ vector unsigned int __ATTRS_o_ai
1972vec_parity_lsbb(vector signed int __a) {
1973 return __builtin_altivec_vprtybw(__a);
1974}
1975
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001976#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +08001977static __inline__ vector unsigned __int128 __ATTRS_o_ai
1978vec_parity_lsbb(vector unsigned __int128 __a) {
1979 return __builtin_altivec_vprtybq(__a);
1980}
1981
1982static __inline__ vector unsigned __int128 __ATTRS_o_ai
1983vec_parity_lsbb(vector signed __int128 __a) {
1984 return __builtin_altivec_vprtybq(__a);
1985}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001986#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08001987
1988static __inline__ vector unsigned long long __ATTRS_o_ai
1989vec_parity_lsbb(vector unsigned long long __a) {
1990 return __builtin_altivec_vprtybd(__a);
1991}
1992
1993static __inline__ vector unsigned long long __ATTRS_o_ai
1994vec_parity_lsbb(vector signed long long __a) {
1995 return __builtin_altivec_vprtybd(__a);
1996}
1997
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001998#else
1999/* vec_cmpne */
2000
2001static __inline__ vector bool char __ATTRS_o_ai
2002vec_cmpne(vector bool char __a, vector bool char __b) {
2003 return ~(vec_cmpeq(__a, __b));
2004}
2005
2006static __inline__ vector bool char __ATTRS_o_ai
2007vec_cmpne(vector signed char __a, vector signed char __b) {
2008 return ~(vec_cmpeq(__a, __b));
2009}
2010
2011static __inline__ vector bool char __ATTRS_o_ai
2012vec_cmpne(vector unsigned char __a, vector unsigned char __b) {
2013 return ~(vec_cmpeq(__a, __b));
2014}
2015
2016static __inline__ vector bool short __ATTRS_o_ai
2017vec_cmpne(vector bool short __a, vector bool short __b) {
2018 return ~(vec_cmpeq(__a, __b));
2019}
2020
2021static __inline__ vector bool short __ATTRS_o_ai
2022vec_cmpne(vector signed short __a, vector signed short __b) {
2023 return ~(vec_cmpeq(__a, __b));
2024}
2025
2026static __inline__ vector bool short __ATTRS_o_ai
2027vec_cmpne(vector unsigned short __a, vector unsigned short __b) {
2028 return ~(vec_cmpeq(__a, __b));
2029}
2030
2031static __inline__ vector bool int __ATTRS_o_ai
2032vec_cmpne(vector bool int __a, vector bool int __b) {
2033 return ~(vec_cmpeq(__a, __b));
2034}
2035
2036static __inline__ vector bool int __ATTRS_o_ai
2037vec_cmpne(vector signed int __a, vector signed int __b) {
2038 return ~(vec_cmpeq(__a, __b));
2039}
2040
2041static __inline__ vector bool int __ATTRS_o_ai
2042vec_cmpne(vector unsigned int __a, vector unsigned int __b) {
2043 return ~(vec_cmpeq(__a, __b));
2044}
2045
2046static __inline__ vector bool int __ATTRS_o_ai
2047vec_cmpne(vector float __a, vector float __b) {
2048 return ~(vec_cmpeq(__a, __b));
2049}
2050#endif
2051
2052#ifdef __POWER8_VECTOR__
2053static __inline__ vector bool long long __ATTRS_o_ai
2054vec_cmpne(vector bool long long __a, vector bool long long __b) {
2055 return (vector bool long long)
2056 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2057}
2058
2059static __inline__ vector bool long long __ATTRS_o_ai
2060vec_cmpne(vector signed long long __a, vector signed long long __b) {
2061 return (vector bool long long)
2062 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2063}
2064
2065static __inline__ vector bool long long __ATTRS_o_ai
2066vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
2067 return (vector bool long long)
2068 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2069}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002070#elif defined(__VSX__)
2071static __inline__ vector bool long long __ATTRS_o_ai
2072vec_cmpne(vector bool long long __a, vector bool long long __b) {
2073 return (vector bool long long)~(
2074 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2075}
2076
2077static __inline__ vector bool long long __ATTRS_o_ai
2078vec_cmpne(vector signed long long __a, vector signed long long __b) {
2079 return (vector bool long long)~(
2080 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2081}
2082
2083static __inline__ vector bool long long __ATTRS_o_ai
2084vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
2085 return (vector bool long long)~(
2086 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2087}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002088#endif
2089
2090#ifdef __VSX__
2091static __inline__ vector bool long long __ATTRS_o_ai
2092vec_cmpne(vector double __a, vector double __b) {
2093 return (vector bool long long)
2094 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2095}
Logan Chien55afb0a2018-10-15 10:42:14 +08002096#endif
2097
Logan Chien2833ffb2018-10-09 10:03:24 +08002098/* vec_cmpgt */
2099
2100static __inline__ vector bool char __ATTRS_o_ai
2101vec_cmpgt(vector signed char __a, vector signed char __b) {
2102 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
2103}
2104
2105static __inline__ vector bool char __ATTRS_o_ai
2106vec_cmpgt(vector unsigned char __a, vector unsigned char __b) {
2107 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
2108}
2109
2110static __inline__ vector bool short __ATTRS_o_ai vec_cmpgt(vector short __a,
2111 vector short __b) {
2112 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
2113}
2114
2115static __inline__ vector bool short __ATTRS_o_ai
2116vec_cmpgt(vector unsigned short __a, vector unsigned short __b) {
2117 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
2118}
2119
2120static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector int __a,
2121 vector int __b) {
2122 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
2123}
2124
2125static __inline__ vector bool int __ATTRS_o_ai
2126vec_cmpgt(vector unsigned int __a, vector unsigned int __b) {
2127 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
2128}
2129
2130#ifdef __POWER8_VECTOR__
2131static __inline__ vector bool long long __ATTRS_o_ai
2132vec_cmpgt(vector signed long long __a, vector signed long long __b) {
2133 return (vector bool long long)__builtin_altivec_vcmpgtsd(__a, __b);
2134}
2135
2136static __inline__ vector bool long long __ATTRS_o_ai
2137vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
2138 return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b);
2139}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002140#elif defined(__VSX__)
2141static __inline__ vector bool long long __ATTRS_o_ai
2142vec_cmpgt(vector signed long long __a, vector signed long long __b) {
2143 vector signed int __sgtw = (vector signed int)vec_cmpgt(
2144 (vector signed int)__a, (vector signed int)__b);
2145 vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt(
2146 (vector unsigned int)__a, (vector unsigned int)__b);
2147 vector unsigned int __eqw = (vector unsigned int)vec_cmpeq(
2148 (vector signed int)__a, (vector signed int)__b);
2149#ifdef __LITTLE_ENDIAN__
2150 __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw;
2151 __sgtw |= (vector signed int)__ugtw;
2152 return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 1, 1, 3,
2153 3);
2154#else
2155 __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw;
2156 __sgtw |= (vector signed int)__ugtw;
2157 return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 0, 0, 2,
2158 2);
2159#endif
2160}
2161
2162static __inline__ vector bool long long __ATTRS_o_ai
2163vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
2164 vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt(
2165 (vector unsigned int)__a, (vector unsigned int)__b);
2166 vector unsigned int __eqw = (vector unsigned int)vec_cmpeq(
2167 (vector signed int)__a, (vector signed int)__b);
2168#ifdef __LITTLE_ENDIAN__
2169 __eqw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw;
2170 __ugtw |= __eqw;
2171 return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 1, 1, 3,
2172 3);
2173#else
2174 __eqw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw;
2175 __ugtw |= __eqw;
2176 return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 0, 0, 2,
2177 2);
2178#endif
2179}
Logan Chien2833ffb2018-10-09 10:03:24 +08002180#endif
2181
2182static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector float __a,
2183 vector float __b) {
2184#ifdef __VSX__
2185 return (vector bool int)__builtin_vsx_xvcmpgtsp(__a, __b);
2186#else
2187 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
2188#endif
2189}
2190
2191#ifdef __VSX__
2192static __inline__ vector bool long long __ATTRS_o_ai
2193vec_cmpgt(vector double __a, vector double __b) {
2194 return (vector bool long long)__builtin_vsx_xvcmpgtdp(__a, __b);
2195}
2196#endif
2197
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002198#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002199static __inline__ vector bool __int128 __ATTRS_o_ai
2200vec_cmpgt(vector signed __int128 __a, vector signed __int128 __b) {
2201 return (vector bool __int128)__builtin_altivec_vcmpgtsq(
2202 (vector bool __int128)__a, (vector bool __int128)__b);
2203}
2204
2205static __inline__ vector bool __int128 __ATTRS_o_ai
2206vec_cmpgt(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2207 return (vector bool __int128)__builtin_altivec_vcmpgtuq(
2208 (vector bool __int128)__a, (vector bool __int128)__b);
2209}
2210#endif
2211
Logan Chien2833ffb2018-10-09 10:03:24 +08002212/* vec_cmpge */
2213
2214static __inline__ vector bool char __ATTRS_o_ai
2215vec_cmpge(vector signed char __a, vector signed char __b) {
2216 return ~(vec_cmpgt(__b, __a));
2217}
2218
2219static __inline__ vector bool char __ATTRS_o_ai
2220vec_cmpge(vector unsigned char __a, vector unsigned char __b) {
2221 return ~(vec_cmpgt(__b, __a));
2222}
2223
2224static __inline__ vector bool short __ATTRS_o_ai
2225vec_cmpge(vector signed short __a, vector signed short __b) {
2226 return ~(vec_cmpgt(__b, __a));
2227}
2228
2229static __inline__ vector bool short __ATTRS_o_ai
2230vec_cmpge(vector unsigned short __a, vector unsigned short __b) {
2231 return ~(vec_cmpgt(__b, __a));
2232}
2233
2234static __inline__ vector bool int __ATTRS_o_ai
2235vec_cmpge(vector signed int __a, vector signed int __b) {
2236 return ~(vec_cmpgt(__b, __a));
2237}
2238
2239static __inline__ vector bool int __ATTRS_o_ai
2240vec_cmpge(vector unsigned int __a, vector unsigned int __b) {
2241 return ~(vec_cmpgt(__b, __a));
2242}
2243
2244static __inline__ vector bool int __ATTRS_o_ai vec_cmpge(vector float __a,
2245 vector float __b) {
2246#ifdef __VSX__
2247 return (vector bool int)__builtin_vsx_xvcmpgesp(__a, __b);
2248#else
2249 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
2250#endif
2251}
2252
2253#ifdef __VSX__
2254static __inline__ vector bool long long __ATTRS_o_ai
2255vec_cmpge(vector double __a, vector double __b) {
2256 return (vector bool long long)__builtin_vsx_xvcmpgedp(__a, __b);
2257}
Logan Chien2833ffb2018-10-09 10:03:24 +08002258
Logan Chien2833ffb2018-10-09 10:03:24 +08002259static __inline__ vector bool long long __ATTRS_o_ai
2260vec_cmpge(vector signed long long __a, vector signed long long __b) {
2261 return ~(vec_cmpgt(__b, __a));
2262}
2263
2264static __inline__ vector bool long long __ATTRS_o_ai
2265vec_cmpge(vector unsigned long long __a, vector unsigned long long __b) {
2266 return ~(vec_cmpgt(__b, __a));
2267}
2268#endif
2269
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002270#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002271static __inline__ vector bool __int128 __ATTRS_o_ai
2272vec_cmpge(vector signed __int128 __a, vector signed __int128 __b) {
2273 return ~(vec_cmpgt(__b, __a));
2274}
2275
2276static __inline__ vector bool __int128 __ATTRS_o_ai
2277vec_cmpge(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2278 return ~(vec_cmpgt(__b, __a));
2279}
2280#endif
2281
Logan Chien2833ffb2018-10-09 10:03:24 +08002282/* vec_vcmpgefp */
2283
2284static __inline__ vector bool int __attribute__((__always_inline__))
2285vec_vcmpgefp(vector float __a, vector float __b) {
2286 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
2287}
2288
2289/* vec_vcmpgtsb */
2290
2291static __inline__ vector bool char __attribute__((__always_inline__))
2292vec_vcmpgtsb(vector signed char __a, vector signed char __b) {
2293 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
2294}
2295
2296/* vec_vcmpgtub */
2297
2298static __inline__ vector bool char __attribute__((__always_inline__))
2299vec_vcmpgtub(vector unsigned char __a, vector unsigned char __b) {
2300 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
2301}
2302
2303/* vec_vcmpgtsh */
2304
2305static __inline__ vector bool short __attribute__((__always_inline__))
2306vec_vcmpgtsh(vector short __a, vector short __b) {
2307 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
2308}
2309
2310/* vec_vcmpgtuh */
2311
2312static __inline__ vector bool short __attribute__((__always_inline__))
2313vec_vcmpgtuh(vector unsigned short __a, vector unsigned short __b) {
2314 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
2315}
2316
2317/* vec_vcmpgtsw */
2318
2319static __inline__ vector bool int __attribute__((__always_inline__))
2320vec_vcmpgtsw(vector int __a, vector int __b) {
2321 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
2322}
2323
2324/* vec_vcmpgtuw */
2325
2326static __inline__ vector bool int __attribute__((__always_inline__))
2327vec_vcmpgtuw(vector unsigned int __a, vector unsigned int __b) {
2328 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
2329}
2330
2331/* vec_vcmpgtfp */
2332
2333static __inline__ vector bool int __attribute__((__always_inline__))
2334vec_vcmpgtfp(vector float __a, vector float __b) {
2335 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
2336}
2337
2338/* vec_cmple */
2339
2340static __inline__ vector bool char __ATTRS_o_ai
2341vec_cmple(vector signed char __a, vector signed char __b) {
2342 return vec_cmpge(__b, __a);
2343}
2344
2345static __inline__ vector bool char __ATTRS_o_ai
2346vec_cmple(vector unsigned char __a, vector unsigned char __b) {
2347 return vec_cmpge(__b, __a);
2348}
2349
2350static __inline__ vector bool short __ATTRS_o_ai
2351vec_cmple(vector signed short __a, vector signed short __b) {
2352 return vec_cmpge(__b, __a);
2353}
2354
2355static __inline__ vector bool short __ATTRS_o_ai
2356vec_cmple(vector unsigned short __a, vector unsigned short __b) {
2357 return vec_cmpge(__b, __a);
2358}
2359
2360static __inline__ vector bool int __ATTRS_o_ai
2361vec_cmple(vector signed int __a, vector signed int __b) {
2362 return vec_cmpge(__b, __a);
2363}
2364
2365static __inline__ vector bool int __ATTRS_o_ai
2366vec_cmple(vector unsigned int __a, vector unsigned int __b) {
2367 return vec_cmpge(__b, __a);
2368}
2369
2370static __inline__ vector bool int __ATTRS_o_ai vec_cmple(vector float __a,
2371 vector float __b) {
2372 return vec_cmpge(__b, __a);
2373}
2374
2375#ifdef __VSX__
2376static __inline__ vector bool long long __ATTRS_o_ai
2377vec_cmple(vector double __a, vector double __b) {
2378 return vec_cmpge(__b, __a);
2379}
Logan Chien2833ffb2018-10-09 10:03:24 +08002380
Logan Chien2833ffb2018-10-09 10:03:24 +08002381static __inline__ vector bool long long __ATTRS_o_ai
2382vec_cmple(vector signed long long __a, vector signed long long __b) {
2383 return vec_cmpge(__b, __a);
2384}
2385
2386static __inline__ vector bool long long __ATTRS_o_ai
2387vec_cmple(vector unsigned long long __a, vector unsigned long long __b) {
2388 return vec_cmpge(__b, __a);
2389}
2390#endif
2391
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002392#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002393static __inline__ vector bool __int128 __ATTRS_o_ai
2394vec_cmple(vector signed __int128 __a, vector signed __int128 __b) {
2395 return vec_cmpge(__b, __a);
2396}
2397
2398static __inline__ vector bool __int128 __ATTRS_o_ai
2399vec_cmple(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2400 return vec_cmpge(__b, __a);
2401}
2402#endif
2403
Logan Chien2833ffb2018-10-09 10:03:24 +08002404/* vec_cmplt */
2405
2406static __inline__ vector bool char __ATTRS_o_ai
2407vec_cmplt(vector signed char __a, vector signed char __b) {
2408 return vec_cmpgt(__b, __a);
2409}
2410
2411static __inline__ vector bool char __ATTRS_o_ai
2412vec_cmplt(vector unsigned char __a, vector unsigned char __b) {
2413 return vec_cmpgt(__b, __a);
2414}
2415
2416static __inline__ vector bool short __ATTRS_o_ai vec_cmplt(vector short __a,
2417 vector short __b) {
2418 return vec_cmpgt(__b, __a);
2419}
2420
2421static __inline__ vector bool short __ATTRS_o_ai
2422vec_cmplt(vector unsigned short __a, vector unsigned short __b) {
2423 return vec_cmpgt(__b, __a);
2424}
2425
2426static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector int __a,
2427 vector int __b) {
2428 return vec_cmpgt(__b, __a);
2429}
2430
2431static __inline__ vector bool int __ATTRS_o_ai
2432vec_cmplt(vector unsigned int __a, vector unsigned int __b) {
2433 return vec_cmpgt(__b, __a);
2434}
2435
2436static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector float __a,
2437 vector float __b) {
2438 return vec_cmpgt(__b, __a);
2439}
2440
2441#ifdef __VSX__
2442static __inline__ vector bool long long __ATTRS_o_ai
2443vec_cmplt(vector double __a, vector double __b) {
2444 return vec_cmpgt(__b, __a);
2445}
2446#endif
2447
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002448#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002449static __inline__ vector bool __int128 __ATTRS_o_ai
2450vec_cmplt(vector signed __int128 __a, vector signed __int128 __b) {
2451 return vec_cmpgt(__b, __a);
2452}
2453
2454static __inline__ vector bool __int128 __ATTRS_o_ai
2455vec_cmplt(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2456 return vec_cmpgt(__b, __a);
2457}
2458#endif
2459
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002460#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +08002461static __inline__ vector bool long long __ATTRS_o_ai
2462vec_cmplt(vector signed long long __a, vector signed long long __b) {
2463 return vec_cmpgt(__b, __a);
2464}
2465
2466static __inline__ vector bool long long __ATTRS_o_ai
2467vec_cmplt(vector unsigned long long __a, vector unsigned long long __b) {
2468 return vec_cmpgt(__b, __a);
2469}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002470#endif
Logan Chien2833ffb2018-10-09 10:03:24 +08002471
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002472#ifdef __POWER8_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +08002473/* vec_popcnt */
2474
2475static __inline__ vector signed char __ATTRS_o_ai
2476vec_popcnt(vector signed char __a) {
2477 return __builtin_altivec_vpopcntb(__a);
2478}
2479static __inline__ vector unsigned char __ATTRS_o_ai
2480vec_popcnt(vector unsigned char __a) {
2481 return __builtin_altivec_vpopcntb(__a);
2482}
2483static __inline__ vector signed short __ATTRS_o_ai
2484vec_popcnt(vector signed short __a) {
2485 return __builtin_altivec_vpopcnth(__a);
2486}
2487static __inline__ vector unsigned short __ATTRS_o_ai
2488vec_popcnt(vector unsigned short __a) {
2489 return __builtin_altivec_vpopcnth(__a);
2490}
2491static __inline__ vector signed int __ATTRS_o_ai
2492vec_popcnt(vector signed int __a) {
2493 return __builtin_altivec_vpopcntw(__a);
2494}
2495static __inline__ vector unsigned int __ATTRS_o_ai
2496vec_popcnt(vector unsigned int __a) {
2497 return __builtin_altivec_vpopcntw(__a);
2498}
2499static __inline__ vector signed long long __ATTRS_o_ai
2500vec_popcnt(vector signed long long __a) {
2501 return __builtin_altivec_vpopcntd(__a);
2502}
2503static __inline__ vector unsigned long long __ATTRS_o_ai
2504vec_popcnt(vector unsigned long long __a) {
2505 return __builtin_altivec_vpopcntd(__a);
2506}
2507
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002508#define vec_vclz vec_cntlz
Logan Chien2833ffb2018-10-09 10:03:24 +08002509/* vec_cntlz */
2510
2511static __inline__ vector signed char __ATTRS_o_ai
2512vec_cntlz(vector signed char __a) {
2513 return __builtin_altivec_vclzb(__a);
2514}
2515static __inline__ vector unsigned char __ATTRS_o_ai
2516vec_cntlz(vector unsigned char __a) {
2517 return __builtin_altivec_vclzb(__a);
2518}
2519static __inline__ vector signed short __ATTRS_o_ai
2520vec_cntlz(vector signed short __a) {
2521 return __builtin_altivec_vclzh(__a);
2522}
2523static __inline__ vector unsigned short __ATTRS_o_ai
2524vec_cntlz(vector unsigned short __a) {
2525 return __builtin_altivec_vclzh(__a);
2526}
2527static __inline__ vector signed int __ATTRS_o_ai
2528vec_cntlz(vector signed int __a) {
2529 return __builtin_altivec_vclzw(__a);
2530}
2531static __inline__ vector unsigned int __ATTRS_o_ai
2532vec_cntlz(vector unsigned int __a) {
2533 return __builtin_altivec_vclzw(__a);
2534}
2535static __inline__ vector signed long long __ATTRS_o_ai
2536vec_cntlz(vector signed long long __a) {
2537 return __builtin_altivec_vclzd(__a);
2538}
2539static __inline__ vector unsigned long long __ATTRS_o_ai
2540vec_cntlz(vector unsigned long long __a) {
2541 return __builtin_altivec_vclzd(__a);
2542}
2543#endif
2544
Logan Chien55afb0a2018-10-15 10:42:14 +08002545#ifdef __POWER9_VECTOR__
2546
2547/* vec_cnttz */
2548
2549static __inline__ vector signed char __ATTRS_o_ai
2550vec_cnttz(vector signed char __a) {
2551 return __builtin_altivec_vctzb(__a);
2552}
2553static __inline__ vector unsigned char __ATTRS_o_ai
2554vec_cnttz(vector unsigned char __a) {
2555 return __builtin_altivec_vctzb(__a);
2556}
2557static __inline__ vector signed short __ATTRS_o_ai
2558vec_cnttz(vector signed short __a) {
2559 return __builtin_altivec_vctzh(__a);
2560}
2561static __inline__ vector unsigned short __ATTRS_o_ai
2562vec_cnttz(vector unsigned short __a) {
2563 return __builtin_altivec_vctzh(__a);
2564}
2565static __inline__ vector signed int __ATTRS_o_ai
2566vec_cnttz(vector signed int __a) {
2567 return __builtin_altivec_vctzw(__a);
2568}
2569static __inline__ vector unsigned int __ATTRS_o_ai
2570vec_cnttz(vector unsigned int __a) {
2571 return __builtin_altivec_vctzw(__a);
2572}
2573static __inline__ vector signed long long __ATTRS_o_ai
2574vec_cnttz(vector signed long long __a) {
2575 return __builtin_altivec_vctzd(__a);
2576}
2577static __inline__ vector unsigned long long __ATTRS_o_ai
2578vec_cnttz(vector unsigned long long __a) {
2579 return __builtin_altivec_vctzd(__a);
2580}
2581
2582/* vec_first_match_index */
2583
2584static __inline__ unsigned __ATTRS_o_ai
2585vec_first_match_index(vector signed char __a, vector signed char __b) {
2586 vector unsigned long long __res =
2587#ifdef __LITTLE_ENDIAN__
2588 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2589#else
2590 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2591#endif
2592 if (__res[0] == 64) {
2593 return (__res[1] + 64) >> 3;
2594 }
2595 return __res[0] >> 3;
2596}
2597
2598static __inline__ unsigned __ATTRS_o_ai
2599vec_first_match_index(vector unsigned char __a, vector unsigned char __b) {
2600 vector unsigned long long __res =
2601#ifdef __LITTLE_ENDIAN__
2602 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2603#else
2604 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2605#endif
2606 if (__res[0] == 64) {
2607 return (__res[1] + 64) >> 3;
2608 }
2609 return __res[0] >> 3;
2610}
2611
2612static __inline__ unsigned __ATTRS_o_ai
2613vec_first_match_index(vector signed short __a, vector signed short __b) {
2614 vector unsigned long long __res =
2615#ifdef __LITTLE_ENDIAN__
2616 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2617#else
2618 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2619#endif
2620 if (__res[0] == 64) {
2621 return (__res[1] + 64) >> 4;
2622 }
2623 return __res[0] >> 4;
2624}
2625
2626static __inline__ unsigned __ATTRS_o_ai
2627vec_first_match_index(vector unsigned short __a, vector unsigned short __b) {
2628 vector unsigned long long __res =
2629#ifdef __LITTLE_ENDIAN__
2630 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2631#else
2632 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2633#endif
2634 if (__res[0] == 64) {
2635 return (__res[1] + 64) >> 4;
2636 }
2637 return __res[0] >> 4;
2638}
2639
2640static __inline__ unsigned __ATTRS_o_ai
2641vec_first_match_index(vector signed int __a, vector signed int __b) {
2642 vector unsigned long long __res =
2643#ifdef __LITTLE_ENDIAN__
2644 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2645#else
2646 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2647#endif
2648 if (__res[0] == 64) {
2649 return (__res[1] + 64) >> 5;
2650 }
2651 return __res[0] >> 5;
2652}
2653
2654static __inline__ unsigned __ATTRS_o_ai
2655vec_first_match_index(vector unsigned int __a, vector unsigned int __b) {
2656 vector unsigned long long __res =
2657#ifdef __LITTLE_ENDIAN__
2658 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2659#else
2660 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2661#endif
2662 if (__res[0] == 64) {
2663 return (__res[1] + 64) >> 5;
2664 }
2665 return __res[0] >> 5;
2666}
2667
2668/* vec_first_match_or_eos_index */
2669
2670static __inline__ unsigned __ATTRS_o_ai
2671vec_first_match_or_eos_index(vector signed char __a, vector signed char __b) {
2672 /* Compare the result of the comparison of two vectors with either and OR the
2673 result. Either the elements are equal or one will equal the comparison
2674 result if either is zero.
2675 */
2676 vector bool char __tmp1 = vec_cmpeq(__a, __b);
2677 vector bool char __tmp2 = __tmp1 |
2678 vec_cmpeq((vector signed char)__tmp1, __a) |
2679 vec_cmpeq((vector signed char)__tmp1, __b);
2680
2681 vector unsigned long long __res =
2682#ifdef __LITTLE_ENDIAN__
2683 vec_cnttz((vector unsigned long long)__tmp2);
2684#else
2685 vec_cntlz((vector unsigned long long)__tmp2);
2686#endif
2687 if (__res[0] == 64) {
2688 return (__res[1] + 64) >> 3;
2689 }
2690 return __res[0] >> 3;
2691}
2692
2693static __inline__ unsigned __ATTRS_o_ai
2694vec_first_match_or_eos_index(vector unsigned char __a,
2695 vector unsigned char __b) {
2696 vector bool char __tmp1 = vec_cmpeq(__a, __b);
2697 vector bool char __tmp2 = __tmp1 |
2698 vec_cmpeq((vector unsigned char)__tmp1, __a) |
2699 vec_cmpeq((vector unsigned char)__tmp1, __b);
2700
2701 vector unsigned long long __res =
2702#ifdef __LITTLE_ENDIAN__
2703 vec_cnttz((vector unsigned long long)__tmp2);
2704#else
2705 vec_cntlz((vector unsigned long long)__tmp2);
2706#endif
2707 if (__res[0] == 64) {
2708 return (__res[1] + 64) >> 3;
2709 }
2710 return __res[0] >> 3;
2711}
2712
2713static __inline__ unsigned __ATTRS_o_ai
2714vec_first_match_or_eos_index(vector signed short __a, vector signed short __b) {
2715 vector bool short __tmp1 = vec_cmpeq(__a, __b);
2716 vector bool short __tmp2 = __tmp1 |
2717 vec_cmpeq((vector signed short)__tmp1, __a) |
2718 vec_cmpeq((vector signed short)__tmp1, __b);
2719
2720 vector unsigned long long __res =
2721#ifdef __LITTLE_ENDIAN__
2722 vec_cnttz((vector unsigned long long)__tmp2);
2723#else
2724 vec_cntlz((vector unsigned long long)__tmp2);
2725#endif
2726 if (__res[0] == 64) {
2727 return (__res[1] + 64) >> 4;
2728 }
2729 return __res[0] >> 4;
2730}
2731
2732static __inline__ unsigned __ATTRS_o_ai
2733vec_first_match_or_eos_index(vector unsigned short __a,
2734 vector unsigned short __b) {
2735 vector bool short __tmp1 = vec_cmpeq(__a, __b);
2736 vector bool short __tmp2 = __tmp1 |
2737 vec_cmpeq((vector unsigned short)__tmp1, __a) |
2738 vec_cmpeq((vector unsigned short)__tmp1, __b);
2739
2740 vector unsigned long long __res =
2741#ifdef __LITTLE_ENDIAN__
2742 vec_cnttz((vector unsigned long long)__tmp2);
2743#else
2744 vec_cntlz((vector unsigned long long)__tmp2);
2745#endif
2746 if (__res[0] == 64) {
2747 return (__res[1] + 64) >> 4;
2748 }
2749 return __res[0] >> 4;
2750}
2751
2752static __inline__ unsigned __ATTRS_o_ai
2753vec_first_match_or_eos_index(vector signed int __a, vector signed int __b) {
2754 vector bool int __tmp1 = vec_cmpeq(__a, __b);
2755 vector bool int __tmp2 = __tmp1 | vec_cmpeq((vector signed int)__tmp1, __a) |
2756 vec_cmpeq((vector signed int)__tmp1, __b);
2757
2758 vector unsigned long long __res =
2759#ifdef __LITTLE_ENDIAN__
2760 vec_cnttz((vector unsigned long long)__tmp2);
2761#else
2762 vec_cntlz((vector unsigned long long)__tmp2);
2763#endif
2764 if (__res[0] == 64) {
2765 return (__res[1] + 64) >> 5;
2766 }
2767 return __res[0] >> 5;
2768}
2769
2770static __inline__ unsigned __ATTRS_o_ai
2771vec_first_match_or_eos_index(vector unsigned int __a, vector unsigned int __b) {
2772 vector bool int __tmp1 = vec_cmpeq(__a, __b);
2773 vector bool int __tmp2 = __tmp1 |
2774 vec_cmpeq((vector unsigned int)__tmp1, __a) |
2775 vec_cmpeq((vector unsigned int)__tmp1, __b);
2776
2777 vector unsigned long long __res =
2778#ifdef __LITTLE_ENDIAN__
2779 vec_cnttz((vector unsigned long long)__tmp2);
2780#else
2781 vec_cntlz((vector unsigned long long)__tmp2);
2782#endif
2783 if (__res[0] == 64) {
2784 return (__res[1] + 64) >> 5;
2785 }
2786 return __res[0] >> 5;
2787}
2788
2789/* vec_first_mismatch_index */
2790
2791static __inline__ unsigned __ATTRS_o_ai
2792vec_first_mismatch_index(vector signed char __a, vector signed char __b) {
2793 vector unsigned long long __res =
2794#ifdef __LITTLE_ENDIAN__
2795 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2796#else
2797 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2798#endif
2799 if (__res[0] == 64) {
2800 return (__res[1] + 64) >> 3;
2801 }
2802 return __res[0] >> 3;
2803}
2804
2805static __inline__ unsigned __ATTRS_o_ai
2806vec_first_mismatch_index(vector unsigned char __a, vector unsigned char __b) {
2807 vector unsigned long long __res =
2808#ifdef __LITTLE_ENDIAN__
2809 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2810#else
2811 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2812#endif
2813 if (__res[0] == 64) {
2814 return (__res[1] + 64) >> 3;
2815 }
2816 return __res[0] >> 3;
2817}
2818
2819static __inline__ unsigned __ATTRS_o_ai
2820vec_first_mismatch_index(vector signed short __a, vector signed short __b) {
2821 vector unsigned long long __res =
2822#ifdef __LITTLE_ENDIAN__
2823 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2824#else
2825 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2826#endif
2827 if (__res[0] == 64) {
2828 return (__res[1] + 64) >> 4;
2829 }
2830 return __res[0] >> 4;
2831}
2832
2833static __inline__ unsigned __ATTRS_o_ai
2834vec_first_mismatch_index(vector unsigned short __a, vector unsigned short __b) {
2835 vector unsigned long long __res =
2836#ifdef __LITTLE_ENDIAN__
2837 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2838#else
2839 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2840#endif
2841 if (__res[0] == 64) {
2842 return (__res[1] + 64) >> 4;
2843 }
2844 return __res[0] >> 4;
2845}
2846
2847static __inline__ unsigned __ATTRS_o_ai
2848vec_first_mismatch_index(vector signed int __a, vector signed int __b) {
2849 vector unsigned long long __res =
2850#ifdef __LITTLE_ENDIAN__
2851 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2852#else
2853 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2854#endif
2855 if (__res[0] == 64) {
2856 return (__res[1] + 64) >> 5;
2857 }
2858 return __res[0] >> 5;
2859}
2860
2861static __inline__ unsigned __ATTRS_o_ai
2862vec_first_mismatch_index(vector unsigned int __a, vector unsigned int __b) {
2863 vector unsigned long long __res =
2864#ifdef __LITTLE_ENDIAN__
2865 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2866#else
2867 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2868#endif
2869 if (__res[0] == 64) {
2870 return (__res[1] + 64) >> 5;
2871 }
2872 return __res[0] >> 5;
2873}
2874
2875/* vec_first_mismatch_or_eos_index */
2876
2877static __inline__ unsigned __ATTRS_o_ai
2878vec_first_mismatch_or_eos_index(vector signed char __a,
2879 vector signed char __b) {
2880 vector unsigned long long __res =
2881#ifdef __LITTLE_ENDIAN__
2882 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2883#else
2884 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2885#endif
2886 if (__res[0] == 64) {
2887 return (__res[1] + 64) >> 3;
2888 }
2889 return __res[0] >> 3;
2890}
2891
2892static __inline__ unsigned __ATTRS_o_ai
2893vec_first_mismatch_or_eos_index(vector unsigned char __a,
2894 vector unsigned char __b) {
2895 vector unsigned long long __res =
2896#ifdef __LITTLE_ENDIAN__
2897 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2898#else
2899 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2900#endif
2901 if (__res[0] == 64) {
2902 return (__res[1] + 64) >> 3;
2903 }
2904 return __res[0] >> 3;
2905}
2906
2907static __inline__ unsigned __ATTRS_o_ai
2908vec_first_mismatch_or_eos_index(vector signed short __a,
2909 vector signed short __b) {
2910 vector unsigned long long __res =
2911#ifdef __LITTLE_ENDIAN__
2912 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2913#else
2914 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2915#endif
2916 if (__res[0] == 64) {
2917 return (__res[1] + 64) >> 4;
2918 }
2919 return __res[0] >> 4;
2920}
2921
2922static __inline__ unsigned __ATTRS_o_ai
2923vec_first_mismatch_or_eos_index(vector unsigned short __a,
2924 vector unsigned short __b) {
2925 vector unsigned long long __res =
2926#ifdef __LITTLE_ENDIAN__
2927 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2928#else
2929 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2930#endif
2931 if (__res[0] == 64) {
2932 return (__res[1] + 64) >> 4;
2933 }
2934 return __res[0] >> 4;
2935}
2936
2937static __inline__ unsigned __ATTRS_o_ai
2938vec_first_mismatch_or_eos_index(vector signed int __a, vector signed int __b) {
2939 vector unsigned long long __res =
2940#ifdef __LITTLE_ENDIAN__
2941 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2942#else
2943 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2944#endif
2945 if (__res[0] == 64) {
2946 return (__res[1] + 64) >> 5;
2947 }
2948 return __res[0] >> 5;
2949}
2950
2951static __inline__ unsigned __ATTRS_o_ai
2952vec_first_mismatch_or_eos_index(vector unsigned int __a,
2953 vector unsigned int __b) {
2954 vector unsigned long long __res =
2955#ifdef __LITTLE_ENDIAN__
2956 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2957#else
2958 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2959#endif
2960 if (__res[0] == 64) {
2961 return (__res[1] + 64) >> 5;
2962 }
2963 return __res[0] >> 5;
2964}
2965
2966static __inline__ vector double __ATTRS_o_ai
2967vec_insert_exp(vector double __a, vector unsigned long long __b) {
2968 return __builtin_vsx_xviexpdp((vector unsigned long long)__a,__b);
2969}
2970
2971static __inline__ vector double __ATTRS_o_ai
2972vec_insert_exp(vector unsigned long long __a, vector unsigned long long __b) {
2973 return __builtin_vsx_xviexpdp(__a,__b);
2974}
2975
2976static __inline__ vector float __ATTRS_o_ai
2977vec_insert_exp(vector float __a, vector unsigned int __b) {
2978 return __builtin_vsx_xviexpsp((vector unsigned int)__a,__b);
2979}
2980
2981static __inline__ vector float __ATTRS_o_ai
2982vec_insert_exp(vector unsigned int __a, vector unsigned int __b) {
2983 return __builtin_vsx_xviexpsp(__a,__b);
2984}
2985
2986#if defined(__powerpc64__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002987static __inline__ vector signed char __ATTRS_o_ai vec_xl_len(const signed char *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08002988 size_t __b) {
2989 return (vector signed char)__builtin_vsx_lxvl(__a, (__b << 56));
2990}
2991
2992static __inline__ vector unsigned char __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002993vec_xl_len(const unsigned char *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08002994 return (vector unsigned char)__builtin_vsx_lxvl(__a, (__b << 56));
2995}
2996
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002997static __inline__ vector signed short __ATTRS_o_ai vec_xl_len(const signed short *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08002998 size_t __b) {
2999 return (vector signed short)__builtin_vsx_lxvl(__a, (__b << 56));
3000}
3001
3002static __inline__ vector unsigned short __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003003vec_xl_len(const unsigned short *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003004 return (vector unsigned short)__builtin_vsx_lxvl(__a, (__b << 56));
3005}
3006
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003007static __inline__ vector signed int __ATTRS_o_ai vec_xl_len(const signed int *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003008 size_t __b) {
3009 return (vector signed int)__builtin_vsx_lxvl(__a, (__b << 56));
3010}
3011
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003012static __inline__ vector unsigned int __ATTRS_o_ai vec_xl_len(const unsigned int *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003013 size_t __b) {
3014 return (vector unsigned int)__builtin_vsx_lxvl(__a, (__b << 56));
3015}
3016
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003017static __inline__ vector float __ATTRS_o_ai vec_xl_len(const float *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003018 return (vector float)__builtin_vsx_lxvl(__a, (__b << 56));
3019}
3020
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003021#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +08003022static __inline__ vector signed __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003023vec_xl_len(const signed __int128 *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003024 return (vector signed __int128)__builtin_vsx_lxvl(__a, (__b << 56));
3025}
3026
3027static __inline__ vector unsigned __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003028vec_xl_len(const unsigned __int128 *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003029 return (vector unsigned __int128)__builtin_vsx_lxvl(__a, (__b << 56));
3030}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003031#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08003032
3033static __inline__ vector signed long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003034vec_xl_len(const signed long long *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003035 return (vector signed long long)__builtin_vsx_lxvl(__a, (__b << 56));
3036}
3037
3038static __inline__ vector unsigned long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003039vec_xl_len(const unsigned long long *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003040 return (vector unsigned long long)__builtin_vsx_lxvl(__a, (__b << 56));
3041}
3042
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003043static __inline__ vector double __ATTRS_o_ai vec_xl_len(const double *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003044 size_t __b) {
3045 return (vector double)__builtin_vsx_lxvl(__a, (__b << 56));
3046}
3047
Sasha Smundak746b0222020-02-25 09:19:04 -08003048static __inline__ vector unsigned char __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003049vec_xl_len_r(const unsigned char *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003050 vector unsigned char __res =
3051 (vector unsigned char)__builtin_vsx_lxvll(__a, (__b << 56));
Logan Chien55afb0a2018-10-15 10:42:14 +08003052 vector unsigned char __mask =
3053 (vector unsigned char)__builtin_altivec_lvsr(16 - __b, (int *)NULL);
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08003054 return (vector unsigned char)__builtin_altivec_vperm_4si(
Logan Chien55afb0a2018-10-15 10:42:14 +08003055 (vector int)__res, (vector int)__res, __mask);
Logan Chien55afb0a2018-10-15 10:42:14 +08003056}
3057
3058// vec_xst_len
3059static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned char __a,
3060 unsigned char *__b,
3061 size_t __c) {
3062 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3063}
3064
3065static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed char __a,
3066 signed char *__b, size_t __c) {
3067 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3068}
3069
3070static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed short __a,
3071 signed short *__b, size_t __c) {
3072 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3073}
3074
3075static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned short __a,
3076 unsigned short *__b,
3077 size_t __c) {
3078 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3079}
3080
3081static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed int __a,
3082 signed int *__b, size_t __c) {
3083 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3084}
3085
3086static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned int __a,
3087 unsigned int *__b, size_t __c) {
3088 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3089}
3090
3091static __inline__ void __ATTRS_o_ai vec_xst_len(vector float __a, float *__b,
3092 size_t __c) {
3093 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3094}
3095
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003096#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +08003097static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed __int128 __a,
3098 signed __int128 *__b,
3099 size_t __c) {
3100 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3101}
3102
3103static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned __int128 __a,
3104 unsigned __int128 *__b,
3105 size_t __c) {
3106 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3107}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003108#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08003109
3110static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed long long __a,
3111 signed long long *__b,
3112 size_t __c) {
3113 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3114}
3115
3116static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned long long __a,
3117 unsigned long long *__b,
3118 size_t __c) {
3119 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3120}
3121
3122static __inline__ void __ATTRS_o_ai vec_xst_len(vector double __a, double *__b,
3123 size_t __c) {
3124 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3125}
3126
3127static __inline__ void __ATTRS_o_ai vec_xst_len_r(vector unsigned char __a,
3128 unsigned char *__b,
3129 size_t __c) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003130 vector unsigned char __mask =
3131 (vector unsigned char)__builtin_altivec_lvsl(16 - __c, (int *)NULL);
3132 vector unsigned char __res =
3133 __builtin_altivec_vperm_4si((vector int)__a, (vector int)__a, __mask);
3134 return __builtin_vsx_stxvll((vector int)__res, __b, (__c << 56));
Logan Chien55afb0a2018-10-15 10:42:14 +08003135}
3136#endif
3137#endif
3138
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08003139#if defined(__POWER9_VECTOR__) && defined(__powerpc64__)
3140#define __vec_ldrmb(PTR, CNT) vec_xl_len_r((const unsigned char *)(PTR), (CNT))
3141#define __vec_strmb(PTR, CNT, VAL) \
3142 vec_xst_len_r((VAL), (unsigned char *)(PTR), (CNT))
3143#else
3144#define __vec_ldrmb __builtin_vsx_ldrmb
3145#define __vec_strmb __builtin_vsx_strmb
3146#endif
3147
Logan Chien2833ffb2018-10-09 10:03:24 +08003148/* vec_cpsgn */
3149
3150#ifdef __VSX__
3151static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a,
3152 vector float __b) {
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07003153 return __builtin_vsx_xvcpsgnsp(__b, __a);
Logan Chien2833ffb2018-10-09 10:03:24 +08003154}
3155
3156static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
3157 vector double __b) {
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07003158 return __builtin_vsx_xvcpsgndp(__b, __a);
Logan Chien2833ffb2018-10-09 10:03:24 +08003159}
3160#endif
3161
3162/* vec_ctf */
3163
Logan Chien2833ffb2018-10-09 10:03:24 +08003164#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003165// There are some functions that have different signatures with the XL compiler
3166// from those in Clang/GCC and documented in the PVIPR. This macro ensures that
3167// the XL-compatible signatures are used for those functions.
3168#ifdef __XL_COMPAT_ALTIVEC__
3169#define vec_ctf(__a, __b) \
3170 _Generic((__a), vector int \
3171 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
3172 vector unsigned int \
3173 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3174 (__b)), \
3175 vector unsigned long long \
3176 : (__builtin_vsx_xvcvuxdsp((vector unsigned long long)(__a)) * \
3177 (vector float)(vector unsigned)((0x7f - (__b)) << 23)), \
3178 vector signed long long \
3179 : (__builtin_vsx_xvcvsxdsp((vector signed long long)(__a)) * \
3180 (vector float)(vector unsigned)((0x7f - (__b)) << 23)))
3181#else // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003182#define vec_ctf(__a, __b) \
3183 _Generic((__a), vector int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003184 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
Logan Chien55afb0a2018-10-15 10:42:14 +08003185 vector unsigned int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003186 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3187 (__b)), \
Logan Chien55afb0a2018-10-15 10:42:14 +08003188 vector unsigned long long \
3189 : (__builtin_convertvector((vector unsigned long long)(__a), \
3190 vector double) * \
3191 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3192 << 52)), \
3193 vector signed long long \
3194 : (__builtin_convertvector((vector signed long long)(__a), \
3195 vector double) * \
3196 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3197 << 52)))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003198#endif // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003199#else
3200#define vec_ctf(__a, __b) \
3201 _Generic((__a), vector int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003202 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
Logan Chien55afb0a2018-10-15 10:42:14 +08003203 vector unsigned int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003204 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3205 (__b)))
Logan Chien2833ffb2018-10-09 10:03:24 +08003206#endif
3207
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003208/* vec_ctd */
3209#ifdef __VSX__
3210#define vec_ctd(__a, __b) \
3211 _Generic((__a), vector signed int \
3212 : (vec_doublee((vector signed int)(__a)) * \
3213 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3214 << 52)), \
3215 vector unsigned int \
3216 : (vec_doublee((vector unsigned int)(__a)) * \
3217 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3218 << 52)), \
3219 vector unsigned long long \
3220 : (__builtin_convertvector((vector unsigned long long)(__a), \
3221 vector double) * \
3222 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3223 << 52)), \
3224 vector signed long long \
3225 : (__builtin_convertvector((vector signed long long)(__a), \
3226 vector double) * \
3227 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3228 << 52)))
3229#endif // __VSX__
3230
Logan Chien2833ffb2018-10-09 10:03:24 +08003231/* vec_vcfsx */
3232
Logan Chien55afb0a2018-10-15 10:42:14 +08003233#define vec_vcfux __builtin_altivec_vcfux
Logan Chien2833ffb2018-10-09 10:03:24 +08003234/* vec_vcfux */
3235
Logan Chien55afb0a2018-10-15 10:42:14 +08003236#define vec_vcfsx(__a, __b) __builtin_altivec_vcfsx((vector int)(__a), (__b))
Logan Chien2833ffb2018-10-09 10:03:24 +08003237
3238/* vec_cts */
3239
Logan Chien2833ffb2018-10-09 10:03:24 +08003240#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003241#ifdef __XL_COMPAT_ALTIVEC__
3242#define vec_cts(__a, __b) \
3243 _Generic((__a), vector float \
3244 : __builtin_altivec_vctsxs((vector float)(__a), (__b)), \
3245 vector double \
3246 : __extension__({ \
3247 vector double __ret = \
3248 (vector double)(__a) * \
3249 (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
3250 << 52); \
3251 __builtin_vsx_xvcvdpsxws(__ret); \
3252 }))
3253#else // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003254#define vec_cts(__a, __b) \
3255 _Generic((__a), vector float \
Sasha Smundak746b0222020-02-25 09:19:04 -08003256 : __builtin_altivec_vctsxs((vector float)(__a), (__b)), \
3257 vector double \
Logan Chien55afb0a2018-10-15 10:42:14 +08003258 : __extension__({ \
3259 vector double __ret = \
Sasha Smundak746b0222020-02-25 09:19:04 -08003260 (vector double)(__a) * \
Logan Chien55afb0a2018-10-15 10:42:14 +08003261 (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
3262 << 52); \
3263 __builtin_convertvector(__ret, vector signed long long); \
3264 }))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003265#endif // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003266#else
3267#define vec_cts __builtin_altivec_vctsxs
Logan Chien2833ffb2018-10-09 10:03:24 +08003268#endif
3269
3270/* vec_vctsxs */
3271
Logan Chien55afb0a2018-10-15 10:42:14 +08003272#define vec_vctsxs __builtin_altivec_vctsxs
Logan Chien2833ffb2018-10-09 10:03:24 +08003273
3274/* vec_ctu */
3275
Logan Chien2833ffb2018-10-09 10:03:24 +08003276#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003277#ifdef __XL_COMPAT_ALTIVEC__
3278#define vec_ctu(__a, __b) \
3279 _Generic((__a), vector float \
3280 : __builtin_altivec_vctuxs((vector float)(__a), (__b)), \
3281 vector double \
3282 : __extension__({ \
3283 vector double __ret = \
3284 (vector double)(__a) * \
3285 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3286 << 52); \
3287 __builtin_vsx_xvcvdpuxws(__ret); \
3288 }))
3289#else // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003290#define vec_ctu(__a, __b) \
3291 _Generic((__a), vector float \
Sasha Smundak746b0222020-02-25 09:19:04 -08003292 : __builtin_altivec_vctuxs((vector float)(__a), (__b)), \
3293 vector double \
Logan Chien55afb0a2018-10-15 10:42:14 +08003294 : __extension__({ \
3295 vector double __ret = \
Sasha Smundak746b0222020-02-25 09:19:04 -08003296 (vector double)(__a) * \
Logan Chien55afb0a2018-10-15 10:42:14 +08003297 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3298 << 52); \
3299 __builtin_convertvector(__ret, vector unsigned long long); \
3300 }))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003301#endif // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003302#else
3303#define vec_ctu __builtin_altivec_vctuxs
Logan Chien2833ffb2018-10-09 10:03:24 +08003304#endif
3305
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003306#ifdef __LITTLE_ENDIAN__
3307/* vec_ctsl */
3308
3309#ifdef __VSX__
3310#define vec_ctsl(__a, __b) \
3311 _Generic((__a), vector float \
3312 : __extension__({ \
3313 vector float __ret = \
3314 (vector float)(__a) * \
3315 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3316 __builtin_vsx_xvcvspsxds( \
3317 __builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3318 }), \
3319 vector double \
3320 : __extension__({ \
3321 vector double __ret = \
3322 (vector double)(__a) * \
3323 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3324 << 52); \
3325 __builtin_convertvector(__ret, vector signed long long); \
3326 }))
3327
3328/* vec_ctul */
3329
3330#define vec_ctul(__a, __b) \
3331 _Generic((__a), vector float \
3332 : __extension__({ \
3333 vector float __ret = \
3334 (vector float)(__a) * \
3335 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3336 __builtin_vsx_xvcvspuxds( \
3337 __builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3338 }), \
3339 vector double \
3340 : __extension__({ \
3341 vector double __ret = \
3342 (vector double)(__a) * \
3343 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3344 << 52); \
3345 __builtin_convertvector(__ret, vector unsigned long long); \
3346 }))
3347#endif
3348#else // __LITTLE_ENDIAN__
3349/* vec_ctsl */
3350
3351#ifdef __VSX__
3352#define vec_ctsl(__a, __b) \
3353 _Generic((__a), vector float \
3354 : __extension__({ \
3355 vector float __ret = \
3356 (vector float)(__a) * \
3357 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3358 __builtin_vsx_xvcvspsxds(__ret); \
3359 }), \
3360 vector double \
3361 : __extension__({ \
3362 vector double __ret = \
3363 (vector double)(__a) * \
3364 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3365 << 52); \
3366 __builtin_convertvector(__ret, vector signed long long); \
3367 }))
3368
3369/* vec_ctul */
3370
3371#define vec_ctul(__a, __b) \
3372 _Generic((__a), vector float \
3373 : __extension__({ \
3374 vector float __ret = \
3375 (vector float)(__a) * \
3376 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3377 __builtin_vsx_xvcvspuxds(__ret); \
3378 }), \
3379 vector double \
3380 : __extension__({ \
3381 vector double __ret = \
3382 (vector double)(__a) * \
3383 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3384 << 52); \
3385 __builtin_convertvector(__ret, vector unsigned long long); \
3386 }))
3387#endif
3388#endif // __LITTLE_ENDIAN__
3389
Logan Chien2833ffb2018-10-09 10:03:24 +08003390/* vec_vctuxs */
3391
Logan Chien55afb0a2018-10-15 10:42:14 +08003392#define vec_vctuxs __builtin_altivec_vctuxs
3393
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003394/* vec_signext */
3395
3396#ifdef __POWER9_VECTOR__
3397static __inline__ vector signed int __ATTRS_o_ai
3398vec_signexti(vector signed char __a) {
3399 return __builtin_altivec_vextsb2w(__a);
3400}
3401
3402static __inline__ vector signed int __ATTRS_o_ai
3403vec_signexti(vector signed short __a) {
3404 return __builtin_altivec_vextsh2w(__a);
3405}
3406
3407static __inline__ vector signed long long __ATTRS_o_ai
3408vec_signextll(vector signed char __a) {
3409 return __builtin_altivec_vextsb2d(__a);
3410}
3411
3412static __inline__ vector signed long long __ATTRS_o_ai
3413vec_signextll(vector signed short __a) {
3414 return __builtin_altivec_vextsh2d(__a);
3415}
3416
3417static __inline__ vector signed long long __ATTRS_o_ai
3418vec_signextll(vector signed int __a) {
3419 return __builtin_altivec_vextsw2d(__a);
3420}
3421#endif
3422
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003423#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003424static __inline__ vector signed __int128 __ATTRS_o_ai
3425vec_signextq(vector signed long long __a) {
3426 return __builtin_altivec_vextsd2q(__a);
3427}
3428#endif
3429
Logan Chien55afb0a2018-10-15 10:42:14 +08003430/* vec_signed */
3431
3432static __inline__ vector signed int __ATTRS_o_ai
3433vec_sld(vector signed int, vector signed int, unsigned const int __c);
3434
3435static __inline__ vector signed int __ATTRS_o_ai
3436vec_signed(vector float __a) {
3437 return __builtin_convertvector(__a, vector signed int);
Logan Chien2833ffb2018-10-09 10:03:24 +08003438}
3439
Logan Chien55afb0a2018-10-15 10:42:14 +08003440#ifdef __VSX__
3441static __inline__ vector signed long long __ATTRS_o_ai
3442vec_signed(vector double __a) {
3443 return __builtin_convertvector(__a, vector signed long long);
3444}
3445
3446static __inline__ vector signed int __attribute__((__always_inline__))
3447vec_signed2(vector double __a, vector double __b) {
3448 return (vector signed int) { __a[0], __a[1], __b[0], __b[1] };
3449}
3450
3451static __inline__ vector signed int __ATTRS_o_ai
3452vec_signede(vector double __a) {
3453#ifdef __LITTLE_ENDIAN__
3454 vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a);
3455 return vec_sld(__ret, __ret, 12);
3456#else
3457 return __builtin_vsx_xvcvdpsxws(__a);
3458#endif
3459}
3460
3461static __inline__ vector signed int __ATTRS_o_ai
3462vec_signedo(vector double __a) {
3463#ifdef __LITTLE_ENDIAN__
3464 return __builtin_vsx_xvcvdpsxws(__a);
3465#else
3466 vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a);
3467 return vec_sld(__ret, __ret, 12);
3468#endif
3469}
3470#endif
3471
3472/* vec_unsigned */
3473
3474static __inline__ vector unsigned int __ATTRS_o_ai
3475vec_sld(vector unsigned int, vector unsigned int, unsigned const int __c);
3476
3477static __inline__ vector unsigned int __ATTRS_o_ai
3478vec_unsigned(vector float __a) {
3479 return __builtin_convertvector(__a, vector unsigned int);
3480}
3481
3482#ifdef __VSX__
3483static __inline__ vector unsigned long long __ATTRS_o_ai
3484vec_unsigned(vector double __a) {
3485 return __builtin_convertvector(__a, vector unsigned long long);
3486}
3487
3488static __inline__ vector unsigned int __attribute__((__always_inline__))
3489vec_unsigned2(vector double __a, vector double __b) {
3490 return (vector unsigned int) { __a[0], __a[1], __b[0], __b[1] };
3491}
3492
3493static __inline__ vector unsigned int __ATTRS_o_ai
3494vec_unsignede(vector double __a) {
3495#ifdef __LITTLE_ENDIAN__
3496 vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a);
3497 return vec_sld(__ret, __ret, 12);
3498#else
3499 return __builtin_vsx_xvcvdpuxws(__a);
3500#endif
3501}
3502
3503static __inline__ vector unsigned int __ATTRS_o_ai
3504vec_unsignedo(vector double __a) {
3505#ifdef __LITTLE_ENDIAN__
3506 return __builtin_vsx_xvcvdpuxws(__a);
3507#else
3508 vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a);
3509 return vec_sld(__ret, __ret, 12);
3510#endif
3511}
3512#endif
3513
3514/* vec_float */
3515
3516static __inline__ vector float __ATTRS_o_ai
3517vec_sld(vector float, vector float, unsigned const int __c);
3518
3519static __inline__ vector float __ATTRS_o_ai
3520vec_float(vector signed int __a) {
3521 return __builtin_convertvector(__a, vector float);
3522}
3523
3524static __inline__ vector float __ATTRS_o_ai
3525vec_float(vector unsigned int __a) {
3526 return __builtin_convertvector(__a, vector float);
3527}
3528
3529#ifdef __VSX__
3530static __inline__ vector float __ATTRS_o_ai
3531vec_float2(vector signed long long __a, vector signed long long __b) {
3532 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3533}
3534
3535static __inline__ vector float __ATTRS_o_ai
3536vec_float2(vector unsigned long long __a, vector unsigned long long __b) {
3537 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3538}
3539
3540static __inline__ vector float __ATTRS_o_ai
3541vec_float2(vector double __a, vector double __b) {
3542 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3543}
3544
3545static __inline__ vector float __ATTRS_o_ai
3546vec_floate(vector signed long long __a) {
3547#ifdef __LITTLE_ENDIAN__
3548 vector float __ret = __builtin_vsx_xvcvsxdsp(__a);
3549 return vec_sld(__ret, __ret, 12);
3550#else
3551 return __builtin_vsx_xvcvsxdsp(__a);
3552#endif
3553}
3554
3555static __inline__ vector float __ATTRS_o_ai
3556vec_floate(vector unsigned long long __a) {
3557#ifdef __LITTLE_ENDIAN__
3558 vector float __ret = __builtin_vsx_xvcvuxdsp(__a);
3559 return vec_sld(__ret, __ret, 12);
3560#else
3561 return __builtin_vsx_xvcvuxdsp(__a);
3562#endif
3563}
3564
3565static __inline__ vector float __ATTRS_o_ai
3566vec_floate(vector double __a) {
3567#ifdef __LITTLE_ENDIAN__
3568 vector float __ret = __builtin_vsx_xvcvdpsp(__a);
3569 return vec_sld(__ret, __ret, 12);
3570#else
3571 return __builtin_vsx_xvcvdpsp(__a);
3572#endif
3573}
3574
3575static __inline__ vector float __ATTRS_o_ai
3576vec_floato(vector signed long long __a) {
3577#ifdef __LITTLE_ENDIAN__
3578 return __builtin_vsx_xvcvsxdsp(__a);
3579#else
3580 vector float __ret = __builtin_vsx_xvcvsxdsp(__a);
3581 return vec_sld(__ret, __ret, 12);
3582#endif
3583}
3584
3585static __inline__ vector float __ATTRS_o_ai
3586vec_floato(vector unsigned long long __a) {
3587#ifdef __LITTLE_ENDIAN__
3588 return __builtin_vsx_xvcvuxdsp(__a);
3589#else
3590 vector float __ret = __builtin_vsx_xvcvuxdsp(__a);
3591 return vec_sld(__ret, __ret, 12);
3592#endif
3593}
3594
3595static __inline__ vector float __ATTRS_o_ai
3596vec_floato(vector double __a) {
3597#ifdef __LITTLE_ENDIAN__
3598 return __builtin_vsx_xvcvdpsp(__a);
3599#else
3600 vector float __ret = __builtin_vsx_xvcvdpsp(__a);
3601 return vec_sld(__ret, __ret, 12);
3602#endif
3603}
3604#endif
3605
Logan Chien2833ffb2018-10-09 10:03:24 +08003606/* vec_double */
3607
3608#ifdef __VSX__
3609static __inline__ vector double __ATTRS_o_ai
3610vec_double(vector signed long long __a) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003611 return __builtin_convertvector(__a, vector double);
3612}
3613
3614static __inline__ vector double __ATTRS_o_ai
3615vec_double(vector unsigned long long __a) {
3616 return __builtin_convertvector(__a, vector double);
3617}
3618
3619static __inline__ vector double __ATTRS_o_ai
3620vec_doublee(vector signed int __a) {
3621#ifdef __LITTLE_ENDIAN__
3622 return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4));
3623#else
3624 return __builtin_vsx_xvcvsxwdp(__a);
3625#endif
3626}
3627
3628static __inline__ vector double __ATTRS_o_ai
3629vec_doublee(vector unsigned int __a) {
3630#ifdef __LITTLE_ENDIAN__
3631 return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4));
3632#else
3633 return __builtin_vsx_xvcvuxwdp(__a);
3634#endif
3635}
3636
3637static __inline__ vector double __ATTRS_o_ai
3638vec_doublee(vector float __a) {
3639#ifdef __LITTLE_ENDIAN__
3640 return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4));
3641#else
3642 return __builtin_vsx_xvcvspdp(__a);
3643#endif
3644}
3645
3646static __inline__ vector double __ATTRS_o_ai
3647vec_doubleh(vector signed int __a) {
Logan Chien2833ffb2018-10-09 10:03:24 +08003648 vector double __ret = {__a[0], __a[1]};
3649 return __ret;
3650}
3651
3652static __inline__ vector double __ATTRS_o_ai
Logan Chien55afb0a2018-10-15 10:42:14 +08003653vec_doubleh(vector unsigned int __a) {
Logan Chien2833ffb2018-10-09 10:03:24 +08003654 vector double __ret = {__a[0], __a[1]};
3655 return __ret;
3656}
Logan Chien55afb0a2018-10-15 10:42:14 +08003657
3658static __inline__ vector double __ATTRS_o_ai
3659vec_doubleh(vector float __a) {
3660 vector double __ret = {__a[0], __a[1]};
3661 return __ret;
3662}
3663
3664static __inline__ vector double __ATTRS_o_ai
3665vec_doublel(vector signed int __a) {
3666 vector double __ret = {__a[2], __a[3]};
3667 return __ret;
3668}
3669
3670static __inline__ vector double __ATTRS_o_ai
3671vec_doublel(vector unsigned int __a) {
3672 vector double __ret = {__a[2], __a[3]};
3673 return __ret;
3674}
3675
3676static __inline__ vector double __ATTRS_o_ai
3677vec_doublel(vector float __a) {
3678 vector double __ret = {__a[2], __a[3]};
3679 return __ret;
3680}
3681
3682static __inline__ vector double __ATTRS_o_ai
3683vec_doubleo(vector signed int __a) {
3684#ifdef __LITTLE_ENDIAN__
3685 return __builtin_vsx_xvcvsxwdp(__a);
3686#else
3687 return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4));
3688#endif
3689}
3690
3691static __inline__ vector double __ATTRS_o_ai
3692vec_doubleo(vector unsigned int __a) {
3693#ifdef __LITTLE_ENDIAN__
3694 return __builtin_vsx_xvcvuxwdp(__a);
3695#else
3696 return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4));
3697#endif
3698}
3699
3700static __inline__ vector double __ATTRS_o_ai
3701vec_doubleo(vector float __a) {
3702#ifdef __LITTLE_ENDIAN__
3703 return __builtin_vsx_xvcvspdp(__a);
3704#else
3705 return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4));
3706#endif
3707}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003708
3709/* vec_cvf */
3710static __inline__ vector double __ATTRS_o_ai vec_cvf(vector float __a) {
3711 return vec_doublee(__a);
3712}
3713
3714static __inline__ vector float __ATTRS_o_ai vec_cvf(vector double __a) {
3715 return vec_floate(__a);
3716}
Logan Chien2833ffb2018-10-09 10:03:24 +08003717#endif
3718
3719/* vec_div */
3720
3721/* Integer vector divides (vectors are scalarized, elements divided
3722 and the vectors reassembled).
3723*/
3724static __inline__ vector signed char __ATTRS_o_ai
3725vec_div(vector signed char __a, vector signed char __b) {
3726 return __a / __b;
3727}
3728
3729static __inline__ vector unsigned char __ATTRS_o_ai
3730vec_div(vector unsigned char __a, vector unsigned char __b) {
3731 return __a / __b;
3732}
3733
3734static __inline__ vector signed short __ATTRS_o_ai
3735vec_div(vector signed short __a, vector signed short __b) {
3736 return __a / __b;
3737}
3738
3739static __inline__ vector unsigned short __ATTRS_o_ai
3740vec_div(vector unsigned short __a, vector unsigned short __b) {
3741 return __a / __b;
3742}
3743
3744static __inline__ vector signed int __ATTRS_o_ai
3745vec_div(vector signed int __a, vector signed int __b) {
3746 return __a / __b;
3747}
3748
3749static __inline__ vector unsigned int __ATTRS_o_ai
3750vec_div(vector unsigned int __a, vector unsigned int __b) {
3751 return __a / __b;
3752}
3753
3754#ifdef __VSX__
3755static __inline__ vector signed long long __ATTRS_o_ai
3756vec_div(vector signed long long __a, vector signed long long __b) {
3757 return __a / __b;
3758}
3759
3760static __inline__ vector unsigned long long __ATTRS_o_ai
3761vec_div(vector unsigned long long __a, vector unsigned long long __b) {
3762 return __a / __b;
3763}
3764
3765static __inline__ vector float __ATTRS_o_ai vec_div(vector float __a,
3766 vector float __b) {
3767 return __a / __b;
3768}
3769
3770static __inline__ vector double __ATTRS_o_ai vec_div(vector double __a,
3771 vector double __b) {
3772 return __a / __b;
3773}
3774#endif
3775
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003776/* vec_dive */
3777
3778#ifdef __POWER10_VECTOR__
3779static __inline__ vector signed int __ATTRS_o_ai
3780vec_dive(vector signed int __a, vector signed int __b) {
3781 return __builtin_altivec_vdivesw(__a, __b);
3782}
3783
3784static __inline__ vector unsigned int __ATTRS_o_ai
3785vec_dive(vector unsigned int __a, vector unsigned int __b) {
3786 return __builtin_altivec_vdiveuw(__a, __b);
3787}
3788
3789static __inline__ vector signed long long __ATTRS_o_ai
3790vec_dive(vector signed long long __a, vector signed long long __b) {
3791 return __builtin_altivec_vdivesd(__a, __b);
3792}
3793
3794static __inline__ vector unsigned long long __ATTRS_o_ai
3795vec_dive(vector unsigned long long __a, vector unsigned long long __b) {
3796 return __builtin_altivec_vdiveud(__a, __b);
3797}
3798
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003799#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003800static __inline__ vector unsigned __int128 __ATTRS_o_ai
3801vec_dive(vector unsigned __int128 __a, vector unsigned __int128 __b) {
3802 return __builtin_altivec_vdiveuq(__a, __b);
3803}
3804
3805static __inline__ vector signed __int128 __ATTRS_o_ai
3806vec_dive(vector signed __int128 __a, vector signed __int128 __b) {
3807 return __builtin_altivec_vdivesq(__a, __b);
3808}
3809#endif
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003810#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003811
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003812#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003813static __inline__ vector unsigned __int128 __ATTRS_o_ai
3814vec_div(vector unsigned __int128 __a, vector unsigned __int128 __b) {
3815 return __a / __b;
3816}
3817
3818static __inline__ vector signed __int128 __ATTRS_o_ai
3819vec_div(vector signed __int128 __a, vector signed __int128 __b) {
3820 return __a / __b;
3821}
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07003822#endif /* __POWER10_VECTOR__ */
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003823
3824/* vec_xvtdiv */
3825
3826#ifdef __VSX__
3827static __inline__ int __ATTRS_o_ai vec_test_swdiv(vector double __a,
3828 vector double __b) {
3829 return __builtin_vsx_xvtdivdp(__a, __b);
3830}
3831
3832static __inline__ int __ATTRS_o_ai vec_test_swdivs(vector float __a,
3833 vector float __b) {
3834 return __builtin_vsx_xvtdivsp(__a, __b);
3835}
3836#endif
3837
Logan Chien2833ffb2018-10-09 10:03:24 +08003838/* vec_dss */
3839
Sasha Smundak746b0222020-02-25 09:19:04 -08003840#define vec_dss __builtin_altivec_dss
Logan Chien2833ffb2018-10-09 10:03:24 +08003841
3842/* vec_dssall */
3843
3844static __inline__ void __attribute__((__always_inline__)) vec_dssall(void) {
3845 __builtin_altivec_dssall();
3846}
3847
3848/* vec_dst */
3849#define vec_dst(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003850 __builtin_altivec_dst((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003851
3852/* vec_dstst */
3853#define vec_dstst(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003854 __builtin_altivec_dstst((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003855
3856/* vec_dststt */
3857#define vec_dststt(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003858 __builtin_altivec_dststt((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003859
3860/* vec_dstt */
3861#define vec_dstt(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003862 __builtin_altivec_dstt((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003863
3864/* vec_eqv */
3865
3866#ifdef __POWER8_VECTOR__
3867static __inline__ vector signed char __ATTRS_o_ai
3868vec_eqv(vector signed char __a, vector signed char __b) {
3869 return (vector signed char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3870 (vector unsigned int)__b);
3871}
3872
3873static __inline__ vector unsigned char __ATTRS_o_ai
3874vec_eqv(vector unsigned char __a, vector unsigned char __b) {
3875 return (vector unsigned char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3876 (vector unsigned int)__b);
3877}
3878
3879static __inline__ vector bool char __ATTRS_o_ai vec_eqv(vector bool char __a,
3880 vector bool char __b) {
3881 return (vector bool char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3882 (vector unsigned int)__b);
3883}
3884
3885static __inline__ vector signed short __ATTRS_o_ai
3886vec_eqv(vector signed short __a, vector signed short __b) {
3887 return (vector signed short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3888 (vector unsigned int)__b);
3889}
3890
3891static __inline__ vector unsigned short __ATTRS_o_ai
3892vec_eqv(vector unsigned short __a, vector unsigned short __b) {
3893 return (vector unsigned short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3894 (vector unsigned int)__b);
3895}
3896
3897static __inline__ vector bool short __ATTRS_o_ai
3898vec_eqv(vector bool short __a, vector bool short __b) {
3899 return (vector bool short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3900 (vector unsigned int)__b);
3901}
3902
3903static __inline__ vector signed int __ATTRS_o_ai
3904vec_eqv(vector signed int __a, vector signed int __b) {
3905 return (vector signed int)__builtin_vsx_xxleqv((vector unsigned int)__a,
3906 (vector unsigned int)__b);
3907}
3908
3909static __inline__ vector unsigned int __ATTRS_o_ai
3910vec_eqv(vector unsigned int __a, vector unsigned int __b) {
3911 return __builtin_vsx_xxleqv(__a, __b);
3912}
3913
3914static __inline__ vector bool int __ATTRS_o_ai vec_eqv(vector bool int __a,
3915 vector bool int __b) {
3916 return (vector bool int)__builtin_vsx_xxleqv((vector unsigned int)__a,
3917 (vector unsigned int)__b);
3918}
3919
3920static __inline__ vector signed long long __ATTRS_o_ai
3921vec_eqv(vector signed long long __a, vector signed long long __b) {
3922 return (vector signed long long)__builtin_vsx_xxleqv(
3923 (vector unsigned int)__a, (vector unsigned int)__b);
3924}
3925
3926static __inline__ vector unsigned long long __ATTRS_o_ai
3927vec_eqv(vector unsigned long long __a, vector unsigned long long __b) {
3928 return (vector unsigned long long)__builtin_vsx_xxleqv(
3929 (vector unsigned int)__a, (vector unsigned int)__b);
3930}
3931
3932static __inline__ vector bool long long __ATTRS_o_ai
3933vec_eqv(vector bool long long __a, vector bool long long __b) {
3934 return (vector bool long long)__builtin_vsx_xxleqv((vector unsigned int)__a,
3935 (vector unsigned int)__b);
3936}
3937
3938static __inline__ vector float __ATTRS_o_ai vec_eqv(vector float __a,
3939 vector float __b) {
3940 return (vector float)__builtin_vsx_xxleqv((vector unsigned int)__a,
3941 (vector unsigned int)__b);
3942}
3943
3944static __inline__ vector double __ATTRS_o_ai vec_eqv(vector double __a,
3945 vector double __b) {
3946 return (vector double)__builtin_vsx_xxleqv((vector unsigned int)__a,
3947 (vector unsigned int)__b);
3948}
3949#endif
3950
3951/* vec_expte */
3952
3953static __inline__ vector float __attribute__((__always_inline__))
3954vec_expte(vector float __a) {
3955 return __builtin_altivec_vexptefp(__a);
3956}
3957
3958/* vec_vexptefp */
3959
3960static __inline__ vector float __attribute__((__always_inline__))
3961vec_vexptefp(vector float __a) {
3962 return __builtin_altivec_vexptefp(__a);
3963}
3964
3965/* vec_floor */
3966
3967static __inline__ vector float __ATTRS_o_ai vec_floor(vector float __a) {
3968#ifdef __VSX__
3969 return __builtin_vsx_xvrspim(__a);
3970#else
3971 return __builtin_altivec_vrfim(__a);
3972#endif
3973}
3974
3975#ifdef __VSX__
3976static __inline__ vector double __ATTRS_o_ai vec_floor(vector double __a) {
3977 return __builtin_vsx_xvrdpim(__a);
3978}
3979#endif
3980
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003981/* vec_roundm */
3982static __inline__ vector float __ATTRS_o_ai vec_roundm(vector float __a) {
3983 return vec_floor(__a);
3984}
3985
3986#ifdef __VSX__
3987static __inline__ vector double __ATTRS_o_ai vec_roundm(vector double __a) {
3988 return vec_floor(__a);
3989}
3990#endif
3991
Logan Chien2833ffb2018-10-09 10:03:24 +08003992/* vec_vrfim */
3993
3994static __inline__ vector float __attribute__((__always_inline__))
3995vec_vrfim(vector float __a) {
3996 return __builtin_altivec_vrfim(__a);
3997}
3998
3999/* vec_ld */
4000
4001static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004002vec_ld(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004003 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4004}
4005
4006static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004007vec_ld(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004008 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4009}
4010
4011static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004012vec_ld(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004013 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4014}
4015
4016static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004017vec_ld(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004018 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4019}
4020
4021static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004022vec_ld(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004023 return (vector bool char)__builtin_altivec_lvx(__a, __b);
4024}
4025
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004026static __inline__ vector short __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004027 const vector short *__b) {
4028 return (vector short)__builtin_altivec_lvx(__a, __b);
4029}
4030
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004031static __inline__ vector short __ATTRS_o_ai vec_ld(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004032 return (vector short)__builtin_altivec_lvx(__a, __b);
4033}
4034
4035static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004036vec_ld(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004037 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4038}
4039
4040static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004041vec_ld(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004042 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4043}
4044
4045static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004046vec_ld(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004047 return (vector bool short)__builtin_altivec_lvx(__a, __b);
4048}
4049
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004050static __inline__ vector pixel __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004051 const vector pixel *__b) {
4052 return (vector pixel)__builtin_altivec_lvx(__a, __b);
4053}
4054
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004055static __inline__ vector int __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004056 const vector int *__b) {
4057 return (vector int)__builtin_altivec_lvx(__a, __b);
4058}
4059
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004060static __inline__ vector int __ATTRS_o_ai vec_ld(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004061 return (vector int)__builtin_altivec_lvx(__a, __b);
4062}
4063
4064static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004065vec_ld(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004066 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4067}
4068
4069static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004070vec_ld(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004071 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4072}
4073
4074static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004075vec_ld(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004076 return (vector bool int)__builtin_altivec_lvx(__a, __b);
4077}
4078
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004079static __inline__ vector float __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004080 const vector float *__b) {
4081 return (vector float)__builtin_altivec_lvx(__a, __b);
4082}
4083
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004084static __inline__ vector float __ATTRS_o_ai vec_ld(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004085 return (vector float)__builtin_altivec_lvx(__a, __b);
4086}
4087
4088/* vec_lvx */
4089
4090static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004091vec_lvx(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004092 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4093}
4094
4095static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004096vec_lvx(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004097 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4098}
4099
4100static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004101vec_lvx(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004102 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4103}
4104
4105static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004106vec_lvx(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004107 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4108}
4109
4110static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004111vec_lvx(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004112 return (vector bool char)__builtin_altivec_lvx(__a, __b);
4113}
4114
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004115static __inline__ vector short __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004116 const vector short *__b) {
4117 return (vector short)__builtin_altivec_lvx(__a, __b);
4118}
4119
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004120static __inline__ vector short __ATTRS_o_ai vec_lvx(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004121 return (vector short)__builtin_altivec_lvx(__a, __b);
4122}
4123
4124static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004125vec_lvx(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004126 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4127}
4128
4129static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004130vec_lvx(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004131 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4132}
4133
4134static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004135vec_lvx(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004136 return (vector bool short)__builtin_altivec_lvx(__a, __b);
4137}
4138
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004139static __inline__ vector pixel __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004140 const vector pixel *__b) {
4141 return (vector pixel)__builtin_altivec_lvx(__a, __b);
4142}
4143
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004144static __inline__ vector int __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004145 const vector int *__b) {
4146 return (vector int)__builtin_altivec_lvx(__a, __b);
4147}
4148
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004149static __inline__ vector int __ATTRS_o_ai vec_lvx(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004150 return (vector int)__builtin_altivec_lvx(__a, __b);
4151}
4152
4153static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004154vec_lvx(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004155 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4156}
4157
4158static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004159vec_lvx(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004160 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4161}
4162
4163static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004164vec_lvx(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004165 return (vector bool int)__builtin_altivec_lvx(__a, __b);
4166}
4167
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004168static __inline__ vector float __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004169 const vector float *__b) {
4170 return (vector float)__builtin_altivec_lvx(__a, __b);
4171}
4172
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004173static __inline__ vector float __ATTRS_o_ai vec_lvx(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004174 return (vector float)__builtin_altivec_lvx(__a, __b);
4175}
4176
4177/* vec_lde */
4178
4179static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004180vec_lde(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004181 return (vector signed char)__builtin_altivec_lvebx(__a, __b);
4182}
4183
4184static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004185vec_lde(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004186 return (vector unsigned char)__builtin_altivec_lvebx(__a, __b);
4187}
4188
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004189static __inline__ vector short __ATTRS_o_ai vec_lde(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004190 return (vector short)__builtin_altivec_lvehx(__a, __b);
4191}
4192
4193static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004194vec_lde(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004195 return (vector unsigned short)__builtin_altivec_lvehx(__a, __b);
4196}
4197
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004198static __inline__ vector int __ATTRS_o_ai vec_lde(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004199 return (vector int)__builtin_altivec_lvewx(__a, __b);
4200}
4201
4202static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004203vec_lde(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004204 return (vector unsigned int)__builtin_altivec_lvewx(__a, __b);
4205}
4206
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004207static __inline__ vector float __ATTRS_o_ai vec_lde(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004208 return (vector float)__builtin_altivec_lvewx(__a, __b);
4209}
4210
4211/* vec_lvebx */
4212
4213static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004214vec_lvebx(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004215 return (vector signed char)__builtin_altivec_lvebx(__a, __b);
4216}
4217
4218static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004219vec_lvebx(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004220 return (vector unsigned char)__builtin_altivec_lvebx(__a, __b);
4221}
4222
4223/* vec_lvehx */
4224
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004225static __inline__ vector short __ATTRS_o_ai vec_lvehx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004226 const short *__b) {
4227 return (vector short)__builtin_altivec_lvehx(__a, __b);
4228}
4229
4230static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004231vec_lvehx(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004232 return (vector unsigned short)__builtin_altivec_lvehx(__a, __b);
4233}
4234
4235/* vec_lvewx */
4236
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004237static __inline__ vector int __ATTRS_o_ai vec_lvewx(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004238 return (vector int)__builtin_altivec_lvewx(__a, __b);
4239}
4240
4241static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004242vec_lvewx(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004243 return (vector unsigned int)__builtin_altivec_lvewx(__a, __b);
4244}
4245
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004246static __inline__ vector float __ATTRS_o_ai vec_lvewx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004247 const float *__b) {
4248 return (vector float)__builtin_altivec_lvewx(__a, __b);
4249}
4250
4251/* vec_ldl */
4252
4253static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004254vec_ldl(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004255 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4256}
4257
4258static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004259vec_ldl(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004260 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4261}
4262
4263static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004264vec_ldl(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004265 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4266}
4267
4268static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004269vec_ldl(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004270 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4271}
4272
4273static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004274vec_ldl(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004275 return (vector bool char)__builtin_altivec_lvxl(__a, __b);
4276}
4277
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004278static __inline__ vector short __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004279 const vector short *__b) {
4280 return (vector short)__builtin_altivec_lvxl(__a, __b);
4281}
4282
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004283static __inline__ vector short __ATTRS_o_ai vec_ldl(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004284 return (vector short)__builtin_altivec_lvxl(__a, __b);
4285}
4286
4287static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004288vec_ldl(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004289 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4290}
4291
4292static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004293vec_ldl(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004294 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4295}
4296
4297static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004298vec_ldl(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004299 return (vector bool short)__builtin_altivec_lvxl(__a, __b);
4300}
4301
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004302static __inline__ vector pixel __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004303 const vector pixel *__b) {
4304 return (vector pixel short)__builtin_altivec_lvxl(__a, __b);
4305}
4306
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004307static __inline__ vector int __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004308 const vector int *__b) {
4309 return (vector int)__builtin_altivec_lvxl(__a, __b);
4310}
4311
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004312static __inline__ vector int __ATTRS_o_ai vec_ldl(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004313 return (vector int)__builtin_altivec_lvxl(__a, __b);
4314}
4315
4316static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004317vec_ldl(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004318 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4319}
4320
4321static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004322vec_ldl(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004323 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4324}
4325
4326static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004327vec_ldl(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004328 return (vector bool int)__builtin_altivec_lvxl(__a, __b);
4329}
4330
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004331static __inline__ vector float __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004332 const vector float *__b) {
4333 return (vector float)__builtin_altivec_lvxl(__a, __b);
4334}
4335
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004336static __inline__ vector float __ATTRS_o_ai vec_ldl(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004337 return (vector float)__builtin_altivec_lvxl(__a, __b);
4338}
4339
4340/* vec_lvxl */
4341
4342static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004343vec_lvxl(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004344 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4345}
4346
4347static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004348vec_lvxl(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004349 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4350}
4351
4352static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004353vec_lvxl(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004354 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4355}
4356
4357static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004358vec_lvxl(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004359 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4360}
4361
4362static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004363vec_lvxl(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004364 return (vector bool char)__builtin_altivec_lvxl(__a, __b);
4365}
4366
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004367static __inline__ vector short __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004368 const vector short *__b) {
4369 return (vector short)__builtin_altivec_lvxl(__a, __b);
4370}
4371
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004372static __inline__ vector short __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004373 const short *__b) {
4374 return (vector short)__builtin_altivec_lvxl(__a, __b);
4375}
4376
4377static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004378vec_lvxl(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004379 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4380}
4381
4382static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004383vec_lvxl(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004384 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4385}
4386
4387static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004388vec_lvxl(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004389 return (vector bool short)__builtin_altivec_lvxl(__a, __b);
4390}
4391
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004392static __inline__ vector pixel __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004393 const vector pixel *__b) {
4394 return (vector pixel)__builtin_altivec_lvxl(__a, __b);
4395}
4396
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004397static __inline__ vector int __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004398 const vector int *__b) {
4399 return (vector int)__builtin_altivec_lvxl(__a, __b);
4400}
4401
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004402static __inline__ vector int __ATTRS_o_ai vec_lvxl(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004403 return (vector int)__builtin_altivec_lvxl(__a, __b);
4404}
4405
4406static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004407vec_lvxl(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004408 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4409}
4410
4411static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004412vec_lvxl(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004413 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4414}
4415
4416static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004417vec_lvxl(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004418 return (vector bool int)__builtin_altivec_lvxl(__a, __b);
4419}
4420
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004421static __inline__ vector float __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004422 const vector float *__b) {
4423 return (vector float)__builtin_altivec_lvxl(__a, __b);
4424}
4425
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004426static __inline__ vector float __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004427 const float *__b) {
4428 return (vector float)__builtin_altivec_lvxl(__a, __b);
4429}
4430
4431/* vec_loge */
4432
4433static __inline__ vector float __attribute__((__always_inline__))
4434vec_loge(vector float __a) {
4435 return __builtin_altivec_vlogefp(__a);
4436}
4437
4438/* vec_vlogefp */
4439
4440static __inline__ vector float __attribute__((__always_inline__))
4441vec_vlogefp(vector float __a) {
4442 return __builtin_altivec_vlogefp(__a);
4443}
4444
4445/* vec_lvsl */
4446
4447#ifdef __LITTLE_ENDIAN__
4448static __inline__ vector unsigned char __ATTRS_o_ai
4449 __attribute__((__deprecated__("use assignment for unaligned little endian \
4450loads/stores"))) vec_lvsl(int __a, const signed char *__b) {
4451 vector unsigned char mask =
4452 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4453 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4454 7, 6, 5, 4, 3, 2, 1, 0};
4455 return vec_perm(mask, mask, reverse);
4456}
4457#else
4458static __inline__ vector unsigned char __ATTRS_o_ai
4459vec_lvsl(int __a, const signed char *__b) {
4460 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4461}
4462#endif
4463
4464#ifdef __LITTLE_ENDIAN__
4465static __inline__ vector unsigned char __ATTRS_o_ai
4466 __attribute__((__deprecated__("use assignment for unaligned little endian \
4467loads/stores"))) vec_lvsl(int __a, const unsigned char *__b) {
4468 vector unsigned char mask =
4469 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4470 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4471 7, 6, 5, 4, 3, 2, 1, 0};
4472 return vec_perm(mask, mask, reverse);
4473}
4474#else
4475static __inline__ vector unsigned char __ATTRS_o_ai
4476vec_lvsl(int __a, const unsigned char *__b) {
4477 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4478}
4479#endif
4480
4481#ifdef __LITTLE_ENDIAN__
4482static __inline__ vector unsigned char __ATTRS_o_ai
4483 __attribute__((__deprecated__("use assignment for unaligned little endian \
4484loads/stores"))) vec_lvsl(int __a, const short *__b) {
4485 vector unsigned char mask =
4486 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4487 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4488 7, 6, 5, 4, 3, 2, 1, 0};
4489 return vec_perm(mask, mask, reverse);
4490}
4491#else
4492static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
4493 const short *__b) {
4494 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4495}
4496#endif
4497
4498#ifdef __LITTLE_ENDIAN__
4499static __inline__ vector unsigned char __ATTRS_o_ai
4500 __attribute__((__deprecated__("use assignment for unaligned little endian \
4501loads/stores"))) vec_lvsl(int __a, const unsigned short *__b) {
4502 vector unsigned char mask =
4503 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4504 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4505 7, 6, 5, 4, 3, 2, 1, 0};
4506 return vec_perm(mask, mask, reverse);
4507}
4508#else
4509static __inline__ vector unsigned char __ATTRS_o_ai
4510vec_lvsl(int __a, const unsigned short *__b) {
4511 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4512}
4513#endif
4514
4515#ifdef __LITTLE_ENDIAN__
4516static __inline__ vector unsigned char __ATTRS_o_ai
4517 __attribute__((__deprecated__("use assignment for unaligned little endian \
4518loads/stores"))) vec_lvsl(int __a, const int *__b) {
4519 vector unsigned char mask =
4520 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4521 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4522 7, 6, 5, 4, 3, 2, 1, 0};
4523 return vec_perm(mask, mask, reverse);
4524}
4525#else
4526static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
4527 const int *__b) {
4528 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4529}
4530#endif
4531
4532#ifdef __LITTLE_ENDIAN__
4533static __inline__ vector unsigned char __ATTRS_o_ai
4534 __attribute__((__deprecated__("use assignment for unaligned little endian \
4535loads/stores"))) vec_lvsl(int __a, const unsigned int *__b) {
4536 vector unsigned char mask =
4537 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4538 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4539 7, 6, 5, 4, 3, 2, 1, 0};
4540 return vec_perm(mask, mask, reverse);
4541}
4542#else
4543static __inline__ vector unsigned char __ATTRS_o_ai
4544vec_lvsl(int __a, const unsigned int *__b) {
4545 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4546}
4547#endif
4548
4549#ifdef __LITTLE_ENDIAN__
4550static __inline__ vector unsigned char __ATTRS_o_ai
4551 __attribute__((__deprecated__("use assignment for unaligned little endian \
4552loads/stores"))) vec_lvsl(int __a, const float *__b) {
4553 vector unsigned char mask =
4554 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4555 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4556 7, 6, 5, 4, 3, 2, 1, 0};
4557 return vec_perm(mask, mask, reverse);
4558}
4559#else
4560static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
4561 const float *__b) {
4562 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4563}
4564#endif
4565
4566/* vec_lvsr */
4567
4568#ifdef __LITTLE_ENDIAN__
4569static __inline__ vector unsigned char __ATTRS_o_ai
4570 __attribute__((__deprecated__("use assignment for unaligned little endian \
4571loads/stores"))) vec_lvsr(int __a, const signed char *__b) {
4572 vector unsigned char mask =
4573 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4574 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4575 7, 6, 5, 4, 3, 2, 1, 0};
4576 return vec_perm(mask, mask, reverse);
4577}
4578#else
4579static __inline__ vector unsigned char __ATTRS_o_ai
4580vec_lvsr(int __a, const signed char *__b) {
4581 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4582}
4583#endif
4584
4585#ifdef __LITTLE_ENDIAN__
4586static __inline__ vector unsigned char __ATTRS_o_ai
4587 __attribute__((__deprecated__("use assignment for unaligned little endian \
4588loads/stores"))) vec_lvsr(int __a, const unsigned char *__b) {
4589 vector unsigned char mask =
4590 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4591 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4592 7, 6, 5, 4, 3, 2, 1, 0};
4593 return vec_perm(mask, mask, reverse);
4594}
4595#else
4596static __inline__ vector unsigned char __ATTRS_o_ai
4597vec_lvsr(int __a, const unsigned char *__b) {
4598 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4599}
4600#endif
4601
4602#ifdef __LITTLE_ENDIAN__
4603static __inline__ vector unsigned char __ATTRS_o_ai
4604 __attribute__((__deprecated__("use assignment for unaligned little endian \
4605loads/stores"))) vec_lvsr(int __a, const short *__b) {
4606 vector unsigned char mask =
4607 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4608 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4609 7, 6, 5, 4, 3, 2, 1, 0};
4610 return vec_perm(mask, mask, reverse);
4611}
4612#else
4613static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
4614 const short *__b) {
4615 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4616}
4617#endif
4618
4619#ifdef __LITTLE_ENDIAN__
4620static __inline__ vector unsigned char __ATTRS_o_ai
4621 __attribute__((__deprecated__("use assignment for unaligned little endian \
4622loads/stores"))) vec_lvsr(int __a, const unsigned short *__b) {
4623 vector unsigned char mask =
4624 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4625 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4626 7, 6, 5, 4, 3, 2, 1, 0};
4627 return vec_perm(mask, mask, reverse);
4628}
4629#else
4630static __inline__ vector unsigned char __ATTRS_o_ai
4631vec_lvsr(int __a, const unsigned short *__b) {
4632 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4633}
4634#endif
4635
4636#ifdef __LITTLE_ENDIAN__
4637static __inline__ vector unsigned char __ATTRS_o_ai
4638 __attribute__((__deprecated__("use assignment for unaligned little endian \
4639loads/stores"))) vec_lvsr(int __a, const int *__b) {
4640 vector unsigned char mask =
4641 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4642 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4643 7, 6, 5, 4, 3, 2, 1, 0};
4644 return vec_perm(mask, mask, reverse);
4645}
4646#else
4647static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
4648 const int *__b) {
4649 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4650}
4651#endif
4652
4653#ifdef __LITTLE_ENDIAN__
4654static __inline__ vector unsigned char __ATTRS_o_ai
4655 __attribute__((__deprecated__("use assignment for unaligned little endian \
4656loads/stores"))) vec_lvsr(int __a, const unsigned int *__b) {
4657 vector unsigned char mask =
4658 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4659 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4660 7, 6, 5, 4, 3, 2, 1, 0};
4661 return vec_perm(mask, mask, reverse);
4662}
4663#else
4664static __inline__ vector unsigned char __ATTRS_o_ai
4665vec_lvsr(int __a, const unsigned int *__b) {
4666 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4667}
4668#endif
4669
4670#ifdef __LITTLE_ENDIAN__
4671static __inline__ vector unsigned char __ATTRS_o_ai
4672 __attribute__((__deprecated__("use assignment for unaligned little endian \
4673loads/stores"))) vec_lvsr(int __a, const float *__b) {
4674 vector unsigned char mask =
4675 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4676 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4677 7, 6, 5, 4, 3, 2, 1, 0};
4678 return vec_perm(mask, mask, reverse);
4679}
4680#else
4681static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
4682 const float *__b) {
4683 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4684}
4685#endif
4686
4687/* vec_madd */
4688static __inline__ vector signed short __ATTRS_o_ai
4689vec_mladd(vector signed short, vector signed short, vector signed short);
4690static __inline__ vector signed short __ATTRS_o_ai
4691vec_mladd(vector signed short, vector unsigned short, vector unsigned short);
4692static __inline__ vector signed short __ATTRS_o_ai
4693vec_mladd(vector unsigned short, vector signed short, vector signed short);
4694static __inline__ vector unsigned short __ATTRS_o_ai
4695vec_mladd(vector unsigned short, vector unsigned short, vector unsigned short);
4696
4697static __inline__ vector signed short __ATTRS_o_ai vec_madd(
4698 vector signed short __a, vector signed short __b, vector signed short __c) {
4699 return vec_mladd(__a, __b, __c);
4700}
4701
4702static __inline__ vector signed short __ATTRS_o_ai
4703vec_madd(vector signed short __a, vector unsigned short __b,
4704 vector unsigned short __c) {
4705 return vec_mladd(__a, __b, __c);
4706}
4707
4708static __inline__ vector signed short __ATTRS_o_ai
4709vec_madd(vector unsigned short __a, vector signed short __b,
4710 vector signed short __c) {
4711 return vec_mladd(__a, __b, __c);
4712}
4713
4714static __inline__ vector unsigned short __ATTRS_o_ai
4715vec_madd(vector unsigned short __a, vector unsigned short __b,
4716 vector unsigned short __c) {
4717 return vec_mladd(__a, __b, __c);
4718}
4719
4720static __inline__ vector float __ATTRS_o_ai vec_madd(vector float __a,
4721 vector float __b,
4722 vector float __c) {
4723#ifdef __VSX__
4724 return __builtin_vsx_xvmaddasp(__a, __b, __c);
4725#else
4726 return __builtin_altivec_vmaddfp(__a, __b, __c);
4727#endif
4728}
4729
4730#ifdef __VSX__
4731static __inline__ vector double __ATTRS_o_ai vec_madd(vector double __a,
4732 vector double __b,
4733 vector double __c) {
4734 return __builtin_vsx_xvmaddadp(__a, __b, __c);
4735}
4736#endif
4737
4738/* vec_vmaddfp */
4739
4740static __inline__ vector float __attribute__((__always_inline__))
4741vec_vmaddfp(vector float __a, vector float __b, vector float __c) {
4742 return __builtin_altivec_vmaddfp(__a, __b, __c);
4743}
4744
4745/* vec_madds */
4746
4747static __inline__ vector signed short __attribute__((__always_inline__))
4748vec_madds(vector signed short __a, vector signed short __b,
4749 vector signed short __c) {
4750 return __builtin_altivec_vmhaddshs(__a, __b, __c);
4751}
4752
4753/* vec_vmhaddshs */
4754static __inline__ vector signed short __attribute__((__always_inline__))
4755vec_vmhaddshs(vector signed short __a, vector signed short __b,
4756 vector signed short __c) {
4757 return __builtin_altivec_vmhaddshs(__a, __b, __c);
4758}
4759
4760/* vec_msub */
4761
4762#ifdef __VSX__
4763static __inline__ vector float __ATTRS_o_ai vec_msub(vector float __a,
4764 vector float __b,
4765 vector float __c) {
4766 return __builtin_vsx_xvmsubasp(__a, __b, __c);
4767}
4768
4769static __inline__ vector double __ATTRS_o_ai vec_msub(vector double __a,
4770 vector double __b,
4771 vector double __c) {
4772 return __builtin_vsx_xvmsubadp(__a, __b, __c);
4773}
4774#endif
4775
4776/* vec_max */
4777
4778static __inline__ vector signed char __ATTRS_o_ai
4779vec_max(vector signed char __a, vector signed char __b) {
4780 return __builtin_altivec_vmaxsb(__a, __b);
4781}
4782
4783static __inline__ vector signed char __ATTRS_o_ai
4784vec_max(vector bool char __a, vector signed char __b) {
4785 return __builtin_altivec_vmaxsb((vector signed char)__a, __b);
4786}
4787
4788static __inline__ vector signed char __ATTRS_o_ai
4789vec_max(vector signed char __a, vector bool char __b) {
4790 return __builtin_altivec_vmaxsb(__a, (vector signed char)__b);
4791}
4792
4793static __inline__ vector unsigned char __ATTRS_o_ai
4794vec_max(vector unsigned char __a, vector unsigned char __b) {
4795 return __builtin_altivec_vmaxub(__a, __b);
4796}
4797
4798static __inline__ vector unsigned char __ATTRS_o_ai
4799vec_max(vector bool char __a, vector unsigned char __b) {
4800 return __builtin_altivec_vmaxub((vector unsigned char)__a, __b);
4801}
4802
4803static __inline__ vector unsigned char __ATTRS_o_ai
4804vec_max(vector unsigned char __a, vector bool char __b) {
4805 return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b);
4806}
4807
4808static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a,
4809 vector short __b) {
4810 return __builtin_altivec_vmaxsh(__a, __b);
4811}
4812
4813static __inline__ vector short __ATTRS_o_ai vec_max(vector bool short __a,
4814 vector short __b) {
4815 return __builtin_altivec_vmaxsh((vector short)__a, __b);
4816}
4817
4818static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a,
4819 vector bool short __b) {
4820 return __builtin_altivec_vmaxsh(__a, (vector short)__b);
4821}
4822
4823static __inline__ vector unsigned short __ATTRS_o_ai
4824vec_max(vector unsigned short __a, vector unsigned short __b) {
4825 return __builtin_altivec_vmaxuh(__a, __b);
4826}
4827
4828static __inline__ vector unsigned short __ATTRS_o_ai
4829vec_max(vector bool short __a, vector unsigned short __b) {
4830 return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b);
4831}
4832
4833static __inline__ vector unsigned short __ATTRS_o_ai
4834vec_max(vector unsigned short __a, vector bool short __b) {
4835 return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b);
4836}
4837
4838static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a,
4839 vector int __b) {
4840 return __builtin_altivec_vmaxsw(__a, __b);
4841}
4842
4843static __inline__ vector int __ATTRS_o_ai vec_max(vector bool int __a,
4844 vector int __b) {
4845 return __builtin_altivec_vmaxsw((vector int)__a, __b);
4846}
4847
4848static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a,
4849 vector bool int __b) {
4850 return __builtin_altivec_vmaxsw(__a, (vector int)__b);
4851}
4852
4853static __inline__ vector unsigned int __ATTRS_o_ai
4854vec_max(vector unsigned int __a, vector unsigned int __b) {
4855 return __builtin_altivec_vmaxuw(__a, __b);
4856}
4857
4858static __inline__ vector unsigned int __ATTRS_o_ai
4859vec_max(vector bool int __a, vector unsigned int __b) {
4860 return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b);
4861}
4862
4863static __inline__ vector unsigned int __ATTRS_o_ai
4864vec_max(vector unsigned int __a, vector bool int __b) {
4865 return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b);
4866}
4867
4868#ifdef __POWER8_VECTOR__
4869static __inline__ vector signed long long __ATTRS_o_ai
4870vec_max(vector signed long long __a, vector signed long long __b) {
4871 return __builtin_altivec_vmaxsd(__a, __b);
4872}
4873
4874static __inline__ vector signed long long __ATTRS_o_ai
4875vec_max(vector bool long long __a, vector signed long long __b) {
4876 return __builtin_altivec_vmaxsd((vector signed long long)__a, __b);
4877}
4878
4879static __inline__ vector signed long long __ATTRS_o_ai
4880vec_max(vector signed long long __a, vector bool long long __b) {
4881 return __builtin_altivec_vmaxsd(__a, (vector signed long long)__b);
4882}
4883
4884static __inline__ vector unsigned long long __ATTRS_o_ai
4885vec_max(vector unsigned long long __a, vector unsigned long long __b) {
4886 return __builtin_altivec_vmaxud(__a, __b);
4887}
4888
4889static __inline__ vector unsigned long long __ATTRS_o_ai
4890vec_max(vector bool long long __a, vector unsigned long long __b) {
4891 return __builtin_altivec_vmaxud((vector unsigned long long)__a, __b);
4892}
4893
4894static __inline__ vector unsigned long long __ATTRS_o_ai
4895vec_max(vector unsigned long long __a, vector bool long long __b) {
4896 return __builtin_altivec_vmaxud(__a, (vector unsigned long long)__b);
4897}
4898#endif
4899
4900static __inline__ vector float __ATTRS_o_ai vec_max(vector float __a,
4901 vector float __b) {
4902#ifdef __VSX__
4903 return __builtin_vsx_xvmaxsp(__a, __b);
4904#else
4905 return __builtin_altivec_vmaxfp(__a, __b);
4906#endif
4907}
4908
4909#ifdef __VSX__
4910static __inline__ vector double __ATTRS_o_ai vec_max(vector double __a,
4911 vector double __b) {
4912 return __builtin_vsx_xvmaxdp(__a, __b);
4913}
4914#endif
4915
4916/* vec_vmaxsb */
4917
4918static __inline__ vector signed char __ATTRS_o_ai
4919vec_vmaxsb(vector signed char __a, vector signed char __b) {
4920 return __builtin_altivec_vmaxsb(__a, __b);
4921}
4922
4923static __inline__ vector signed char __ATTRS_o_ai
4924vec_vmaxsb(vector bool char __a, vector signed char __b) {
4925 return __builtin_altivec_vmaxsb((vector signed char)__a, __b);
4926}
4927
4928static __inline__ vector signed char __ATTRS_o_ai
4929vec_vmaxsb(vector signed char __a, vector bool char __b) {
4930 return __builtin_altivec_vmaxsb(__a, (vector signed char)__b);
4931}
4932
4933/* vec_vmaxub */
4934
4935static __inline__ vector unsigned char __ATTRS_o_ai
4936vec_vmaxub(vector unsigned char __a, vector unsigned char __b) {
4937 return __builtin_altivec_vmaxub(__a, __b);
4938}
4939
4940static __inline__ vector unsigned char __ATTRS_o_ai
4941vec_vmaxub(vector bool char __a, vector unsigned char __b) {
4942 return __builtin_altivec_vmaxub((vector unsigned char)__a, __b);
4943}
4944
4945static __inline__ vector unsigned char __ATTRS_o_ai
4946vec_vmaxub(vector unsigned char __a, vector bool char __b) {
4947 return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b);
4948}
4949
4950/* vec_vmaxsh */
4951
4952static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a,
4953 vector short __b) {
4954 return __builtin_altivec_vmaxsh(__a, __b);
4955}
4956
4957static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector bool short __a,
4958 vector short __b) {
4959 return __builtin_altivec_vmaxsh((vector short)__a, __b);
4960}
4961
4962static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a,
4963 vector bool short __b) {
4964 return __builtin_altivec_vmaxsh(__a, (vector short)__b);
4965}
4966
4967/* vec_vmaxuh */
4968
4969static __inline__ vector unsigned short __ATTRS_o_ai
4970vec_vmaxuh(vector unsigned short __a, vector unsigned short __b) {
4971 return __builtin_altivec_vmaxuh(__a, __b);
4972}
4973
4974static __inline__ vector unsigned short __ATTRS_o_ai
4975vec_vmaxuh(vector bool short __a, vector unsigned short __b) {
4976 return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b);
4977}
4978
4979static __inline__ vector unsigned short __ATTRS_o_ai
4980vec_vmaxuh(vector unsigned short __a, vector bool short __b) {
4981 return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b);
4982}
4983
4984/* vec_vmaxsw */
4985
4986static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a,
4987 vector int __b) {
4988 return __builtin_altivec_vmaxsw(__a, __b);
4989}
4990
4991static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector bool int __a,
4992 vector int __b) {
4993 return __builtin_altivec_vmaxsw((vector int)__a, __b);
4994}
4995
4996static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a,
4997 vector bool int __b) {
4998 return __builtin_altivec_vmaxsw(__a, (vector int)__b);
4999}
5000
5001/* vec_vmaxuw */
5002
5003static __inline__ vector unsigned int __ATTRS_o_ai
5004vec_vmaxuw(vector unsigned int __a, vector unsigned int __b) {
5005 return __builtin_altivec_vmaxuw(__a, __b);
5006}
5007
5008static __inline__ vector unsigned int __ATTRS_o_ai
5009vec_vmaxuw(vector bool int __a, vector unsigned int __b) {
5010 return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b);
5011}
5012
5013static __inline__ vector unsigned int __ATTRS_o_ai
5014vec_vmaxuw(vector unsigned int __a, vector bool int __b) {
5015 return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b);
5016}
5017
5018/* vec_vmaxfp */
5019
5020static __inline__ vector float __attribute__((__always_inline__))
5021vec_vmaxfp(vector float __a, vector float __b) {
5022#ifdef __VSX__
5023 return __builtin_vsx_xvmaxsp(__a, __b);
5024#else
5025 return __builtin_altivec_vmaxfp(__a, __b);
5026#endif
5027}
5028
5029/* vec_mergeh */
5030
5031static __inline__ vector signed char __ATTRS_o_ai
5032vec_mergeh(vector signed char __a, vector signed char __b) {
5033 return vec_perm(__a, __b,
5034 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5035 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5036 0x06, 0x16, 0x07, 0x17));
5037}
5038
5039static __inline__ vector unsigned char __ATTRS_o_ai
5040vec_mergeh(vector unsigned char __a, vector unsigned char __b) {
5041 return vec_perm(__a, __b,
5042 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5043 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5044 0x06, 0x16, 0x07, 0x17));
5045}
5046
5047static __inline__ vector bool char __ATTRS_o_ai
5048vec_mergeh(vector bool char __a, vector bool char __b) {
5049 return vec_perm(__a, __b,
5050 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5051 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5052 0x06, 0x16, 0x07, 0x17));
5053}
5054
5055static __inline__ vector short __ATTRS_o_ai vec_mergeh(vector short __a,
5056 vector short __b) {
5057 return vec_perm(__a, __b,
5058 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5059 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5060 0x06, 0x07, 0x16, 0x17));
5061}
5062
5063static __inline__ vector unsigned short __ATTRS_o_ai
5064vec_mergeh(vector unsigned short __a, vector unsigned short __b) {
5065 return vec_perm(__a, __b,
5066 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5067 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5068 0x06, 0x07, 0x16, 0x17));
5069}
5070
5071static __inline__ vector bool short __ATTRS_o_ai
5072vec_mergeh(vector bool short __a, vector bool short __b) {
5073 return vec_perm(__a, __b,
5074 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5075 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5076 0x06, 0x07, 0x16, 0x17));
5077}
5078
5079static __inline__ vector pixel __ATTRS_o_ai vec_mergeh(vector pixel __a,
5080 vector pixel __b) {
5081 return vec_perm(__a, __b,
5082 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5083 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5084 0x06, 0x07, 0x16, 0x17));
5085}
5086
5087static __inline__ vector int __ATTRS_o_ai vec_mergeh(vector int __a,
5088 vector int __b) {
5089 return vec_perm(__a, __b,
5090 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5091 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5092 0x14, 0x15, 0x16, 0x17));
5093}
5094
5095static __inline__ vector unsigned int __ATTRS_o_ai
5096vec_mergeh(vector unsigned int __a, vector unsigned int __b) {
5097 return vec_perm(__a, __b,
5098 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5099 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5100 0x14, 0x15, 0x16, 0x17));
5101}
5102
5103static __inline__ vector bool int __ATTRS_o_ai vec_mergeh(vector bool int __a,
5104 vector bool int __b) {
5105 return vec_perm(__a, __b,
5106 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5107 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5108 0x14, 0x15, 0x16, 0x17));
5109}
5110
5111static __inline__ vector float __ATTRS_o_ai vec_mergeh(vector float __a,
5112 vector float __b) {
5113 return vec_perm(__a, __b,
5114 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5115 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5116 0x14, 0x15, 0x16, 0x17));
5117}
5118
5119#ifdef __VSX__
5120static __inline__ vector signed long long __ATTRS_o_ai
5121vec_mergeh(vector signed long long __a, vector signed long long __b) {
5122 return vec_perm(__a, __b,
5123 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5124 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5125 0x14, 0x15, 0x16, 0x17));
5126}
5127
5128static __inline__ vector signed long long __ATTRS_o_ai
5129vec_mergeh(vector signed long long __a, vector bool long long __b) {
5130 return vec_perm(__a, (vector signed long long)__b,
5131 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5132 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5133 0x14, 0x15, 0x16, 0x17));
5134}
5135
5136static __inline__ vector signed long long __ATTRS_o_ai
5137vec_mergeh(vector bool long long __a, vector signed long long __b) {
5138 return vec_perm((vector signed long long)__a, __b,
5139 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5140 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5141 0x14, 0x15, 0x16, 0x17));
5142}
5143
5144static __inline__ vector unsigned long long __ATTRS_o_ai
5145vec_mergeh(vector unsigned long long __a, vector unsigned long long __b) {
5146 return vec_perm(__a, __b,
5147 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5148 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5149 0x14, 0x15, 0x16, 0x17));
5150}
5151
5152static __inline__ vector unsigned long long __ATTRS_o_ai
5153vec_mergeh(vector unsigned long long __a, vector bool long long __b) {
5154 return vec_perm(__a, (vector unsigned long long)__b,
5155 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5156 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5157 0x14, 0x15, 0x16, 0x17));
5158}
5159
5160static __inline__ vector unsigned long long __ATTRS_o_ai
5161vec_mergeh(vector bool long long __a, vector unsigned long long __b) {
5162 return vec_perm((vector unsigned long long)__a, __b,
5163 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5164 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5165 0x14, 0x15, 0x16, 0x17));
5166}
5167
5168static __inline__ vector bool long long __ATTRS_o_ai
5169vec_mergeh(vector bool long long __a, vector bool long long __b) {
5170 return vec_perm(__a, __b,
5171 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5172 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5173 0x14, 0x15, 0x16, 0x17));
5174}
5175
5176static __inline__ vector double __ATTRS_o_ai vec_mergeh(vector double __a,
5177 vector double __b) {
5178 return vec_perm(__a, __b,
5179 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5180 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5181 0x14, 0x15, 0x16, 0x17));
5182}
5183static __inline__ vector double __ATTRS_o_ai
5184vec_mergeh(vector double __a, vector bool long long __b) {
5185 return vec_perm(__a, (vector double)__b,
5186 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5187 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5188 0x14, 0x15, 0x16, 0x17));
5189}
5190static __inline__ vector double __ATTRS_o_ai
5191vec_mergeh(vector bool long long __a, vector double __b) {
5192 return vec_perm((vector double)__a, __b,
5193 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5194 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5195 0x14, 0x15, 0x16, 0x17));
5196}
5197#endif
5198
5199/* vec_vmrghb */
5200
5201#define __builtin_altivec_vmrghb vec_vmrghb
5202
5203static __inline__ vector signed char __ATTRS_o_ai
5204vec_vmrghb(vector signed char __a, vector signed char __b) {
5205 return vec_perm(__a, __b,
5206 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5207 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5208 0x06, 0x16, 0x07, 0x17));
5209}
5210
5211static __inline__ vector unsigned char __ATTRS_o_ai
5212vec_vmrghb(vector unsigned char __a, vector unsigned char __b) {
5213 return vec_perm(__a, __b,
5214 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5215 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5216 0x06, 0x16, 0x07, 0x17));
5217}
5218
5219static __inline__ vector bool char __ATTRS_o_ai
5220vec_vmrghb(vector bool char __a, vector bool char __b) {
5221 return vec_perm(__a, __b,
5222 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5223 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5224 0x06, 0x16, 0x07, 0x17));
5225}
5226
5227/* vec_vmrghh */
5228
5229#define __builtin_altivec_vmrghh vec_vmrghh
5230
5231static __inline__ vector short __ATTRS_o_ai vec_vmrghh(vector short __a,
5232 vector short __b) {
5233 return vec_perm(__a, __b,
5234 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5235 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5236 0x06, 0x07, 0x16, 0x17));
5237}
5238
5239static __inline__ vector unsigned short __ATTRS_o_ai
5240vec_vmrghh(vector unsigned short __a, vector unsigned short __b) {
5241 return vec_perm(__a, __b,
5242 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5243 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5244 0x06, 0x07, 0x16, 0x17));
5245}
5246
5247static __inline__ vector bool short __ATTRS_o_ai
5248vec_vmrghh(vector bool short __a, vector bool short __b) {
5249 return vec_perm(__a, __b,
5250 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5251 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5252 0x06, 0x07, 0x16, 0x17));
5253}
5254
5255static __inline__ vector pixel __ATTRS_o_ai vec_vmrghh(vector pixel __a,
5256 vector pixel __b) {
5257 return vec_perm(__a, __b,
5258 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5259 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5260 0x06, 0x07, 0x16, 0x17));
5261}
5262
5263/* vec_vmrghw */
5264
5265#define __builtin_altivec_vmrghw vec_vmrghw
5266
5267static __inline__ vector int __ATTRS_o_ai vec_vmrghw(vector int __a,
5268 vector int __b) {
5269 return vec_perm(__a, __b,
5270 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5271 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5272 0x14, 0x15, 0x16, 0x17));
5273}
5274
5275static __inline__ vector unsigned int __ATTRS_o_ai
5276vec_vmrghw(vector unsigned int __a, vector unsigned int __b) {
5277 return vec_perm(__a, __b,
5278 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5279 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5280 0x14, 0x15, 0x16, 0x17));
5281}
5282
5283static __inline__ vector bool int __ATTRS_o_ai vec_vmrghw(vector bool int __a,
5284 vector bool int __b) {
5285 return vec_perm(__a, __b,
5286 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5287 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5288 0x14, 0x15, 0x16, 0x17));
5289}
5290
5291static __inline__ vector float __ATTRS_o_ai vec_vmrghw(vector float __a,
5292 vector float __b) {
5293 return vec_perm(__a, __b,
5294 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5295 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5296 0x14, 0x15, 0x16, 0x17));
5297}
5298
5299/* vec_mergel */
5300
5301static __inline__ vector signed char __ATTRS_o_ai
5302vec_mergel(vector signed char __a, vector signed char __b) {
5303 return vec_perm(__a, __b,
5304 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5305 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5306 0x0E, 0x1E, 0x0F, 0x1F));
5307}
5308
5309static __inline__ vector unsigned char __ATTRS_o_ai
5310vec_mergel(vector unsigned char __a, vector unsigned char __b) {
5311 return vec_perm(__a, __b,
5312 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5313 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5314 0x0E, 0x1E, 0x0F, 0x1F));
5315}
5316
5317static __inline__ vector bool char __ATTRS_o_ai
5318vec_mergel(vector bool char __a, vector bool char __b) {
5319 return vec_perm(__a, __b,
5320 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5321 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5322 0x0E, 0x1E, 0x0F, 0x1F));
5323}
5324
5325static __inline__ vector short __ATTRS_o_ai vec_mergel(vector short __a,
5326 vector short __b) {
5327 return vec_perm(__a, __b,
5328 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5329 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5330 0x0E, 0x0F, 0x1E, 0x1F));
5331}
5332
5333static __inline__ vector unsigned short __ATTRS_o_ai
5334vec_mergel(vector unsigned short __a, vector unsigned short __b) {
5335 return vec_perm(__a, __b,
5336 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5337 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5338 0x0E, 0x0F, 0x1E, 0x1F));
5339}
5340
5341static __inline__ vector bool short __ATTRS_o_ai
5342vec_mergel(vector bool short __a, vector bool short __b) {
5343 return vec_perm(__a, __b,
5344 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5345 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5346 0x0E, 0x0F, 0x1E, 0x1F));
5347}
5348
5349static __inline__ vector pixel __ATTRS_o_ai vec_mergel(vector pixel __a,
5350 vector pixel __b) {
5351 return vec_perm(__a, __b,
5352 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5353 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5354 0x0E, 0x0F, 0x1E, 0x1F));
5355}
5356
5357static __inline__ vector int __ATTRS_o_ai vec_mergel(vector int __a,
5358 vector int __b) {
5359 return vec_perm(__a, __b,
5360 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5361 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5362 0x1C, 0x1D, 0x1E, 0x1F));
5363}
5364
5365static __inline__ vector unsigned int __ATTRS_o_ai
5366vec_mergel(vector unsigned int __a, vector unsigned int __b) {
5367 return vec_perm(__a, __b,
5368 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5369 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5370 0x1C, 0x1D, 0x1E, 0x1F));
5371}
5372
5373static __inline__ vector bool int __ATTRS_o_ai vec_mergel(vector bool int __a,
5374 vector bool int __b) {
5375 return vec_perm(__a, __b,
5376 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5377 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5378 0x1C, 0x1D, 0x1E, 0x1F));
5379}
5380
5381static __inline__ vector float __ATTRS_o_ai vec_mergel(vector float __a,
5382 vector float __b) {
5383 return vec_perm(__a, __b,
5384 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5385 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5386 0x1C, 0x1D, 0x1E, 0x1F));
5387}
5388
5389#ifdef __VSX__
5390static __inline__ vector signed long long __ATTRS_o_ai
5391vec_mergel(vector signed long long __a, vector signed long long __b) {
5392 return vec_perm(__a, __b,
5393 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5394 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5395 0x1C, 0x1D, 0x1E, 0x1F));
5396}
5397static __inline__ vector signed long long __ATTRS_o_ai
5398vec_mergel(vector signed long long __a, vector bool long long __b) {
5399 return vec_perm(__a, (vector signed long long)__b,
5400 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5401 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5402 0x1C, 0x1D, 0x1E, 0x1F));
5403}
5404static __inline__ vector signed long long __ATTRS_o_ai
5405vec_mergel(vector bool long long __a, vector signed long long __b) {
5406 return vec_perm((vector signed long long)__a, __b,
5407 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5408 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5409 0x1C, 0x1D, 0x1E, 0x1F));
5410}
5411static __inline__ vector unsigned long long __ATTRS_o_ai
5412vec_mergel(vector unsigned long long __a, vector unsigned long long __b) {
5413 return vec_perm(__a, __b,
5414 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5415 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5416 0x1C, 0x1D, 0x1E, 0x1F));
5417}
5418static __inline__ vector unsigned long long __ATTRS_o_ai
5419vec_mergel(vector unsigned long long __a, vector bool long long __b) {
5420 return vec_perm(__a, (vector unsigned long long)__b,
5421 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5422 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5423 0x1C, 0x1D, 0x1E, 0x1F));
5424}
5425static __inline__ vector unsigned long long __ATTRS_o_ai
5426vec_mergel(vector bool long long __a, vector unsigned long long __b) {
5427 return vec_perm((vector unsigned long long)__a, __b,
5428 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5429 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5430 0x1C, 0x1D, 0x1E, 0x1F));
5431}
5432static __inline__ vector bool long long __ATTRS_o_ai
5433vec_mergel(vector bool long long __a, vector bool long long __b) {
5434 return vec_perm(__a, __b,
5435 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5436 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5437 0x1C, 0x1D, 0x1E, 0x1F));
5438}
5439static __inline__ vector double __ATTRS_o_ai vec_mergel(vector double __a,
5440 vector double __b) {
5441 return vec_perm(__a, __b,
5442 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5443 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5444 0x1C, 0x1D, 0x1E, 0x1F));
5445}
5446static __inline__ vector double __ATTRS_o_ai
5447vec_mergel(vector double __a, vector bool long long __b) {
5448 return vec_perm(__a, (vector double)__b,
5449 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5450 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5451 0x1C, 0x1D, 0x1E, 0x1F));
5452}
5453static __inline__ vector double __ATTRS_o_ai
5454vec_mergel(vector bool long long __a, vector double __b) {
5455 return vec_perm((vector double)__a, __b,
5456 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5457 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5458 0x1C, 0x1D, 0x1E, 0x1F));
5459}
5460#endif
5461
5462/* vec_vmrglb */
5463
5464#define __builtin_altivec_vmrglb vec_vmrglb
5465
5466static __inline__ vector signed char __ATTRS_o_ai
5467vec_vmrglb(vector signed char __a, vector signed char __b) {
5468 return vec_perm(__a, __b,
5469 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5470 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5471 0x0E, 0x1E, 0x0F, 0x1F));
5472}
5473
5474static __inline__ vector unsigned char __ATTRS_o_ai
5475vec_vmrglb(vector unsigned char __a, vector unsigned char __b) {
5476 return vec_perm(__a, __b,
5477 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5478 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5479 0x0E, 0x1E, 0x0F, 0x1F));
5480}
5481
5482static __inline__ vector bool char __ATTRS_o_ai
5483vec_vmrglb(vector bool char __a, vector bool char __b) {
5484 return vec_perm(__a, __b,
5485 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5486 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5487 0x0E, 0x1E, 0x0F, 0x1F));
5488}
5489
5490/* vec_vmrglh */
5491
5492#define __builtin_altivec_vmrglh vec_vmrglh
5493
5494static __inline__ vector short __ATTRS_o_ai vec_vmrglh(vector short __a,
5495 vector short __b) {
5496 return vec_perm(__a, __b,
5497 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5498 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5499 0x0E, 0x0F, 0x1E, 0x1F));
5500}
5501
5502static __inline__ vector unsigned short __ATTRS_o_ai
5503vec_vmrglh(vector unsigned short __a, vector unsigned short __b) {
5504 return vec_perm(__a, __b,
5505 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5506 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5507 0x0E, 0x0F, 0x1E, 0x1F));
5508}
5509
5510static __inline__ vector bool short __ATTRS_o_ai
5511vec_vmrglh(vector bool short __a, vector bool short __b) {
5512 return vec_perm(__a, __b,
5513 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5514 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5515 0x0E, 0x0F, 0x1E, 0x1F));
5516}
5517
5518static __inline__ vector pixel __ATTRS_o_ai vec_vmrglh(vector pixel __a,
5519 vector pixel __b) {
5520 return vec_perm(__a, __b,
5521 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5522 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5523 0x0E, 0x0F, 0x1E, 0x1F));
5524}
5525
5526/* vec_vmrglw */
5527
5528#define __builtin_altivec_vmrglw vec_vmrglw
5529
5530static __inline__ vector int __ATTRS_o_ai vec_vmrglw(vector int __a,
5531 vector int __b) {
5532 return vec_perm(__a, __b,
5533 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5534 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5535 0x1C, 0x1D, 0x1E, 0x1F));
5536}
5537
5538static __inline__ vector unsigned int __ATTRS_o_ai
5539vec_vmrglw(vector unsigned int __a, vector unsigned int __b) {
5540 return vec_perm(__a, __b,
5541 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5542 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5543 0x1C, 0x1D, 0x1E, 0x1F));
5544}
5545
5546static __inline__ vector bool int __ATTRS_o_ai vec_vmrglw(vector bool int __a,
5547 vector bool int __b) {
5548 return vec_perm(__a, __b,
5549 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5550 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5551 0x1C, 0x1D, 0x1E, 0x1F));
5552}
5553
5554static __inline__ vector float __ATTRS_o_ai vec_vmrglw(vector float __a,
5555 vector float __b) {
5556 return vec_perm(__a, __b,
5557 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5558 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5559 0x1C, 0x1D, 0x1E, 0x1F));
5560}
5561
5562#ifdef __POWER8_VECTOR__
5563/* vec_mergee */
5564
5565static __inline__ vector bool int __ATTRS_o_ai vec_mergee(vector bool int __a,
5566 vector bool int __b) {
5567 return vec_perm(__a, __b,
5568 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5569 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5570 0x18, 0x19, 0x1A, 0x1B));
5571}
5572
5573static __inline__ vector signed int __ATTRS_o_ai
5574vec_mergee(vector signed int __a, vector signed int __b) {
5575 return vec_perm(__a, __b,
5576 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5577 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5578 0x18, 0x19, 0x1A, 0x1B));
5579}
5580
5581static __inline__ vector unsigned int __ATTRS_o_ai
5582vec_mergee(vector unsigned int __a, vector unsigned int __b) {
5583 return vec_perm(__a, __b,
5584 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5585 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5586 0x18, 0x19, 0x1A, 0x1B));
5587}
5588
Logan Chien55afb0a2018-10-15 10:42:14 +08005589static __inline__ vector bool long long __ATTRS_o_ai
5590vec_mergee(vector bool long long __a, vector bool long long __b) {
5591 return vec_mergeh(__a, __b);
5592}
5593
5594static __inline__ vector signed long long __ATTRS_o_ai
5595vec_mergee(vector signed long long __a, vector signed long long __b) {
5596 return vec_mergeh(__a, __b);
5597}
5598
5599static __inline__ vector unsigned long long __ATTRS_o_ai
5600vec_mergee(vector unsigned long long __a, vector unsigned long long __b) {
5601 return vec_mergeh(__a, __b);
5602}
5603
5604static __inline__ vector float __ATTRS_o_ai
5605vec_mergee(vector float __a, vector float __b) {
5606 return vec_perm(__a, __b,
5607 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5608 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5609 0x18, 0x19, 0x1A, 0x1B));
5610}
5611
5612static __inline__ vector double __ATTRS_o_ai
5613vec_mergee(vector double __a, vector double __b) {
5614 return vec_mergeh(__a, __b);
5615}
5616
Logan Chien2833ffb2018-10-09 10:03:24 +08005617/* vec_mergeo */
5618
5619static __inline__ vector bool int __ATTRS_o_ai vec_mergeo(vector bool int __a,
5620 vector bool int __b) {
5621 return vec_perm(__a, __b,
5622 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5623 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5624 0x1C, 0x1D, 0x1E, 0x1F));
5625}
5626
5627static __inline__ vector signed int __ATTRS_o_ai
5628vec_mergeo(vector signed int __a, vector signed int __b) {
5629 return vec_perm(__a, __b,
5630 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5631 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5632 0x1C, 0x1D, 0x1E, 0x1F));
5633}
5634
5635static __inline__ vector unsigned int __ATTRS_o_ai
5636vec_mergeo(vector unsigned int __a, vector unsigned int __b) {
5637 return vec_perm(__a, __b,
5638 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5639 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5640 0x1C, 0x1D, 0x1E, 0x1F));
5641}
5642
Logan Chien55afb0a2018-10-15 10:42:14 +08005643static __inline__ vector bool long long __ATTRS_o_ai
5644vec_mergeo(vector bool long long __a, vector bool long long __b) {
5645 return vec_mergel(__a, __b);
5646}
5647
5648static __inline__ vector signed long long __ATTRS_o_ai
5649vec_mergeo(vector signed long long __a, vector signed long long __b) {
5650 return vec_mergel(__a, __b);
5651}
5652
5653static __inline__ vector unsigned long long __ATTRS_o_ai
5654vec_mergeo(vector unsigned long long __a, vector unsigned long long __b) {
5655 return vec_mergel(__a, __b);
5656}
5657
5658static __inline__ vector float __ATTRS_o_ai
5659vec_mergeo(vector float __a, vector float __b) {
5660 return vec_perm(__a, __b,
5661 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5662 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5663 0x1C, 0x1D, 0x1E, 0x1F));
5664}
5665
5666static __inline__ vector double __ATTRS_o_ai
5667vec_mergeo(vector double __a, vector double __b) {
5668 return vec_mergel(__a, __b);
5669}
5670
Logan Chien2833ffb2018-10-09 10:03:24 +08005671#endif
5672
5673/* vec_mfvscr */
5674
5675static __inline__ vector unsigned short __attribute__((__always_inline__))
5676vec_mfvscr(void) {
5677 return __builtin_altivec_mfvscr();
5678}
5679
5680/* vec_min */
5681
5682static __inline__ vector signed char __ATTRS_o_ai
5683vec_min(vector signed char __a, vector signed char __b) {
5684 return __builtin_altivec_vminsb(__a, __b);
5685}
5686
5687static __inline__ vector signed char __ATTRS_o_ai
5688vec_min(vector bool char __a, vector signed char __b) {
5689 return __builtin_altivec_vminsb((vector signed char)__a, __b);
5690}
5691
5692static __inline__ vector signed char __ATTRS_o_ai
5693vec_min(vector signed char __a, vector bool char __b) {
5694 return __builtin_altivec_vminsb(__a, (vector signed char)__b);
5695}
5696
5697static __inline__ vector unsigned char __ATTRS_o_ai
5698vec_min(vector unsigned char __a, vector unsigned char __b) {
5699 return __builtin_altivec_vminub(__a, __b);
5700}
5701
5702static __inline__ vector unsigned char __ATTRS_o_ai
5703vec_min(vector bool char __a, vector unsigned char __b) {
5704 return __builtin_altivec_vminub((vector unsigned char)__a, __b);
5705}
5706
5707static __inline__ vector unsigned char __ATTRS_o_ai
5708vec_min(vector unsigned char __a, vector bool char __b) {
5709 return __builtin_altivec_vminub(__a, (vector unsigned char)__b);
5710}
5711
5712static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a,
5713 vector short __b) {
5714 return __builtin_altivec_vminsh(__a, __b);
5715}
5716
5717static __inline__ vector short __ATTRS_o_ai vec_min(vector bool short __a,
5718 vector short __b) {
5719 return __builtin_altivec_vminsh((vector short)__a, __b);
5720}
5721
5722static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a,
5723 vector bool short __b) {
5724 return __builtin_altivec_vminsh(__a, (vector short)__b);
5725}
5726
5727static __inline__ vector unsigned short __ATTRS_o_ai
5728vec_min(vector unsigned short __a, vector unsigned short __b) {
5729 return __builtin_altivec_vminuh(__a, __b);
5730}
5731
5732static __inline__ vector unsigned short __ATTRS_o_ai
5733vec_min(vector bool short __a, vector unsigned short __b) {
5734 return __builtin_altivec_vminuh((vector unsigned short)__a, __b);
5735}
5736
5737static __inline__ vector unsigned short __ATTRS_o_ai
5738vec_min(vector unsigned short __a, vector bool short __b) {
5739 return __builtin_altivec_vminuh(__a, (vector unsigned short)__b);
5740}
5741
5742static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a,
5743 vector int __b) {
5744 return __builtin_altivec_vminsw(__a, __b);
5745}
5746
5747static __inline__ vector int __ATTRS_o_ai vec_min(vector bool int __a,
5748 vector int __b) {
5749 return __builtin_altivec_vminsw((vector int)__a, __b);
5750}
5751
5752static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a,
5753 vector bool int __b) {
5754 return __builtin_altivec_vminsw(__a, (vector int)__b);
5755}
5756
5757static __inline__ vector unsigned int __ATTRS_o_ai
5758vec_min(vector unsigned int __a, vector unsigned int __b) {
5759 return __builtin_altivec_vminuw(__a, __b);
5760}
5761
5762static __inline__ vector unsigned int __ATTRS_o_ai
5763vec_min(vector bool int __a, vector unsigned int __b) {
5764 return __builtin_altivec_vminuw((vector unsigned int)__a, __b);
5765}
5766
5767static __inline__ vector unsigned int __ATTRS_o_ai
5768vec_min(vector unsigned int __a, vector bool int __b) {
5769 return __builtin_altivec_vminuw(__a, (vector unsigned int)__b);
5770}
5771
5772#ifdef __POWER8_VECTOR__
5773static __inline__ vector signed long long __ATTRS_o_ai
5774vec_min(vector signed long long __a, vector signed long long __b) {
5775 return __builtin_altivec_vminsd(__a, __b);
5776}
5777
5778static __inline__ vector signed long long __ATTRS_o_ai
5779vec_min(vector bool long long __a, vector signed long long __b) {
5780 return __builtin_altivec_vminsd((vector signed long long)__a, __b);
5781}
5782
5783static __inline__ vector signed long long __ATTRS_o_ai
5784vec_min(vector signed long long __a, vector bool long long __b) {
5785 return __builtin_altivec_vminsd(__a, (vector signed long long)__b);
5786}
5787
5788static __inline__ vector unsigned long long __ATTRS_o_ai
5789vec_min(vector unsigned long long __a, vector unsigned long long __b) {
5790 return __builtin_altivec_vminud(__a, __b);
5791}
5792
5793static __inline__ vector unsigned long long __ATTRS_o_ai
5794vec_min(vector bool long long __a, vector unsigned long long __b) {
5795 return __builtin_altivec_vminud((vector unsigned long long)__a, __b);
5796}
5797
5798static __inline__ vector unsigned long long __ATTRS_o_ai
5799vec_min(vector unsigned long long __a, vector bool long long __b) {
5800 return __builtin_altivec_vminud(__a, (vector unsigned long long)__b);
5801}
5802#endif
5803
5804static __inline__ vector float __ATTRS_o_ai vec_min(vector float __a,
5805 vector float __b) {
5806#ifdef __VSX__
5807 return __builtin_vsx_xvminsp(__a, __b);
5808#else
5809 return __builtin_altivec_vminfp(__a, __b);
5810#endif
5811}
5812
5813#ifdef __VSX__
5814static __inline__ vector double __ATTRS_o_ai vec_min(vector double __a,
5815 vector double __b) {
5816 return __builtin_vsx_xvmindp(__a, __b);
5817}
5818#endif
5819
5820/* vec_vminsb */
5821
5822static __inline__ vector signed char __ATTRS_o_ai
5823vec_vminsb(vector signed char __a, vector signed char __b) {
5824 return __builtin_altivec_vminsb(__a, __b);
5825}
5826
5827static __inline__ vector signed char __ATTRS_o_ai
5828vec_vminsb(vector bool char __a, vector signed char __b) {
5829 return __builtin_altivec_vminsb((vector signed char)__a, __b);
5830}
5831
5832static __inline__ vector signed char __ATTRS_o_ai
5833vec_vminsb(vector signed char __a, vector bool char __b) {
5834 return __builtin_altivec_vminsb(__a, (vector signed char)__b);
5835}
5836
5837/* vec_vminub */
5838
5839static __inline__ vector unsigned char __ATTRS_o_ai
5840vec_vminub(vector unsigned char __a, vector unsigned char __b) {
5841 return __builtin_altivec_vminub(__a, __b);
5842}
5843
5844static __inline__ vector unsigned char __ATTRS_o_ai
5845vec_vminub(vector bool char __a, vector unsigned char __b) {
5846 return __builtin_altivec_vminub((vector unsigned char)__a, __b);
5847}
5848
5849static __inline__ vector unsigned char __ATTRS_o_ai
5850vec_vminub(vector unsigned char __a, vector bool char __b) {
5851 return __builtin_altivec_vminub(__a, (vector unsigned char)__b);
5852}
5853
5854/* vec_vminsh */
5855
5856static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a,
5857 vector short __b) {
5858 return __builtin_altivec_vminsh(__a, __b);
5859}
5860
5861static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector bool short __a,
5862 vector short __b) {
5863 return __builtin_altivec_vminsh((vector short)__a, __b);
5864}
5865
5866static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a,
5867 vector bool short __b) {
5868 return __builtin_altivec_vminsh(__a, (vector short)__b);
5869}
5870
5871/* vec_vminuh */
5872
5873static __inline__ vector unsigned short __ATTRS_o_ai
5874vec_vminuh(vector unsigned short __a, vector unsigned short __b) {
5875 return __builtin_altivec_vminuh(__a, __b);
5876}
5877
5878static __inline__ vector unsigned short __ATTRS_o_ai
5879vec_vminuh(vector bool short __a, vector unsigned short __b) {
5880 return __builtin_altivec_vminuh((vector unsigned short)__a, __b);
5881}
5882
5883static __inline__ vector unsigned short __ATTRS_o_ai
5884vec_vminuh(vector unsigned short __a, vector bool short __b) {
5885 return __builtin_altivec_vminuh(__a, (vector unsigned short)__b);
5886}
5887
5888/* vec_vminsw */
5889
5890static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a,
5891 vector int __b) {
5892 return __builtin_altivec_vminsw(__a, __b);
5893}
5894
5895static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector bool int __a,
5896 vector int __b) {
5897 return __builtin_altivec_vminsw((vector int)__a, __b);
5898}
5899
5900static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a,
5901 vector bool int __b) {
5902 return __builtin_altivec_vminsw(__a, (vector int)__b);
5903}
5904
5905/* vec_vminuw */
5906
5907static __inline__ vector unsigned int __ATTRS_o_ai
5908vec_vminuw(vector unsigned int __a, vector unsigned int __b) {
5909 return __builtin_altivec_vminuw(__a, __b);
5910}
5911
5912static __inline__ vector unsigned int __ATTRS_o_ai
5913vec_vminuw(vector bool int __a, vector unsigned int __b) {
5914 return __builtin_altivec_vminuw((vector unsigned int)__a, __b);
5915}
5916
5917static __inline__ vector unsigned int __ATTRS_o_ai
5918vec_vminuw(vector unsigned int __a, vector bool int __b) {
5919 return __builtin_altivec_vminuw(__a, (vector unsigned int)__b);
5920}
5921
5922/* vec_vminfp */
5923
5924static __inline__ vector float __attribute__((__always_inline__))
5925vec_vminfp(vector float __a, vector float __b) {
5926#ifdef __VSX__
5927 return __builtin_vsx_xvminsp(__a, __b);
5928#else
5929 return __builtin_altivec_vminfp(__a, __b);
5930#endif
5931}
5932
5933/* vec_mladd */
5934
5935#define __builtin_altivec_vmladduhm vec_mladd
5936
5937static __inline__ vector short __ATTRS_o_ai vec_mladd(vector short __a,
5938 vector short __b,
5939 vector short __c) {
5940 return __a * __b + __c;
5941}
5942
5943static __inline__ vector short __ATTRS_o_ai vec_mladd(
5944 vector short __a, vector unsigned short __b, vector unsigned short __c) {
5945 return __a * (vector short)__b + (vector short)__c;
5946}
5947
5948static __inline__ vector short __ATTRS_o_ai vec_mladd(vector unsigned short __a,
5949 vector short __b,
5950 vector short __c) {
5951 return (vector short)__a * __b + __c;
5952}
5953
5954static __inline__ vector unsigned short __ATTRS_o_ai
5955vec_mladd(vector unsigned short __a, vector unsigned short __b,
5956 vector unsigned short __c) {
5957 return __a * __b + __c;
5958}
5959
5960/* vec_vmladduhm */
5961
5962static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(vector short __a,
5963 vector short __b,
5964 vector short __c) {
5965 return __a * __b + __c;
5966}
5967
5968static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(
5969 vector short __a, vector unsigned short __b, vector unsigned short __c) {
5970 return __a * (vector short)__b + (vector short)__c;
5971}
5972
5973static __inline__ vector short __ATTRS_o_ai
5974vec_vmladduhm(vector unsigned short __a, vector short __b, vector short __c) {
5975 return (vector short)__a * __b + __c;
5976}
5977
5978static __inline__ vector unsigned short __ATTRS_o_ai
5979vec_vmladduhm(vector unsigned short __a, vector unsigned short __b,
5980 vector unsigned short __c) {
5981 return __a * __b + __c;
5982}
5983
5984/* vec_mradds */
5985
5986static __inline__ vector short __attribute__((__always_inline__))
5987vec_mradds(vector short __a, vector short __b, vector short __c) {
5988 return __builtin_altivec_vmhraddshs(__a, __b, __c);
5989}
5990
5991/* vec_vmhraddshs */
5992
5993static __inline__ vector short __attribute__((__always_inline__))
5994vec_vmhraddshs(vector short __a, vector short __b, vector short __c) {
5995 return __builtin_altivec_vmhraddshs(__a, __b, __c);
5996}
5997
5998/* vec_msum */
5999
6000static __inline__ vector int __ATTRS_o_ai vec_msum(vector signed char __a,
6001 vector unsigned char __b,
6002 vector int __c) {
6003 return __builtin_altivec_vmsummbm(__a, __b, __c);
6004}
6005
6006static __inline__ vector unsigned int __ATTRS_o_ai
6007vec_msum(vector unsigned char __a, vector unsigned char __b,
6008 vector unsigned int __c) {
6009 return __builtin_altivec_vmsumubm(__a, __b, __c);
6010}
6011
6012static __inline__ vector int __ATTRS_o_ai vec_msum(vector short __a,
6013 vector short __b,
6014 vector int __c) {
6015 return __builtin_altivec_vmsumshm(__a, __b, __c);
6016}
6017
6018static __inline__ vector unsigned int __ATTRS_o_ai
6019vec_msum(vector unsigned short __a, vector unsigned short __b,
6020 vector unsigned int __c) {
6021 return __builtin_altivec_vmsumuhm(__a, __b, __c);
6022}
6023
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006024/* vec_msumc */
6025
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07006026#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006027static __inline__ vector unsigned __int128 __ATTRS_o_ai
6028vec_msumc(vector unsigned long long __a, vector unsigned long long __b,
6029 vector unsigned __int128 __c) {
6030 return __builtin_altivec_vmsumcud(__a, __b, __c);
6031}
6032#endif
6033
Logan Chien2833ffb2018-10-09 10:03:24 +08006034/* vec_vmsummbm */
6035
6036static __inline__ vector int __attribute__((__always_inline__))
6037vec_vmsummbm(vector signed char __a, vector unsigned char __b, vector int __c) {
6038 return __builtin_altivec_vmsummbm(__a, __b, __c);
6039}
6040
6041/* vec_vmsumubm */
6042
6043static __inline__ vector unsigned int __attribute__((__always_inline__))
6044vec_vmsumubm(vector unsigned char __a, vector unsigned char __b,
6045 vector unsigned int __c) {
6046 return __builtin_altivec_vmsumubm(__a, __b, __c);
6047}
6048
6049/* vec_vmsumshm */
6050
6051static __inline__ vector int __attribute__((__always_inline__))
6052vec_vmsumshm(vector short __a, vector short __b, vector int __c) {
6053 return __builtin_altivec_vmsumshm(__a, __b, __c);
6054}
6055
6056/* vec_vmsumuhm */
6057
6058static __inline__ vector unsigned int __attribute__((__always_inline__))
6059vec_vmsumuhm(vector unsigned short __a, vector unsigned short __b,
6060 vector unsigned int __c) {
6061 return __builtin_altivec_vmsumuhm(__a, __b, __c);
6062}
6063
6064/* vec_msums */
6065
6066static __inline__ vector int __ATTRS_o_ai vec_msums(vector short __a,
6067 vector short __b,
6068 vector int __c) {
6069 return __builtin_altivec_vmsumshs(__a, __b, __c);
6070}
6071
6072static __inline__ vector unsigned int __ATTRS_o_ai
6073vec_msums(vector unsigned short __a, vector unsigned short __b,
6074 vector unsigned int __c) {
6075 return __builtin_altivec_vmsumuhs(__a, __b, __c);
6076}
6077
6078/* vec_vmsumshs */
6079
6080static __inline__ vector int __attribute__((__always_inline__))
6081vec_vmsumshs(vector short __a, vector short __b, vector int __c) {
6082 return __builtin_altivec_vmsumshs(__a, __b, __c);
6083}
6084
6085/* vec_vmsumuhs */
6086
6087static __inline__ vector unsigned int __attribute__((__always_inline__))
6088vec_vmsumuhs(vector unsigned short __a, vector unsigned short __b,
6089 vector unsigned int __c) {
6090 return __builtin_altivec_vmsumuhs(__a, __b, __c);
6091}
6092
6093/* vec_mtvscr */
6094
6095static __inline__ void __ATTRS_o_ai vec_mtvscr(vector signed char __a) {
6096 __builtin_altivec_mtvscr((vector int)__a);
6097}
6098
6099static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned char __a) {
6100 __builtin_altivec_mtvscr((vector int)__a);
6101}
6102
6103static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool char __a) {
6104 __builtin_altivec_mtvscr((vector int)__a);
6105}
6106
6107static __inline__ void __ATTRS_o_ai vec_mtvscr(vector short __a) {
6108 __builtin_altivec_mtvscr((vector int)__a);
6109}
6110
6111static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned short __a) {
6112 __builtin_altivec_mtvscr((vector int)__a);
6113}
6114
6115static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool short __a) {
6116 __builtin_altivec_mtvscr((vector int)__a);
6117}
6118
6119static __inline__ void __ATTRS_o_ai vec_mtvscr(vector pixel __a) {
6120 __builtin_altivec_mtvscr((vector int)__a);
6121}
6122
6123static __inline__ void __ATTRS_o_ai vec_mtvscr(vector int __a) {
6124 __builtin_altivec_mtvscr((vector int)__a);
6125}
6126
6127static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned int __a) {
6128 __builtin_altivec_mtvscr((vector int)__a);
6129}
6130
6131static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool int __a) {
6132 __builtin_altivec_mtvscr((vector int)__a);
6133}
6134
6135static __inline__ void __ATTRS_o_ai vec_mtvscr(vector float __a) {
6136 __builtin_altivec_mtvscr((vector int)__a);
6137}
6138
6139/* vec_mul */
6140
6141/* Integer vector multiplication will involve multiplication of the odd/even
6142 elements separately, then truncating the results and moving to the
6143 result vector.
6144*/
6145static __inline__ vector signed char __ATTRS_o_ai
6146vec_mul(vector signed char __a, vector signed char __b) {
6147 return __a * __b;
6148}
6149
6150static __inline__ vector unsigned char __ATTRS_o_ai
6151vec_mul(vector unsigned char __a, vector unsigned char __b) {
6152 return __a * __b;
6153}
6154
6155static __inline__ vector signed short __ATTRS_o_ai
6156vec_mul(vector signed short __a, vector signed short __b) {
6157 return __a * __b;
6158}
6159
6160static __inline__ vector unsigned short __ATTRS_o_ai
6161vec_mul(vector unsigned short __a, vector unsigned short __b) {
6162 return __a * __b;
6163}
6164
6165static __inline__ vector signed int __ATTRS_o_ai
6166vec_mul(vector signed int __a, vector signed int __b) {
6167 return __a * __b;
6168}
6169
6170static __inline__ vector unsigned int __ATTRS_o_ai
6171vec_mul(vector unsigned int __a, vector unsigned int __b) {
6172 return __a * __b;
6173}
6174
6175#ifdef __VSX__
6176static __inline__ vector signed long long __ATTRS_o_ai
6177vec_mul(vector signed long long __a, vector signed long long __b) {
6178 return __a * __b;
6179}
6180
6181static __inline__ vector unsigned long long __ATTRS_o_ai
6182vec_mul(vector unsigned long long __a, vector unsigned long long __b) {
6183 return __a * __b;
6184}
6185#endif
6186
6187static __inline__ vector float __ATTRS_o_ai vec_mul(vector float __a,
6188 vector float __b) {
6189 return __a * __b;
6190}
6191
6192#ifdef __VSX__
6193static __inline__ vector double __ATTRS_o_ai vec_mul(vector double __a,
6194 vector double __b) {
6195 return __a * __b;
6196}
6197#endif
6198
6199/* The vmulos* and vmules* instructions have a big endian bias, so
6200 we must reverse the meaning of "even" and "odd" for little endian. */
6201
6202/* vec_mule */
6203
6204static __inline__ vector short __ATTRS_o_ai vec_mule(vector signed char __a,
6205 vector signed char __b) {
6206#ifdef __LITTLE_ENDIAN__
6207 return __builtin_altivec_vmulosb(__a, __b);
6208#else
6209 return __builtin_altivec_vmulesb(__a, __b);
6210#endif
6211}
6212
6213static __inline__ vector unsigned short __ATTRS_o_ai
6214vec_mule(vector unsigned char __a, vector unsigned char __b) {
6215#ifdef __LITTLE_ENDIAN__
6216 return __builtin_altivec_vmuloub(__a, __b);
6217#else
6218 return __builtin_altivec_vmuleub(__a, __b);
6219#endif
6220}
6221
6222static __inline__ vector int __ATTRS_o_ai vec_mule(vector short __a,
6223 vector short __b) {
6224#ifdef __LITTLE_ENDIAN__
6225 return __builtin_altivec_vmulosh(__a, __b);
6226#else
6227 return __builtin_altivec_vmulesh(__a, __b);
6228#endif
6229}
6230
6231static __inline__ vector unsigned int __ATTRS_o_ai
6232vec_mule(vector unsigned short __a, vector unsigned short __b) {
6233#ifdef __LITTLE_ENDIAN__
6234 return __builtin_altivec_vmulouh(__a, __b);
6235#else
6236 return __builtin_altivec_vmuleuh(__a, __b);
6237#endif
6238}
6239
6240#ifdef __POWER8_VECTOR__
6241static __inline__ vector signed long long __ATTRS_o_ai
6242vec_mule(vector signed int __a, vector signed int __b) {
6243#ifdef __LITTLE_ENDIAN__
6244 return __builtin_altivec_vmulosw(__a, __b);
6245#else
6246 return __builtin_altivec_vmulesw(__a, __b);
6247#endif
6248}
6249
6250static __inline__ vector unsigned long long __ATTRS_o_ai
6251vec_mule(vector unsigned int __a, vector unsigned int __b) {
6252#ifdef __LITTLE_ENDIAN__
6253 return __builtin_altivec_vmulouw(__a, __b);
6254#else
6255 return __builtin_altivec_vmuleuw(__a, __b);
6256#endif
6257}
6258#endif
6259
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07006260#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006261static __inline__ vector signed __int128 __ATTRS_o_ai
6262vec_mule(vector signed long long __a, vector signed long long __b) {
6263#ifdef __LITTLE_ENDIAN__
6264 return __builtin_altivec_vmulosd(__a, __b);
6265#else
6266 return __builtin_altivec_vmulesd(__a, __b);
6267#endif
6268}
6269
6270static __inline__ vector unsigned __int128 __ATTRS_o_ai
6271vec_mule(vector unsigned long long __a, vector unsigned long long __b) {
6272#ifdef __LITTLE_ENDIAN__
6273 return __builtin_altivec_vmuloud(__a, __b);
6274#else
6275 return __builtin_altivec_vmuleud(__a, __b);
6276#endif
6277}
6278#endif
6279
Logan Chien2833ffb2018-10-09 10:03:24 +08006280/* vec_vmulesb */
6281
6282static __inline__ vector short __attribute__((__always_inline__))
6283vec_vmulesb(vector signed char __a, vector signed char __b) {
6284#ifdef __LITTLE_ENDIAN__
6285 return __builtin_altivec_vmulosb(__a, __b);
6286#else
6287 return __builtin_altivec_vmulesb(__a, __b);
6288#endif
6289}
6290
6291/* vec_vmuleub */
6292
6293static __inline__ vector unsigned short __attribute__((__always_inline__))
6294vec_vmuleub(vector unsigned char __a, vector unsigned char __b) {
6295#ifdef __LITTLE_ENDIAN__
6296 return __builtin_altivec_vmuloub(__a, __b);
6297#else
6298 return __builtin_altivec_vmuleub(__a, __b);
6299#endif
6300}
6301
6302/* vec_vmulesh */
6303
6304static __inline__ vector int __attribute__((__always_inline__))
6305vec_vmulesh(vector short __a, vector short __b) {
6306#ifdef __LITTLE_ENDIAN__
6307 return __builtin_altivec_vmulosh(__a, __b);
6308#else
6309 return __builtin_altivec_vmulesh(__a, __b);
6310#endif
6311}
6312
6313/* vec_vmuleuh */
6314
6315static __inline__ vector unsigned int __attribute__((__always_inline__))
6316vec_vmuleuh(vector unsigned short __a, vector unsigned short __b) {
6317#ifdef __LITTLE_ENDIAN__
6318 return __builtin_altivec_vmulouh(__a, __b);
6319#else
6320 return __builtin_altivec_vmuleuh(__a, __b);
6321#endif
6322}
6323
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006324/* vec_mulh */
6325
6326#ifdef __POWER10_VECTOR__
6327static __inline__ vector signed int __ATTRS_o_ai
6328vec_mulh(vector signed int __a, vector signed int __b) {
6329 return __builtin_altivec_vmulhsw(__a, __b);
6330}
6331
6332static __inline__ vector unsigned int __ATTRS_o_ai
6333vec_mulh(vector unsigned int __a, vector unsigned int __b) {
6334 return __builtin_altivec_vmulhuw(__a, __b);
6335}
6336
6337static __inline__ vector signed long long __ATTRS_o_ai
6338vec_mulh(vector signed long long __a, vector signed long long __b) {
6339 return __builtin_altivec_vmulhsd(__a, __b);
6340}
6341
6342static __inline__ vector unsigned long long __ATTRS_o_ai
6343vec_mulh(vector unsigned long long __a, vector unsigned long long __b) {
6344 return __builtin_altivec_vmulhud(__a, __b);
6345}
6346#endif
6347
Logan Chien2833ffb2018-10-09 10:03:24 +08006348/* vec_mulo */
6349
6350static __inline__ vector short __ATTRS_o_ai vec_mulo(vector signed char __a,
6351 vector signed char __b) {
6352#ifdef __LITTLE_ENDIAN__
6353 return __builtin_altivec_vmulesb(__a, __b);
6354#else
6355 return __builtin_altivec_vmulosb(__a, __b);
6356#endif
6357}
6358
6359static __inline__ vector unsigned short __ATTRS_o_ai
6360vec_mulo(vector unsigned char __a, vector unsigned char __b) {
6361#ifdef __LITTLE_ENDIAN__
6362 return __builtin_altivec_vmuleub(__a, __b);
6363#else
6364 return __builtin_altivec_vmuloub(__a, __b);
6365#endif
6366}
6367
6368static __inline__ vector int __ATTRS_o_ai vec_mulo(vector short __a,
6369 vector short __b) {
6370#ifdef __LITTLE_ENDIAN__
6371 return __builtin_altivec_vmulesh(__a, __b);
6372#else
6373 return __builtin_altivec_vmulosh(__a, __b);
6374#endif
6375}
6376
6377static __inline__ vector unsigned int __ATTRS_o_ai
6378vec_mulo(vector unsigned short __a, vector unsigned short __b) {
6379#ifdef __LITTLE_ENDIAN__
6380 return __builtin_altivec_vmuleuh(__a, __b);
6381#else
6382 return __builtin_altivec_vmulouh(__a, __b);
6383#endif
6384}
6385
6386#ifdef __POWER8_VECTOR__
6387static __inline__ vector signed long long __ATTRS_o_ai
6388vec_mulo(vector signed int __a, vector signed int __b) {
6389#ifdef __LITTLE_ENDIAN__
6390 return __builtin_altivec_vmulesw(__a, __b);
6391#else
6392 return __builtin_altivec_vmulosw(__a, __b);
6393#endif
6394}
6395
6396static __inline__ vector unsigned long long __ATTRS_o_ai
6397vec_mulo(vector unsigned int __a, vector unsigned int __b) {
6398#ifdef __LITTLE_ENDIAN__
6399 return __builtin_altivec_vmuleuw(__a, __b);
6400#else
6401 return __builtin_altivec_vmulouw(__a, __b);
6402#endif
6403}
6404#endif
6405
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07006406#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006407static __inline__ vector signed __int128 __ATTRS_o_ai
6408vec_mulo(vector signed long long __a, vector signed long long __b) {
6409#ifdef __LITTLE_ENDIAN__
6410 return __builtin_altivec_vmulesd(__a, __b);
6411#else
6412 return __builtin_altivec_vmulosd(__a, __b);
6413#endif
6414}
6415
6416static __inline__ vector unsigned __int128 __ATTRS_o_ai
6417vec_mulo(vector unsigned long long __a, vector unsigned long long __b) {
6418#ifdef __LITTLE_ENDIAN__
6419 return __builtin_altivec_vmuleud(__a, __b);
6420#else
6421 return __builtin_altivec_vmuloud(__a, __b);
6422#endif
6423}
6424#endif
6425
Logan Chien2833ffb2018-10-09 10:03:24 +08006426/* vec_vmulosb */
6427
6428static __inline__ vector short __attribute__((__always_inline__))
6429vec_vmulosb(vector signed char __a, vector signed char __b) {
6430#ifdef __LITTLE_ENDIAN__
6431 return __builtin_altivec_vmulesb(__a, __b);
6432#else
6433 return __builtin_altivec_vmulosb(__a, __b);
6434#endif
6435}
6436
6437/* vec_vmuloub */
6438
6439static __inline__ vector unsigned short __attribute__((__always_inline__))
6440vec_vmuloub(vector unsigned char __a, vector unsigned char __b) {
6441#ifdef __LITTLE_ENDIAN__
6442 return __builtin_altivec_vmuleub(__a, __b);
6443#else
6444 return __builtin_altivec_vmuloub(__a, __b);
6445#endif
6446}
6447
6448/* vec_vmulosh */
6449
6450static __inline__ vector int __attribute__((__always_inline__))
6451vec_vmulosh(vector short __a, vector short __b) {
6452#ifdef __LITTLE_ENDIAN__
6453 return __builtin_altivec_vmulesh(__a, __b);
6454#else
6455 return __builtin_altivec_vmulosh(__a, __b);
6456#endif
6457}
6458
6459/* vec_vmulouh */
6460
6461static __inline__ vector unsigned int __attribute__((__always_inline__))
6462vec_vmulouh(vector unsigned short __a, vector unsigned short __b) {
6463#ifdef __LITTLE_ENDIAN__
6464 return __builtin_altivec_vmuleuh(__a, __b);
6465#else
6466 return __builtin_altivec_vmulouh(__a, __b);
6467#endif
6468}
6469
6470/* vec_nand */
6471
6472#ifdef __POWER8_VECTOR__
6473static __inline__ vector signed char __ATTRS_o_ai
6474vec_nand(vector signed char __a, vector signed char __b) {
6475 return ~(__a & __b);
6476}
6477
6478static __inline__ vector signed char __ATTRS_o_ai
6479vec_nand(vector signed char __a, vector bool char __b) {
6480 return ~(__a & __b);
6481}
6482
6483static __inline__ vector signed char __ATTRS_o_ai
6484vec_nand(vector bool char __a, vector signed char __b) {
6485 return ~(__a & __b);
6486}
6487
6488static __inline__ vector unsigned char __ATTRS_o_ai
6489vec_nand(vector unsigned char __a, vector unsigned char __b) {
6490 return ~(__a & __b);
6491}
6492
6493static __inline__ vector unsigned char __ATTRS_o_ai
6494vec_nand(vector unsigned char __a, vector bool char __b) {
6495 return ~(__a & __b);
6496}
6497
6498static __inline__ vector unsigned char __ATTRS_o_ai
6499vec_nand(vector bool char __a, vector unsigned char __b) {
6500 return ~(__a & __b);
6501}
6502
6503static __inline__ vector bool char __ATTRS_o_ai vec_nand(vector bool char __a,
6504 vector bool char __b) {
6505 return ~(__a & __b);
6506}
6507
6508static __inline__ vector signed short __ATTRS_o_ai
6509vec_nand(vector signed short __a, vector signed short __b) {
6510 return ~(__a & __b);
6511}
6512
6513static __inline__ vector signed short __ATTRS_o_ai
6514vec_nand(vector signed short __a, vector bool short __b) {
6515 return ~(__a & __b);
6516}
6517
6518static __inline__ vector signed short __ATTRS_o_ai
6519vec_nand(vector bool short __a, vector signed short __b) {
6520 return ~(__a & __b);
6521}
6522
6523static __inline__ vector unsigned short __ATTRS_o_ai
6524vec_nand(vector unsigned short __a, vector unsigned short __b) {
6525 return ~(__a & __b);
6526}
6527
6528static __inline__ vector unsigned short __ATTRS_o_ai
6529vec_nand(vector unsigned short __a, vector bool short __b) {
6530 return ~(__a & __b);
6531}
6532
6533static __inline__ vector bool short __ATTRS_o_ai
6534vec_nand(vector bool short __a, vector bool short __b) {
6535 return ~(__a & __b);
6536}
6537
6538static __inline__ vector signed int __ATTRS_o_ai
6539vec_nand(vector signed int __a, vector signed int __b) {
6540 return ~(__a & __b);
6541}
6542
6543static __inline__ vector signed int __ATTRS_o_ai vec_nand(vector signed int __a,
6544 vector bool int __b) {
6545 return ~(__a & __b);
6546}
6547
6548static __inline__ vector signed int __ATTRS_o_ai
6549vec_nand(vector bool int __a, vector signed int __b) {
6550 return ~(__a & __b);
6551}
6552
6553static __inline__ vector unsigned int __ATTRS_o_ai
6554vec_nand(vector unsigned int __a, vector unsigned int __b) {
6555 return ~(__a & __b);
6556}
6557
6558static __inline__ vector unsigned int __ATTRS_o_ai
6559vec_nand(vector unsigned int __a, vector bool int __b) {
6560 return ~(__a & __b);
6561}
6562
6563static __inline__ vector unsigned int __ATTRS_o_ai
6564vec_nand(vector bool int __a, vector unsigned int __b) {
6565 return ~(__a & __b);
6566}
6567
6568static __inline__ vector bool int __ATTRS_o_ai vec_nand(vector bool int __a,
6569 vector bool int __b) {
6570 return ~(__a & __b);
6571}
6572
Logan Chien55afb0a2018-10-15 10:42:14 +08006573static __inline__ vector float __ATTRS_o_ai
6574vec_nand(vector float __a, vector float __b) {
6575 return (vector float)(~((vector unsigned int)__a &
6576 (vector unsigned int)__b));
6577}
6578
Logan Chien2833ffb2018-10-09 10:03:24 +08006579static __inline__ vector signed long long __ATTRS_o_ai
6580vec_nand(vector signed long long __a, vector signed long long __b) {
6581 return ~(__a & __b);
6582}
6583
6584static __inline__ vector signed long long __ATTRS_o_ai
6585vec_nand(vector signed long long __a, vector bool long long __b) {
6586 return ~(__a & __b);
6587}
6588
6589static __inline__ vector signed long long __ATTRS_o_ai
6590vec_nand(vector bool long long __a, vector signed long long __b) {
6591 return ~(__a & __b);
6592}
6593
6594static __inline__ vector unsigned long long __ATTRS_o_ai
6595vec_nand(vector unsigned long long __a, vector unsigned long long __b) {
6596 return ~(__a & __b);
6597}
6598
6599static __inline__ vector unsigned long long __ATTRS_o_ai
6600vec_nand(vector unsigned long long __a, vector bool long long __b) {
6601 return ~(__a & __b);
6602}
6603
6604static __inline__ vector unsigned long long __ATTRS_o_ai
6605vec_nand(vector bool long long __a, vector unsigned long long __b) {
6606 return ~(__a & __b);
6607}
6608
6609static __inline__ vector bool long long __ATTRS_o_ai
6610vec_nand(vector bool long long __a, vector bool long long __b) {
6611 return ~(__a & __b);
6612}
6613
Logan Chien55afb0a2018-10-15 10:42:14 +08006614static __inline__ vector double __ATTRS_o_ai
6615vec_nand(vector double __a, vector double __b) {
6616 return (vector double)(~((vector unsigned long long)__a &
6617 (vector unsigned long long)__b));
6618}
6619
Logan Chien2833ffb2018-10-09 10:03:24 +08006620#endif
6621
6622/* vec_nmadd */
6623
6624#ifdef __VSX__
6625static __inline__ vector float __ATTRS_o_ai vec_nmadd(vector float __a,
6626 vector float __b,
6627 vector float __c) {
6628 return __builtin_vsx_xvnmaddasp(__a, __b, __c);
6629}
6630
6631static __inline__ vector double __ATTRS_o_ai vec_nmadd(vector double __a,
6632 vector double __b,
6633 vector double __c) {
6634 return __builtin_vsx_xvnmaddadp(__a, __b, __c);
6635}
6636#endif
6637
6638/* vec_nmsub */
6639
6640static __inline__ vector float __ATTRS_o_ai vec_nmsub(vector float __a,
6641 vector float __b,
6642 vector float __c) {
6643#ifdef __VSX__
6644 return __builtin_vsx_xvnmsubasp(__a, __b, __c);
6645#else
6646 return __builtin_altivec_vnmsubfp(__a, __b, __c);
6647#endif
6648}
6649
6650#ifdef __VSX__
6651static __inline__ vector double __ATTRS_o_ai vec_nmsub(vector double __a,
6652 vector double __b,
6653 vector double __c) {
6654 return __builtin_vsx_xvnmsubadp(__a, __b, __c);
6655}
6656#endif
6657
6658/* vec_vnmsubfp */
6659
6660static __inline__ vector float __attribute__((__always_inline__))
6661vec_vnmsubfp(vector float __a, vector float __b, vector float __c) {
6662 return __builtin_altivec_vnmsubfp(__a, __b, __c);
6663}
6664
6665/* vec_nor */
6666
6667#define __builtin_altivec_vnor vec_nor
6668
6669static __inline__ vector signed char __ATTRS_o_ai
6670vec_nor(vector signed char __a, vector signed char __b) {
6671 return ~(__a | __b);
6672}
6673
6674static __inline__ vector unsigned char __ATTRS_o_ai
6675vec_nor(vector unsigned char __a, vector unsigned char __b) {
6676 return ~(__a | __b);
6677}
6678
6679static __inline__ vector bool char __ATTRS_o_ai vec_nor(vector bool char __a,
6680 vector bool char __b) {
6681 return ~(__a | __b);
6682}
6683
6684static __inline__ vector short __ATTRS_o_ai vec_nor(vector short __a,
6685 vector short __b) {
6686 return ~(__a | __b);
6687}
6688
6689static __inline__ vector unsigned short __ATTRS_o_ai
6690vec_nor(vector unsigned short __a, vector unsigned short __b) {
6691 return ~(__a | __b);
6692}
6693
6694static __inline__ vector bool short __ATTRS_o_ai
6695vec_nor(vector bool short __a, vector bool short __b) {
6696 return ~(__a | __b);
6697}
6698
6699static __inline__ vector int __ATTRS_o_ai vec_nor(vector int __a,
6700 vector int __b) {
6701 return ~(__a | __b);
6702}
6703
6704static __inline__ vector unsigned int __ATTRS_o_ai
6705vec_nor(vector unsigned int __a, vector unsigned int __b) {
6706 return ~(__a | __b);
6707}
6708
6709static __inline__ vector bool int __ATTRS_o_ai vec_nor(vector bool int __a,
6710 vector bool int __b) {
6711 return ~(__a | __b);
6712}
6713
6714static __inline__ vector float __ATTRS_o_ai vec_nor(vector float __a,
6715 vector float __b) {
6716 vector unsigned int __res =
6717 ~((vector unsigned int)__a | (vector unsigned int)__b);
6718 return (vector float)__res;
6719}
6720
6721#ifdef __VSX__
6722static __inline__ vector double __ATTRS_o_ai vec_nor(vector double __a,
6723 vector double __b) {
6724 vector unsigned long long __res =
6725 ~((vector unsigned long long)__a | (vector unsigned long long)__b);
6726 return (vector double)__res;
6727}
6728#endif
6729
6730/* vec_vnor */
6731
6732static __inline__ vector signed char __ATTRS_o_ai
6733vec_vnor(vector signed char __a, vector signed char __b) {
6734 return ~(__a | __b);
6735}
6736
6737static __inline__ vector unsigned char __ATTRS_o_ai
6738vec_vnor(vector unsigned char __a, vector unsigned char __b) {
6739 return ~(__a | __b);
6740}
6741
6742static __inline__ vector bool char __ATTRS_o_ai vec_vnor(vector bool char __a,
6743 vector bool char __b) {
6744 return ~(__a | __b);
6745}
6746
6747static __inline__ vector short __ATTRS_o_ai vec_vnor(vector short __a,
6748 vector short __b) {
6749 return ~(__a | __b);
6750}
6751
6752static __inline__ vector unsigned short __ATTRS_o_ai
6753vec_vnor(vector unsigned short __a, vector unsigned short __b) {
6754 return ~(__a | __b);
6755}
6756
6757static __inline__ vector bool short __ATTRS_o_ai
6758vec_vnor(vector bool short __a, vector bool short __b) {
6759 return ~(__a | __b);
6760}
6761
6762static __inline__ vector int __ATTRS_o_ai vec_vnor(vector int __a,
6763 vector int __b) {
6764 return ~(__a | __b);
6765}
6766
6767static __inline__ vector unsigned int __ATTRS_o_ai
6768vec_vnor(vector unsigned int __a, vector unsigned int __b) {
6769 return ~(__a | __b);
6770}
6771
6772static __inline__ vector bool int __ATTRS_o_ai vec_vnor(vector bool int __a,
6773 vector bool int __b) {
6774 return ~(__a | __b);
6775}
6776
6777static __inline__ vector float __ATTRS_o_ai vec_vnor(vector float __a,
6778 vector float __b) {
6779 vector unsigned int __res =
6780 ~((vector unsigned int)__a | (vector unsigned int)__b);
6781 return (vector float)__res;
6782}
6783
6784#ifdef __VSX__
6785static __inline__ vector signed long long __ATTRS_o_ai
6786vec_nor(vector signed long long __a, vector signed long long __b) {
6787 return ~(__a | __b);
6788}
6789
6790static __inline__ vector unsigned long long __ATTRS_o_ai
6791vec_nor(vector unsigned long long __a, vector unsigned long long __b) {
6792 return ~(__a | __b);
6793}
6794
6795static __inline__ vector bool long long __ATTRS_o_ai
6796vec_nor(vector bool long long __a, vector bool long long __b) {
6797 return ~(__a | __b);
6798}
6799#endif
6800
6801/* vec_or */
6802
6803#define __builtin_altivec_vor vec_or
6804
6805static __inline__ vector signed char __ATTRS_o_ai
6806vec_or(vector signed char __a, vector signed char __b) {
6807 return __a | __b;
6808}
6809
6810static __inline__ vector signed char __ATTRS_o_ai
6811vec_or(vector bool char __a, vector signed char __b) {
6812 return (vector signed char)__a | __b;
6813}
6814
6815static __inline__ vector signed char __ATTRS_o_ai vec_or(vector signed char __a,
6816 vector bool char __b) {
6817 return __a | (vector signed char)__b;
6818}
6819
6820static __inline__ vector unsigned char __ATTRS_o_ai
6821vec_or(vector unsigned char __a, vector unsigned char __b) {
6822 return __a | __b;
6823}
6824
6825static __inline__ vector unsigned char __ATTRS_o_ai
6826vec_or(vector bool char __a, vector unsigned char __b) {
6827 return (vector unsigned char)__a | __b;
6828}
6829
6830static __inline__ vector unsigned char __ATTRS_o_ai
6831vec_or(vector unsigned char __a, vector bool char __b) {
6832 return __a | (vector unsigned char)__b;
6833}
6834
6835static __inline__ vector bool char __ATTRS_o_ai vec_or(vector bool char __a,
6836 vector bool char __b) {
6837 return __a | __b;
6838}
6839
6840static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a,
6841 vector short __b) {
6842 return __a | __b;
6843}
6844
6845static __inline__ vector short __ATTRS_o_ai vec_or(vector bool short __a,
6846 vector short __b) {
6847 return (vector short)__a | __b;
6848}
6849
6850static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a,
6851 vector bool short __b) {
6852 return __a | (vector short)__b;
6853}
6854
6855static __inline__ vector unsigned short __ATTRS_o_ai
6856vec_or(vector unsigned short __a, vector unsigned short __b) {
6857 return __a | __b;
6858}
6859
6860static __inline__ vector unsigned short __ATTRS_o_ai
6861vec_or(vector bool short __a, vector unsigned short __b) {
6862 return (vector unsigned short)__a | __b;
6863}
6864
6865static __inline__ vector unsigned short __ATTRS_o_ai
6866vec_or(vector unsigned short __a, vector bool short __b) {
6867 return __a | (vector unsigned short)__b;
6868}
6869
6870static __inline__ vector bool short __ATTRS_o_ai vec_or(vector bool short __a,
6871 vector bool short __b) {
6872 return __a | __b;
6873}
6874
6875static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a,
6876 vector int __b) {
6877 return __a | __b;
6878}
6879
6880static __inline__ vector int __ATTRS_o_ai vec_or(vector bool int __a,
6881 vector int __b) {
6882 return (vector int)__a | __b;
6883}
6884
6885static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a,
6886 vector bool int __b) {
6887 return __a | (vector int)__b;
6888}
6889
6890static __inline__ vector unsigned int __ATTRS_o_ai
6891vec_or(vector unsigned int __a, vector unsigned int __b) {
6892 return __a | __b;
6893}
6894
6895static __inline__ vector unsigned int __ATTRS_o_ai
6896vec_or(vector bool int __a, vector unsigned int __b) {
6897 return (vector unsigned int)__a | __b;
6898}
6899
6900static __inline__ vector unsigned int __ATTRS_o_ai
6901vec_or(vector unsigned int __a, vector bool int __b) {
6902 return __a | (vector unsigned int)__b;
6903}
6904
6905static __inline__ vector bool int __ATTRS_o_ai vec_or(vector bool int __a,
6906 vector bool int __b) {
6907 return __a | __b;
6908}
6909
6910static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a,
6911 vector float __b) {
6912 vector unsigned int __res =
6913 (vector unsigned int)__a | (vector unsigned int)__b;
6914 return (vector float)__res;
6915}
6916
6917static __inline__ vector float __ATTRS_o_ai vec_or(vector bool int __a,
6918 vector float __b) {
6919 vector unsigned int __res =
6920 (vector unsigned int)__a | (vector unsigned int)__b;
6921 return (vector float)__res;
6922}
6923
6924static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a,
6925 vector bool int __b) {
6926 vector unsigned int __res =
6927 (vector unsigned int)__a | (vector unsigned int)__b;
6928 return (vector float)__res;
6929}
6930
6931#ifdef __VSX__
6932static __inline__ vector double __ATTRS_o_ai vec_or(vector bool long long __a,
6933 vector double __b) {
Sasha Smundak746b0222020-02-25 09:19:04 -08006934 return (vector double)((vector unsigned long long)__a |
6935 (vector unsigned long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +08006936}
6937
6938static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a,
6939 vector bool long long __b) {
Sasha Smundak746b0222020-02-25 09:19:04 -08006940 return (vector double)((vector unsigned long long)__a |
6941 (vector unsigned long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +08006942}
6943
6944static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a,
6945 vector double __b) {
Sasha Smundak746b0222020-02-25 09:19:04 -08006946 return (vector double)((vector unsigned long long)__a |
6947 (vector unsigned long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +08006948}
6949
6950static __inline__ vector signed long long __ATTRS_o_ai
6951vec_or(vector signed long long __a, vector signed long long __b) {
6952 return __a | __b;
6953}
6954
6955static __inline__ vector signed long long __ATTRS_o_ai
6956vec_or(vector bool long long __a, vector signed long long __b) {
6957 return (vector signed long long)__a | __b;
6958}
6959
6960static __inline__ vector signed long long __ATTRS_o_ai
6961vec_or(vector signed long long __a, vector bool long long __b) {
6962 return __a | (vector signed long long)__b;
6963}
6964
6965static __inline__ vector unsigned long long __ATTRS_o_ai
6966vec_or(vector unsigned long long __a, vector unsigned long long __b) {
6967 return __a | __b;
6968}
6969
6970static __inline__ vector unsigned long long __ATTRS_o_ai
6971vec_or(vector bool long long __a, vector unsigned long long __b) {
6972 return (vector unsigned long long)__a | __b;
6973}
6974
6975static __inline__ vector unsigned long long __ATTRS_o_ai
6976vec_or(vector unsigned long long __a, vector bool long long __b) {
6977 return __a | (vector unsigned long long)__b;
6978}
6979
6980static __inline__ vector bool long long __ATTRS_o_ai
6981vec_or(vector bool long long __a, vector bool long long __b) {
6982 return __a | __b;
6983}
6984#endif
6985
6986#ifdef __POWER8_VECTOR__
6987static __inline__ vector signed char __ATTRS_o_ai
6988vec_orc(vector signed char __a, vector signed char __b) {
6989 return __a | ~__b;
6990}
6991
6992static __inline__ vector signed char __ATTRS_o_ai
6993vec_orc(vector signed char __a, vector bool char __b) {
6994 return __a | ~__b;
6995}
6996
6997static __inline__ vector signed char __ATTRS_o_ai
6998vec_orc(vector bool char __a, vector signed char __b) {
6999 return __a | ~__b;
7000}
7001
7002static __inline__ vector unsigned char __ATTRS_o_ai
7003vec_orc(vector unsigned char __a, vector unsigned char __b) {
7004 return __a | ~__b;
7005}
7006
7007static __inline__ vector unsigned char __ATTRS_o_ai
7008vec_orc(vector unsigned char __a, vector bool char __b) {
7009 return __a | ~__b;
7010}
7011
7012static __inline__ vector unsigned char __ATTRS_o_ai
7013vec_orc(vector bool char __a, vector unsigned char __b) {
7014 return __a | ~__b;
7015}
7016
7017static __inline__ vector bool char __ATTRS_o_ai vec_orc(vector bool char __a,
7018 vector bool char __b) {
7019 return __a | ~__b;
7020}
7021
7022static __inline__ vector signed short __ATTRS_o_ai
7023vec_orc(vector signed short __a, vector signed short __b) {
7024 return __a | ~__b;
7025}
7026
7027static __inline__ vector signed short __ATTRS_o_ai
7028vec_orc(vector signed short __a, vector bool short __b) {
7029 return __a | ~__b;
7030}
7031
7032static __inline__ vector signed short __ATTRS_o_ai
7033vec_orc(vector bool short __a, vector signed short __b) {
7034 return __a | ~__b;
7035}
7036
7037static __inline__ vector unsigned short __ATTRS_o_ai
7038vec_orc(vector unsigned short __a, vector unsigned short __b) {
7039 return __a | ~__b;
7040}
7041
7042static __inline__ vector unsigned short __ATTRS_o_ai
7043vec_orc(vector unsigned short __a, vector bool short __b) {
7044 return __a | ~__b;
7045}
7046
7047static __inline__ vector unsigned short __ATTRS_o_ai
7048vec_orc(vector bool short __a, vector unsigned short __b) {
7049 return __a | ~__b;
7050}
7051
7052static __inline__ vector bool short __ATTRS_o_ai
7053vec_orc(vector bool short __a, vector bool short __b) {
7054 return __a | ~__b;
7055}
7056
7057static __inline__ vector signed int __ATTRS_o_ai
7058vec_orc(vector signed int __a, vector signed int __b) {
7059 return __a | ~__b;
7060}
7061
7062static __inline__ vector signed int __ATTRS_o_ai vec_orc(vector signed int __a,
7063 vector bool int __b) {
7064 return __a | ~__b;
7065}
7066
7067static __inline__ vector signed int __ATTRS_o_ai
7068vec_orc(vector bool int __a, vector signed int __b) {
7069 return __a | ~__b;
7070}
7071
7072static __inline__ vector unsigned int __ATTRS_o_ai
7073vec_orc(vector unsigned int __a, vector unsigned int __b) {
7074 return __a | ~__b;
7075}
7076
7077static __inline__ vector unsigned int __ATTRS_o_ai
7078vec_orc(vector unsigned int __a, vector bool int __b) {
7079 return __a | ~__b;
7080}
7081
7082static __inline__ vector unsigned int __ATTRS_o_ai
7083vec_orc(vector bool int __a, vector unsigned int __b) {
7084 return __a | ~__b;
7085}
7086
7087static __inline__ vector bool int __ATTRS_o_ai vec_orc(vector bool int __a,
7088 vector bool int __b) {
7089 return __a | ~__b;
7090}
7091
Logan Chien55afb0a2018-10-15 10:42:14 +08007092static __inline__ vector float __ATTRS_o_ai
7093vec_orc(vector bool int __a, vector float __b) {
7094 return (vector float)(__a | ~(vector unsigned int)__b);
7095}
7096
7097static __inline__ vector float __ATTRS_o_ai
7098vec_orc(vector float __a, vector bool int __b) {
7099 return (vector float)((vector unsigned int)__a | ~__b);
7100}
7101
Logan Chien2833ffb2018-10-09 10:03:24 +08007102static __inline__ vector signed long long __ATTRS_o_ai
7103vec_orc(vector signed long long __a, vector signed long long __b) {
7104 return __a | ~__b;
7105}
7106
7107static __inline__ vector signed long long __ATTRS_o_ai
7108vec_orc(vector signed long long __a, vector bool long long __b) {
7109 return __a | ~__b;
7110}
7111
7112static __inline__ vector signed long long __ATTRS_o_ai
7113vec_orc(vector bool long long __a, vector signed long long __b) {
7114 return __a | ~__b;
7115}
7116
7117static __inline__ vector unsigned long long __ATTRS_o_ai
7118vec_orc(vector unsigned long long __a, vector unsigned long long __b) {
7119 return __a | ~__b;
7120}
7121
7122static __inline__ vector unsigned long long __ATTRS_o_ai
7123vec_orc(vector unsigned long long __a, vector bool long long __b) {
7124 return __a | ~__b;
7125}
7126
7127static __inline__ vector unsigned long long __ATTRS_o_ai
7128vec_orc(vector bool long long __a, vector unsigned long long __b) {
7129 return __a | ~__b;
7130}
7131
7132static __inline__ vector bool long long __ATTRS_o_ai
7133vec_orc(vector bool long long __a, vector bool long long __b) {
7134 return __a | ~__b;
7135}
Logan Chien55afb0a2018-10-15 10:42:14 +08007136
7137static __inline__ vector double __ATTRS_o_ai
7138vec_orc(vector double __a, vector bool long long __b) {
7139 return (vector double)((vector unsigned long long)__a | ~__b);
7140}
7141
7142static __inline__ vector double __ATTRS_o_ai
7143vec_orc(vector bool long long __a, vector double __b) {
7144 return (vector double)(__a | ~(vector unsigned long long)__b);
7145}
Logan Chien2833ffb2018-10-09 10:03:24 +08007146#endif
7147
7148/* vec_vor */
7149
7150static __inline__ vector signed char __ATTRS_o_ai
7151vec_vor(vector signed char __a, vector signed char __b) {
7152 return __a | __b;
7153}
7154
7155static __inline__ vector signed char __ATTRS_o_ai
7156vec_vor(vector bool char __a, vector signed char __b) {
7157 return (vector signed char)__a | __b;
7158}
7159
7160static __inline__ vector signed char __ATTRS_o_ai
7161vec_vor(vector signed char __a, vector bool char __b) {
7162 return __a | (vector signed char)__b;
7163}
7164
7165static __inline__ vector unsigned char __ATTRS_o_ai
7166vec_vor(vector unsigned char __a, vector unsigned char __b) {
7167 return __a | __b;
7168}
7169
7170static __inline__ vector unsigned char __ATTRS_o_ai
7171vec_vor(vector bool char __a, vector unsigned char __b) {
7172 return (vector unsigned char)__a | __b;
7173}
7174
7175static __inline__ vector unsigned char __ATTRS_o_ai
7176vec_vor(vector unsigned char __a, vector bool char __b) {
7177 return __a | (vector unsigned char)__b;
7178}
7179
7180static __inline__ vector bool char __ATTRS_o_ai vec_vor(vector bool char __a,
7181 vector bool char __b) {
7182 return __a | __b;
7183}
7184
7185static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a,
7186 vector short __b) {
7187 return __a | __b;
7188}
7189
7190static __inline__ vector short __ATTRS_o_ai vec_vor(vector bool short __a,
7191 vector short __b) {
7192 return (vector short)__a | __b;
7193}
7194
7195static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a,
7196 vector bool short __b) {
7197 return __a | (vector short)__b;
7198}
7199
7200static __inline__ vector unsigned short __ATTRS_o_ai
7201vec_vor(vector unsigned short __a, vector unsigned short __b) {
7202 return __a | __b;
7203}
7204
7205static __inline__ vector unsigned short __ATTRS_o_ai
7206vec_vor(vector bool short __a, vector unsigned short __b) {
7207 return (vector unsigned short)__a | __b;
7208}
7209
7210static __inline__ vector unsigned short __ATTRS_o_ai
7211vec_vor(vector unsigned short __a, vector bool short __b) {
7212 return __a | (vector unsigned short)__b;
7213}
7214
7215static __inline__ vector bool short __ATTRS_o_ai
7216vec_vor(vector bool short __a, vector bool short __b) {
7217 return __a | __b;
7218}
7219
7220static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a,
7221 vector int __b) {
7222 return __a | __b;
7223}
7224
7225static __inline__ vector int __ATTRS_o_ai vec_vor(vector bool int __a,
7226 vector int __b) {
7227 return (vector int)__a | __b;
7228}
7229
7230static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a,
7231 vector bool int __b) {
7232 return __a | (vector int)__b;
7233}
7234
7235static __inline__ vector unsigned int __ATTRS_o_ai
7236vec_vor(vector unsigned int __a, vector unsigned int __b) {
7237 return __a | __b;
7238}
7239
7240static __inline__ vector unsigned int __ATTRS_o_ai
7241vec_vor(vector bool int __a, vector unsigned int __b) {
7242 return (vector unsigned int)__a | __b;
7243}
7244
7245static __inline__ vector unsigned int __ATTRS_o_ai
7246vec_vor(vector unsigned int __a, vector bool int __b) {
7247 return __a | (vector unsigned int)__b;
7248}
7249
7250static __inline__ vector bool int __ATTRS_o_ai vec_vor(vector bool int __a,
7251 vector bool int __b) {
7252 return __a | __b;
7253}
7254
7255static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a,
7256 vector float __b) {
7257 vector unsigned int __res =
7258 (vector unsigned int)__a | (vector unsigned int)__b;
7259 return (vector float)__res;
7260}
7261
7262static __inline__ vector float __ATTRS_o_ai vec_vor(vector bool int __a,
7263 vector float __b) {
7264 vector unsigned int __res =
7265 (vector unsigned int)__a | (vector unsigned int)__b;
7266 return (vector float)__res;
7267}
7268
7269static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a,
7270 vector bool int __b) {
7271 vector unsigned int __res =
7272 (vector unsigned int)__a | (vector unsigned int)__b;
7273 return (vector float)__res;
7274}
7275
7276#ifdef __VSX__
7277static __inline__ vector signed long long __ATTRS_o_ai
7278vec_vor(vector signed long long __a, vector signed long long __b) {
7279 return __a | __b;
7280}
7281
7282static __inline__ vector signed long long __ATTRS_o_ai
7283vec_vor(vector bool long long __a, vector signed long long __b) {
7284 return (vector signed long long)__a | __b;
7285}
7286
7287static __inline__ vector signed long long __ATTRS_o_ai
7288vec_vor(vector signed long long __a, vector bool long long __b) {
7289 return __a | (vector signed long long)__b;
7290}
7291
7292static __inline__ vector unsigned long long __ATTRS_o_ai
7293vec_vor(vector unsigned long long __a, vector unsigned long long __b) {
7294 return __a | __b;
7295}
7296
7297static __inline__ vector unsigned long long __ATTRS_o_ai
7298vec_vor(vector bool long long __a, vector unsigned long long __b) {
7299 return (vector unsigned long long)__a | __b;
7300}
7301
7302static __inline__ vector unsigned long long __ATTRS_o_ai
7303vec_vor(vector unsigned long long __a, vector bool long long __b) {
7304 return __a | (vector unsigned long long)__b;
7305}
7306
7307static __inline__ vector bool long long __ATTRS_o_ai
7308vec_vor(vector bool long long __a, vector bool long long __b) {
7309 return __a | __b;
7310}
7311#endif
7312
7313/* vec_pack */
7314
7315/* The various vector pack instructions have a big-endian bias, so for
7316 little endian we must handle reversed element numbering. */
7317
7318static __inline__ vector signed char __ATTRS_o_ai
7319vec_pack(vector signed short __a, vector signed short __b) {
7320#ifdef __LITTLE_ENDIAN__
7321 return (vector signed char)vec_perm(
7322 __a, __b,
7323 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7324 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7325#else
7326 return (vector signed char)vec_perm(
7327 __a, __b,
7328 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7329 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7330#endif
7331}
7332
7333static __inline__ vector unsigned char __ATTRS_o_ai
7334vec_pack(vector unsigned short __a, vector unsigned short __b) {
7335#ifdef __LITTLE_ENDIAN__
7336 return (vector unsigned char)vec_perm(
7337 __a, __b,
7338 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7339 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7340#else
7341 return (vector unsigned char)vec_perm(
7342 __a, __b,
7343 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7344 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7345#endif
7346}
7347
7348static __inline__ vector bool char __ATTRS_o_ai
7349vec_pack(vector bool short __a, vector bool short __b) {
7350#ifdef __LITTLE_ENDIAN__
7351 return (vector bool char)vec_perm(
7352 __a, __b,
7353 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7354 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7355#else
7356 return (vector bool char)vec_perm(
7357 __a, __b,
7358 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7359 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7360#endif
7361}
7362
7363static __inline__ vector short __ATTRS_o_ai vec_pack(vector int __a,
7364 vector int __b) {
7365#ifdef __LITTLE_ENDIAN__
7366 return (vector short)vec_perm(
7367 __a, __b,
7368 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7369 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7370#else
7371 return (vector short)vec_perm(
7372 __a, __b,
7373 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7374 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7375#endif
7376}
7377
7378static __inline__ vector unsigned short __ATTRS_o_ai
7379vec_pack(vector unsigned int __a, vector unsigned int __b) {
7380#ifdef __LITTLE_ENDIAN__
7381 return (vector unsigned short)vec_perm(
7382 __a, __b,
7383 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7384 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7385#else
7386 return (vector unsigned short)vec_perm(
7387 __a, __b,
7388 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7389 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7390#endif
7391}
7392
7393static __inline__ vector bool short __ATTRS_o_ai vec_pack(vector bool int __a,
7394 vector bool int __b) {
7395#ifdef __LITTLE_ENDIAN__
7396 return (vector bool short)vec_perm(
7397 __a, __b,
7398 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7399 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7400#else
7401 return (vector bool short)vec_perm(
7402 __a, __b,
7403 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7404 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7405#endif
7406}
7407
7408#ifdef __VSX__
7409static __inline__ vector signed int __ATTRS_o_ai
7410vec_pack(vector signed long long __a, vector signed long long __b) {
7411#ifdef __LITTLE_ENDIAN__
7412 return (vector signed int)vec_perm(
7413 __a, __b,
7414 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7415 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7416#else
7417 return (vector signed int)vec_perm(
7418 __a, __b,
7419 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7420 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7421#endif
7422}
7423static __inline__ vector unsigned int __ATTRS_o_ai
7424vec_pack(vector unsigned long long __a, vector unsigned long long __b) {
7425#ifdef __LITTLE_ENDIAN__
7426 return (vector unsigned int)vec_perm(
7427 __a, __b,
7428 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7429 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7430#else
7431 return (vector unsigned int)vec_perm(
7432 __a, __b,
7433 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7434 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7435#endif
7436}
7437
7438static __inline__ vector bool int __ATTRS_o_ai
7439vec_pack(vector bool long long __a, vector bool long long __b) {
7440#ifdef __LITTLE_ENDIAN__
7441 return (vector bool int)vec_perm(
7442 __a, __b,
7443 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7444 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7445#else
7446 return (vector bool int)vec_perm(
7447 __a, __b,
7448 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7449 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7450#endif
7451}
7452
Logan Chien55afb0a2018-10-15 10:42:14 +08007453static __inline__ vector float __ATTRS_o_ai
7454vec_pack(vector double __a, vector double __b) {
7455 return (vector float) (__a[0], __a[1], __b[0], __b[1]);
7456}
Logan Chien2833ffb2018-10-09 10:03:24 +08007457#endif
7458
Logan Chien55afb0a2018-10-15 10:42:14 +08007459#ifdef __POWER9_VECTOR__
7460static __inline__ vector unsigned short __ATTRS_o_ai
7461vec_pack_to_short_fp32(vector float __a, vector float __b) {
7462 vector float __resa = __builtin_vsx_xvcvsphp(__a);
7463 vector float __resb = __builtin_vsx_xvcvsphp(__b);
7464#ifdef __LITTLE_ENDIAN__
7465 return (vector unsigned short)vec_mergee(__resa, __resb);
7466#else
7467 return (vector unsigned short)vec_mergeo(__resa, __resb);
7468#endif
7469}
7470
7471#endif
Logan Chien2833ffb2018-10-09 10:03:24 +08007472/* vec_vpkuhum */
7473
7474#define __builtin_altivec_vpkuhum vec_vpkuhum
7475
7476static __inline__ vector signed char __ATTRS_o_ai
7477vec_vpkuhum(vector signed short __a, vector signed short __b) {
7478#ifdef __LITTLE_ENDIAN__
7479 return (vector signed char)vec_perm(
7480 __a, __b,
7481 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7482 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7483#else
7484 return (vector signed char)vec_perm(
7485 __a, __b,
7486 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7487 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7488#endif
7489}
7490
7491static __inline__ vector unsigned char __ATTRS_o_ai
7492vec_vpkuhum(vector unsigned short __a, vector unsigned short __b) {
7493#ifdef __LITTLE_ENDIAN__
7494 return (vector unsigned char)vec_perm(
7495 __a, __b,
7496 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7497 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7498#else
7499 return (vector unsigned char)vec_perm(
7500 __a, __b,
7501 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7502 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7503#endif
7504}
7505
7506static __inline__ vector bool char __ATTRS_o_ai
7507vec_vpkuhum(vector bool short __a, vector bool short __b) {
7508#ifdef __LITTLE_ENDIAN__
7509 return (vector bool char)vec_perm(
7510 __a, __b,
7511 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7512 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7513#else
7514 return (vector bool char)vec_perm(
7515 __a, __b,
7516 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7517 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7518#endif
7519}
7520
7521/* vec_vpkuwum */
7522
7523#define __builtin_altivec_vpkuwum vec_vpkuwum
7524
7525static __inline__ vector short __ATTRS_o_ai vec_vpkuwum(vector int __a,
7526 vector int __b) {
7527#ifdef __LITTLE_ENDIAN__
7528 return (vector short)vec_perm(
7529 __a, __b,
7530 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7531 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7532#else
7533 return (vector short)vec_perm(
7534 __a, __b,
7535 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7536 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7537#endif
7538}
7539
7540static __inline__ vector unsigned short __ATTRS_o_ai
7541vec_vpkuwum(vector unsigned int __a, vector unsigned int __b) {
7542#ifdef __LITTLE_ENDIAN__
7543 return (vector unsigned short)vec_perm(
7544 __a, __b,
7545 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7546 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7547#else
7548 return (vector unsigned short)vec_perm(
7549 __a, __b,
7550 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7551 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7552#endif
7553}
7554
7555static __inline__ vector bool short __ATTRS_o_ai
7556vec_vpkuwum(vector bool int __a, vector bool int __b) {
7557#ifdef __LITTLE_ENDIAN__
7558 return (vector bool short)vec_perm(
7559 __a, __b,
7560 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7561 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7562#else
7563 return (vector bool short)vec_perm(
7564 __a, __b,
7565 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7566 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7567#endif
7568}
7569
7570/* vec_vpkudum */
7571
7572#ifdef __POWER8_VECTOR__
7573#define __builtin_altivec_vpkudum vec_vpkudum
7574
7575static __inline__ vector int __ATTRS_o_ai vec_vpkudum(vector long long __a,
7576 vector long long __b) {
7577#ifdef __LITTLE_ENDIAN__
7578 return (vector int)vec_perm(
7579 __a, __b,
7580 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7581 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7582#else
7583 return (vector int)vec_perm(
7584 __a, __b,
7585 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7586 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7587#endif
7588}
7589
7590static __inline__ vector unsigned int __ATTRS_o_ai
7591vec_vpkudum(vector unsigned long long __a, vector unsigned long long __b) {
7592#ifdef __LITTLE_ENDIAN__
7593 return (vector unsigned int)vec_perm(
7594 __a, __b,
7595 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7596 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7597#else
7598 return (vector unsigned int)vec_perm(
7599 __a, __b,
7600 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7601 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7602#endif
7603}
7604
7605static __inline__ vector bool int __ATTRS_o_ai
7606vec_vpkudum(vector bool long long __a, vector bool long long __b) {
7607#ifdef __LITTLE_ENDIAN__
7608 return (vector bool int)vec_perm(
7609 (vector long long)__a, (vector long long)__b,
7610 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7611 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7612#else
7613 return (vector bool int)vec_perm(
7614 (vector long long)__a, (vector long long)__b,
7615 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7616 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7617#endif
7618}
7619#endif
7620
7621/* vec_packpx */
7622
7623static __inline__ vector pixel __attribute__((__always_inline__))
7624vec_packpx(vector unsigned int __a, vector unsigned int __b) {
7625#ifdef __LITTLE_ENDIAN__
7626 return (vector pixel)__builtin_altivec_vpkpx(__b, __a);
7627#else
7628 return (vector pixel)__builtin_altivec_vpkpx(__a, __b);
7629#endif
7630}
7631
7632/* vec_vpkpx */
7633
7634static __inline__ vector pixel __attribute__((__always_inline__))
7635vec_vpkpx(vector unsigned int __a, vector unsigned int __b) {
7636#ifdef __LITTLE_ENDIAN__
7637 return (vector pixel)__builtin_altivec_vpkpx(__b, __a);
7638#else
7639 return (vector pixel)__builtin_altivec_vpkpx(__a, __b);
7640#endif
7641}
7642
7643/* vec_packs */
7644
7645static __inline__ vector signed char __ATTRS_o_ai vec_packs(vector short __a,
7646 vector short __b) {
7647#ifdef __LITTLE_ENDIAN__
7648 return __builtin_altivec_vpkshss(__b, __a);
7649#else
7650 return __builtin_altivec_vpkshss(__a, __b);
7651#endif
7652}
7653
7654static __inline__ vector unsigned char __ATTRS_o_ai
7655vec_packs(vector unsigned short __a, vector unsigned short __b) {
7656#ifdef __LITTLE_ENDIAN__
7657 return __builtin_altivec_vpkuhus(__b, __a);
7658#else
7659 return __builtin_altivec_vpkuhus(__a, __b);
7660#endif
7661}
7662
7663static __inline__ vector signed short __ATTRS_o_ai vec_packs(vector int __a,
7664 vector int __b) {
7665#ifdef __LITTLE_ENDIAN__
7666 return __builtin_altivec_vpkswss(__b, __a);
7667#else
7668 return __builtin_altivec_vpkswss(__a, __b);
7669#endif
7670}
7671
7672static __inline__ vector unsigned short __ATTRS_o_ai
7673vec_packs(vector unsigned int __a, vector unsigned int __b) {
7674#ifdef __LITTLE_ENDIAN__
7675 return __builtin_altivec_vpkuwus(__b, __a);
7676#else
7677 return __builtin_altivec_vpkuwus(__a, __b);
7678#endif
7679}
7680
7681#ifdef __POWER8_VECTOR__
7682static __inline__ vector int __ATTRS_o_ai vec_packs(vector long long __a,
7683 vector long long __b) {
7684#ifdef __LITTLE_ENDIAN__
7685 return __builtin_altivec_vpksdss(__b, __a);
7686#else
7687 return __builtin_altivec_vpksdss(__a, __b);
7688#endif
7689}
7690
7691static __inline__ vector unsigned int __ATTRS_o_ai
7692vec_packs(vector unsigned long long __a, vector unsigned long long __b) {
7693#ifdef __LITTLE_ENDIAN__
7694 return __builtin_altivec_vpkudus(__b, __a);
7695#else
7696 return __builtin_altivec_vpkudus(__a, __b);
7697#endif
7698}
7699#endif
7700
7701/* vec_vpkshss */
7702
7703static __inline__ vector signed char __attribute__((__always_inline__))
7704vec_vpkshss(vector short __a, vector short __b) {
7705#ifdef __LITTLE_ENDIAN__
7706 return __builtin_altivec_vpkshss(__b, __a);
7707#else
7708 return __builtin_altivec_vpkshss(__a, __b);
7709#endif
7710}
7711
7712/* vec_vpksdss */
7713
7714#ifdef __POWER8_VECTOR__
7715static __inline__ vector int __ATTRS_o_ai vec_vpksdss(vector long long __a,
7716 vector long long __b) {
7717#ifdef __LITTLE_ENDIAN__
7718 return __builtin_altivec_vpksdss(__b, __a);
7719#else
7720 return __builtin_altivec_vpksdss(__a, __b);
7721#endif
7722}
7723#endif
7724
7725/* vec_vpkuhus */
7726
7727static __inline__ vector unsigned char __attribute__((__always_inline__))
7728vec_vpkuhus(vector unsigned short __a, vector unsigned short __b) {
7729#ifdef __LITTLE_ENDIAN__
7730 return __builtin_altivec_vpkuhus(__b, __a);
7731#else
7732 return __builtin_altivec_vpkuhus(__a, __b);
7733#endif
7734}
7735
7736/* vec_vpkudus */
7737
7738#ifdef __POWER8_VECTOR__
7739static __inline__ vector unsigned int __attribute__((__always_inline__))
7740vec_vpkudus(vector unsigned long long __a, vector unsigned long long __b) {
7741#ifdef __LITTLE_ENDIAN__
7742 return __builtin_altivec_vpkudus(__b, __a);
7743#else
7744 return __builtin_altivec_vpkudus(__a, __b);
7745#endif
7746}
7747#endif
7748
7749/* vec_vpkswss */
7750
7751static __inline__ vector signed short __attribute__((__always_inline__))
7752vec_vpkswss(vector int __a, vector int __b) {
7753#ifdef __LITTLE_ENDIAN__
7754 return __builtin_altivec_vpkswss(__b, __a);
7755#else
7756 return __builtin_altivec_vpkswss(__a, __b);
7757#endif
7758}
7759
7760/* vec_vpkuwus */
7761
7762static __inline__ vector unsigned short __attribute__((__always_inline__))
7763vec_vpkuwus(vector unsigned int __a, vector unsigned int __b) {
7764#ifdef __LITTLE_ENDIAN__
7765 return __builtin_altivec_vpkuwus(__b, __a);
7766#else
7767 return __builtin_altivec_vpkuwus(__a, __b);
7768#endif
7769}
7770
7771/* vec_packsu */
7772
7773static __inline__ vector unsigned char __ATTRS_o_ai
7774vec_packsu(vector short __a, vector short __b) {
7775#ifdef __LITTLE_ENDIAN__
7776 return __builtin_altivec_vpkshus(__b, __a);
7777#else
7778 return __builtin_altivec_vpkshus(__a, __b);
7779#endif
7780}
7781
7782static __inline__ vector unsigned char __ATTRS_o_ai
7783vec_packsu(vector unsigned short __a, vector unsigned short __b) {
7784#ifdef __LITTLE_ENDIAN__
7785 return __builtin_altivec_vpkuhus(__b, __a);
7786#else
7787 return __builtin_altivec_vpkuhus(__a, __b);
7788#endif
7789}
7790
7791static __inline__ vector unsigned short __ATTRS_o_ai
7792vec_packsu(vector int __a, vector int __b) {
7793#ifdef __LITTLE_ENDIAN__
7794 return __builtin_altivec_vpkswus(__b, __a);
7795#else
7796 return __builtin_altivec_vpkswus(__a, __b);
7797#endif
7798}
7799
7800static __inline__ vector unsigned short __ATTRS_o_ai
7801vec_packsu(vector unsigned int __a, vector unsigned int __b) {
7802#ifdef __LITTLE_ENDIAN__
7803 return __builtin_altivec_vpkuwus(__b, __a);
7804#else
7805 return __builtin_altivec_vpkuwus(__a, __b);
7806#endif
7807}
7808
7809#ifdef __POWER8_VECTOR__
7810static __inline__ vector unsigned int __ATTRS_o_ai
7811vec_packsu(vector long long __a, vector long long __b) {
7812#ifdef __LITTLE_ENDIAN__
7813 return __builtin_altivec_vpksdus(__b, __a);
7814#else
7815 return __builtin_altivec_vpksdus(__a, __b);
7816#endif
7817}
7818
7819static __inline__ vector unsigned int __ATTRS_o_ai
7820vec_packsu(vector unsigned long long __a, vector unsigned long long __b) {
7821#ifdef __LITTLE_ENDIAN__
7822 return __builtin_altivec_vpkudus(__b, __a);
7823#else
7824 return __builtin_altivec_vpkudus(__a, __b);
7825#endif
7826}
7827#endif
7828
7829/* vec_vpkshus */
7830
7831static __inline__ vector unsigned char __ATTRS_o_ai
7832vec_vpkshus(vector short __a, vector short __b) {
7833#ifdef __LITTLE_ENDIAN__
7834 return __builtin_altivec_vpkshus(__b, __a);
7835#else
7836 return __builtin_altivec_vpkshus(__a, __b);
7837#endif
7838}
7839
7840static __inline__ vector unsigned char __ATTRS_o_ai
7841vec_vpkshus(vector unsigned short __a, vector unsigned short __b) {
7842#ifdef __LITTLE_ENDIAN__
7843 return __builtin_altivec_vpkuhus(__b, __a);
7844#else
7845 return __builtin_altivec_vpkuhus(__a, __b);
7846#endif
7847}
7848
7849/* vec_vpkswus */
7850
7851static __inline__ vector unsigned short __ATTRS_o_ai
7852vec_vpkswus(vector int __a, vector int __b) {
7853#ifdef __LITTLE_ENDIAN__
7854 return __builtin_altivec_vpkswus(__b, __a);
7855#else
7856 return __builtin_altivec_vpkswus(__a, __b);
7857#endif
7858}
7859
7860static __inline__ vector unsigned short __ATTRS_o_ai
7861vec_vpkswus(vector unsigned int __a, vector unsigned int __b) {
7862#ifdef __LITTLE_ENDIAN__
7863 return __builtin_altivec_vpkuwus(__b, __a);
7864#else
7865 return __builtin_altivec_vpkuwus(__a, __b);
7866#endif
7867}
7868
7869/* vec_vpksdus */
7870
7871#ifdef __POWER8_VECTOR__
7872static __inline__ vector unsigned int __ATTRS_o_ai
7873vec_vpksdus(vector long long __a, vector long long __b) {
7874#ifdef __LITTLE_ENDIAN__
7875 return __builtin_altivec_vpksdus(__b, __a);
7876#else
7877 return __builtin_altivec_vpksdus(__a, __b);
7878#endif
7879}
7880#endif
7881
7882/* vec_perm */
7883
7884// The vperm instruction is defined architecturally with a big-endian bias.
7885// For little endian, we swap the input operands and invert the permute
7886// control vector. Only the rightmost 5 bits matter, so we could use
7887// a vector of all 31s instead of all 255s to perform the inversion.
7888// However, when the PCV is not a constant, using 255 has an advantage
7889// in that the vec_xor can be recognized as a vec_nor (and for P8 and
7890// later, possibly a vec_nand).
7891
7892static __inline__ vector signed char __ATTRS_o_ai vec_perm(
7893 vector signed char __a, vector signed char __b, vector unsigned char __c) {
7894#ifdef __LITTLE_ENDIAN__
7895 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7896 255, 255, 255, 255, 255, 255, 255, 255};
7897 __d = vec_xor(__c, __d);
7898 return (vector signed char)__builtin_altivec_vperm_4si((vector int)__b,
7899 (vector int)__a, __d);
7900#else
7901 return (vector signed char)__builtin_altivec_vperm_4si((vector int)__a,
7902 (vector int)__b, __c);
7903#endif
7904}
7905
7906static __inline__ vector unsigned char __ATTRS_o_ai
7907vec_perm(vector unsigned char __a, vector unsigned char __b,
7908 vector unsigned char __c) {
7909#ifdef __LITTLE_ENDIAN__
7910 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7911 255, 255, 255, 255, 255, 255, 255, 255};
7912 __d = vec_xor(__c, __d);
7913 return (vector unsigned char)__builtin_altivec_vperm_4si(
7914 (vector int)__b, (vector int)__a, __d);
7915#else
7916 return (vector unsigned char)__builtin_altivec_vperm_4si(
7917 (vector int)__a, (vector int)__b, __c);
7918#endif
7919}
7920
7921static __inline__ vector bool char __ATTRS_o_ai
7922vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c) {
7923#ifdef __LITTLE_ENDIAN__
7924 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7925 255, 255, 255, 255, 255, 255, 255, 255};
7926 __d = vec_xor(__c, __d);
7927 return (vector bool char)__builtin_altivec_vperm_4si((vector int)__b,
7928 (vector int)__a, __d);
7929#else
7930 return (vector bool char)__builtin_altivec_vperm_4si((vector int)__a,
7931 (vector int)__b, __c);
7932#endif
7933}
7934
7935static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a,
7936 vector signed short __b,
7937 vector unsigned char __c) {
7938#ifdef __LITTLE_ENDIAN__
7939 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7940 255, 255, 255, 255, 255, 255, 255, 255};
7941 __d = vec_xor(__c, __d);
7942 return (vector signed short)__builtin_altivec_vperm_4si((vector int)__b,
7943 (vector int)__a, __d);
7944#else
7945 return (vector signed short)__builtin_altivec_vperm_4si((vector int)__a,
7946 (vector int)__b, __c);
7947#endif
7948}
7949
7950static __inline__ vector unsigned short __ATTRS_o_ai
7951vec_perm(vector unsigned short __a, vector unsigned short __b,
7952 vector unsigned char __c) {
7953#ifdef __LITTLE_ENDIAN__
7954 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7955 255, 255, 255, 255, 255, 255, 255, 255};
7956 __d = vec_xor(__c, __d);
7957 return (vector unsigned short)__builtin_altivec_vperm_4si(
7958 (vector int)__b, (vector int)__a, __d);
7959#else
7960 return (vector unsigned short)__builtin_altivec_vperm_4si(
7961 (vector int)__a, (vector int)__b, __c);
7962#endif
7963}
7964
7965static __inline__ vector bool short __ATTRS_o_ai vec_perm(
7966 vector bool short __a, vector bool short __b, vector unsigned char __c) {
7967#ifdef __LITTLE_ENDIAN__
7968 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7969 255, 255, 255, 255, 255, 255, 255, 255};
7970 __d = vec_xor(__c, __d);
7971 return (vector bool short)__builtin_altivec_vperm_4si((vector int)__b,
7972 (vector int)__a, __d);
7973#else
7974 return (vector bool short)__builtin_altivec_vperm_4si((vector int)__a,
7975 (vector int)__b, __c);
7976#endif
7977}
7978
7979static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a,
7980 vector pixel __b,
7981 vector unsigned char __c) {
7982#ifdef __LITTLE_ENDIAN__
7983 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7984 255, 255, 255, 255, 255, 255, 255, 255};
7985 __d = vec_xor(__c, __d);
7986 return (vector pixel)__builtin_altivec_vperm_4si((vector int)__b,
7987 (vector int)__a, __d);
7988#else
7989 return (vector pixel)__builtin_altivec_vperm_4si((vector int)__a,
7990 (vector int)__b, __c);
7991#endif
7992}
7993
7994static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a,
7995 vector signed int __b,
7996 vector unsigned char __c) {
7997#ifdef __LITTLE_ENDIAN__
7998 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7999 255, 255, 255, 255, 255, 255, 255, 255};
8000 __d = vec_xor(__c, __d);
8001 return (vector signed int)__builtin_altivec_vperm_4si(__b, __a, __d);
8002#else
8003 return (vector signed int)__builtin_altivec_vperm_4si(__a, __b, __c);
8004#endif
8005}
8006
8007static __inline__ vector unsigned int __ATTRS_o_ai
8008vec_perm(vector unsigned int __a, vector unsigned int __b,
8009 vector unsigned char __c) {
8010#ifdef __LITTLE_ENDIAN__
8011 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8012 255, 255, 255, 255, 255, 255, 255, 255};
8013 __d = vec_xor(__c, __d);
8014 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__b,
8015 (vector int)__a, __d);
8016#else
8017 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__a,
8018 (vector int)__b, __c);
8019#endif
8020}
8021
8022static __inline__ vector bool int __ATTRS_o_ai
8023vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c) {
8024#ifdef __LITTLE_ENDIAN__
8025 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8026 255, 255, 255, 255, 255, 255, 255, 255};
8027 __d = vec_xor(__c, __d);
8028 return (vector bool int)__builtin_altivec_vperm_4si((vector int)__b,
8029 (vector int)__a, __d);
8030#else
8031 return (vector bool int)__builtin_altivec_vperm_4si((vector int)__a,
8032 (vector int)__b, __c);
8033#endif
8034}
8035
8036static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a,
8037 vector float __b,
8038 vector unsigned char __c) {
8039#ifdef __LITTLE_ENDIAN__
8040 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8041 255, 255, 255, 255, 255, 255, 255, 255};
8042 __d = vec_xor(__c, __d);
8043 return (vector float)__builtin_altivec_vperm_4si((vector int)__b,
8044 (vector int)__a, __d);
8045#else
8046 return (vector float)__builtin_altivec_vperm_4si((vector int)__a,
8047 (vector int)__b, __c);
8048#endif
8049}
8050
8051#ifdef __VSX__
8052static __inline__ vector long long __ATTRS_o_ai
8053vec_perm(vector signed long long __a, vector signed long long __b,
8054 vector unsigned char __c) {
8055#ifdef __LITTLE_ENDIAN__
8056 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8057 255, 255, 255, 255, 255, 255, 255, 255};
8058 __d = vec_xor(__c, __d);
8059 return (vector signed long long)__builtin_altivec_vperm_4si(
8060 (vector int)__b, (vector int)__a, __d);
8061#else
8062 return (vector signed long long)__builtin_altivec_vperm_4si(
8063 (vector int)__a, (vector int)__b, __c);
8064#endif
8065}
8066
8067static __inline__ vector unsigned long long __ATTRS_o_ai
8068vec_perm(vector unsigned long long __a, vector unsigned long long __b,
8069 vector unsigned char __c) {
8070#ifdef __LITTLE_ENDIAN__
8071 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8072 255, 255, 255, 255, 255, 255, 255, 255};
8073 __d = vec_xor(__c, __d);
8074 return (vector unsigned long long)__builtin_altivec_vperm_4si(
8075 (vector int)__b, (vector int)__a, __d);
8076#else
8077 return (vector unsigned long long)__builtin_altivec_vperm_4si(
8078 (vector int)__a, (vector int)__b, __c);
8079#endif
8080}
8081
8082static __inline__ vector bool long long __ATTRS_o_ai
8083vec_perm(vector bool long long __a, vector bool long long __b,
8084 vector unsigned char __c) {
8085#ifdef __LITTLE_ENDIAN__
8086 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8087 255, 255, 255, 255, 255, 255, 255, 255};
8088 __d = vec_xor(__c, __d);
8089 return (vector bool long long)__builtin_altivec_vperm_4si(
8090 (vector int)__b, (vector int)__a, __d);
8091#else
8092 return (vector bool long long)__builtin_altivec_vperm_4si(
8093 (vector int)__a, (vector int)__b, __c);
8094#endif
8095}
8096
8097static __inline__ vector double __ATTRS_o_ai
8098vec_perm(vector double __a, vector double __b, vector unsigned char __c) {
8099#ifdef __LITTLE_ENDIAN__
8100 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8101 255, 255, 255, 255, 255, 255, 255, 255};
8102 __d = vec_xor(__c, __d);
8103 return (vector double)__builtin_altivec_vperm_4si((vector int)__b,
8104 (vector int)__a, __d);
8105#else
8106 return (vector double)__builtin_altivec_vperm_4si((vector int)__a,
8107 (vector int)__b, __c);
8108#endif
8109}
8110#endif
8111
8112/* vec_vperm */
8113
8114static __inline__ vector signed char __ATTRS_o_ai vec_vperm(
8115 vector signed char __a, vector signed char __b, vector unsigned char __c) {
8116 return vec_perm(__a, __b, __c);
8117}
8118
8119static __inline__ vector unsigned char __ATTRS_o_ai
8120vec_vperm(vector unsigned char __a, vector unsigned char __b,
8121 vector unsigned char __c) {
8122 return vec_perm(__a, __b, __c);
8123}
8124
8125static __inline__ vector bool char __ATTRS_o_ai vec_vperm(
8126 vector bool char __a, vector bool char __b, vector unsigned char __c) {
8127 return vec_perm(__a, __b, __c);
8128}
8129
8130static __inline__ vector short __ATTRS_o_ai
8131vec_vperm(vector short __a, vector short __b, vector unsigned char __c) {
8132 return vec_perm(__a, __b, __c);
8133}
8134
8135static __inline__ vector unsigned short __ATTRS_o_ai
8136vec_vperm(vector unsigned short __a, vector unsigned short __b,
8137 vector unsigned char __c) {
8138 return vec_perm(__a, __b, __c);
8139}
8140
8141static __inline__ vector bool short __ATTRS_o_ai vec_vperm(
8142 vector bool short __a, vector bool short __b, vector unsigned char __c) {
8143 return vec_perm(__a, __b, __c);
8144}
8145
8146static __inline__ vector pixel __ATTRS_o_ai
8147vec_vperm(vector pixel __a, vector pixel __b, vector unsigned char __c) {
8148 return vec_perm(__a, __b, __c);
8149}
8150
8151static __inline__ vector int __ATTRS_o_ai vec_vperm(vector int __a,
8152 vector int __b,
8153 vector unsigned char __c) {
8154 return vec_perm(__a, __b, __c);
8155}
8156
8157static __inline__ vector unsigned int __ATTRS_o_ai
8158vec_vperm(vector unsigned int __a, vector unsigned int __b,
8159 vector unsigned char __c) {
8160 return vec_perm(__a, __b, __c);
8161}
8162
8163static __inline__ vector bool int __ATTRS_o_ai
8164vec_vperm(vector bool int __a, vector bool int __b, vector unsigned char __c) {
8165 return vec_perm(__a, __b, __c);
8166}
8167
8168static __inline__ vector float __ATTRS_o_ai
8169vec_vperm(vector float __a, vector float __b, vector unsigned char __c) {
8170 return vec_perm(__a, __b, __c);
8171}
8172
8173#ifdef __VSX__
8174static __inline__ vector long long __ATTRS_o_ai vec_vperm(
8175 vector long long __a, vector long long __b, vector unsigned char __c) {
8176 return vec_perm(__a, __b, __c);
8177}
8178
8179static __inline__ vector unsigned long long __ATTRS_o_ai
8180vec_vperm(vector unsigned long long __a, vector unsigned long long __b,
8181 vector unsigned char __c) {
8182 return vec_perm(__a, __b, __c);
8183}
8184
8185static __inline__ vector double __ATTRS_o_ai
8186vec_vperm(vector double __a, vector double __b, vector unsigned char __c) {
8187 return vec_perm(__a, __b, __c);
8188}
8189#endif
8190
8191/* vec_re */
8192
8193static __inline__ vector float __ATTRS_o_ai vec_re(vector float __a) {
8194#ifdef __VSX__
8195 return __builtin_vsx_xvresp(__a);
8196#else
8197 return __builtin_altivec_vrefp(__a);
8198#endif
8199}
8200
8201#ifdef __VSX__
8202static __inline__ vector double __ATTRS_o_ai vec_re(vector double __a) {
8203 return __builtin_vsx_xvredp(__a);
8204}
8205#endif
8206
8207/* vec_vrefp */
8208
8209static __inline__ vector float __attribute__((__always_inline__))
8210vec_vrefp(vector float __a) {
8211 return __builtin_altivec_vrefp(__a);
8212}
8213
8214/* vec_rl */
8215
8216static __inline__ vector signed char __ATTRS_o_ai
8217vec_rl(vector signed char __a, vector unsigned char __b) {
8218 return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b);
8219}
8220
8221static __inline__ vector unsigned char __ATTRS_o_ai
8222vec_rl(vector unsigned char __a, vector unsigned char __b) {
8223 return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b);
8224}
8225
8226static __inline__ vector short __ATTRS_o_ai vec_rl(vector short __a,
8227 vector unsigned short __b) {
8228 return __builtin_altivec_vrlh(__a, __b);
8229}
8230
8231static __inline__ vector unsigned short __ATTRS_o_ai
8232vec_rl(vector unsigned short __a, vector unsigned short __b) {
8233 return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b);
8234}
8235
8236static __inline__ vector int __ATTRS_o_ai vec_rl(vector int __a,
8237 vector unsigned int __b) {
8238 return __builtin_altivec_vrlw(__a, __b);
8239}
8240
8241static __inline__ vector unsigned int __ATTRS_o_ai
8242vec_rl(vector unsigned int __a, vector unsigned int __b) {
8243 return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b);
8244}
8245
8246#ifdef __POWER8_VECTOR__
8247static __inline__ vector signed long long __ATTRS_o_ai
8248vec_rl(vector signed long long __a, vector unsigned long long __b) {
8249 return __builtin_altivec_vrld(__a, __b);
8250}
8251
8252static __inline__ vector unsigned long long __ATTRS_o_ai
8253vec_rl(vector unsigned long long __a, vector unsigned long long __b) {
8254 return __builtin_altivec_vrld(__a, __b);
8255}
8256#endif
8257
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008258#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008259static __inline__ vector signed __int128 __ATTRS_o_ai
8260vec_rl(vector signed __int128 __a, vector unsigned __int128 __b) {
8261 return (__b << __a)|(__b >> ((__CHAR_BIT__ * sizeof(vector signed __int128)) - __a));
8262}
8263
8264static __inline__ vector unsigned __int128 __ATTRS_o_ai
8265vec_rl(vector unsigned __int128 __a, vector unsigned __int128 __b) {
8266 return (__b << __a)|(__b >> ((__CHAR_BIT__ * sizeof(vector unsigned __int128)) - __a));
8267}
8268#endif
8269
Logan Chien55afb0a2018-10-15 10:42:14 +08008270/* vec_rlmi */
8271#ifdef __POWER9_VECTOR__
8272static __inline__ vector unsigned int __ATTRS_o_ai
8273vec_rlmi(vector unsigned int __a, vector unsigned int __b,
8274 vector unsigned int __c) {
8275 return __builtin_altivec_vrlwmi(__a, __c, __b);
8276}
8277
8278static __inline__ vector unsigned long long __ATTRS_o_ai
8279vec_rlmi(vector unsigned long long __a, vector unsigned long long __b,
8280 vector unsigned long long __c) {
8281 return __builtin_altivec_vrldmi(__a, __c, __b);
8282}
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008283#endif
8284
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008285#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008286static __inline__ vector unsigned __int128 __ATTRS_o_ai
8287vec_rlmi(vector unsigned __int128 __a, vector unsigned __int128 __b,
8288 vector unsigned __int128 __c) {
8289 return __builtin_altivec_vrlqmi(__a, __c, __b);
8290}
8291
8292static __inline__ vector signed __int128 __ATTRS_o_ai
8293vec_rlmi(vector signed __int128 __a, vector signed __int128 __b,
8294 vector signed __int128 __c) {
8295 return __builtin_altivec_vrlqmi(__a, __c, __b);
8296}
8297#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08008298
8299/* vec_rlnm */
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008300#ifdef __POWER9_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +08008301static __inline__ vector unsigned int __ATTRS_o_ai
8302vec_rlnm(vector unsigned int __a, vector unsigned int __b,
8303 vector unsigned int __c) {
8304 vector unsigned int OneByte = { 0x8, 0x8, 0x8, 0x8 };
8305 return __builtin_altivec_vrlwnm(__a, ((__c << OneByte) | __b));
8306}
8307
8308static __inline__ vector unsigned long long __ATTRS_o_ai
8309vec_rlnm(vector unsigned long long __a, vector unsigned long long __b,
8310 vector unsigned long long __c) {
8311 vector unsigned long long OneByte = { 0x8, 0x8 };
8312 return __builtin_altivec_vrldnm(__a, ((__c << OneByte) | __b));
8313}
8314#endif
8315
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008316#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008317static __inline__ vector unsigned __int128 __ATTRS_o_ai
8318vec_rlnm(vector unsigned __int128 __a, vector unsigned __int128 __b,
8319 vector unsigned __int128 __c) {
8320 // Merge __b and __c using an appropriate shuffle.
8321 vector unsigned char TmpB = (vector unsigned char)__b;
8322 vector unsigned char TmpC = (vector unsigned char)__c;
8323 vector unsigned char MaskAndShift =
8324#ifdef __LITTLE_ENDIAN__
8325 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0,
8326 1, -1, -1, -1, -1, -1);
8327#else
8328 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 31, 30, 15, -1,
8329 -1, -1, -1, -1, -1, -1, -1);
8330#endif
8331 return __builtin_altivec_vrlqnm(__a, (vector unsigned __int128) MaskAndShift);
8332}
8333
8334static __inline__ vector signed __int128 __ATTRS_o_ai
8335vec_rlnm(vector signed __int128 __a, vector signed __int128 __b,
8336 vector signed __int128 __c) {
8337 // Merge __b and __c using an appropriate shuffle.
8338 vector unsigned char TmpB = (vector unsigned char)__b;
8339 vector unsigned char TmpC = (vector unsigned char)__c;
8340 vector unsigned char MaskAndShift =
8341#ifdef __LITTLE_ENDIAN__
8342 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0,
8343 1, -1, -1, -1, -1, -1);
8344#else
8345 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 31, 30, 15, -1,
8346 -1, -1, -1, -1, -1, -1, -1);
8347#endif
8348 return __builtin_altivec_vrlqnm(__a, (vector unsigned __int128) MaskAndShift);
8349}
8350#endif
8351
Logan Chien2833ffb2018-10-09 10:03:24 +08008352/* vec_vrlb */
8353
8354static __inline__ vector signed char __ATTRS_o_ai
8355vec_vrlb(vector signed char __a, vector unsigned char __b) {
8356 return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b);
8357}
8358
8359static __inline__ vector unsigned char __ATTRS_o_ai
8360vec_vrlb(vector unsigned char __a, vector unsigned char __b) {
8361 return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b);
8362}
8363
8364/* vec_vrlh */
8365
8366static __inline__ vector short __ATTRS_o_ai
8367vec_vrlh(vector short __a, vector unsigned short __b) {
8368 return __builtin_altivec_vrlh(__a, __b);
8369}
8370
8371static __inline__ vector unsigned short __ATTRS_o_ai
8372vec_vrlh(vector unsigned short __a, vector unsigned short __b) {
8373 return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b);
8374}
8375
8376/* vec_vrlw */
8377
8378static __inline__ vector int __ATTRS_o_ai vec_vrlw(vector int __a,
8379 vector unsigned int __b) {
8380 return __builtin_altivec_vrlw(__a, __b);
8381}
8382
8383static __inline__ vector unsigned int __ATTRS_o_ai
8384vec_vrlw(vector unsigned int __a, vector unsigned int __b) {
8385 return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b);
8386}
8387
8388/* vec_round */
8389
8390static __inline__ vector float __ATTRS_o_ai vec_round(vector float __a) {
Logan Chien2833ffb2018-10-09 10:03:24 +08008391 return __builtin_altivec_vrfin(__a);
Logan Chien2833ffb2018-10-09 10:03:24 +08008392}
8393
8394#ifdef __VSX__
8395static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) {
8396 return __builtin_vsx_xvrdpi(__a);
8397}
8398
8399/* vec_rint */
8400
8401static __inline__ vector float __ATTRS_o_ai vec_rint(vector float __a) {
8402 return __builtin_vsx_xvrspic(__a);
8403}
8404
8405static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a) {
8406 return __builtin_vsx_xvrdpic(__a);
8407}
8408
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008409/* vec_roundc */
8410
8411static __inline__ vector float __ATTRS_o_ai vec_roundc(vector float __a) {
8412 return __builtin_vsx_xvrspic(__a);
8413}
8414
8415static __inline__ vector double __ATTRS_o_ai vec_roundc(vector double __a) {
8416 return __builtin_vsx_xvrdpic(__a);
8417}
8418
Logan Chien2833ffb2018-10-09 10:03:24 +08008419/* vec_nearbyint */
8420
8421static __inline__ vector float __ATTRS_o_ai vec_nearbyint(vector float __a) {
8422 return __builtin_vsx_xvrspi(__a);
8423}
8424
8425static __inline__ vector double __ATTRS_o_ai vec_nearbyint(vector double __a) {
8426 return __builtin_vsx_xvrdpi(__a);
8427}
8428#endif
8429
8430/* vec_vrfin */
8431
8432static __inline__ vector float __attribute__((__always_inline__))
8433vec_vrfin(vector float __a) {
8434 return __builtin_altivec_vrfin(__a);
8435}
8436
8437/* vec_sqrt */
8438
8439#ifdef __VSX__
8440static __inline__ vector float __ATTRS_o_ai vec_sqrt(vector float __a) {
8441 return __builtin_vsx_xvsqrtsp(__a);
8442}
8443
8444static __inline__ vector double __ATTRS_o_ai vec_sqrt(vector double __a) {
8445 return __builtin_vsx_xvsqrtdp(__a);
8446}
8447#endif
8448
8449/* vec_rsqrte */
8450
8451static __inline__ vector float __ATTRS_o_ai vec_rsqrte(vector float __a) {
8452#ifdef __VSX__
8453 return __builtin_vsx_xvrsqrtesp(__a);
8454#else
8455 return __builtin_altivec_vrsqrtefp(__a);
8456#endif
8457}
8458
8459#ifdef __VSX__
8460static __inline__ vector double __ATTRS_o_ai vec_rsqrte(vector double __a) {
8461 return __builtin_vsx_xvrsqrtedp(__a);
8462}
8463#endif
8464
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008465static vector float __ATTRS_o_ai vec_rsqrt(vector float __a) {
8466 return __builtin_ppc_rsqrtf(__a);
8467}
8468
8469#ifdef __VSX__
8470static vector double __ATTRS_o_ai vec_rsqrt(vector double __a) {
8471 return __builtin_ppc_rsqrtd(__a);
8472}
8473#endif
8474
Logan Chien2833ffb2018-10-09 10:03:24 +08008475/* vec_vrsqrtefp */
8476
8477static __inline__ __vector float __attribute__((__always_inline__))
8478vec_vrsqrtefp(vector float __a) {
8479 return __builtin_altivec_vrsqrtefp(__a);
8480}
8481
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08008482/* vec_xvtsqrt */
8483
8484#ifdef __VSX__
8485static __inline__ int __ATTRS_o_ai vec_test_swsqrt(vector double __a) {
8486 return __builtin_vsx_xvtsqrtdp(__a);
8487}
8488
8489static __inline__ int __ATTRS_o_ai vec_test_swsqrts(vector float __a) {
8490 return __builtin_vsx_xvtsqrtsp(__a);
8491}
8492#endif
8493
Logan Chien2833ffb2018-10-09 10:03:24 +08008494/* vec_sel */
8495
8496#define __builtin_altivec_vsel_4si vec_sel
8497
8498static __inline__ vector signed char __ATTRS_o_ai vec_sel(
8499 vector signed char __a, vector signed char __b, vector unsigned char __c) {
8500 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8501}
8502
8503static __inline__ vector signed char __ATTRS_o_ai
8504vec_sel(vector signed char __a, vector signed char __b, vector bool char __c) {
8505 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8506}
8507
8508static __inline__ vector unsigned char __ATTRS_o_ai
8509vec_sel(vector unsigned char __a, vector unsigned char __b,
8510 vector unsigned char __c) {
8511 return (__a & ~__c) | (__b & __c);
8512}
8513
8514static __inline__ vector unsigned char __ATTRS_o_ai vec_sel(
8515 vector unsigned char __a, vector unsigned char __b, vector bool char __c) {
8516 return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c);
8517}
8518
8519static __inline__ vector bool char __ATTRS_o_ai
8520vec_sel(vector bool char __a, vector bool char __b, vector unsigned char __c) {
8521 return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c);
8522}
8523
8524static __inline__ vector bool char __ATTRS_o_ai vec_sel(vector bool char __a,
8525 vector bool char __b,
8526 vector bool char __c) {
8527 return (__a & ~__c) | (__b & __c);
8528}
8529
8530static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a,
8531 vector short __b,
8532 vector unsigned short __c) {
8533 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8534}
8535
8536static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a,
8537 vector short __b,
8538 vector bool short __c) {
8539 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8540}
8541
8542static __inline__ vector unsigned short __ATTRS_o_ai
8543vec_sel(vector unsigned short __a, vector unsigned short __b,
8544 vector unsigned short __c) {
8545 return (__a & ~__c) | (__b & __c);
8546}
8547
8548static __inline__ vector unsigned short __ATTRS_o_ai
8549vec_sel(vector unsigned short __a, vector unsigned short __b,
8550 vector bool short __c) {
8551 return (__a & ~(vector unsigned short)__c) |
8552 (__b & (vector unsigned short)__c);
8553}
8554
8555static __inline__ vector bool short __ATTRS_o_ai vec_sel(
8556 vector bool short __a, vector bool short __b, vector unsigned short __c) {
8557 return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c);
8558}
8559
8560static __inline__ vector bool short __ATTRS_o_ai
8561vec_sel(vector bool short __a, vector bool short __b, vector bool short __c) {
8562 return (__a & ~__c) | (__b & __c);
8563}
8564
8565static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a,
8566 vector int __b,
8567 vector unsigned int __c) {
8568 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8569}
8570
8571static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a,
8572 vector int __b,
8573 vector bool int __c) {
8574 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8575}
8576
8577static __inline__ vector unsigned int __ATTRS_o_ai vec_sel(
8578 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
8579 return (__a & ~__c) | (__b & __c);
8580}
8581
8582static __inline__ vector unsigned int __ATTRS_o_ai
8583vec_sel(vector unsigned int __a, vector unsigned int __b, vector bool int __c) {
8584 return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c);
8585}
8586
8587static __inline__ vector bool int __ATTRS_o_ai
8588vec_sel(vector bool int __a, vector bool int __b, vector unsigned int __c) {
8589 return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c);
8590}
8591
8592static __inline__ vector bool int __ATTRS_o_ai vec_sel(vector bool int __a,
8593 vector bool int __b,
8594 vector bool int __c) {
8595 return (__a & ~__c) | (__b & __c);
8596}
8597
8598static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a,
8599 vector float __b,
8600 vector unsigned int __c) {
8601 vector int __res = ((vector int)__a & ~(vector int)__c) |
8602 ((vector int)__b & (vector int)__c);
8603 return (vector float)__res;
8604}
8605
8606static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a,
8607 vector float __b,
8608 vector bool int __c) {
8609 vector int __res = ((vector int)__a & ~(vector int)__c) |
8610 ((vector int)__b & (vector int)__c);
8611 return (vector float)__res;
8612}
8613
8614#ifdef __VSX__
8615static __inline__ vector double __ATTRS_o_ai
8616vec_sel(vector double __a, vector double __b, vector bool long long __c) {
8617 vector long long __res = ((vector long long)__a & ~(vector long long)__c) |
8618 ((vector long long)__b & (vector long long)__c);
8619 return (vector double)__res;
8620}
8621
8622static __inline__ vector double __ATTRS_o_ai
8623vec_sel(vector double __a, vector double __b, vector unsigned long long __c) {
8624 vector long long __res = ((vector long long)__a & ~(vector long long)__c) |
8625 ((vector long long)__b & (vector long long)__c);
8626 return (vector double)__res;
8627}
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008628
8629static __inline__ vector bool long long __ATTRS_o_ai
8630vec_sel(vector bool long long __a, vector bool long long __b,
8631 vector bool long long __c) {
8632 return (__a & ~__c) | (__b & __c);
8633}
8634
8635static __inline__ vector bool long long __ATTRS_o_ai
8636vec_sel(vector bool long long __a, vector bool long long __b,
8637 vector unsigned long long __c) {
8638 return (__a & ~(vector bool long long)__c) |
8639 (__b & (vector bool long long)__c);
8640}
8641
8642static __inline__ vector signed long long __ATTRS_o_ai
8643vec_sel(vector signed long long __a, vector signed long long __b,
8644 vector bool long long __c) {
8645 return (__a & ~(vector signed long long)__c) |
8646 (__b & (vector signed long long)__c);
8647}
8648
8649static __inline__ vector signed long long __ATTRS_o_ai
8650vec_sel(vector signed long long __a, vector signed long long __b,
8651 vector unsigned long long __c) {
8652 return (__a & ~(vector signed long long)__c) |
8653 (__b & (vector signed long long)__c);
8654}
8655
8656static __inline__ vector unsigned long long __ATTRS_o_ai
8657vec_sel(vector unsigned long long __a, vector unsigned long long __b,
8658 vector bool long long __c) {
8659 return (__a & ~(vector unsigned long long)__c) |
8660 (__b & (vector unsigned long long)__c);
8661}
8662
8663static __inline__ vector unsigned long long __ATTRS_o_ai
8664vec_sel(vector unsigned long long __a, vector unsigned long long __b,
8665 vector unsigned long long __c) {
8666 return (__a & ~__c) | (__b & __c);
8667}
Logan Chien2833ffb2018-10-09 10:03:24 +08008668#endif
8669
8670/* vec_vsel */
8671
8672static __inline__ vector signed char __ATTRS_o_ai vec_vsel(
8673 vector signed char __a, vector signed char __b, vector unsigned char __c) {
8674 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8675}
8676
8677static __inline__ vector signed char __ATTRS_o_ai
8678vec_vsel(vector signed char __a, vector signed char __b, vector bool char __c) {
8679 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8680}
8681
8682static __inline__ vector unsigned char __ATTRS_o_ai
8683vec_vsel(vector unsigned char __a, vector unsigned char __b,
8684 vector unsigned char __c) {
8685 return (__a & ~__c) | (__b & __c);
8686}
8687
8688static __inline__ vector unsigned char __ATTRS_o_ai vec_vsel(
8689 vector unsigned char __a, vector unsigned char __b, vector bool char __c) {
8690 return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c);
8691}
8692
8693static __inline__ vector bool char __ATTRS_o_ai
8694vec_vsel(vector bool char __a, vector bool char __b, vector unsigned char __c) {
8695 return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c);
8696}
8697
8698static __inline__ vector bool char __ATTRS_o_ai vec_vsel(vector bool char __a,
8699 vector bool char __b,
8700 vector bool char __c) {
8701 return (__a & ~__c) | (__b & __c);
8702}
8703
8704static __inline__ vector short __ATTRS_o_ai
8705vec_vsel(vector short __a, vector short __b, vector unsigned short __c) {
8706 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8707}
8708
8709static __inline__ vector short __ATTRS_o_ai vec_vsel(vector short __a,
8710 vector short __b,
8711 vector bool short __c) {
8712 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8713}
8714
8715static __inline__ vector unsigned short __ATTRS_o_ai
8716vec_vsel(vector unsigned short __a, vector unsigned short __b,
8717 vector unsigned short __c) {
8718 return (__a & ~__c) | (__b & __c);
8719}
8720
8721static __inline__ vector unsigned short __ATTRS_o_ai
8722vec_vsel(vector unsigned short __a, vector unsigned short __b,
8723 vector bool short __c) {
8724 return (__a & ~(vector unsigned short)__c) |
8725 (__b & (vector unsigned short)__c);
8726}
8727
8728static __inline__ vector bool short __ATTRS_o_ai vec_vsel(
8729 vector bool short __a, vector bool short __b, vector unsigned short __c) {
8730 return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c);
8731}
8732
8733static __inline__ vector bool short __ATTRS_o_ai
8734vec_vsel(vector bool short __a, vector bool short __b, vector bool short __c) {
8735 return (__a & ~__c) | (__b & __c);
8736}
8737
8738static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a,
8739 vector int __b,
8740 vector unsigned int __c) {
8741 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8742}
8743
8744static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a,
8745 vector int __b,
8746 vector bool int __c) {
8747 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8748}
8749
8750static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel(
8751 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
8752 return (__a & ~__c) | (__b & __c);
8753}
8754
8755static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel(
8756 vector unsigned int __a, vector unsigned int __b, vector bool int __c) {
8757 return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c);
8758}
8759
8760static __inline__ vector bool int __ATTRS_o_ai
8761vec_vsel(vector bool int __a, vector bool int __b, vector unsigned int __c) {
8762 return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c);
8763}
8764
8765static __inline__ vector bool int __ATTRS_o_ai vec_vsel(vector bool int __a,
8766 vector bool int __b,
8767 vector bool int __c) {
8768 return (__a & ~__c) | (__b & __c);
8769}
8770
8771static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a,
8772 vector float __b,
8773 vector unsigned int __c) {
8774 vector int __res = ((vector int)__a & ~(vector int)__c) |
8775 ((vector int)__b & (vector int)__c);
8776 return (vector float)__res;
8777}
8778
8779static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a,
8780 vector float __b,
8781 vector bool int __c) {
8782 vector int __res = ((vector int)__a & ~(vector int)__c) |
8783 ((vector int)__b & (vector int)__c);
8784 return (vector float)__res;
8785}
8786
8787/* vec_sl */
8788
Logan Chien55afb0a2018-10-15 10:42:14 +08008789// vec_sl does modulo arithmetic on __b first, so __b is allowed to be more
8790// than the length of __a.
Logan Chien2833ffb2018-10-09 10:03:24 +08008791static __inline__ vector unsigned char __ATTRS_o_ai
8792vec_sl(vector unsigned char __a, vector unsigned char __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008793 return __a << (__b %
8794 (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +08008795}
8796
Logan Chien55afb0a2018-10-15 10:42:14 +08008797static __inline__ vector signed char __ATTRS_o_ai
8798vec_sl(vector signed char __a, vector unsigned char __b) {
8799 return (vector signed char)vec_sl((vector unsigned char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008800}
8801
8802static __inline__ vector unsigned short __ATTRS_o_ai
8803vec_sl(vector unsigned short __a, vector unsigned short __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008804 return __a << (__b % (vector unsigned short)(sizeof(unsigned short) *
8805 __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +08008806}
8807
Logan Chien55afb0a2018-10-15 10:42:14 +08008808static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
8809 vector unsigned short __b) {
8810 return (vector short)vec_sl((vector unsigned short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008811}
8812
8813static __inline__ vector unsigned int __ATTRS_o_ai
8814vec_sl(vector unsigned int __a, vector unsigned int __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008815 return __a << (__b %
8816 (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
8817}
8818
8819static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
8820 vector unsigned int __b) {
8821 return (vector int)vec_sl((vector unsigned int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008822}
8823
8824#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +08008825static __inline__ vector unsigned long long __ATTRS_o_ai
8826vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008827 return __a << (__b % (vector unsigned long long)(sizeof(unsigned long long) *
8828 __CHAR_BIT__));
8829}
8830
8831static __inline__ vector long long __ATTRS_o_ai
8832vec_sl(vector long long __a, vector unsigned long long __b) {
8833 return (vector long long)vec_sl((vector unsigned long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008834}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008835#else
8836static __inline__ vector unsigned char __ATTRS_o_ai
8837vec_vspltb(vector unsigned char __a, unsigned char __b);
8838static __inline__ vector unsigned long long __ATTRS_o_ai
8839vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
8840 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
8841
8842 // Big endian element one (the right doubleword) can be left shifted as-is.
8843 // The other element needs to be swapped into the right doubleword and
8844 // shifted. Then the right doublewords of the two result vectors are merged.
8845 vector signed long long __rightelt =
8846 (vector signed long long)__builtin_altivec_vslo((vector signed int)__a,
8847 (vector signed int)__b);
8848#ifdef __LITTLE_ENDIAN__
8849 __rightelt = (vector signed long long)__builtin_altivec_vsl(
8850 (vector signed int)__rightelt,
8851 (vector signed int)vec_vspltb((vector unsigned char)__b, 0));
8852#else
8853 __rightelt = (vector signed long long)__builtin_altivec_vsl(
8854 (vector signed int)__rightelt,
8855 (vector signed int)vec_vspltb((vector unsigned char)__b, 15));
8856#endif
8857 __a = __builtin_shufflevector(__a, __a, 1, 0);
8858 __b = __builtin_shufflevector(__b, __b, 1, 0);
8859 vector signed long long __leftelt =
8860 (vector signed long long)__builtin_altivec_vslo((vector signed int)__a,
8861 (vector signed int)__b);
8862#ifdef __LITTLE_ENDIAN__
8863 __leftelt = (vector signed long long)__builtin_altivec_vsl(
8864 (vector signed int)__leftelt,
8865 (vector signed int)vec_vspltb((vector unsigned char)__b, 0));
8866 return (vector unsigned long long)__builtin_shufflevector(__rightelt,
8867 __leftelt, 0, 2);
8868#else
8869 __leftelt = (vector signed long long)__builtin_altivec_vsl(
8870 (vector signed int)__leftelt,
8871 (vector signed int)vec_vspltb((vector unsigned char)__b, 15));
8872 return (vector unsigned long long)__builtin_shufflevector(__leftelt,
8873 __rightelt, 1, 3);
8874#endif
8875}
8876
8877static __inline__ vector long long __ATTRS_o_ai
8878vec_sl(vector long long __a, vector unsigned long long __b) {
8879 return (vector long long)vec_sl((vector unsigned long long)__a, __b);
8880}
Logan Chien2833ffb2018-10-09 10:03:24 +08008881#endif
8882
8883/* vec_vslb */
8884
8885#define __builtin_altivec_vslb vec_vslb
8886
8887static __inline__ vector signed char __ATTRS_o_ai
8888vec_vslb(vector signed char __a, vector unsigned char __b) {
8889 return vec_sl(__a, __b);
8890}
8891
8892static __inline__ vector unsigned char __ATTRS_o_ai
8893vec_vslb(vector unsigned char __a, vector unsigned char __b) {
8894 return vec_sl(__a, __b);
8895}
8896
8897/* vec_vslh */
8898
8899#define __builtin_altivec_vslh vec_vslh
8900
8901static __inline__ vector short __ATTRS_o_ai
8902vec_vslh(vector short __a, vector unsigned short __b) {
8903 return vec_sl(__a, __b);
8904}
8905
8906static __inline__ vector unsigned short __ATTRS_o_ai
8907vec_vslh(vector unsigned short __a, vector unsigned short __b) {
8908 return vec_sl(__a, __b);
8909}
8910
8911/* vec_vslw */
8912
8913#define __builtin_altivec_vslw vec_vslw
8914
8915static __inline__ vector int __ATTRS_o_ai vec_vslw(vector int __a,
8916 vector unsigned int __b) {
8917 return vec_sl(__a, __b);
8918}
8919
8920static __inline__ vector unsigned int __ATTRS_o_ai
8921vec_vslw(vector unsigned int __a, vector unsigned int __b) {
8922 return vec_sl(__a, __b);
8923}
8924
8925/* vec_sld */
8926
8927#define __builtin_altivec_vsldoi_4si vec_sld
8928
8929static __inline__ vector signed char __ATTRS_o_ai vec_sld(
8930 vector signed char __a, vector signed char __b, unsigned const int __c) {
8931 unsigned char __d = __c & 0x0F;
8932#ifdef __LITTLE_ENDIAN__
8933 return vec_perm(
8934 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
8935 20 - __d, 21 - __d, 22 - __d, 23 - __d,
8936 24 - __d, 25 - __d, 26 - __d, 27 - __d,
8937 28 - __d, 29 - __d, 30 - __d, 31 - __d));
8938#else
8939 return vec_perm(
8940 __a, __b,
8941 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
8942 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
8943 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
8944#endif
8945}
8946
8947static __inline__ vector unsigned char __ATTRS_o_ai
8948vec_sld(vector unsigned char __a, vector unsigned char __b,
8949 unsigned const int __c) {
8950 unsigned char __d = __c & 0x0F;
8951#ifdef __LITTLE_ENDIAN__
8952 return vec_perm(
8953 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
8954 20 - __d, 21 - __d, 22 - __d, 23 - __d,
8955 24 - __d, 25 - __d, 26 - __d, 27 - __d,
8956 28 - __d, 29 - __d, 30 - __d, 31 - __d));
8957#else
8958 return vec_perm(
8959 __a, __b,
8960 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
8961 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
8962 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
8963#endif
8964}
8965
8966static __inline__ vector bool char __ATTRS_o_ai
8967vec_sld(vector bool char __a, vector bool char __b, unsigned const int __c) {
8968 unsigned char __d = __c & 0x0F;
8969#ifdef __LITTLE_ENDIAN__
8970 return vec_perm(
8971 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
8972 20 - __d, 21 - __d, 22 - __d, 23 - __d,
8973 24 - __d, 25 - __d, 26 - __d, 27 - __d,
8974 28 - __d, 29 - __d, 30 - __d, 31 - __d));
8975#else
8976 return vec_perm(
8977 __a, __b,
8978 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
8979 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
8980 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
8981#endif
8982}
8983
8984static __inline__ vector signed short __ATTRS_o_ai vec_sld(
8985 vector signed short __a, vector signed short __b, unsigned const int __c) {
8986 unsigned char __d = __c & 0x0F;
8987#ifdef __LITTLE_ENDIAN__
8988 return vec_perm(
8989 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
8990 20 - __d, 21 - __d, 22 - __d, 23 - __d,
8991 24 - __d, 25 - __d, 26 - __d, 27 - __d,
8992 28 - __d, 29 - __d, 30 - __d, 31 - __d));
8993#else
8994 return vec_perm(
8995 __a, __b,
8996 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
8997 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
8998 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
8999#endif
9000}
9001
9002static __inline__ vector unsigned short __ATTRS_o_ai
9003vec_sld(vector unsigned short __a, vector unsigned short __b,
9004 unsigned const int __c) {
9005 unsigned char __d = __c & 0x0F;
9006#ifdef __LITTLE_ENDIAN__
9007 return vec_perm(
9008 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9009 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9010 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9011 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9012#else
9013 return vec_perm(
9014 __a, __b,
9015 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9016 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9017 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9018#endif
9019}
9020
9021static __inline__ vector bool short __ATTRS_o_ai
9022vec_sld(vector bool short __a, vector bool short __b, unsigned const int __c) {
9023 unsigned char __d = __c & 0x0F;
9024#ifdef __LITTLE_ENDIAN__
9025 return vec_perm(
9026 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9027 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9028 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9029 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9030#else
9031 return vec_perm(
9032 __a, __b,
9033 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9034 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9035 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9036#endif
9037}
9038
9039static __inline__ vector pixel __ATTRS_o_ai vec_sld(vector pixel __a,
9040 vector pixel __b,
9041 unsigned const int __c) {
9042 unsigned char __d = __c & 0x0F;
9043#ifdef __LITTLE_ENDIAN__
9044 return vec_perm(
9045 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9046 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9047 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9048 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9049#else
9050 return vec_perm(
9051 __a, __b,
9052 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9053 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9054 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9055#endif
9056}
9057
9058static __inline__ vector signed int __ATTRS_o_ai
9059vec_sld(vector signed int __a, vector signed int __b, unsigned const int __c) {
9060 unsigned char __d = __c & 0x0F;
9061#ifdef __LITTLE_ENDIAN__
9062 return vec_perm(
9063 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9064 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9065 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9066 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9067#else
9068 return vec_perm(
9069 __a, __b,
9070 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9071 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9072 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9073#endif
9074}
9075
9076static __inline__ vector unsigned int __ATTRS_o_ai vec_sld(
9077 vector unsigned int __a, vector unsigned int __b, unsigned const int __c) {
9078 unsigned char __d = __c & 0x0F;
9079#ifdef __LITTLE_ENDIAN__
9080 return vec_perm(
9081 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9082 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9083 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9084 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9085#else
9086 return vec_perm(
9087 __a, __b,
9088 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9089 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9090 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9091#endif
9092}
9093
9094static __inline__ vector bool int __ATTRS_o_ai vec_sld(vector bool int __a,
9095 vector bool int __b,
9096 unsigned const int __c) {
9097 unsigned char __d = __c & 0x0F;
9098#ifdef __LITTLE_ENDIAN__
9099 return vec_perm(
9100 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9101 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9102 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9103 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9104#else
9105 return vec_perm(
9106 __a, __b,
9107 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9108 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9109 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9110#endif
9111}
9112
9113static __inline__ vector float __ATTRS_o_ai vec_sld(vector float __a,
9114 vector float __b,
9115 unsigned const int __c) {
9116 unsigned char __d = __c & 0x0F;
9117#ifdef __LITTLE_ENDIAN__
9118 return vec_perm(
9119 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9120 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9121 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9122 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9123#else
9124 return vec_perm(
9125 __a, __b,
9126 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9127 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9128 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9129#endif
9130}
9131
Logan Chien55afb0a2018-10-15 10:42:14 +08009132#ifdef __VSX__
9133static __inline__ vector bool long long __ATTRS_o_ai
9134vec_sld(vector bool long long __a, vector bool long long __b,
9135 unsigned const int __c) {
9136 unsigned char __d = __c & 0x0F;
9137#ifdef __LITTLE_ENDIAN__
9138 return vec_perm(
9139 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9140 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9141 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9142 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9143#else
9144 return vec_perm(
9145 __a, __b,
9146 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9147 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9148 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9149#endif
9150}
9151
9152static __inline__ vector signed long long __ATTRS_o_ai
9153vec_sld(vector signed long long __a, vector signed long long __b,
9154 unsigned const int __c) {
9155 unsigned char __d = __c & 0x0F;
9156#ifdef __LITTLE_ENDIAN__
9157 return vec_perm(
9158 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9159 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9160 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9161 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9162#else
9163 return vec_perm(
9164 __a, __b,
9165 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9166 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9167 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9168#endif
9169}
9170
9171static __inline__ vector unsigned long long __ATTRS_o_ai
9172vec_sld(vector unsigned long long __a, vector unsigned long long __b,
9173 unsigned const int __c) {
9174 unsigned char __d = __c & 0x0F;
9175#ifdef __LITTLE_ENDIAN__
9176 return vec_perm(
9177 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9178 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9179 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9180 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9181#else
9182 return vec_perm(
9183 __a, __b,
9184 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9185 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9186 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9187#endif
9188}
9189
9190static __inline__ vector double __ATTRS_o_ai vec_sld(vector double __a,
9191 vector double __b,
9192 unsigned const int __c) {
9193 unsigned char __d = __c & 0x0F;
9194#ifdef __LITTLE_ENDIAN__
9195 return vec_perm(
9196 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9197 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9198 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9199 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9200#else
9201 return vec_perm(
9202 __a, __b,
9203 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9204 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9205 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9206#endif
9207}
9208#endif
9209
9210/* vec_sldw */
9211static __inline__ vector signed char __ATTRS_o_ai vec_sldw(
9212 vector signed char __a, vector signed char __b, unsigned const int __c) {
9213 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9214}
9215
9216static __inline__ vector unsigned char __ATTRS_o_ai
9217vec_sldw(vector unsigned char __a, vector unsigned char __b,
9218 unsigned const int __c) {
9219 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9220}
9221
9222static __inline__ vector signed short __ATTRS_o_ai vec_sldw(
9223 vector signed short __a, vector signed short __b, unsigned const int __c) {
9224 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9225}
9226
9227static __inline__ vector unsigned short __ATTRS_o_ai
9228vec_sldw(vector unsigned short __a, vector unsigned short __b,
9229 unsigned const int __c) {
9230 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9231}
9232
9233static __inline__ vector signed int __ATTRS_o_ai
9234vec_sldw(vector signed int __a, vector signed int __b, unsigned const int __c) {
9235 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9236}
9237
9238static __inline__ vector unsigned int __ATTRS_o_ai vec_sldw(
9239 vector unsigned int __a, vector unsigned int __b, unsigned const int __c) {
9240 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9241}
9242
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07009243static __inline__ vector float __ATTRS_o_ai vec_sldw(
9244 vector float __a, vector float __b, unsigned const int __c) {
9245 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9246}
9247
Logan Chien55afb0a2018-10-15 10:42:14 +08009248#ifdef __VSX__
9249static __inline__ vector signed long long __ATTRS_o_ai
9250vec_sldw(vector signed long long __a, vector signed long long __b,
9251 unsigned const int __c) {
9252 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9253}
9254
9255static __inline__ vector unsigned long long __ATTRS_o_ai
9256vec_sldw(vector unsigned long long __a, vector unsigned long long __b,
9257 unsigned const int __c) {
9258 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9259}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07009260
9261static __inline__ vector double __ATTRS_o_ai vec_sldw(
9262 vector double __a, vector double __b, unsigned const int __c) {
9263 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9264}
Logan Chien55afb0a2018-10-15 10:42:14 +08009265#endif
9266
9267#ifdef __POWER9_VECTOR__
9268/* vec_slv */
9269static __inline__ vector unsigned char __ATTRS_o_ai
9270vec_slv(vector unsigned char __a, vector unsigned char __b) {
9271 return __builtin_altivec_vslv(__a, __b);
9272}
9273
9274/* vec_srv */
9275static __inline__ vector unsigned char __ATTRS_o_ai
9276vec_srv(vector unsigned char __a, vector unsigned char __b) {
9277 return __builtin_altivec_vsrv(__a, __b);
9278}
9279#endif
9280
Logan Chien2833ffb2018-10-09 10:03:24 +08009281/* vec_vsldoi */
9282
9283static __inline__ vector signed char __ATTRS_o_ai
9284vec_vsldoi(vector signed char __a, vector signed char __b, unsigned char __c) {
9285 unsigned char __d = __c & 0x0F;
9286#ifdef __LITTLE_ENDIAN__
9287 return vec_perm(
9288 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9289 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9290 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9291 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9292#else
9293 return vec_perm(
9294 __a, __b,
9295 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9296 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9297 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9298#endif
9299}
9300
9301static __inline__ vector unsigned char __ATTRS_o_ai vec_vsldoi(
9302 vector unsigned char __a, vector unsigned char __b, unsigned char __c) {
9303 unsigned char __d = __c & 0x0F;
9304#ifdef __LITTLE_ENDIAN__
9305 return vec_perm(
9306 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9307 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9308 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9309 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9310#else
9311 return vec_perm(
9312 __a, __b,
9313 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9314 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9315 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9316#endif
9317}
9318
9319static __inline__ vector short __ATTRS_o_ai vec_vsldoi(vector short __a,
9320 vector short __b,
9321 unsigned char __c) {
9322 unsigned char __d = __c & 0x0F;
9323#ifdef __LITTLE_ENDIAN__
9324 return vec_perm(
9325 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9326 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9327 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9328 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9329#else
9330 return vec_perm(
9331 __a, __b,
9332 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9333 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9334 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9335#endif
9336}
9337
9338static __inline__ vector unsigned short __ATTRS_o_ai vec_vsldoi(
9339 vector unsigned short __a, vector unsigned short __b, unsigned char __c) {
9340 unsigned char __d = __c & 0x0F;
9341#ifdef __LITTLE_ENDIAN__
9342 return vec_perm(
9343 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9344 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9345 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9346 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9347#else
9348 return vec_perm(
9349 __a, __b,
9350 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9351 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9352 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9353#endif
9354}
9355
9356static __inline__ vector pixel __ATTRS_o_ai vec_vsldoi(vector pixel __a,
9357 vector pixel __b,
9358 unsigned char __c) {
9359 unsigned char __d = __c & 0x0F;
9360#ifdef __LITTLE_ENDIAN__
9361 return vec_perm(
9362 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9363 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9364 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9365 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9366#else
9367 return vec_perm(
9368 __a, __b,
9369 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9370 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9371 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9372#endif
9373}
9374
9375static __inline__ vector int __ATTRS_o_ai vec_vsldoi(vector int __a,
9376 vector int __b,
9377 unsigned char __c) {
9378 unsigned char __d = __c & 0x0F;
9379#ifdef __LITTLE_ENDIAN__
9380 return vec_perm(
9381 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9382 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9383 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9384 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9385#else
9386 return vec_perm(
9387 __a, __b,
9388 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9389 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9390 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9391#endif
9392}
9393
9394static __inline__ vector unsigned int __ATTRS_o_ai vec_vsldoi(
9395 vector unsigned int __a, vector unsigned int __b, unsigned char __c) {
9396 unsigned char __d = __c & 0x0F;
9397#ifdef __LITTLE_ENDIAN__
9398 return vec_perm(
9399 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9400 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9401 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9402 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9403#else
9404 return vec_perm(
9405 __a, __b,
9406 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9407 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9408 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9409#endif
9410}
9411
9412static __inline__ vector float __ATTRS_o_ai vec_vsldoi(vector float __a,
9413 vector float __b,
9414 unsigned char __c) {
9415 unsigned char __d = __c & 0x0F;
9416#ifdef __LITTLE_ENDIAN__
9417 return vec_perm(
9418 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9419 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9420 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9421 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9422#else
9423 return vec_perm(
9424 __a, __b,
9425 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9426 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9427 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9428#endif
9429}
9430
9431/* vec_sll */
9432
9433static __inline__ vector signed char __ATTRS_o_ai
9434vec_sll(vector signed char __a, vector unsigned char __b) {
9435 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9436 (vector int)__b);
9437}
9438
9439static __inline__ vector signed char __ATTRS_o_ai
9440vec_sll(vector signed char __a, vector unsigned short __b) {
9441 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9442 (vector int)__b);
9443}
9444
9445static __inline__ vector signed char __ATTRS_o_ai
9446vec_sll(vector signed char __a, vector unsigned int __b) {
9447 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9448 (vector int)__b);
9449}
9450
9451static __inline__ vector unsigned char __ATTRS_o_ai
9452vec_sll(vector unsigned char __a, vector unsigned char __b) {
9453 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9454 (vector int)__b);
9455}
9456
9457static __inline__ vector unsigned char __ATTRS_o_ai
9458vec_sll(vector unsigned char __a, vector unsigned short __b) {
9459 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9460 (vector int)__b);
9461}
9462
9463static __inline__ vector unsigned char __ATTRS_o_ai
9464vec_sll(vector unsigned char __a, vector unsigned int __b) {
9465 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9466 (vector int)__b);
9467}
9468
9469static __inline__ vector bool char __ATTRS_o_ai
9470vec_sll(vector bool char __a, vector unsigned char __b) {
9471 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9472 (vector int)__b);
9473}
9474
9475static __inline__ vector bool char __ATTRS_o_ai
9476vec_sll(vector bool char __a, vector unsigned short __b) {
9477 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9478 (vector int)__b);
9479}
9480
9481static __inline__ vector bool char __ATTRS_o_ai
9482vec_sll(vector bool char __a, vector unsigned int __b) {
9483 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9484 (vector int)__b);
9485}
9486
9487static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
9488 vector unsigned char __b) {
9489 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9490}
9491
9492static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
9493 vector unsigned short __b) {
9494 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9495}
9496
9497static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
9498 vector unsigned int __b) {
9499 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9500}
9501
9502static __inline__ vector unsigned short __ATTRS_o_ai
9503vec_sll(vector unsigned short __a, vector unsigned char __b) {
9504 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9505 (vector int)__b);
9506}
9507
9508static __inline__ vector unsigned short __ATTRS_o_ai
9509vec_sll(vector unsigned short __a, vector unsigned short __b) {
9510 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9511 (vector int)__b);
9512}
9513
9514static __inline__ vector unsigned short __ATTRS_o_ai
9515vec_sll(vector unsigned short __a, vector unsigned int __b) {
9516 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9517 (vector int)__b);
9518}
9519
9520static __inline__ vector bool short __ATTRS_o_ai
9521vec_sll(vector bool short __a, vector unsigned char __b) {
9522 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9523 (vector int)__b);
9524}
9525
9526static __inline__ vector bool short __ATTRS_o_ai
9527vec_sll(vector bool short __a, vector unsigned short __b) {
9528 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9529 (vector int)__b);
9530}
9531
9532static __inline__ vector bool short __ATTRS_o_ai
9533vec_sll(vector bool short __a, vector unsigned int __b) {
9534 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9535 (vector int)__b);
9536}
9537
9538static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
9539 vector unsigned char __b) {
9540 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9541}
9542
9543static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
9544 vector unsigned short __b) {
9545 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9546}
9547
9548static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
9549 vector unsigned int __b) {
9550 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9551}
9552
9553static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
9554 vector unsigned char __b) {
9555 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9556}
9557
9558static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
9559 vector unsigned short __b) {
9560 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9561}
9562
9563static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
9564 vector unsigned int __b) {
9565 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9566}
9567
9568static __inline__ vector unsigned int __ATTRS_o_ai
9569vec_sll(vector unsigned int __a, vector unsigned char __b) {
9570 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9571 (vector int)__b);
9572}
9573
9574static __inline__ vector unsigned int __ATTRS_o_ai
9575vec_sll(vector unsigned int __a, vector unsigned short __b) {
9576 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9577 (vector int)__b);
9578}
9579
9580static __inline__ vector unsigned int __ATTRS_o_ai
9581vec_sll(vector unsigned int __a, vector unsigned int __b) {
9582 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9583 (vector int)__b);
9584}
9585
9586static __inline__ vector bool int __ATTRS_o_ai
9587vec_sll(vector bool int __a, vector unsigned char __b) {
9588 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9589 (vector int)__b);
9590}
9591
9592static __inline__ vector bool int __ATTRS_o_ai
9593vec_sll(vector bool int __a, vector unsigned short __b) {
9594 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9595 (vector int)__b);
9596}
9597
9598static __inline__ vector bool int __ATTRS_o_ai
9599vec_sll(vector bool int __a, vector unsigned int __b) {
9600 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9601 (vector int)__b);
9602}
9603
Logan Chien55afb0a2018-10-15 10:42:14 +08009604#ifdef __VSX__
9605static __inline__ vector signed long long __ATTRS_o_ai
9606vec_sll(vector signed long long __a, vector unsigned char __b) {
9607 return (vector signed long long)__builtin_altivec_vsl((vector int)__a,
9608 (vector int)__b);
9609}
9610
9611static __inline__ vector unsigned long long __ATTRS_o_ai
9612vec_sll(vector unsigned long long __a, vector unsigned char __b) {
9613 return (vector unsigned long long)__builtin_altivec_vsl((vector int)__a,
9614 (vector int)__b);
9615}
9616#endif
9617
Logan Chien2833ffb2018-10-09 10:03:24 +08009618/* vec_vsl */
9619
9620static __inline__ vector signed char __ATTRS_o_ai
9621vec_vsl(vector signed char __a, vector unsigned char __b) {
9622 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9623 (vector int)__b);
9624}
9625
9626static __inline__ vector signed char __ATTRS_o_ai
9627vec_vsl(vector signed char __a, vector unsigned short __b) {
9628 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9629 (vector int)__b);
9630}
9631
9632static __inline__ vector signed char __ATTRS_o_ai
9633vec_vsl(vector signed char __a, vector unsigned int __b) {
9634 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9635 (vector int)__b);
9636}
9637
9638static __inline__ vector unsigned char __ATTRS_o_ai
9639vec_vsl(vector unsigned char __a, vector unsigned char __b) {
9640 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9641 (vector int)__b);
9642}
9643
9644static __inline__ vector unsigned char __ATTRS_o_ai
9645vec_vsl(vector unsigned char __a, vector unsigned short __b) {
9646 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9647 (vector int)__b);
9648}
9649
9650static __inline__ vector unsigned char __ATTRS_o_ai
9651vec_vsl(vector unsigned char __a, vector unsigned int __b) {
9652 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9653 (vector int)__b);
9654}
9655
9656static __inline__ vector bool char __ATTRS_o_ai
9657vec_vsl(vector bool char __a, vector unsigned char __b) {
9658 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9659 (vector int)__b);
9660}
9661
9662static __inline__ vector bool char __ATTRS_o_ai
9663vec_vsl(vector bool char __a, vector unsigned short __b) {
9664 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9665 (vector int)__b);
9666}
9667
9668static __inline__ vector bool char __ATTRS_o_ai
9669vec_vsl(vector bool char __a, vector unsigned int __b) {
9670 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9671 (vector int)__b);
9672}
9673
9674static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
9675 vector unsigned char __b) {
9676 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9677}
9678
9679static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
9680 vector unsigned short __b) {
9681 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9682}
9683
9684static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
9685 vector unsigned int __b) {
9686 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9687}
9688
9689static __inline__ vector unsigned short __ATTRS_o_ai
9690vec_vsl(vector unsigned short __a, vector unsigned char __b) {
9691 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9692 (vector int)__b);
9693}
9694
9695static __inline__ vector unsigned short __ATTRS_o_ai
9696vec_vsl(vector unsigned short __a, vector unsigned short __b) {
9697 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9698 (vector int)__b);
9699}
9700
9701static __inline__ vector unsigned short __ATTRS_o_ai
9702vec_vsl(vector unsigned short __a, vector unsigned int __b) {
9703 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9704 (vector int)__b);
9705}
9706
9707static __inline__ vector bool short __ATTRS_o_ai
9708vec_vsl(vector bool short __a, vector unsigned char __b) {
9709 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9710 (vector int)__b);
9711}
9712
9713static __inline__ vector bool short __ATTRS_o_ai
9714vec_vsl(vector bool short __a, vector unsigned short __b) {
9715 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9716 (vector int)__b);
9717}
9718
9719static __inline__ vector bool short __ATTRS_o_ai
9720vec_vsl(vector bool short __a, vector unsigned int __b) {
9721 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9722 (vector int)__b);
9723}
9724
9725static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
9726 vector unsigned char __b) {
9727 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9728}
9729
9730static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
9731 vector unsigned short __b) {
9732 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9733}
9734
9735static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
9736 vector unsigned int __b) {
9737 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9738}
9739
9740static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
9741 vector unsigned char __b) {
9742 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9743}
9744
9745static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
9746 vector unsigned short __b) {
9747 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9748}
9749
9750static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
9751 vector unsigned int __b) {
9752 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9753}
9754
9755static __inline__ vector unsigned int __ATTRS_o_ai
9756vec_vsl(vector unsigned int __a, vector unsigned char __b) {
9757 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9758 (vector int)__b);
9759}
9760
9761static __inline__ vector unsigned int __ATTRS_o_ai
9762vec_vsl(vector unsigned int __a, vector unsigned short __b) {
9763 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9764 (vector int)__b);
9765}
9766
9767static __inline__ vector unsigned int __ATTRS_o_ai
9768vec_vsl(vector unsigned int __a, vector unsigned int __b) {
9769 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9770 (vector int)__b);
9771}
9772
9773static __inline__ vector bool int __ATTRS_o_ai
9774vec_vsl(vector bool int __a, vector unsigned char __b) {
9775 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9776 (vector int)__b);
9777}
9778
9779static __inline__ vector bool int __ATTRS_o_ai
9780vec_vsl(vector bool int __a, vector unsigned short __b) {
9781 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9782 (vector int)__b);
9783}
9784
9785static __inline__ vector bool int __ATTRS_o_ai
9786vec_vsl(vector bool int __a, vector unsigned int __b) {
9787 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9788 (vector int)__b);
9789}
9790
9791/* vec_slo */
9792
9793static __inline__ vector signed char __ATTRS_o_ai
9794vec_slo(vector signed char __a, vector signed char __b) {
9795 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9796 (vector int)__b);
9797}
9798
9799static __inline__ vector signed char __ATTRS_o_ai
9800vec_slo(vector signed char __a, vector unsigned char __b) {
9801 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9802 (vector int)__b);
9803}
9804
9805static __inline__ vector unsigned char __ATTRS_o_ai
9806vec_slo(vector unsigned char __a, vector signed char __b) {
9807 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9808 (vector int)__b);
9809}
9810
9811static __inline__ vector unsigned char __ATTRS_o_ai
9812vec_slo(vector unsigned char __a, vector unsigned char __b) {
9813 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9814 (vector int)__b);
9815}
9816
9817static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a,
9818 vector signed char __b) {
9819 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9820}
9821
9822static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a,
9823 vector unsigned char __b) {
9824 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9825}
9826
9827static __inline__ vector unsigned short __ATTRS_o_ai
9828vec_slo(vector unsigned short __a, vector signed char __b) {
9829 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9830 (vector int)__b);
9831}
9832
9833static __inline__ vector unsigned short __ATTRS_o_ai
9834vec_slo(vector unsigned short __a, vector unsigned char __b) {
9835 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9836 (vector int)__b);
9837}
9838
9839static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a,
9840 vector signed char __b) {
9841 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9842}
9843
9844static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a,
9845 vector unsigned char __b) {
9846 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9847}
9848
9849static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a,
9850 vector signed char __b) {
9851 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
9852}
9853
9854static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a,
9855 vector unsigned char __b) {
9856 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
9857}
9858
9859static __inline__ vector unsigned int __ATTRS_o_ai
9860vec_slo(vector unsigned int __a, vector signed char __b) {
9861 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
9862 (vector int)__b);
9863}
9864
9865static __inline__ vector unsigned int __ATTRS_o_ai
9866vec_slo(vector unsigned int __a, vector unsigned char __b) {
9867 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
9868 (vector int)__b);
9869}
9870
9871static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a,
9872 vector signed char __b) {
9873 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9874}
9875
9876static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a,
9877 vector unsigned char __b) {
9878 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9879}
9880
Logan Chien55afb0a2018-10-15 10:42:14 +08009881#ifdef __VSX__
9882static __inline__ vector signed long long __ATTRS_o_ai
9883vec_slo(vector signed long long __a, vector signed char __b) {
9884 return (vector signed long long)__builtin_altivec_vslo((vector int)__a,
9885 (vector int)__b);
9886}
9887
9888static __inline__ vector signed long long __ATTRS_o_ai
9889vec_slo(vector signed long long __a, vector unsigned char __b) {
9890 return (vector signed long long)__builtin_altivec_vslo((vector int)__a,
9891 (vector int)__b);
9892}
9893
9894static __inline__ vector unsigned long long __ATTRS_o_ai
9895vec_slo(vector unsigned long long __a, vector signed char __b) {
9896 return (vector unsigned long long)__builtin_altivec_vslo((vector int)__a,
9897 (vector int)__b);
9898}
9899
9900static __inline__ vector unsigned long long __ATTRS_o_ai
9901vec_slo(vector unsigned long long __a, vector unsigned char __b) {
9902 return (vector unsigned long long)__builtin_altivec_vslo((vector int)__a,
9903 (vector int)__b);
9904}
9905#endif
9906
Logan Chien2833ffb2018-10-09 10:03:24 +08009907/* vec_vslo */
9908
9909static __inline__ vector signed char __ATTRS_o_ai
9910vec_vslo(vector signed char __a, vector signed char __b) {
9911 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9912 (vector int)__b);
9913}
9914
9915static __inline__ vector signed char __ATTRS_o_ai
9916vec_vslo(vector signed char __a, vector unsigned char __b) {
9917 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9918 (vector int)__b);
9919}
9920
9921static __inline__ vector unsigned char __ATTRS_o_ai
9922vec_vslo(vector unsigned char __a, vector signed char __b) {
9923 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9924 (vector int)__b);
9925}
9926
9927static __inline__ vector unsigned char __ATTRS_o_ai
9928vec_vslo(vector unsigned char __a, vector unsigned char __b) {
9929 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9930 (vector int)__b);
9931}
9932
9933static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a,
9934 vector signed char __b) {
9935 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9936}
9937
9938static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a,
9939 vector unsigned char __b) {
9940 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9941}
9942
9943static __inline__ vector unsigned short __ATTRS_o_ai
9944vec_vslo(vector unsigned short __a, vector signed char __b) {
9945 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9946 (vector int)__b);
9947}
9948
9949static __inline__ vector unsigned short __ATTRS_o_ai
9950vec_vslo(vector unsigned short __a, vector unsigned char __b) {
9951 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9952 (vector int)__b);
9953}
9954
9955static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a,
9956 vector signed char __b) {
9957 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9958}
9959
9960static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a,
9961 vector unsigned char __b) {
9962 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9963}
9964
9965static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a,
9966 vector signed char __b) {
9967 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
9968}
9969
9970static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a,
9971 vector unsigned char __b) {
9972 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
9973}
9974
9975static __inline__ vector unsigned int __ATTRS_o_ai
9976vec_vslo(vector unsigned int __a, vector signed char __b) {
9977 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
9978 (vector int)__b);
9979}
9980
9981static __inline__ vector unsigned int __ATTRS_o_ai
9982vec_vslo(vector unsigned int __a, vector unsigned char __b) {
9983 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
9984 (vector int)__b);
9985}
9986
9987static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a,
9988 vector signed char __b) {
9989 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9990}
9991
9992static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a,
9993 vector unsigned char __b) {
9994 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9995}
9996
9997/* vec_splat */
9998
9999static __inline__ vector signed char __ATTRS_o_ai
10000vec_splat(vector signed char __a, unsigned const int __b) {
10001 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
10002}
10003
10004static __inline__ vector unsigned char __ATTRS_o_ai
10005vec_splat(vector unsigned char __a, unsigned const int __b) {
10006 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
10007}
10008
10009static __inline__ vector bool char __ATTRS_o_ai
10010vec_splat(vector bool char __a, unsigned const int __b) {
10011 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
10012}
10013
10014static __inline__ vector signed short __ATTRS_o_ai
10015vec_splat(vector signed short __a, unsigned const int __b) {
10016 unsigned char b0 = (__b & 0x07) * 2;
10017 unsigned char b1 = b0 + 1;
10018 return vec_perm(__a, __a,
10019 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10020 b0, b1, b0, b1, b0, b1));
10021}
10022
10023static __inline__ vector unsigned short __ATTRS_o_ai
10024vec_splat(vector unsigned short __a, unsigned const int __b) {
10025 unsigned char b0 = (__b & 0x07) * 2;
10026 unsigned char b1 = b0 + 1;
10027 return vec_perm(__a, __a,
10028 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10029 b0, b1, b0, b1, b0, b1));
10030}
10031
10032static __inline__ vector bool short __ATTRS_o_ai
10033vec_splat(vector bool short __a, unsigned const int __b) {
10034 unsigned char b0 = (__b & 0x07) * 2;
10035 unsigned char b1 = b0 + 1;
10036 return vec_perm(__a, __a,
10037 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10038 b0, b1, b0, b1, b0, b1));
10039}
10040
10041static __inline__ vector pixel __ATTRS_o_ai vec_splat(vector pixel __a,
10042 unsigned const int __b) {
10043 unsigned char b0 = (__b & 0x07) * 2;
10044 unsigned char b1 = b0 + 1;
10045 return vec_perm(__a, __a,
10046 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10047 b0, b1, b0, b1, b0, b1));
10048}
10049
10050static __inline__ vector signed int __ATTRS_o_ai
10051vec_splat(vector signed int __a, unsigned const int __b) {
10052 unsigned char b0 = (__b & 0x03) * 4;
10053 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10054 return vec_perm(__a, __a,
10055 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10056 b2, b3, b0, b1, b2, b3));
10057}
10058
10059static __inline__ vector unsigned int __ATTRS_o_ai
10060vec_splat(vector unsigned int __a, unsigned const int __b) {
10061 unsigned char b0 = (__b & 0x03) * 4;
10062 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10063 return vec_perm(__a, __a,
10064 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10065 b2, b3, b0, b1, b2, b3));
10066}
10067
10068static __inline__ vector bool int __ATTRS_o_ai
10069vec_splat(vector bool int __a, unsigned const int __b) {
10070 unsigned char b0 = (__b & 0x03) * 4;
10071 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10072 return vec_perm(__a, __a,
10073 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10074 b2, b3, b0, b1, b2, b3));
10075}
10076
10077static __inline__ vector float __ATTRS_o_ai vec_splat(vector float __a,
10078 unsigned const int __b) {
10079 unsigned char b0 = (__b & 0x03) * 4;
10080 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10081 return vec_perm(__a, __a,
10082 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10083 b2, b3, b0, b1, b2, b3));
10084}
10085
10086#ifdef __VSX__
10087static __inline__ vector double __ATTRS_o_ai vec_splat(vector double __a,
10088 unsigned const int __b) {
10089 unsigned char b0 = (__b & 0x01) * 8;
10090 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10091 b6 = b0 + 6, b7 = b0 + 7;
10092 return vec_perm(__a, __a,
10093 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10094 b2, b3, b4, b5, b6, b7));
10095}
10096static __inline__ vector bool long long __ATTRS_o_ai
10097vec_splat(vector bool long long __a, unsigned const int __b) {
10098 unsigned char b0 = (__b & 0x01) * 8;
10099 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10100 b6 = b0 + 6, b7 = b0 + 7;
10101 return vec_perm(__a, __a,
10102 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10103 b2, b3, b4, b5, b6, b7));
10104}
10105static __inline__ vector signed long long __ATTRS_o_ai
10106vec_splat(vector signed long long __a, unsigned const int __b) {
10107 unsigned char b0 = (__b & 0x01) * 8;
10108 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10109 b6 = b0 + 6, b7 = b0 + 7;
10110 return vec_perm(__a, __a,
10111 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10112 b2, b3, b4, b5, b6, b7));
10113}
10114static __inline__ vector unsigned long long __ATTRS_o_ai
10115vec_splat(vector unsigned long long __a, unsigned const int __b) {
10116 unsigned char b0 = (__b & 0x01) * 8;
10117 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10118 b6 = b0 + 6, b7 = b0 + 7;
10119 return vec_perm(__a, __a,
10120 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10121 b2, b3, b4, b5, b6, b7));
10122}
10123#endif
10124
10125/* vec_vspltb */
10126
10127#define __builtin_altivec_vspltb vec_vspltb
10128
10129static __inline__ vector signed char __ATTRS_o_ai
10130vec_vspltb(vector signed char __a, unsigned char __b) {
10131 return vec_perm(__a, __a, (vector unsigned char)(__b));
10132}
10133
10134static __inline__ vector unsigned char __ATTRS_o_ai
10135vec_vspltb(vector unsigned char __a, unsigned char __b) {
10136 return vec_perm(__a, __a, (vector unsigned char)(__b));
10137}
10138
10139static __inline__ vector bool char __ATTRS_o_ai vec_vspltb(vector bool char __a,
10140 unsigned char __b) {
10141 return vec_perm(__a, __a, (vector unsigned char)(__b));
10142}
10143
10144/* vec_vsplth */
10145
10146#define __builtin_altivec_vsplth vec_vsplth
10147
10148static __inline__ vector short __ATTRS_o_ai vec_vsplth(vector short __a,
10149 unsigned char __b) {
10150 __b *= 2;
10151 unsigned char b1 = __b + 1;
10152 return vec_perm(__a, __a,
10153 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10154 __b, b1, __b, b1, __b, b1, __b, b1));
10155}
10156
10157static __inline__ vector unsigned short __ATTRS_o_ai
10158vec_vsplth(vector unsigned short __a, unsigned char __b) {
10159 __b *= 2;
10160 unsigned char b1 = __b + 1;
10161 return vec_perm(__a, __a,
10162 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10163 __b, b1, __b, b1, __b, b1, __b, b1));
10164}
10165
10166static __inline__ vector bool short __ATTRS_o_ai
10167vec_vsplth(vector bool short __a, unsigned char __b) {
10168 __b *= 2;
10169 unsigned char b1 = __b + 1;
10170 return vec_perm(__a, __a,
10171 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10172 __b, b1, __b, b1, __b, b1, __b, b1));
10173}
10174
10175static __inline__ vector pixel __ATTRS_o_ai vec_vsplth(vector pixel __a,
10176 unsigned char __b) {
10177 __b *= 2;
10178 unsigned char b1 = __b + 1;
10179 return vec_perm(__a, __a,
10180 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10181 __b, b1, __b, b1, __b, b1, __b, b1));
10182}
10183
10184/* vec_vspltw */
10185
10186#define __builtin_altivec_vspltw vec_vspltw
10187
10188static __inline__ vector int __ATTRS_o_ai vec_vspltw(vector int __a,
10189 unsigned char __b) {
10190 __b *= 4;
10191 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10192 return vec_perm(__a, __a,
10193 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10194 b1, b2, b3, __b, b1, b2, b3));
10195}
10196
10197static __inline__ vector unsigned int __ATTRS_o_ai
10198vec_vspltw(vector unsigned int __a, unsigned char __b) {
10199 __b *= 4;
10200 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10201 return vec_perm(__a, __a,
10202 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10203 b1, b2, b3, __b, b1, b2, b3));
10204}
10205
10206static __inline__ vector bool int __ATTRS_o_ai vec_vspltw(vector bool int __a,
10207 unsigned char __b) {
10208 __b *= 4;
10209 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10210 return vec_perm(__a, __a,
10211 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10212 b1, b2, b3, __b, b1, b2, b3));
10213}
10214
10215static __inline__ vector float __ATTRS_o_ai vec_vspltw(vector float __a,
10216 unsigned char __b) {
10217 __b *= 4;
10218 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10219 return vec_perm(__a, __a,
10220 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10221 b1, b2, b3, __b, b1, b2, b3));
10222}
10223
10224/* vec_splat_s8 */
10225
10226#define __builtin_altivec_vspltisb vec_splat_s8
10227
10228// FIXME: parameter should be treated as 5-bit signed literal
10229static __inline__ vector signed char __ATTRS_o_ai
10230vec_splat_s8(signed char __a) {
10231 return (vector signed char)(__a);
10232}
10233
10234/* vec_vspltisb */
10235
10236// FIXME: parameter should be treated as 5-bit signed literal
10237static __inline__ vector signed char __ATTRS_o_ai
10238vec_vspltisb(signed char __a) {
10239 return (vector signed char)(__a);
10240}
10241
10242/* vec_splat_s16 */
10243
10244#define __builtin_altivec_vspltish vec_splat_s16
10245
10246// FIXME: parameter should be treated as 5-bit signed literal
10247static __inline__ vector short __ATTRS_o_ai vec_splat_s16(signed char __a) {
10248 return (vector short)(__a);
10249}
10250
10251/* vec_vspltish */
10252
10253// FIXME: parameter should be treated as 5-bit signed literal
10254static __inline__ vector short __ATTRS_o_ai vec_vspltish(signed char __a) {
10255 return (vector short)(__a);
10256}
10257
10258/* vec_splat_s32 */
10259
10260#define __builtin_altivec_vspltisw vec_splat_s32
10261
10262// FIXME: parameter should be treated as 5-bit signed literal
10263static __inline__ vector int __ATTRS_o_ai vec_splat_s32(signed char __a) {
10264 return (vector int)(__a);
10265}
10266
10267/* vec_vspltisw */
10268
10269// FIXME: parameter should be treated as 5-bit signed literal
10270static __inline__ vector int __ATTRS_o_ai vec_vspltisw(signed char __a) {
10271 return (vector int)(__a);
10272}
10273
10274/* vec_splat_u8 */
10275
10276// FIXME: parameter should be treated as 5-bit signed literal
10277static __inline__ vector unsigned char __ATTRS_o_ai
10278vec_splat_u8(unsigned char __a) {
10279 return (vector unsigned char)(__a);
10280}
10281
10282/* vec_splat_u16 */
10283
10284// FIXME: parameter should be treated as 5-bit signed literal
10285static __inline__ vector unsigned short __ATTRS_o_ai
10286vec_splat_u16(signed char __a) {
10287 return (vector unsigned short)(__a);
10288}
10289
10290/* vec_splat_u32 */
10291
10292// FIXME: parameter should be treated as 5-bit signed literal
10293static __inline__ vector unsigned int __ATTRS_o_ai
10294vec_splat_u32(signed char __a) {
10295 return (vector unsigned int)(__a);
10296}
10297
10298/* vec_sr */
10299
Logan Chiendbcf4122019-03-21 10:50:25 +080010300// vec_sr does modulo arithmetic on __b first, so __b is allowed to be more
10301// than the length of __a.
Logan Chien2833ffb2018-10-09 10:03:24 +080010302static __inline__ vector unsigned char __ATTRS_o_ai
10303vec_sr(vector unsigned char __a, vector unsigned char __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010304 return __a >>
10305 (__b % (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +080010306}
10307
Logan Chiendbcf4122019-03-21 10:50:25 +080010308static __inline__ vector signed char __ATTRS_o_ai
10309vec_sr(vector signed char __a, vector unsigned char __b) {
10310 return (vector signed char)vec_sr((vector unsigned char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010311}
10312
10313static __inline__ vector unsigned short __ATTRS_o_ai
10314vec_sr(vector unsigned short __a, vector unsigned short __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010315 return __a >>
10316 (__b % (vector unsigned short)(sizeof(unsigned short) * __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +080010317}
10318
Logan Chiendbcf4122019-03-21 10:50:25 +080010319static __inline__ vector short __ATTRS_o_ai vec_sr(vector short __a,
10320 vector unsigned short __b) {
10321 return (vector short)vec_sr((vector unsigned short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010322}
10323
10324static __inline__ vector unsigned int __ATTRS_o_ai
10325vec_sr(vector unsigned int __a, vector unsigned int __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010326 return __a >>
10327 (__b % (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
10328}
10329
10330static __inline__ vector int __ATTRS_o_ai vec_sr(vector int __a,
10331 vector unsigned int __b) {
10332 return (vector int)vec_sr((vector unsigned int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010333}
10334
10335#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080010336static __inline__ vector unsigned long long __ATTRS_o_ai
10337vec_sr(vector unsigned long long __a, vector unsigned long long __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010338 return __a >> (__b % (vector unsigned long long)(sizeof(unsigned long long) *
10339 __CHAR_BIT__));
10340}
10341
10342static __inline__ vector long long __ATTRS_o_ai
10343vec_sr(vector long long __a, vector unsigned long long __b) {
10344 return (vector long long)vec_sr((vector unsigned long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010345}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070010346#else
10347static __inline__ vector unsigned long long __ATTRS_o_ai
10348vec_sr(vector unsigned long long __a, vector unsigned long long __b) {
10349 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
10350
10351 // Big endian element zero (the left doubleword) can be right shifted as-is.
10352 // However the shift amount must be in the right doubleword.
10353 // The other element needs to be swapped into the left doubleword and
10354 // shifted. Then the left doublewords of the two result vectors are merged.
10355 vector unsigned long long __swapshift =
10356 __builtin_shufflevector(__b, __b, 1, 0);
10357 vector unsigned long long __leftelt =
10358 (vector unsigned long long)__builtin_altivec_vsro(
10359 (vector signed int)__a, (vector signed int)__swapshift);
10360#ifdef __LITTLE_ENDIAN__
10361 __leftelt = (vector unsigned long long)__builtin_altivec_vsr(
10362 (vector signed int)__leftelt,
10363 (vector signed int)vec_vspltb((vector unsigned char)__swapshift, 0));
10364#else
10365 __leftelt = (vector unsigned long long)__builtin_altivec_vsr(
10366 (vector signed int)__leftelt,
10367 (vector signed int)vec_vspltb((vector unsigned char)__swapshift, 15));
10368#endif
10369 __a = __builtin_shufflevector(__a, __a, 1, 0);
10370 vector unsigned long long __rightelt =
10371 (vector unsigned long long)__builtin_altivec_vsro((vector signed int)__a,
10372 (vector signed int)__b);
10373#ifdef __LITTLE_ENDIAN__
10374 __rightelt = (vector unsigned long long)__builtin_altivec_vsr(
10375 (vector signed int)__rightelt,
10376 (vector signed int)vec_vspltb((vector unsigned char)__b, 0));
10377 return __builtin_shufflevector(__rightelt, __leftelt, 1, 3);
10378#else
10379 __rightelt = (vector unsigned long long)__builtin_altivec_vsr(
10380 (vector signed int)__rightelt,
10381 (vector signed int)vec_vspltb((vector unsigned char)__b, 15));
10382 return __builtin_shufflevector(__leftelt, __rightelt, 0, 2);
10383#endif
10384}
10385
10386static __inline__ vector long long __ATTRS_o_ai
10387vec_sr(vector long long __a, vector unsigned long long __b) {
10388 return (vector long long)vec_sr((vector unsigned long long)__a, __b);
10389}
Logan Chien2833ffb2018-10-09 10:03:24 +080010390#endif
10391
10392/* vec_vsrb */
10393
10394#define __builtin_altivec_vsrb vec_vsrb
10395
10396static __inline__ vector signed char __ATTRS_o_ai
10397vec_vsrb(vector signed char __a, vector unsigned char __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010398 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010399}
10400
10401static __inline__ vector unsigned char __ATTRS_o_ai
10402vec_vsrb(vector unsigned char __a, vector unsigned char __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010403 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010404}
10405
10406/* vec_vsrh */
10407
10408#define __builtin_altivec_vsrh vec_vsrh
10409
10410static __inline__ vector short __ATTRS_o_ai
10411vec_vsrh(vector short __a, vector unsigned short __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010412 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010413}
10414
10415static __inline__ vector unsigned short __ATTRS_o_ai
10416vec_vsrh(vector unsigned short __a, vector unsigned short __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010417 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010418}
10419
10420/* vec_vsrw */
10421
10422#define __builtin_altivec_vsrw vec_vsrw
10423
10424static __inline__ vector int __ATTRS_o_ai vec_vsrw(vector int __a,
10425 vector unsigned int __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010426 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010427}
10428
10429static __inline__ vector unsigned int __ATTRS_o_ai
10430vec_vsrw(vector unsigned int __a, vector unsigned int __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010431 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010432}
10433
10434/* vec_sra */
10435
10436static __inline__ vector signed char __ATTRS_o_ai
10437vec_sra(vector signed char __a, vector unsigned char __b) {
10438 return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b);
10439}
10440
10441static __inline__ vector unsigned char __ATTRS_o_ai
10442vec_sra(vector unsigned char __a, vector unsigned char __b) {
10443 return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b);
10444}
10445
10446static __inline__ vector short __ATTRS_o_ai vec_sra(vector short __a,
10447 vector unsigned short __b) {
10448 return __builtin_altivec_vsrah(__a, (vector unsigned short)__b);
10449}
10450
10451static __inline__ vector unsigned short __ATTRS_o_ai
10452vec_sra(vector unsigned short __a, vector unsigned short __b) {
10453 return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b);
10454}
10455
10456static __inline__ vector int __ATTRS_o_ai vec_sra(vector int __a,
10457 vector unsigned int __b) {
10458 return __builtin_altivec_vsraw(__a, __b);
10459}
10460
10461static __inline__ vector unsigned int __ATTRS_o_ai
10462vec_sra(vector unsigned int __a, vector unsigned int __b) {
10463 return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b);
10464}
10465
10466#ifdef __POWER8_VECTOR__
10467static __inline__ vector signed long long __ATTRS_o_ai
10468vec_sra(vector signed long long __a, vector unsigned long long __b) {
10469 return __a >> __b;
10470}
10471
10472static __inline__ vector unsigned long long __ATTRS_o_ai
10473vec_sra(vector unsigned long long __a, vector unsigned long long __b) {
10474 return (vector unsigned long long)((vector signed long long)__a >> __b);
10475}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070010476#else
10477static __inline__ vector signed long long __ATTRS_o_ai
10478vec_sra(vector signed long long __a, vector unsigned long long __b) {
10479 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
10480 return __a >> __b;
10481}
10482
10483static __inline__ vector unsigned long long __ATTRS_o_ai
10484vec_sra(vector unsigned long long __a, vector unsigned long long __b) {
10485 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
10486 return (vector unsigned long long)((vector signed long long)__a >> __b);
10487}
Logan Chien2833ffb2018-10-09 10:03:24 +080010488#endif
10489
10490/* vec_vsrab */
10491
10492static __inline__ vector signed char __ATTRS_o_ai
10493vec_vsrab(vector signed char __a, vector unsigned char __b) {
10494 return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b);
10495}
10496
10497static __inline__ vector unsigned char __ATTRS_o_ai
10498vec_vsrab(vector unsigned char __a, vector unsigned char __b) {
10499 return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b);
10500}
10501
10502/* vec_vsrah */
10503
10504static __inline__ vector short __ATTRS_o_ai
10505vec_vsrah(vector short __a, vector unsigned short __b) {
10506 return __builtin_altivec_vsrah(__a, (vector unsigned short)__b);
10507}
10508
10509static __inline__ vector unsigned short __ATTRS_o_ai
10510vec_vsrah(vector unsigned short __a, vector unsigned short __b) {
10511 return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b);
10512}
10513
10514/* vec_vsraw */
10515
10516static __inline__ vector int __ATTRS_o_ai vec_vsraw(vector int __a,
10517 vector unsigned int __b) {
10518 return __builtin_altivec_vsraw(__a, __b);
10519}
10520
10521static __inline__ vector unsigned int __ATTRS_o_ai
10522vec_vsraw(vector unsigned int __a, vector unsigned int __b) {
10523 return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b);
10524}
10525
10526/* vec_srl */
10527
10528static __inline__ vector signed char __ATTRS_o_ai
10529vec_srl(vector signed char __a, vector unsigned char __b) {
10530 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10531 (vector int)__b);
10532}
10533
10534static __inline__ vector signed char __ATTRS_o_ai
10535vec_srl(vector signed char __a, vector unsigned short __b) {
10536 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10537 (vector int)__b);
10538}
10539
10540static __inline__ vector signed char __ATTRS_o_ai
10541vec_srl(vector signed char __a, vector unsigned int __b) {
10542 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10543 (vector int)__b);
10544}
10545
10546static __inline__ vector unsigned char __ATTRS_o_ai
10547vec_srl(vector unsigned char __a, vector unsigned char __b) {
10548 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10549 (vector int)__b);
10550}
10551
10552static __inline__ vector unsigned char __ATTRS_o_ai
10553vec_srl(vector unsigned char __a, vector unsigned short __b) {
10554 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10555 (vector int)__b);
10556}
10557
10558static __inline__ vector unsigned char __ATTRS_o_ai
10559vec_srl(vector unsigned char __a, vector unsigned int __b) {
10560 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10561 (vector int)__b);
10562}
10563
10564static __inline__ vector bool char __ATTRS_o_ai
10565vec_srl(vector bool char __a, vector unsigned char __b) {
10566 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10567 (vector int)__b);
10568}
10569
10570static __inline__ vector bool char __ATTRS_o_ai
10571vec_srl(vector bool char __a, vector unsigned short __b) {
10572 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10573 (vector int)__b);
10574}
10575
10576static __inline__ vector bool char __ATTRS_o_ai
10577vec_srl(vector bool char __a, vector unsigned int __b) {
10578 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10579 (vector int)__b);
10580}
10581
10582static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
10583 vector unsigned char __b) {
10584 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10585}
10586
10587static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
10588 vector unsigned short __b) {
10589 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10590}
10591
10592static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
10593 vector unsigned int __b) {
10594 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10595}
10596
10597static __inline__ vector unsigned short __ATTRS_o_ai
10598vec_srl(vector unsigned short __a, vector unsigned char __b) {
10599 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10600 (vector int)__b);
10601}
10602
10603static __inline__ vector unsigned short __ATTRS_o_ai
10604vec_srl(vector unsigned short __a, vector unsigned short __b) {
10605 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10606 (vector int)__b);
10607}
10608
10609static __inline__ vector unsigned short __ATTRS_o_ai
10610vec_srl(vector unsigned short __a, vector unsigned int __b) {
10611 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10612 (vector int)__b);
10613}
10614
10615static __inline__ vector bool short __ATTRS_o_ai
10616vec_srl(vector bool short __a, vector unsigned char __b) {
10617 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10618 (vector int)__b);
10619}
10620
10621static __inline__ vector bool short __ATTRS_o_ai
10622vec_srl(vector bool short __a, vector unsigned short __b) {
10623 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10624 (vector int)__b);
10625}
10626
10627static __inline__ vector bool short __ATTRS_o_ai
10628vec_srl(vector bool short __a, vector unsigned int __b) {
10629 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10630 (vector int)__b);
10631}
10632
10633static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
10634 vector unsigned char __b) {
10635 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10636}
10637
10638static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
10639 vector unsigned short __b) {
10640 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10641}
10642
10643static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
10644 vector unsigned int __b) {
10645 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10646}
10647
10648static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
10649 vector unsigned char __b) {
10650 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10651}
10652
10653static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
10654 vector unsigned short __b) {
10655 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10656}
10657
10658static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
10659 vector unsigned int __b) {
10660 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10661}
10662
10663static __inline__ vector unsigned int __ATTRS_o_ai
10664vec_srl(vector unsigned int __a, vector unsigned char __b) {
10665 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10666 (vector int)__b);
10667}
10668
10669static __inline__ vector unsigned int __ATTRS_o_ai
10670vec_srl(vector unsigned int __a, vector unsigned short __b) {
10671 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10672 (vector int)__b);
10673}
10674
10675static __inline__ vector unsigned int __ATTRS_o_ai
10676vec_srl(vector unsigned int __a, vector unsigned int __b) {
10677 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10678 (vector int)__b);
10679}
10680
10681static __inline__ vector bool int __ATTRS_o_ai
10682vec_srl(vector bool int __a, vector unsigned char __b) {
10683 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10684 (vector int)__b);
10685}
10686
10687static __inline__ vector bool int __ATTRS_o_ai
10688vec_srl(vector bool int __a, vector unsigned short __b) {
10689 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10690 (vector int)__b);
10691}
10692
10693static __inline__ vector bool int __ATTRS_o_ai
10694vec_srl(vector bool int __a, vector unsigned int __b) {
10695 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10696 (vector int)__b);
10697}
10698
Logan Chien55afb0a2018-10-15 10:42:14 +080010699#ifdef __VSX__
10700static __inline__ vector signed long long __ATTRS_o_ai
10701vec_srl(vector signed long long __a, vector unsigned char __b) {
10702 return (vector signed long long)__builtin_altivec_vsr((vector int)__a,
10703 (vector int)__b);
10704}
10705
10706static __inline__ vector unsigned long long __ATTRS_o_ai
10707vec_srl(vector unsigned long long __a, vector unsigned char __b) {
10708 return (vector unsigned long long)__builtin_altivec_vsr((vector int)__a,
10709 (vector int)__b);
10710}
10711#endif
10712
Logan Chien2833ffb2018-10-09 10:03:24 +080010713/* vec_vsr */
10714
10715static __inline__ vector signed char __ATTRS_o_ai
10716vec_vsr(vector signed char __a, vector unsigned char __b) {
10717 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10718 (vector int)__b);
10719}
10720
10721static __inline__ vector signed char __ATTRS_o_ai
10722vec_vsr(vector signed char __a, vector unsigned short __b) {
10723 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10724 (vector int)__b);
10725}
10726
10727static __inline__ vector signed char __ATTRS_o_ai
10728vec_vsr(vector signed char __a, vector unsigned int __b) {
10729 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10730 (vector int)__b);
10731}
10732
10733static __inline__ vector unsigned char __ATTRS_o_ai
10734vec_vsr(vector unsigned char __a, vector unsigned char __b) {
10735 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10736 (vector int)__b);
10737}
10738
10739static __inline__ vector unsigned char __ATTRS_o_ai
10740vec_vsr(vector unsigned char __a, vector unsigned short __b) {
10741 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10742 (vector int)__b);
10743}
10744
10745static __inline__ vector unsigned char __ATTRS_o_ai
10746vec_vsr(vector unsigned char __a, vector unsigned int __b) {
10747 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10748 (vector int)__b);
10749}
10750
10751static __inline__ vector bool char __ATTRS_o_ai
10752vec_vsr(vector bool char __a, vector unsigned char __b) {
10753 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10754 (vector int)__b);
10755}
10756
10757static __inline__ vector bool char __ATTRS_o_ai
10758vec_vsr(vector bool char __a, vector unsigned short __b) {
10759 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10760 (vector int)__b);
10761}
10762
10763static __inline__ vector bool char __ATTRS_o_ai
10764vec_vsr(vector bool char __a, vector unsigned int __b) {
10765 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10766 (vector int)__b);
10767}
10768
10769static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
10770 vector unsigned char __b) {
10771 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10772}
10773
10774static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
10775 vector unsigned short __b) {
10776 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10777}
10778
10779static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
10780 vector unsigned int __b) {
10781 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10782}
10783
10784static __inline__ vector unsigned short __ATTRS_o_ai
10785vec_vsr(vector unsigned short __a, vector unsigned char __b) {
10786 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10787 (vector int)__b);
10788}
10789
10790static __inline__ vector unsigned short __ATTRS_o_ai
10791vec_vsr(vector unsigned short __a, vector unsigned short __b) {
10792 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10793 (vector int)__b);
10794}
10795
10796static __inline__ vector unsigned short __ATTRS_o_ai
10797vec_vsr(vector unsigned short __a, vector unsigned int __b) {
10798 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10799 (vector int)__b);
10800}
10801
10802static __inline__ vector bool short __ATTRS_o_ai
10803vec_vsr(vector bool short __a, vector unsigned char __b) {
10804 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10805 (vector int)__b);
10806}
10807
10808static __inline__ vector bool short __ATTRS_o_ai
10809vec_vsr(vector bool short __a, vector unsigned short __b) {
10810 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10811 (vector int)__b);
10812}
10813
10814static __inline__ vector bool short __ATTRS_o_ai
10815vec_vsr(vector bool short __a, vector unsigned int __b) {
10816 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10817 (vector int)__b);
10818}
10819
10820static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
10821 vector unsigned char __b) {
10822 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10823}
10824
10825static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
10826 vector unsigned short __b) {
10827 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10828}
10829
10830static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
10831 vector unsigned int __b) {
10832 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10833}
10834
10835static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
10836 vector unsigned char __b) {
10837 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10838}
10839
10840static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
10841 vector unsigned short __b) {
10842 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10843}
10844
10845static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
10846 vector unsigned int __b) {
10847 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10848}
10849
10850static __inline__ vector unsigned int __ATTRS_o_ai
10851vec_vsr(vector unsigned int __a, vector unsigned char __b) {
10852 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10853 (vector int)__b);
10854}
10855
10856static __inline__ vector unsigned int __ATTRS_o_ai
10857vec_vsr(vector unsigned int __a, vector unsigned short __b) {
10858 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10859 (vector int)__b);
10860}
10861
10862static __inline__ vector unsigned int __ATTRS_o_ai
10863vec_vsr(vector unsigned int __a, vector unsigned int __b) {
10864 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10865 (vector int)__b);
10866}
10867
10868static __inline__ vector bool int __ATTRS_o_ai
10869vec_vsr(vector bool int __a, vector unsigned char __b) {
10870 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10871 (vector int)__b);
10872}
10873
10874static __inline__ vector bool int __ATTRS_o_ai
10875vec_vsr(vector bool int __a, vector unsigned short __b) {
10876 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10877 (vector int)__b);
10878}
10879
10880static __inline__ vector bool int __ATTRS_o_ai
10881vec_vsr(vector bool int __a, vector unsigned int __b) {
10882 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10883 (vector int)__b);
10884}
10885
10886/* vec_sro */
10887
10888static __inline__ vector signed char __ATTRS_o_ai
10889vec_sro(vector signed char __a, vector signed char __b) {
10890 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
10891 (vector int)__b);
10892}
10893
10894static __inline__ vector signed char __ATTRS_o_ai
10895vec_sro(vector signed char __a, vector unsigned char __b) {
10896 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
10897 (vector int)__b);
10898}
10899
10900static __inline__ vector unsigned char __ATTRS_o_ai
10901vec_sro(vector unsigned char __a, vector signed char __b) {
10902 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
10903 (vector int)__b);
10904}
10905
10906static __inline__ vector unsigned char __ATTRS_o_ai
10907vec_sro(vector unsigned char __a, vector unsigned char __b) {
10908 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
10909 (vector int)__b);
10910}
10911
10912static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a,
10913 vector signed char __b) {
10914 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10915}
10916
10917static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a,
10918 vector unsigned char __b) {
10919 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10920}
10921
10922static __inline__ vector unsigned short __ATTRS_o_ai
10923vec_sro(vector unsigned short __a, vector signed char __b) {
10924 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
10925 (vector int)__b);
10926}
10927
10928static __inline__ vector unsigned short __ATTRS_o_ai
10929vec_sro(vector unsigned short __a, vector unsigned char __b) {
10930 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
10931 (vector int)__b);
10932}
10933
10934static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a,
10935 vector signed char __b) {
10936 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10937}
10938
10939static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a,
10940 vector unsigned char __b) {
10941 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10942}
10943
10944static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a,
10945 vector signed char __b) {
10946 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
10947}
10948
10949static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a,
10950 vector unsigned char __b) {
10951 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
10952}
10953
10954static __inline__ vector unsigned int __ATTRS_o_ai
10955vec_sro(vector unsigned int __a, vector signed char __b) {
10956 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
10957 (vector int)__b);
10958}
10959
10960static __inline__ vector unsigned int __ATTRS_o_ai
10961vec_sro(vector unsigned int __a, vector unsigned char __b) {
10962 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
10963 (vector int)__b);
10964}
10965
10966static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a,
10967 vector signed char __b) {
10968 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10969}
10970
10971static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a,
10972 vector unsigned char __b) {
10973 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10974}
10975
Logan Chien55afb0a2018-10-15 10:42:14 +080010976#ifdef __VSX__
10977static __inline__ vector signed long long __ATTRS_o_ai
10978vec_sro(vector signed long long __a, vector signed char __b) {
10979 return (vector signed long long)__builtin_altivec_vsro((vector int)__a,
10980 (vector int)__b);
10981}
10982
10983static __inline__ vector signed long long __ATTRS_o_ai
10984vec_sro(vector signed long long __a, vector unsigned char __b) {
10985 return (vector signed long long)__builtin_altivec_vsro((vector int)__a,
10986 (vector int)__b);
10987}
10988
10989static __inline__ vector unsigned long long __ATTRS_o_ai
10990vec_sro(vector unsigned long long __a, vector signed char __b) {
10991 return (vector unsigned long long)__builtin_altivec_vsro((vector int)__a,
10992 (vector int)__b);
10993}
10994
10995static __inline__ vector unsigned long long __ATTRS_o_ai
10996vec_sro(vector unsigned long long __a, vector unsigned char __b) {
10997 return (vector unsigned long long)__builtin_altivec_vsro((vector int)__a,
10998 (vector int)__b);
10999}
11000#endif
11001
Logan Chien2833ffb2018-10-09 10:03:24 +080011002/* vec_vsro */
11003
11004static __inline__ vector signed char __ATTRS_o_ai
11005vec_vsro(vector signed char __a, vector signed char __b) {
11006 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
11007 (vector int)__b);
11008}
11009
11010static __inline__ vector signed char __ATTRS_o_ai
11011vec_vsro(vector signed char __a, vector unsigned char __b) {
11012 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
11013 (vector int)__b);
11014}
11015
11016static __inline__ vector unsigned char __ATTRS_o_ai
11017vec_vsro(vector unsigned char __a, vector signed char __b) {
11018 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
11019 (vector int)__b);
11020}
11021
11022static __inline__ vector unsigned char __ATTRS_o_ai
11023vec_vsro(vector unsigned char __a, vector unsigned char __b) {
11024 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
11025 (vector int)__b);
11026}
11027
11028static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a,
11029 vector signed char __b) {
11030 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11031}
11032
11033static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a,
11034 vector unsigned char __b) {
11035 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11036}
11037
11038static __inline__ vector unsigned short __ATTRS_o_ai
11039vec_vsro(vector unsigned short __a, vector signed char __b) {
11040 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
11041 (vector int)__b);
11042}
11043
11044static __inline__ vector unsigned short __ATTRS_o_ai
11045vec_vsro(vector unsigned short __a, vector unsigned char __b) {
11046 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
11047 (vector int)__b);
11048}
11049
11050static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a,
11051 vector signed char __b) {
11052 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11053}
11054
11055static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a,
11056 vector unsigned char __b) {
11057 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11058}
11059
11060static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a,
11061 vector signed char __b) {
11062 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
11063}
11064
11065static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a,
11066 vector unsigned char __b) {
11067 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
11068}
11069
11070static __inline__ vector unsigned int __ATTRS_o_ai
11071vec_vsro(vector unsigned int __a, vector signed char __b) {
11072 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
11073 (vector int)__b);
11074}
11075
11076static __inline__ vector unsigned int __ATTRS_o_ai
11077vec_vsro(vector unsigned int __a, vector unsigned char __b) {
11078 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
11079 (vector int)__b);
11080}
11081
11082static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a,
11083 vector signed char __b) {
11084 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11085}
11086
11087static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a,
11088 vector unsigned char __b) {
11089 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11090}
11091
11092/* vec_st */
11093
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011094static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011095 vector signed char *__c) {
11096 __builtin_altivec_stvx((vector int)__a, __b, __c);
11097}
11098
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011099static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011100 signed char *__c) {
11101 __builtin_altivec_stvx((vector int)__a, __b, __c);
11102}
11103
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011104static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011105 vector unsigned char *__c) {
11106 __builtin_altivec_stvx((vector int)__a, __b, __c);
11107}
11108
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011109static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011110 unsigned char *__c) {
11111 __builtin_altivec_stvx((vector int)__a, __b, __c);
11112}
11113
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011114static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011115 signed char *__c) {
11116 __builtin_altivec_stvx((vector int)__a, __b, __c);
11117}
11118
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011119static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011120 unsigned char *__c) {
11121 __builtin_altivec_stvx((vector int)__a, __b, __c);
11122}
11123
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011124static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011125 vector bool char *__c) {
11126 __builtin_altivec_stvx((vector int)__a, __b, __c);
11127}
11128
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011129static __inline__ void __ATTRS_o_ai vec_st(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011130 vector short *__c) {
11131 __builtin_altivec_stvx((vector int)__a, __b, __c);
11132}
11133
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011134static __inline__ void __ATTRS_o_ai vec_st(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011135 short *__c) {
11136 __builtin_altivec_stvx((vector int)__a, __b, __c);
11137}
11138
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011139static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011140 vector unsigned short *__c) {
11141 __builtin_altivec_stvx((vector int)__a, __b, __c);
11142}
11143
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011144static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011145 unsigned short *__c) {
11146 __builtin_altivec_stvx((vector int)__a, __b, __c);
11147}
11148
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011149static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011150 short *__c) {
11151 __builtin_altivec_stvx((vector int)__a, __b, __c);
11152}
11153
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011154static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011155 unsigned short *__c) {
11156 __builtin_altivec_stvx((vector int)__a, __b, __c);
11157}
11158
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011159static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011160 vector bool short *__c) {
11161 __builtin_altivec_stvx((vector int)__a, __b, __c);
11162}
11163
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011164static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011165 short *__c) {
11166 __builtin_altivec_stvx((vector int)__a, __b, __c);
11167}
11168
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011169static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011170 unsigned short *__c) {
11171 __builtin_altivec_stvx((vector int)__a, __b, __c);
11172}
11173
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011174static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011175 vector pixel *__c) {
11176 __builtin_altivec_stvx((vector int)__a, __b, __c);
11177}
11178
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011179static __inline__ void __ATTRS_o_ai vec_st(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011180 vector int *__c) {
11181 __builtin_altivec_stvx(__a, __b, __c);
11182}
11183
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011184static __inline__ void __ATTRS_o_ai vec_st(vector int __a, long __b, int *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011185 __builtin_altivec_stvx(__a, __b, __c);
11186}
11187
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011188static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011189 vector unsigned int *__c) {
11190 __builtin_altivec_stvx((vector int)__a, __b, __c);
11191}
11192
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011193static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011194 unsigned int *__c) {
11195 __builtin_altivec_stvx((vector int)__a, __b, __c);
11196}
11197
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011198static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011199 int *__c) {
11200 __builtin_altivec_stvx((vector int)__a, __b, __c);
11201}
11202
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011203static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011204 unsigned int *__c) {
11205 __builtin_altivec_stvx((vector int)__a, __b, __c);
11206}
11207
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011208static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011209 vector bool int *__c) {
11210 __builtin_altivec_stvx((vector int)__a, __b, __c);
11211}
11212
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011213static __inline__ void __ATTRS_o_ai vec_st(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011214 vector float *__c) {
11215 __builtin_altivec_stvx((vector int)__a, __b, __c);
11216}
11217
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011218static __inline__ void __ATTRS_o_ai vec_st(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011219 float *__c) {
11220 __builtin_altivec_stvx((vector int)__a, __b, __c);
11221}
11222
11223/* vec_stvx */
11224
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011225static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011226 vector signed char *__c) {
11227 __builtin_altivec_stvx((vector int)__a, __b, __c);
11228}
11229
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011230static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011231 signed char *__c) {
11232 __builtin_altivec_stvx((vector int)__a, __b, __c);
11233}
11234
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011235static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011236 vector unsigned char *__c) {
11237 __builtin_altivec_stvx((vector int)__a, __b, __c);
11238}
11239
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011240static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011241 unsigned char *__c) {
11242 __builtin_altivec_stvx((vector int)__a, __b, __c);
11243}
11244
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011245static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011246 signed char *__c) {
11247 __builtin_altivec_stvx((vector int)__a, __b, __c);
11248}
11249
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011250static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011251 unsigned char *__c) {
11252 __builtin_altivec_stvx((vector int)__a, __b, __c);
11253}
11254
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011255static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011256 vector bool char *__c) {
11257 __builtin_altivec_stvx((vector int)__a, __b, __c);
11258}
11259
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011260static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011261 vector short *__c) {
11262 __builtin_altivec_stvx((vector int)__a, __b, __c);
11263}
11264
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011265static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011266 short *__c) {
11267 __builtin_altivec_stvx((vector int)__a, __b, __c);
11268}
11269
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011270static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011271 vector unsigned short *__c) {
11272 __builtin_altivec_stvx((vector int)__a, __b, __c);
11273}
11274
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011275static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011276 unsigned short *__c) {
11277 __builtin_altivec_stvx((vector int)__a, __b, __c);
11278}
11279
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011280static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011281 short *__c) {
11282 __builtin_altivec_stvx((vector int)__a, __b, __c);
11283}
11284
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011285static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011286 unsigned short *__c) {
11287 __builtin_altivec_stvx((vector int)__a, __b, __c);
11288}
11289
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011290static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011291 vector bool short *__c) {
11292 __builtin_altivec_stvx((vector int)__a, __b, __c);
11293}
11294
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011295static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011296 short *__c) {
11297 __builtin_altivec_stvx((vector int)__a, __b, __c);
11298}
11299
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011300static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011301 unsigned short *__c) {
11302 __builtin_altivec_stvx((vector int)__a, __b, __c);
11303}
11304
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011305static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011306 vector pixel *__c) {
11307 __builtin_altivec_stvx((vector int)__a, __b, __c);
11308}
11309
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011310static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011311 vector int *__c) {
11312 __builtin_altivec_stvx(__a, __b, __c);
11313}
11314
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011315static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011316 int *__c) {
11317 __builtin_altivec_stvx(__a, __b, __c);
11318}
11319
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011320static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011321 vector unsigned int *__c) {
11322 __builtin_altivec_stvx((vector int)__a, __b, __c);
11323}
11324
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011325static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011326 unsigned int *__c) {
11327 __builtin_altivec_stvx((vector int)__a, __b, __c);
11328}
11329
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011330static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011331 int *__c) {
11332 __builtin_altivec_stvx((vector int)__a, __b, __c);
11333}
11334
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011335static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011336 unsigned int *__c) {
11337 __builtin_altivec_stvx((vector int)__a, __b, __c);
11338}
11339
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011340static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011341 vector bool int *__c) {
11342 __builtin_altivec_stvx((vector int)__a, __b, __c);
11343}
11344
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011345static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011346 vector float *__c) {
11347 __builtin_altivec_stvx((vector int)__a, __b, __c);
11348}
11349
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011350static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011351 float *__c) {
11352 __builtin_altivec_stvx((vector int)__a, __b, __c);
11353}
11354
11355/* vec_ste */
11356
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011357static __inline__ void __ATTRS_o_ai vec_ste(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011358 signed char *__c) {
11359 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11360}
11361
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011362static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011363 unsigned char *__c) {
11364 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11365}
11366
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011367static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011368 signed char *__c) {
11369 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11370}
11371
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011372static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011373 unsigned char *__c) {
11374 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11375}
11376
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011377static __inline__ void __ATTRS_o_ai vec_ste(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011378 short *__c) {
11379 __builtin_altivec_stvehx(__a, __b, __c);
11380}
11381
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011382static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011383 unsigned short *__c) {
11384 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11385}
11386
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011387static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011388 short *__c) {
11389 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11390}
11391
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011392static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011393 unsigned short *__c) {
11394 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11395}
11396
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011397static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011398 short *__c) {
11399 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11400}
11401
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011402static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011403 unsigned short *__c) {
11404 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11405}
11406
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011407static __inline__ void __ATTRS_o_ai vec_ste(vector int __a, long __b, int *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011408 __builtin_altivec_stvewx(__a, __b, __c);
11409}
11410
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011411static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011412 unsigned int *__c) {
11413 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11414}
11415
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011416static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011417 int *__c) {
11418 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11419}
11420
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011421static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011422 unsigned int *__c) {
11423 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11424}
11425
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011426static __inline__ void __ATTRS_o_ai vec_ste(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011427 float *__c) {
11428 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11429}
11430
11431/* vec_stvebx */
11432
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011433static __inline__ void __ATTRS_o_ai vec_stvebx(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011434 signed char *__c) {
11435 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11436}
11437
11438static __inline__ void __ATTRS_o_ai vec_stvebx(vector unsigned char __a,
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011439 long __b, unsigned char *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011440 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11441}
11442
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011443static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011444 signed char *__c) {
11445 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11446}
11447
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011448static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011449 unsigned char *__c) {
11450 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11451}
11452
11453/* vec_stvehx */
11454
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011455static __inline__ void __ATTRS_o_ai vec_stvehx(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011456 short *__c) {
11457 __builtin_altivec_stvehx(__a, __b, __c);
11458}
11459
11460static __inline__ void __ATTRS_o_ai vec_stvehx(vector unsigned short __a,
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011461 long __b, unsigned short *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011462 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11463}
11464
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011465static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011466 short *__c) {
11467 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11468}
11469
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011470static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011471 unsigned short *__c) {
11472 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11473}
11474
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011475static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011476 short *__c) {
11477 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11478}
11479
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011480static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011481 unsigned short *__c) {
11482 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11483}
11484
11485/* vec_stvewx */
11486
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011487static __inline__ void __ATTRS_o_ai vec_stvewx(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011488 int *__c) {
11489 __builtin_altivec_stvewx(__a, __b, __c);
11490}
11491
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011492static __inline__ void __ATTRS_o_ai vec_stvewx(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011493 unsigned int *__c) {
11494 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11495}
11496
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011497static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011498 int *__c) {
11499 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11500}
11501
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011502static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011503 unsigned int *__c) {
11504 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11505}
11506
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011507static __inline__ void __ATTRS_o_ai vec_stvewx(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011508 float *__c) {
11509 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11510}
11511
11512/* vec_stl */
11513
11514static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b,
11515 vector signed char *__c) {
11516 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11517}
11518
11519static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b,
11520 signed char *__c) {
11521 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11522}
11523
11524static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b,
11525 vector unsigned char *__c) {
11526 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11527}
11528
11529static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b,
11530 unsigned char *__c) {
11531 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11532}
11533
11534static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
11535 signed char *__c) {
11536 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11537}
11538
11539static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
11540 unsigned char *__c) {
11541 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11542}
11543
11544static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
11545 vector bool char *__c) {
11546 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11547}
11548
11549static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b,
11550 vector short *__c) {
11551 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11552}
11553
11554static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b,
11555 short *__c) {
11556 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11557}
11558
11559static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b,
11560 vector unsigned short *__c) {
11561 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11562}
11563
11564static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b,
11565 unsigned short *__c) {
11566 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11567}
11568
11569static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
11570 short *__c) {
11571 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11572}
11573
11574static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
11575 unsigned short *__c) {
11576 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11577}
11578
11579static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
11580 vector bool short *__c) {
11581 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11582}
11583
11584static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
11585 short *__c) {
11586 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11587}
11588
11589static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
11590 unsigned short *__c) {
11591 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11592}
11593
11594static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
11595 vector pixel *__c) {
11596 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11597}
11598
11599static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b,
11600 vector int *__c) {
11601 __builtin_altivec_stvxl(__a, __b, __c);
11602}
11603
11604static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b, int *__c) {
11605 __builtin_altivec_stvxl(__a, __b, __c);
11606}
11607
11608static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b,
11609 vector unsigned int *__c) {
11610 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11611}
11612
11613static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b,
11614 unsigned int *__c) {
11615 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11616}
11617
11618static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
11619 int *__c) {
11620 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11621}
11622
11623static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
11624 unsigned int *__c) {
11625 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11626}
11627
11628static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
11629 vector bool int *__c) {
11630 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11631}
11632
11633static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b,
11634 vector float *__c) {
11635 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11636}
11637
11638static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b,
11639 float *__c) {
11640 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11641}
11642
11643/* vec_stvxl */
11644
11645static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b,
11646 vector signed char *__c) {
11647 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11648}
11649
11650static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b,
11651 signed char *__c) {
11652 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11653}
11654
11655static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b,
11656 vector unsigned char *__c) {
11657 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11658}
11659
11660static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b,
11661 unsigned char *__c) {
11662 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11663}
11664
11665static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
11666 signed char *__c) {
11667 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11668}
11669
11670static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
11671 unsigned char *__c) {
11672 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11673}
11674
11675static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
11676 vector bool char *__c) {
11677 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11678}
11679
11680static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b,
11681 vector short *__c) {
11682 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11683}
11684
11685static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b,
11686 short *__c) {
11687 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11688}
11689
11690static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a,
11691 int __b,
11692 vector unsigned short *__c) {
11693 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11694}
11695
11696static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a,
11697 int __b, unsigned short *__c) {
11698 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11699}
11700
11701static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
11702 short *__c) {
11703 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11704}
11705
11706static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
11707 unsigned short *__c) {
11708 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11709}
11710
11711static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
11712 vector bool short *__c) {
11713 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11714}
11715
11716static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
11717 short *__c) {
11718 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11719}
11720
11721static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
11722 unsigned short *__c) {
11723 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11724}
11725
11726static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
11727 vector pixel *__c) {
11728 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11729}
11730
11731static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b,
11732 vector int *__c) {
11733 __builtin_altivec_stvxl(__a, __b, __c);
11734}
11735
11736static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b,
11737 int *__c) {
11738 __builtin_altivec_stvxl(__a, __b, __c);
11739}
11740
11741static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b,
11742 vector unsigned int *__c) {
11743 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11744}
11745
11746static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b,
11747 unsigned int *__c) {
11748 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11749}
11750
11751static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
11752 int *__c) {
11753 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11754}
11755
11756static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
11757 unsigned int *__c) {
11758 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11759}
11760
11761static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
11762 vector bool int *__c) {
11763 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11764}
11765
11766static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b,
11767 vector float *__c) {
11768 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11769}
11770
11771static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b,
11772 float *__c) {
11773 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11774}
11775
11776/* vec_sub */
11777
11778static __inline__ vector signed char __ATTRS_o_ai
11779vec_sub(vector signed char __a, vector signed char __b) {
11780 return __a - __b;
11781}
11782
11783static __inline__ vector signed char __ATTRS_o_ai
11784vec_sub(vector bool char __a, vector signed char __b) {
11785 return (vector signed char)__a - __b;
11786}
11787
11788static __inline__ vector signed char __ATTRS_o_ai
11789vec_sub(vector signed char __a, vector bool char __b) {
11790 return __a - (vector signed char)__b;
11791}
11792
11793static __inline__ vector unsigned char __ATTRS_o_ai
11794vec_sub(vector unsigned char __a, vector unsigned char __b) {
11795 return __a - __b;
11796}
11797
11798static __inline__ vector unsigned char __ATTRS_o_ai
11799vec_sub(vector bool char __a, vector unsigned char __b) {
11800 return (vector unsigned char)__a - __b;
11801}
11802
11803static __inline__ vector unsigned char __ATTRS_o_ai
11804vec_sub(vector unsigned char __a, vector bool char __b) {
11805 return __a - (vector unsigned char)__b;
11806}
11807
11808static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a,
11809 vector short __b) {
11810 return __a - __b;
11811}
11812
11813static __inline__ vector short __ATTRS_o_ai vec_sub(vector bool short __a,
11814 vector short __b) {
11815 return (vector short)__a - __b;
11816}
11817
11818static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a,
11819 vector bool short __b) {
11820 return __a - (vector short)__b;
11821}
11822
11823static __inline__ vector unsigned short __ATTRS_o_ai
11824vec_sub(vector unsigned short __a, vector unsigned short __b) {
11825 return __a - __b;
11826}
11827
11828static __inline__ vector unsigned short __ATTRS_o_ai
11829vec_sub(vector bool short __a, vector unsigned short __b) {
11830 return (vector unsigned short)__a - __b;
11831}
11832
11833static __inline__ vector unsigned short __ATTRS_o_ai
11834vec_sub(vector unsigned short __a, vector bool short __b) {
11835 return __a - (vector unsigned short)__b;
11836}
11837
11838static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a,
11839 vector int __b) {
11840 return __a - __b;
11841}
11842
11843static __inline__ vector int __ATTRS_o_ai vec_sub(vector bool int __a,
11844 vector int __b) {
11845 return (vector int)__a - __b;
11846}
11847
11848static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a,
11849 vector bool int __b) {
11850 return __a - (vector int)__b;
11851}
11852
11853static __inline__ vector unsigned int __ATTRS_o_ai
11854vec_sub(vector unsigned int __a, vector unsigned int __b) {
11855 return __a - __b;
11856}
11857
11858static __inline__ vector unsigned int __ATTRS_o_ai
11859vec_sub(vector bool int __a, vector unsigned int __b) {
11860 return (vector unsigned int)__a - __b;
11861}
11862
11863static __inline__ vector unsigned int __ATTRS_o_ai
11864vec_sub(vector unsigned int __a, vector bool int __b) {
11865 return __a - (vector unsigned int)__b;
11866}
11867
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070011868#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
11869 defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080011870static __inline__ vector signed __int128 __ATTRS_o_ai
11871vec_sub(vector signed __int128 __a, vector signed __int128 __b) {
11872 return __a - __b;
11873}
11874
11875static __inline__ vector unsigned __int128 __ATTRS_o_ai
11876vec_sub(vector unsigned __int128 __a, vector unsigned __int128 __b) {
11877 return __a - __b;
11878}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070011879#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) &&
11880 // defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080011881
11882#ifdef __VSX__
11883static __inline__ vector signed long long __ATTRS_o_ai
11884vec_sub(vector signed long long __a, vector signed long long __b) {
11885 return __a - __b;
11886}
11887
11888static __inline__ vector unsigned long long __ATTRS_o_ai
11889vec_sub(vector unsigned long long __a, vector unsigned long long __b) {
11890 return __a - __b;
11891}
11892
11893static __inline__ vector double __ATTRS_o_ai vec_sub(vector double __a,
11894 vector double __b) {
11895 return __a - __b;
11896}
11897#endif
11898
11899static __inline__ vector float __ATTRS_o_ai vec_sub(vector float __a,
11900 vector float __b) {
11901 return __a - __b;
11902}
11903
11904/* vec_vsububm */
11905
11906#define __builtin_altivec_vsububm vec_vsububm
11907
11908static __inline__ vector signed char __ATTRS_o_ai
11909vec_vsububm(vector signed char __a, vector signed char __b) {
11910 return __a - __b;
11911}
11912
11913static __inline__ vector signed char __ATTRS_o_ai
11914vec_vsububm(vector bool char __a, vector signed char __b) {
11915 return (vector signed char)__a - __b;
11916}
11917
11918static __inline__ vector signed char __ATTRS_o_ai
11919vec_vsububm(vector signed char __a, vector bool char __b) {
11920 return __a - (vector signed char)__b;
11921}
11922
11923static __inline__ vector unsigned char __ATTRS_o_ai
11924vec_vsububm(vector unsigned char __a, vector unsigned char __b) {
11925 return __a - __b;
11926}
11927
11928static __inline__ vector unsigned char __ATTRS_o_ai
11929vec_vsububm(vector bool char __a, vector unsigned char __b) {
11930 return (vector unsigned char)__a - __b;
11931}
11932
11933static __inline__ vector unsigned char __ATTRS_o_ai
11934vec_vsububm(vector unsigned char __a, vector bool char __b) {
11935 return __a - (vector unsigned char)__b;
11936}
11937
11938/* vec_vsubuhm */
11939
11940#define __builtin_altivec_vsubuhm vec_vsubuhm
11941
11942static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a,
11943 vector short __b) {
11944 return __a - __b;
11945}
11946
11947static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector bool short __a,
11948 vector short __b) {
11949 return (vector short)__a - __b;
11950}
11951
11952static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a,
11953 vector bool short __b) {
11954 return __a - (vector short)__b;
11955}
11956
11957static __inline__ vector unsigned short __ATTRS_o_ai
11958vec_vsubuhm(vector unsigned short __a, vector unsigned short __b) {
11959 return __a - __b;
11960}
11961
11962static __inline__ vector unsigned short __ATTRS_o_ai
11963vec_vsubuhm(vector bool short __a, vector unsigned short __b) {
11964 return (vector unsigned short)__a - __b;
11965}
11966
11967static __inline__ vector unsigned short __ATTRS_o_ai
11968vec_vsubuhm(vector unsigned short __a, vector bool short __b) {
11969 return __a - (vector unsigned short)__b;
11970}
11971
11972/* vec_vsubuwm */
11973
11974#define __builtin_altivec_vsubuwm vec_vsubuwm
11975
11976static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a,
11977 vector int __b) {
11978 return __a - __b;
11979}
11980
11981static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector bool int __a,
11982 vector int __b) {
11983 return (vector int)__a - __b;
11984}
11985
11986static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a,
11987 vector bool int __b) {
11988 return __a - (vector int)__b;
11989}
11990
11991static __inline__ vector unsigned int __ATTRS_o_ai
11992vec_vsubuwm(vector unsigned int __a, vector unsigned int __b) {
11993 return __a - __b;
11994}
11995
11996static __inline__ vector unsigned int __ATTRS_o_ai
11997vec_vsubuwm(vector bool int __a, vector unsigned int __b) {
11998 return (vector unsigned int)__a - __b;
11999}
12000
12001static __inline__ vector unsigned int __ATTRS_o_ai
12002vec_vsubuwm(vector unsigned int __a, vector bool int __b) {
12003 return __a - (vector unsigned int)__b;
12004}
12005
12006/* vec_vsubfp */
12007
12008#define __builtin_altivec_vsubfp vec_vsubfp
12009
12010static __inline__ vector float __attribute__((__always_inline__))
12011vec_vsubfp(vector float __a, vector float __b) {
12012 return __a - __b;
12013}
12014
12015/* vec_subc */
12016
Logan Chien55afb0a2018-10-15 10:42:14 +080012017static __inline__ vector signed int __ATTRS_o_ai
12018vec_subc(vector signed int __a, vector signed int __b) {
12019 return (vector signed int)__builtin_altivec_vsubcuw((vector unsigned int)__a,
12020 (vector unsigned int) __b);
12021}
12022
Logan Chien2833ffb2018-10-09 10:03:24 +080012023static __inline__ vector unsigned int __ATTRS_o_ai
12024vec_subc(vector unsigned int __a, vector unsigned int __b) {
12025 return __builtin_altivec_vsubcuw(__a, __b);
12026}
12027
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012028#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012029#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012030static __inline__ vector unsigned __int128 __ATTRS_o_ai
12031vec_subc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
12032 return __builtin_altivec_vsubcuq(__a, __b);
12033}
12034
12035static __inline__ vector signed __int128 __ATTRS_o_ai
12036vec_subc(vector signed __int128 __a, vector signed __int128 __b) {
12037 return __builtin_altivec_vsubcuq(__a, __b);
12038}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012039#endif
12040
12041static __inline__ vector unsigned char __attribute__((__always_inline__))
12042vec_subc_u128(vector unsigned char __a, vector unsigned char __b) {
12043 return (vector unsigned char)__builtin_altivec_vsubcuq(__a, __b);
12044}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012045#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080012046
12047/* vec_vsubcuw */
12048
12049static __inline__ vector unsigned int __attribute__((__always_inline__))
12050vec_vsubcuw(vector unsigned int __a, vector unsigned int __b) {
12051 return __builtin_altivec_vsubcuw(__a, __b);
12052}
12053
12054/* vec_subs */
12055
12056static __inline__ vector signed char __ATTRS_o_ai
12057vec_subs(vector signed char __a, vector signed char __b) {
12058 return __builtin_altivec_vsubsbs(__a, __b);
12059}
12060
12061static __inline__ vector signed char __ATTRS_o_ai
12062vec_subs(vector bool char __a, vector signed char __b) {
12063 return __builtin_altivec_vsubsbs((vector signed char)__a, __b);
12064}
12065
12066static __inline__ vector signed char __ATTRS_o_ai
12067vec_subs(vector signed char __a, vector bool char __b) {
12068 return __builtin_altivec_vsubsbs(__a, (vector signed char)__b);
12069}
12070
12071static __inline__ vector unsigned char __ATTRS_o_ai
12072vec_subs(vector unsigned char __a, vector unsigned char __b) {
12073 return __builtin_altivec_vsububs(__a, __b);
12074}
12075
12076static __inline__ vector unsigned char __ATTRS_o_ai
12077vec_subs(vector bool char __a, vector unsigned char __b) {
12078 return __builtin_altivec_vsububs((vector unsigned char)__a, __b);
12079}
12080
12081static __inline__ vector unsigned char __ATTRS_o_ai
12082vec_subs(vector unsigned char __a, vector bool char __b) {
12083 return __builtin_altivec_vsububs(__a, (vector unsigned char)__b);
12084}
12085
12086static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a,
12087 vector short __b) {
12088 return __builtin_altivec_vsubshs(__a, __b);
12089}
12090
12091static __inline__ vector short __ATTRS_o_ai vec_subs(vector bool short __a,
12092 vector short __b) {
12093 return __builtin_altivec_vsubshs((vector short)__a, __b);
12094}
12095
12096static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a,
12097 vector bool short __b) {
12098 return __builtin_altivec_vsubshs(__a, (vector short)__b);
12099}
12100
12101static __inline__ vector unsigned short __ATTRS_o_ai
12102vec_subs(vector unsigned short __a, vector unsigned short __b) {
12103 return __builtin_altivec_vsubuhs(__a, __b);
12104}
12105
12106static __inline__ vector unsigned short __ATTRS_o_ai
12107vec_subs(vector bool short __a, vector unsigned short __b) {
12108 return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b);
12109}
12110
12111static __inline__ vector unsigned short __ATTRS_o_ai
12112vec_subs(vector unsigned short __a, vector bool short __b) {
12113 return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b);
12114}
12115
12116static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a,
12117 vector int __b) {
12118 return __builtin_altivec_vsubsws(__a, __b);
12119}
12120
12121static __inline__ vector int __ATTRS_o_ai vec_subs(vector bool int __a,
12122 vector int __b) {
12123 return __builtin_altivec_vsubsws((vector int)__a, __b);
12124}
12125
12126static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a,
12127 vector bool int __b) {
12128 return __builtin_altivec_vsubsws(__a, (vector int)__b);
12129}
12130
12131static __inline__ vector unsigned int __ATTRS_o_ai
12132vec_subs(vector unsigned int __a, vector unsigned int __b) {
12133 return __builtin_altivec_vsubuws(__a, __b);
12134}
12135
12136static __inline__ vector unsigned int __ATTRS_o_ai
12137vec_subs(vector bool int __a, vector unsigned int __b) {
12138 return __builtin_altivec_vsubuws((vector unsigned int)__a, __b);
12139}
12140
12141static __inline__ vector unsigned int __ATTRS_o_ai
12142vec_subs(vector unsigned int __a, vector bool int __b) {
12143 return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
12144}
12145
12146/* vec_vsubsbs */
12147
12148static __inline__ vector signed char __ATTRS_o_ai
12149vec_vsubsbs(vector signed char __a, vector signed char __b) {
12150 return __builtin_altivec_vsubsbs(__a, __b);
12151}
12152
12153static __inline__ vector signed char __ATTRS_o_ai
12154vec_vsubsbs(vector bool char __a, vector signed char __b) {
12155 return __builtin_altivec_vsubsbs((vector signed char)__a, __b);
12156}
12157
12158static __inline__ vector signed char __ATTRS_o_ai
12159vec_vsubsbs(vector signed char __a, vector bool char __b) {
12160 return __builtin_altivec_vsubsbs(__a, (vector signed char)__b);
12161}
12162
12163/* vec_vsububs */
12164
12165static __inline__ vector unsigned char __ATTRS_o_ai
12166vec_vsububs(vector unsigned char __a, vector unsigned char __b) {
12167 return __builtin_altivec_vsububs(__a, __b);
12168}
12169
12170static __inline__ vector unsigned char __ATTRS_o_ai
12171vec_vsububs(vector bool char __a, vector unsigned char __b) {
12172 return __builtin_altivec_vsububs((vector unsigned char)__a, __b);
12173}
12174
12175static __inline__ vector unsigned char __ATTRS_o_ai
12176vec_vsububs(vector unsigned char __a, vector bool char __b) {
12177 return __builtin_altivec_vsububs(__a, (vector unsigned char)__b);
12178}
12179
12180/* vec_vsubshs */
12181
12182static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a,
12183 vector short __b) {
12184 return __builtin_altivec_vsubshs(__a, __b);
12185}
12186
12187static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector bool short __a,
12188 vector short __b) {
12189 return __builtin_altivec_vsubshs((vector short)__a, __b);
12190}
12191
12192static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a,
12193 vector bool short __b) {
12194 return __builtin_altivec_vsubshs(__a, (vector short)__b);
12195}
12196
12197/* vec_vsubuhs */
12198
12199static __inline__ vector unsigned short __ATTRS_o_ai
12200vec_vsubuhs(vector unsigned short __a, vector unsigned short __b) {
12201 return __builtin_altivec_vsubuhs(__a, __b);
12202}
12203
12204static __inline__ vector unsigned short __ATTRS_o_ai
12205vec_vsubuhs(vector bool short __a, vector unsigned short __b) {
12206 return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b);
12207}
12208
12209static __inline__ vector unsigned short __ATTRS_o_ai
12210vec_vsubuhs(vector unsigned short __a, vector bool short __b) {
12211 return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b);
12212}
12213
12214/* vec_vsubsws */
12215
12216static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a,
12217 vector int __b) {
12218 return __builtin_altivec_vsubsws(__a, __b);
12219}
12220
12221static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector bool int __a,
12222 vector int __b) {
12223 return __builtin_altivec_vsubsws((vector int)__a, __b);
12224}
12225
12226static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a,
12227 vector bool int __b) {
12228 return __builtin_altivec_vsubsws(__a, (vector int)__b);
12229}
12230
12231/* vec_vsubuws */
12232
12233static __inline__ vector unsigned int __ATTRS_o_ai
12234vec_vsubuws(vector unsigned int __a, vector unsigned int __b) {
12235 return __builtin_altivec_vsubuws(__a, __b);
12236}
12237
12238static __inline__ vector unsigned int __ATTRS_o_ai
12239vec_vsubuws(vector bool int __a, vector unsigned int __b) {
12240 return __builtin_altivec_vsubuws((vector unsigned int)__a, __b);
12241}
12242
12243static __inline__ vector unsigned int __ATTRS_o_ai
12244vec_vsubuws(vector unsigned int __a, vector bool int __b) {
12245 return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
12246}
12247
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012248#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080012249/* vec_vsubuqm */
12250
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012251#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012252static __inline__ vector signed __int128 __ATTRS_o_ai
12253vec_vsubuqm(vector signed __int128 __a, vector signed __int128 __b) {
12254 return __a - __b;
12255}
12256
12257static __inline__ vector unsigned __int128 __ATTRS_o_ai
12258vec_vsubuqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
12259 return __a - __b;
12260}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012261#endif
12262
12263static __inline__ vector unsigned char __attribute__((__always_inline__))
12264vec_sub_u128(vector unsigned char __a, vector unsigned char __b) {
12265 return __builtin_altivec_vsubuqm(__a, __b);
12266}
Logan Chien2833ffb2018-10-09 10:03:24 +080012267
12268/* vec_vsubeuqm */
12269
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012270#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012271static __inline__ vector signed __int128 __ATTRS_o_ai
12272vec_vsubeuqm(vector signed __int128 __a, vector signed __int128 __b,
12273 vector signed __int128 __c) {
12274 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12275}
12276
12277static __inline__ vector unsigned __int128 __ATTRS_o_ai
12278vec_vsubeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
12279 vector unsigned __int128 __c) {
12280 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12281}
12282
Logan Chien55afb0a2018-10-15 10:42:14 +080012283static __inline__ vector signed __int128 __ATTRS_o_ai
12284vec_sube(vector signed __int128 __a, vector signed __int128 __b,
12285 vector signed __int128 __c) {
12286 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12287}
12288
12289static __inline__ vector unsigned __int128 __ATTRS_o_ai
12290vec_sube(vector unsigned __int128 __a, vector unsigned __int128 __b,
12291 vector unsigned __int128 __c) {
12292 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12293}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012294#endif
12295
12296static __inline__ vector unsigned char __attribute__((__always_inline__))
12297vec_sube_u128(vector unsigned char __a, vector unsigned char __b,
12298 vector unsigned char __c) {
12299 return (vector unsigned char)__builtin_altivec_vsubeuqm(__a, __b, __c);
12300}
Logan Chien55afb0a2018-10-15 10:42:14 +080012301
Logan Chien2833ffb2018-10-09 10:03:24 +080012302/* vec_vsubcuq */
12303
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012304#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012305static __inline__ vector signed __int128 __ATTRS_o_ai
12306vec_vsubcuq(vector signed __int128 __a, vector signed __int128 __b) {
12307 return __builtin_altivec_vsubcuq(__a, __b);
12308}
12309
12310static __inline__ vector unsigned __int128 __ATTRS_o_ai
12311vec_vsubcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
12312 return __builtin_altivec_vsubcuq(__a, __b);
12313}
12314
12315/* vec_vsubecuq */
12316
12317static __inline__ vector signed __int128 __ATTRS_o_ai
12318vec_vsubecuq(vector signed __int128 __a, vector signed __int128 __b,
12319 vector signed __int128 __c) {
12320 return __builtin_altivec_vsubecuq(__a, __b, __c);
12321}
12322
12323static __inline__ vector unsigned __int128 __ATTRS_o_ai
12324vec_vsubecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
12325 vector unsigned __int128 __c) {
12326 return __builtin_altivec_vsubecuq(__a, __b, __c);
12327}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012328#endif
Logan Chien55afb0a2018-10-15 10:42:14 +080012329
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012330#ifdef __powerpc64__
Logan Chien55afb0a2018-10-15 10:42:14 +080012331static __inline__ vector signed int __ATTRS_o_ai
12332vec_subec(vector signed int __a, vector signed int __b,
12333 vector signed int __c) {
12334 return vec_addec(__a, ~__b, __c);
12335}
12336
12337static __inline__ vector unsigned int __ATTRS_o_ai
12338vec_subec(vector unsigned int __a, vector unsigned int __b,
12339 vector unsigned int __c) {
12340 return vec_addec(__a, ~__b, __c);
12341}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012342#endif
Logan Chien55afb0a2018-10-15 10:42:14 +080012343
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012344#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +080012345static __inline__ vector signed __int128 __ATTRS_o_ai
12346vec_subec(vector signed __int128 __a, vector signed __int128 __b,
12347 vector signed __int128 __c) {
12348 return __builtin_altivec_vsubecuq(__a, __b, __c);
12349}
12350
12351static __inline__ vector unsigned __int128 __ATTRS_o_ai
12352vec_subec(vector unsigned __int128 __a, vector unsigned __int128 __b,
12353 vector unsigned __int128 __c) {
12354 return __builtin_altivec_vsubecuq(__a, __b, __c);
12355}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012356#endif
12357
12358static __inline__ vector unsigned char __attribute__((__always_inline__))
12359vec_subec_u128(vector unsigned char __a, vector unsigned char __b,
12360 vector unsigned char __c) {
12361 return (vector unsigned char)__builtin_altivec_vsubecuq(__a, __b, __c);
12362}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012363#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080012364
Logan Chien55afb0a2018-10-15 10:42:14 +080012365static __inline__ vector signed int __ATTRS_o_ai
12366vec_sube(vector signed int __a, vector signed int __b,
12367 vector signed int __c) {
12368 vector signed int __mask = {1, 1, 1, 1};
12369 vector signed int __carry = __c & __mask;
12370 return vec_adde(__a, ~__b, __carry);
12371}
12372
12373static __inline__ vector unsigned int __ATTRS_o_ai
12374vec_sube(vector unsigned int __a, vector unsigned int __b,
12375 vector unsigned int __c) {
12376 vector unsigned int __mask = {1, 1, 1, 1};
12377 vector unsigned int __carry = __c & __mask;
12378 return vec_adde(__a, ~__b, __carry);
12379}
Logan Chien2833ffb2018-10-09 10:03:24 +080012380/* vec_sum4s */
12381
12382static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed char __a,
12383 vector int __b) {
12384 return __builtin_altivec_vsum4sbs(__a, __b);
12385}
12386
12387static __inline__ vector unsigned int __ATTRS_o_ai
12388vec_sum4s(vector unsigned char __a, vector unsigned int __b) {
12389 return __builtin_altivec_vsum4ubs(__a, __b);
12390}
12391
12392static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed short __a,
12393 vector int __b) {
12394 return __builtin_altivec_vsum4shs(__a, __b);
12395}
12396
12397/* vec_vsum4sbs */
12398
12399static __inline__ vector int __attribute__((__always_inline__))
12400vec_vsum4sbs(vector signed char __a, vector int __b) {
12401 return __builtin_altivec_vsum4sbs(__a, __b);
12402}
12403
12404/* vec_vsum4ubs */
12405
12406static __inline__ vector unsigned int __attribute__((__always_inline__))
12407vec_vsum4ubs(vector unsigned char __a, vector unsigned int __b) {
12408 return __builtin_altivec_vsum4ubs(__a, __b);
12409}
12410
12411/* vec_vsum4shs */
12412
12413static __inline__ vector int __attribute__((__always_inline__))
12414vec_vsum4shs(vector signed short __a, vector int __b) {
12415 return __builtin_altivec_vsum4shs(__a, __b);
12416}
12417
12418/* vec_sum2s */
12419
12420/* The vsum2sws instruction has a big-endian bias, so that the second
12421 input vector and the result always reference big-endian elements
12422 1 and 3 (little-endian element 0 and 2). For ease of porting the
12423 programmer wants elements 1 and 3 in both cases, so for little
12424 endian we must perform some permutes. */
12425
12426static __inline__ vector signed int __attribute__((__always_inline__))
12427vec_sum2s(vector int __a, vector int __b) {
12428#ifdef __LITTLE_ENDIAN__
12429 vector int __c = (vector signed int)vec_perm(
12430 __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12431 8, 9, 10, 11));
12432 __c = __builtin_altivec_vsum2sws(__a, __c);
12433 return (vector signed int)vec_perm(
12434 __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12435 8, 9, 10, 11));
12436#else
12437 return __builtin_altivec_vsum2sws(__a, __b);
12438#endif
12439}
12440
12441/* vec_vsum2sws */
12442
12443static __inline__ vector signed int __attribute__((__always_inline__))
12444vec_vsum2sws(vector int __a, vector int __b) {
12445#ifdef __LITTLE_ENDIAN__
12446 vector int __c = (vector signed int)vec_perm(
12447 __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12448 8, 9, 10, 11));
12449 __c = __builtin_altivec_vsum2sws(__a, __c);
12450 return (vector signed int)vec_perm(
12451 __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12452 8, 9, 10, 11));
12453#else
12454 return __builtin_altivec_vsum2sws(__a, __b);
12455#endif
12456}
12457
12458/* vec_sums */
12459
12460/* The vsumsws instruction has a big-endian bias, so that the second
12461 input vector and the result always reference big-endian element 3
12462 (little-endian element 0). For ease of porting the programmer
12463 wants element 3 in both cases, so for little endian we must perform
12464 some permutes. */
12465
12466static __inline__ vector signed int __attribute__((__always_inline__))
12467vec_sums(vector signed int __a, vector signed int __b) {
12468#ifdef __LITTLE_ENDIAN__
12469 __b = (vector signed int)vec_splat(__b, 3);
12470 __b = __builtin_altivec_vsumsws(__a, __b);
12471 return (vector signed int)(0, 0, 0, __b[0]);
12472#else
12473 return __builtin_altivec_vsumsws(__a, __b);
12474#endif
12475}
12476
12477/* vec_vsumsws */
12478
12479static __inline__ vector signed int __attribute__((__always_inline__))
12480vec_vsumsws(vector signed int __a, vector signed int __b) {
12481#ifdef __LITTLE_ENDIAN__
12482 __b = (vector signed int)vec_splat(__b, 3);
12483 __b = __builtin_altivec_vsumsws(__a, __b);
12484 return (vector signed int)(0, 0, 0, __b[0]);
12485#else
12486 return __builtin_altivec_vsumsws(__a, __b);
12487#endif
12488}
12489
12490/* vec_trunc */
12491
12492static __inline__ vector float __ATTRS_o_ai vec_trunc(vector float __a) {
12493#ifdef __VSX__
12494 return __builtin_vsx_xvrspiz(__a);
12495#else
12496 return __builtin_altivec_vrfiz(__a);
12497#endif
12498}
12499
12500#ifdef __VSX__
12501static __inline__ vector double __ATTRS_o_ai vec_trunc(vector double __a) {
12502 return __builtin_vsx_xvrdpiz(__a);
12503}
12504#endif
12505
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012506/* vec_roundz */
12507static __inline__ vector float __ATTRS_o_ai vec_roundz(vector float __a) {
12508 return vec_trunc(__a);
12509}
12510
12511#ifdef __VSX__
12512static __inline__ vector double __ATTRS_o_ai vec_roundz(vector double __a) {
12513 return vec_trunc(__a);
12514}
12515#endif
12516
Logan Chien2833ffb2018-10-09 10:03:24 +080012517/* vec_vrfiz */
12518
12519static __inline__ vector float __attribute__((__always_inline__))
12520vec_vrfiz(vector float __a) {
12521 return __builtin_altivec_vrfiz(__a);
12522}
12523
12524/* vec_unpackh */
12525
12526/* The vector unpack instructions all have a big-endian bias, so for
12527 little endian we must reverse the meanings of "high" and "low." */
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012528#ifdef __LITTLE_ENDIAN__
12529#define vec_vupkhpx(__a) __builtin_altivec_vupklpx((vector short)(__a))
12530#define vec_vupklpx(__a) __builtin_altivec_vupkhpx((vector short)(__a))
12531#else
12532#define vec_vupkhpx(__a) __builtin_altivec_vupkhpx((vector short)(__a))
12533#define vec_vupklpx(__a) __builtin_altivec_vupklpx((vector short)(__a))
12534#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080012535
12536static __inline__ vector short __ATTRS_o_ai
12537vec_unpackh(vector signed char __a) {
12538#ifdef __LITTLE_ENDIAN__
12539 return __builtin_altivec_vupklsb((vector char)__a);
12540#else
12541 return __builtin_altivec_vupkhsb((vector char)__a);
12542#endif
12543}
12544
12545static __inline__ vector bool short __ATTRS_o_ai
12546vec_unpackh(vector bool char __a) {
12547#ifdef __LITTLE_ENDIAN__
12548 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12549#else
12550 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12551#endif
12552}
12553
12554static __inline__ vector int __ATTRS_o_ai vec_unpackh(vector short __a) {
12555#ifdef __LITTLE_ENDIAN__
12556 return __builtin_altivec_vupklsh(__a);
12557#else
12558 return __builtin_altivec_vupkhsh(__a);
12559#endif
12560}
12561
12562static __inline__ vector bool int __ATTRS_o_ai
12563vec_unpackh(vector bool short __a) {
12564#ifdef __LITTLE_ENDIAN__
12565 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12566#else
12567 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12568#endif
12569}
12570
12571static __inline__ vector unsigned int __ATTRS_o_ai
12572vec_unpackh(vector pixel __a) {
12573#ifdef __LITTLE_ENDIAN__
12574 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12575#else
12576 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12577#endif
12578}
12579
12580#ifdef __POWER8_VECTOR__
12581static __inline__ vector long long __ATTRS_o_ai vec_unpackh(vector int __a) {
12582#ifdef __LITTLE_ENDIAN__
12583 return __builtin_altivec_vupklsw(__a);
12584#else
12585 return __builtin_altivec_vupkhsw(__a);
12586#endif
12587}
12588
12589static __inline__ vector bool long long __ATTRS_o_ai
12590vec_unpackh(vector bool int __a) {
12591#ifdef __LITTLE_ENDIAN__
12592 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12593#else
12594 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12595#endif
12596}
Logan Chien55afb0a2018-10-15 10:42:14 +080012597
12598static __inline__ vector double __ATTRS_o_ai
12599vec_unpackh(vector float __a) {
12600 return (vector double)(__a[0], __a[1]);
12601}
Logan Chien2833ffb2018-10-09 10:03:24 +080012602#endif
12603
12604/* vec_vupkhsb */
12605
12606static __inline__ vector short __ATTRS_o_ai
12607vec_vupkhsb(vector signed char __a) {
12608#ifdef __LITTLE_ENDIAN__
12609 return __builtin_altivec_vupklsb((vector char)__a);
12610#else
12611 return __builtin_altivec_vupkhsb((vector char)__a);
12612#endif
12613}
12614
12615static __inline__ vector bool short __ATTRS_o_ai
12616vec_vupkhsb(vector bool char __a) {
12617#ifdef __LITTLE_ENDIAN__
12618 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12619#else
12620 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12621#endif
12622}
12623
12624/* vec_vupkhsh */
12625
12626static __inline__ vector int __ATTRS_o_ai vec_vupkhsh(vector short __a) {
12627#ifdef __LITTLE_ENDIAN__
12628 return __builtin_altivec_vupklsh(__a);
12629#else
12630 return __builtin_altivec_vupkhsh(__a);
12631#endif
12632}
12633
12634static __inline__ vector bool int __ATTRS_o_ai
12635vec_vupkhsh(vector bool short __a) {
12636#ifdef __LITTLE_ENDIAN__
12637 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12638#else
12639 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12640#endif
12641}
12642
12643static __inline__ vector unsigned int __ATTRS_o_ai
12644vec_vupkhsh(vector pixel __a) {
12645#ifdef __LITTLE_ENDIAN__
12646 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12647#else
12648 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12649#endif
12650}
12651
12652/* vec_vupkhsw */
12653
12654#ifdef __POWER8_VECTOR__
12655static __inline__ vector long long __ATTRS_o_ai vec_vupkhsw(vector int __a) {
12656#ifdef __LITTLE_ENDIAN__
12657 return __builtin_altivec_vupklsw(__a);
12658#else
12659 return __builtin_altivec_vupkhsw(__a);
12660#endif
12661}
12662
12663static __inline__ vector bool long long __ATTRS_o_ai
12664vec_vupkhsw(vector bool int __a) {
12665#ifdef __LITTLE_ENDIAN__
12666 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12667#else
12668 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12669#endif
12670}
12671#endif
12672
12673/* vec_unpackl */
12674
12675static __inline__ vector short __ATTRS_o_ai
12676vec_unpackl(vector signed char __a) {
12677#ifdef __LITTLE_ENDIAN__
12678 return __builtin_altivec_vupkhsb((vector char)__a);
12679#else
12680 return __builtin_altivec_vupklsb((vector char)__a);
12681#endif
12682}
12683
12684static __inline__ vector bool short __ATTRS_o_ai
12685vec_unpackl(vector bool char __a) {
12686#ifdef __LITTLE_ENDIAN__
12687 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12688#else
12689 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12690#endif
12691}
12692
12693static __inline__ vector int __ATTRS_o_ai vec_unpackl(vector short __a) {
12694#ifdef __LITTLE_ENDIAN__
12695 return __builtin_altivec_vupkhsh(__a);
12696#else
12697 return __builtin_altivec_vupklsh(__a);
12698#endif
12699}
12700
12701static __inline__ vector bool int __ATTRS_o_ai
12702vec_unpackl(vector bool short __a) {
12703#ifdef __LITTLE_ENDIAN__
12704 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12705#else
12706 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12707#endif
12708}
12709
12710static __inline__ vector unsigned int __ATTRS_o_ai
12711vec_unpackl(vector pixel __a) {
12712#ifdef __LITTLE_ENDIAN__
12713 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12714#else
12715 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12716#endif
12717}
12718
12719#ifdef __POWER8_VECTOR__
12720static __inline__ vector long long __ATTRS_o_ai vec_unpackl(vector int __a) {
12721#ifdef __LITTLE_ENDIAN__
12722 return __builtin_altivec_vupkhsw(__a);
12723#else
12724 return __builtin_altivec_vupklsw(__a);
12725#endif
12726}
12727
12728static __inline__ vector bool long long __ATTRS_o_ai
12729vec_unpackl(vector bool int __a) {
12730#ifdef __LITTLE_ENDIAN__
12731 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12732#else
12733 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12734#endif
12735}
Logan Chien55afb0a2018-10-15 10:42:14 +080012736
12737static __inline__ vector double __ATTRS_o_ai
12738vec_unpackl(vector float __a) {
12739 return (vector double)(__a[2], __a[3]);
12740}
Logan Chien2833ffb2018-10-09 10:03:24 +080012741#endif
12742
12743/* vec_vupklsb */
12744
12745static __inline__ vector short __ATTRS_o_ai
12746vec_vupklsb(vector signed char __a) {
12747#ifdef __LITTLE_ENDIAN__
12748 return __builtin_altivec_vupkhsb((vector char)__a);
12749#else
12750 return __builtin_altivec_vupklsb((vector char)__a);
12751#endif
12752}
12753
12754static __inline__ vector bool short __ATTRS_o_ai
12755vec_vupklsb(vector bool char __a) {
12756#ifdef __LITTLE_ENDIAN__
12757 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12758#else
12759 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12760#endif
12761}
12762
12763/* vec_vupklsh */
12764
12765static __inline__ vector int __ATTRS_o_ai vec_vupklsh(vector short __a) {
12766#ifdef __LITTLE_ENDIAN__
12767 return __builtin_altivec_vupkhsh(__a);
12768#else
12769 return __builtin_altivec_vupklsh(__a);
12770#endif
12771}
12772
12773static __inline__ vector bool int __ATTRS_o_ai
12774vec_vupklsh(vector bool short __a) {
12775#ifdef __LITTLE_ENDIAN__
12776 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12777#else
12778 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12779#endif
12780}
12781
12782static __inline__ vector unsigned int __ATTRS_o_ai
12783vec_vupklsh(vector pixel __a) {
12784#ifdef __LITTLE_ENDIAN__
12785 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12786#else
12787 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12788#endif
12789}
12790
12791/* vec_vupklsw */
12792
12793#ifdef __POWER8_VECTOR__
12794static __inline__ vector long long __ATTRS_o_ai vec_vupklsw(vector int __a) {
12795#ifdef __LITTLE_ENDIAN__
12796 return __builtin_altivec_vupkhsw(__a);
12797#else
12798 return __builtin_altivec_vupklsw(__a);
12799#endif
12800}
12801
12802static __inline__ vector bool long long __ATTRS_o_ai
12803vec_vupklsw(vector bool int __a) {
12804#ifdef __LITTLE_ENDIAN__
12805 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12806#else
12807 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12808#endif
12809}
12810#endif
12811
12812/* vec_vsx_ld */
12813
12814#ifdef __VSX__
12815
12816static __inline__ vector bool int __ATTRS_o_ai
12817vec_vsx_ld(int __a, const vector bool int *__b) {
12818 return (vector bool int)__builtin_vsx_lxvw4x(__a, __b);
12819}
12820
12821static __inline__ vector signed int __ATTRS_o_ai
12822vec_vsx_ld(int __a, const vector signed int *__b) {
12823 return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
12824}
12825
12826static __inline__ vector signed int __ATTRS_o_ai
12827vec_vsx_ld(int __a, const signed int *__b) {
12828 return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
12829}
12830
12831static __inline__ vector unsigned int __ATTRS_o_ai
12832vec_vsx_ld(int __a, const vector unsigned int *__b) {
12833 return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
12834}
12835
12836static __inline__ vector unsigned int __ATTRS_o_ai
12837vec_vsx_ld(int __a, const unsigned int *__b) {
12838 return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
12839}
12840
12841static __inline__ vector float __ATTRS_o_ai
12842vec_vsx_ld(int __a, const vector float *__b) {
12843 return (vector float)__builtin_vsx_lxvw4x(__a, __b);
12844}
12845
12846static __inline__ vector float __ATTRS_o_ai vec_vsx_ld(int __a,
12847 const float *__b) {
12848 return (vector float)__builtin_vsx_lxvw4x(__a, __b);
12849}
12850
12851static __inline__ vector signed long long __ATTRS_o_ai
12852vec_vsx_ld(int __a, const vector signed long long *__b) {
12853 return (vector signed long long)__builtin_vsx_lxvd2x(__a, __b);
12854}
12855
12856static __inline__ vector unsigned long long __ATTRS_o_ai
12857vec_vsx_ld(int __a, const vector unsigned long long *__b) {
12858 return (vector unsigned long long)__builtin_vsx_lxvd2x(__a, __b);
12859}
12860
12861static __inline__ vector double __ATTRS_o_ai
12862vec_vsx_ld(int __a, const vector double *__b) {
12863 return (vector double)__builtin_vsx_lxvd2x(__a, __b);
12864}
12865
12866static __inline__ vector double __ATTRS_o_ai
12867vec_vsx_ld(int __a, const double *__b) {
12868 return (vector double)__builtin_vsx_lxvd2x(__a, __b);
12869}
12870
12871static __inline__ vector bool short __ATTRS_o_ai
12872vec_vsx_ld(int __a, const vector bool short *__b) {
12873 return (vector bool short)__builtin_vsx_lxvw4x(__a, __b);
12874}
12875
12876static __inline__ vector signed short __ATTRS_o_ai
12877vec_vsx_ld(int __a, const vector signed short *__b) {
12878 return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
12879}
12880
12881static __inline__ vector signed short __ATTRS_o_ai
12882vec_vsx_ld(int __a, const signed short *__b) {
12883 return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
12884}
12885
12886static __inline__ vector unsigned short __ATTRS_o_ai
12887vec_vsx_ld(int __a, const vector unsigned short *__b) {
12888 return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
12889}
12890
12891static __inline__ vector unsigned short __ATTRS_o_ai
12892vec_vsx_ld(int __a, const unsigned short *__b) {
12893 return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
12894}
12895
12896static __inline__ vector bool char __ATTRS_o_ai
12897vec_vsx_ld(int __a, const vector bool char *__b) {
12898 return (vector bool char)__builtin_vsx_lxvw4x(__a, __b);
12899}
12900
12901static __inline__ vector signed char __ATTRS_o_ai
12902vec_vsx_ld(int __a, const vector signed char *__b) {
12903 return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
12904}
12905
12906static __inline__ vector signed char __ATTRS_o_ai
12907vec_vsx_ld(int __a, const signed char *__b) {
12908 return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
12909}
12910
12911static __inline__ vector unsigned char __ATTRS_o_ai
12912vec_vsx_ld(int __a, const vector unsigned char *__b) {
12913 return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
12914}
12915
12916static __inline__ vector unsigned char __ATTRS_o_ai
12917vec_vsx_ld(int __a, const unsigned char *__b) {
12918 return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
12919}
12920
12921#endif
12922
12923/* vec_vsx_st */
12924
12925#ifdef __VSX__
12926
12927static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
12928 vector bool int *__c) {
12929 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12930}
12931
12932static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
12933 signed int *__c) {
12934 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12935}
12936
12937static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
12938 unsigned int *__c) {
12939 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12940}
12941
12942static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
12943 vector signed int *__c) {
12944 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12945}
12946
12947static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
12948 signed int *__c) {
12949 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12950}
12951
12952static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
12953 vector unsigned int *__c) {
12954 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12955}
12956
12957static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
12958 unsigned int *__c) {
12959 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12960}
12961
12962static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
12963 vector float *__c) {
12964 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12965}
12966
12967static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
12968 float *__c) {
12969 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12970}
12971
12972static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed long long __a,
12973 int __b,
12974 vector signed long long *__c) {
12975 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
12976}
12977
12978static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned long long __a,
12979 int __b,
12980 vector unsigned long long *__c) {
12981 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
12982}
12983
12984static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
12985 vector double *__c) {
12986 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
12987}
12988
12989static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
12990 double *__c) {
12991 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
12992}
12993
12994static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
12995 vector bool short *__c) {
12996 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12997}
12998
12999static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
13000 signed short *__c) {
13001 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13002}
13003
13004static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
13005 unsigned short *__c) {
13006 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13007}
13008static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
13009 vector signed short *__c) {
13010 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13011}
13012
13013static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
13014 signed short *__c) {
13015 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13016}
13017
13018static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a,
13019 int __b,
13020 vector unsigned short *__c) {
13021 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13022}
13023
13024static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a,
13025 int __b, unsigned short *__c) {
13026 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13027}
13028
13029static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
13030 vector bool char *__c) {
13031 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13032}
13033
13034static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
13035 signed char *__c) {
13036 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13037}
13038
13039static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
13040 unsigned char *__c) {
13041 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13042}
13043
13044static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
13045 vector signed char *__c) {
13046 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13047}
13048
13049static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
13050 signed char *__c) {
13051 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13052}
13053
13054static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a,
13055 int __b,
13056 vector unsigned char *__c) {
13057 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13058}
13059
13060static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a,
13061 int __b, unsigned char *__c) {
13062 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13063}
13064
13065#endif
13066
Logan Chien55afb0a2018-10-15 10:42:14 +080013067#ifdef __VSX__
13068#define vec_xxpermdi __builtin_vsx_xxpermdi
13069#define vec_xxsldwi __builtin_vsx_xxsldwi
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013070#define vec_permi(__a, __b, __c) \
13071 _Generic((__a), vector signed long long \
13072 : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \
13073 (((__c)&0x1) + 2)), \
13074 vector unsigned long long \
13075 : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \
13076 (((__c)&0x1) + 2)), \
13077 vector double \
13078 : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \
13079 (((__c)&0x1) + 2)))
Logan Chien55afb0a2018-10-15 10:42:14 +080013080#endif
13081
Logan Chien2833ffb2018-10-09 10:03:24 +080013082/* vec_xor */
13083
13084#define __builtin_altivec_vxor vec_xor
13085
13086static __inline__ vector signed char __ATTRS_o_ai
13087vec_xor(vector signed char __a, vector signed char __b) {
13088 return __a ^ __b;
13089}
13090
13091static __inline__ vector signed char __ATTRS_o_ai
13092vec_xor(vector bool char __a, vector signed char __b) {
13093 return (vector signed char)__a ^ __b;
13094}
13095
13096static __inline__ vector signed char __ATTRS_o_ai
13097vec_xor(vector signed char __a, vector bool char __b) {
13098 return __a ^ (vector signed char)__b;
13099}
13100
13101static __inline__ vector unsigned char __ATTRS_o_ai
13102vec_xor(vector unsigned char __a, vector unsigned char __b) {
13103 return __a ^ __b;
13104}
13105
13106static __inline__ vector unsigned char __ATTRS_o_ai
13107vec_xor(vector bool char __a, vector unsigned char __b) {
13108 return (vector unsigned char)__a ^ __b;
13109}
13110
13111static __inline__ vector unsigned char __ATTRS_o_ai
13112vec_xor(vector unsigned char __a, vector bool char __b) {
13113 return __a ^ (vector unsigned char)__b;
13114}
13115
13116static __inline__ vector bool char __ATTRS_o_ai vec_xor(vector bool char __a,
13117 vector bool char __b) {
13118 return __a ^ __b;
13119}
13120
13121static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a,
13122 vector short __b) {
13123 return __a ^ __b;
13124}
13125
13126static __inline__ vector short __ATTRS_o_ai vec_xor(vector bool short __a,
13127 vector short __b) {
13128 return (vector short)__a ^ __b;
13129}
13130
13131static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a,
13132 vector bool short __b) {
13133 return __a ^ (vector short)__b;
13134}
13135
13136static __inline__ vector unsigned short __ATTRS_o_ai
13137vec_xor(vector unsigned short __a, vector unsigned short __b) {
13138 return __a ^ __b;
13139}
13140
13141static __inline__ vector unsigned short __ATTRS_o_ai
13142vec_xor(vector bool short __a, vector unsigned short __b) {
13143 return (vector unsigned short)__a ^ __b;
13144}
13145
13146static __inline__ vector unsigned short __ATTRS_o_ai
13147vec_xor(vector unsigned short __a, vector bool short __b) {
13148 return __a ^ (vector unsigned short)__b;
13149}
13150
13151static __inline__ vector bool short __ATTRS_o_ai
13152vec_xor(vector bool short __a, vector bool short __b) {
13153 return __a ^ __b;
13154}
13155
13156static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a,
13157 vector int __b) {
13158 return __a ^ __b;
13159}
13160
13161static __inline__ vector int __ATTRS_o_ai vec_xor(vector bool int __a,
13162 vector int __b) {
13163 return (vector int)__a ^ __b;
13164}
13165
13166static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a,
13167 vector bool int __b) {
13168 return __a ^ (vector int)__b;
13169}
13170
13171static __inline__ vector unsigned int __ATTRS_o_ai
13172vec_xor(vector unsigned int __a, vector unsigned int __b) {
13173 return __a ^ __b;
13174}
13175
13176static __inline__ vector unsigned int __ATTRS_o_ai
13177vec_xor(vector bool int __a, vector unsigned int __b) {
13178 return (vector unsigned int)__a ^ __b;
13179}
13180
13181static __inline__ vector unsigned int __ATTRS_o_ai
13182vec_xor(vector unsigned int __a, vector bool int __b) {
13183 return __a ^ (vector unsigned int)__b;
13184}
13185
13186static __inline__ vector bool int __ATTRS_o_ai vec_xor(vector bool int __a,
13187 vector bool int __b) {
13188 return __a ^ __b;
13189}
13190
13191static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a,
13192 vector float __b) {
13193 vector unsigned int __res =
13194 (vector unsigned int)__a ^ (vector unsigned int)__b;
13195 return (vector float)__res;
13196}
13197
13198static __inline__ vector float __ATTRS_o_ai vec_xor(vector bool int __a,
13199 vector float __b) {
13200 vector unsigned int __res =
13201 (vector unsigned int)__a ^ (vector unsigned int)__b;
13202 return (vector float)__res;
13203}
13204
13205static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a,
13206 vector bool int __b) {
13207 vector unsigned int __res =
13208 (vector unsigned int)__a ^ (vector unsigned int)__b;
13209 return (vector float)__res;
13210}
13211
13212#ifdef __VSX__
13213static __inline__ vector signed long long __ATTRS_o_ai
13214vec_xor(vector signed long long __a, vector signed long long __b) {
13215 return __a ^ __b;
13216}
13217
13218static __inline__ vector signed long long __ATTRS_o_ai
13219vec_xor(vector bool long long __a, vector signed long long __b) {
13220 return (vector signed long long)__a ^ __b;
13221}
13222
13223static __inline__ vector signed long long __ATTRS_o_ai
13224vec_xor(vector signed long long __a, vector bool long long __b) {
13225 return __a ^ (vector signed long long)__b;
13226}
13227
13228static __inline__ vector unsigned long long __ATTRS_o_ai
13229vec_xor(vector unsigned long long __a, vector unsigned long long __b) {
13230 return __a ^ __b;
13231}
13232
13233static __inline__ vector unsigned long long __ATTRS_o_ai
13234vec_xor(vector bool long long __a, vector unsigned long long __b) {
13235 return (vector unsigned long long)__a ^ __b;
13236}
13237
13238static __inline__ vector unsigned long long __ATTRS_o_ai
13239vec_xor(vector unsigned long long __a, vector bool long long __b) {
13240 return __a ^ (vector unsigned long long)__b;
13241}
13242
13243static __inline__ vector bool long long __ATTRS_o_ai
13244vec_xor(vector bool long long __a, vector bool long long __b) {
13245 return __a ^ __b;
13246}
13247
13248static __inline__ vector double __ATTRS_o_ai vec_xor(vector double __a,
13249 vector double __b) {
13250 return (vector double)((vector unsigned long long)__a ^
13251 (vector unsigned long long)__b);
13252}
13253
13254static __inline__ vector double __ATTRS_o_ai
13255vec_xor(vector double __a, vector bool long long __b) {
13256 return (vector double)((vector unsigned long long)__a ^
13257 (vector unsigned long long)__b);
13258}
13259
13260static __inline__ vector double __ATTRS_o_ai vec_xor(vector bool long long __a,
13261 vector double __b) {
13262 return (vector double)((vector unsigned long long)__a ^
13263 (vector unsigned long long)__b);
13264}
13265#endif
13266
13267/* vec_vxor */
13268
13269static __inline__ vector signed char __ATTRS_o_ai
13270vec_vxor(vector signed char __a, vector signed char __b) {
13271 return __a ^ __b;
13272}
13273
13274static __inline__ vector signed char __ATTRS_o_ai
13275vec_vxor(vector bool char __a, vector signed char __b) {
13276 return (vector signed char)__a ^ __b;
13277}
13278
13279static __inline__ vector signed char __ATTRS_o_ai
13280vec_vxor(vector signed char __a, vector bool char __b) {
13281 return __a ^ (vector signed char)__b;
13282}
13283
13284static __inline__ vector unsigned char __ATTRS_o_ai
13285vec_vxor(vector unsigned char __a, vector unsigned char __b) {
13286 return __a ^ __b;
13287}
13288
13289static __inline__ vector unsigned char __ATTRS_o_ai
13290vec_vxor(vector bool char __a, vector unsigned char __b) {
13291 return (vector unsigned char)__a ^ __b;
13292}
13293
13294static __inline__ vector unsigned char __ATTRS_o_ai
13295vec_vxor(vector unsigned char __a, vector bool char __b) {
13296 return __a ^ (vector unsigned char)__b;
13297}
13298
13299static __inline__ vector bool char __ATTRS_o_ai vec_vxor(vector bool char __a,
13300 vector bool char __b) {
13301 return __a ^ __b;
13302}
13303
13304static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a,
13305 vector short __b) {
13306 return __a ^ __b;
13307}
13308
13309static __inline__ vector short __ATTRS_o_ai vec_vxor(vector bool short __a,
13310 vector short __b) {
13311 return (vector short)__a ^ __b;
13312}
13313
13314static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a,
13315 vector bool short __b) {
13316 return __a ^ (vector short)__b;
13317}
13318
13319static __inline__ vector unsigned short __ATTRS_o_ai
13320vec_vxor(vector unsigned short __a, vector unsigned short __b) {
13321 return __a ^ __b;
13322}
13323
13324static __inline__ vector unsigned short __ATTRS_o_ai
13325vec_vxor(vector bool short __a, vector unsigned short __b) {
13326 return (vector unsigned short)__a ^ __b;
13327}
13328
13329static __inline__ vector unsigned short __ATTRS_o_ai
13330vec_vxor(vector unsigned short __a, vector bool short __b) {
13331 return __a ^ (vector unsigned short)__b;
13332}
13333
13334static __inline__ vector bool short __ATTRS_o_ai
13335vec_vxor(vector bool short __a, vector bool short __b) {
13336 return __a ^ __b;
13337}
13338
13339static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a,
13340 vector int __b) {
13341 return __a ^ __b;
13342}
13343
13344static __inline__ vector int __ATTRS_o_ai vec_vxor(vector bool int __a,
13345 vector int __b) {
13346 return (vector int)__a ^ __b;
13347}
13348
13349static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a,
13350 vector bool int __b) {
13351 return __a ^ (vector int)__b;
13352}
13353
13354static __inline__ vector unsigned int __ATTRS_o_ai
13355vec_vxor(vector unsigned int __a, vector unsigned int __b) {
13356 return __a ^ __b;
13357}
13358
13359static __inline__ vector unsigned int __ATTRS_o_ai
13360vec_vxor(vector bool int __a, vector unsigned int __b) {
13361 return (vector unsigned int)__a ^ __b;
13362}
13363
13364static __inline__ vector unsigned int __ATTRS_o_ai
13365vec_vxor(vector unsigned int __a, vector bool int __b) {
13366 return __a ^ (vector unsigned int)__b;
13367}
13368
13369static __inline__ vector bool int __ATTRS_o_ai vec_vxor(vector bool int __a,
13370 vector bool int __b) {
13371 return __a ^ __b;
13372}
13373
13374static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a,
13375 vector float __b) {
13376 vector unsigned int __res =
13377 (vector unsigned int)__a ^ (vector unsigned int)__b;
13378 return (vector float)__res;
13379}
13380
13381static __inline__ vector float __ATTRS_o_ai vec_vxor(vector bool int __a,
13382 vector float __b) {
13383 vector unsigned int __res =
13384 (vector unsigned int)__a ^ (vector unsigned int)__b;
13385 return (vector float)__res;
13386}
13387
13388static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a,
13389 vector bool int __b) {
13390 vector unsigned int __res =
13391 (vector unsigned int)__a ^ (vector unsigned int)__b;
13392 return (vector float)__res;
13393}
13394
13395#ifdef __VSX__
13396static __inline__ vector signed long long __ATTRS_o_ai
13397vec_vxor(vector signed long long __a, vector signed long long __b) {
13398 return __a ^ __b;
13399}
13400
13401static __inline__ vector signed long long __ATTRS_o_ai
13402vec_vxor(vector bool long long __a, vector signed long long __b) {
13403 return (vector signed long long)__a ^ __b;
13404}
13405
13406static __inline__ vector signed long long __ATTRS_o_ai
13407vec_vxor(vector signed long long __a, vector bool long long __b) {
13408 return __a ^ (vector signed long long)__b;
13409}
13410
13411static __inline__ vector unsigned long long __ATTRS_o_ai
13412vec_vxor(vector unsigned long long __a, vector unsigned long long __b) {
13413 return __a ^ __b;
13414}
13415
13416static __inline__ vector unsigned long long __ATTRS_o_ai
13417vec_vxor(vector bool long long __a, vector unsigned long long __b) {
13418 return (vector unsigned long long)__a ^ __b;
13419}
13420
13421static __inline__ vector unsigned long long __ATTRS_o_ai
13422vec_vxor(vector unsigned long long __a, vector bool long long __b) {
13423 return __a ^ (vector unsigned long long)__b;
13424}
13425
13426static __inline__ vector bool long long __ATTRS_o_ai
13427vec_vxor(vector bool long long __a, vector bool long long __b) {
13428 return __a ^ __b;
13429}
13430#endif
13431
13432/* ------------------------ extensions for CBEA ----------------------------- */
13433
13434/* vec_extract */
13435
13436static __inline__ signed char __ATTRS_o_ai vec_extract(vector signed char __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013437 unsigned int __b) {
13438 return __a[__b & 0xf];
Logan Chien2833ffb2018-10-09 10:03:24 +080013439}
13440
13441static __inline__ unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013442vec_extract(vector unsigned char __a, unsigned int __b) {
13443 return __a[__b & 0xf];
Logan Chien2833ffb2018-10-09 10:03:24 +080013444}
13445
13446static __inline__ unsigned char __ATTRS_o_ai vec_extract(vector bool char __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013447 unsigned int __b) {
13448 return __a[__b & 0xf];
Logan Chien2833ffb2018-10-09 10:03:24 +080013449}
13450
13451static __inline__ signed short __ATTRS_o_ai vec_extract(vector signed short __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013452 unsigned int __b) {
13453 return __a[__b & 0x7];
Logan Chien2833ffb2018-10-09 10:03:24 +080013454}
13455
13456static __inline__ unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013457vec_extract(vector unsigned short __a, unsigned int __b) {
13458 return __a[__b & 0x7];
Logan Chien2833ffb2018-10-09 10:03:24 +080013459}
13460
13461static __inline__ unsigned short __ATTRS_o_ai vec_extract(vector bool short __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013462 unsigned int __b) {
13463 return __a[__b & 0x7];
Logan Chien2833ffb2018-10-09 10:03:24 +080013464}
13465
13466static __inline__ signed int __ATTRS_o_ai vec_extract(vector signed int __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013467 unsigned int __b) {
13468 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013469}
13470
13471static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector unsigned int __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013472 unsigned int __b) {
13473 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013474}
13475
13476static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector bool int __a,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013477 unsigned int __b) {
13478 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013479}
13480
13481#ifdef __VSX__
13482static __inline__ signed long long __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013483vec_extract(vector signed long long __a, unsigned int __b) {
13484 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013485}
13486
13487static __inline__ unsigned long long __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013488vec_extract(vector unsigned long long __a, unsigned int __b) {
13489 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013490}
13491
13492static __inline__ unsigned long long __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013493vec_extract(vector bool long long __a, unsigned int __b) {
13494 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013495}
13496
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013497static __inline__ double __ATTRS_o_ai vec_extract(vector double __a,
13498 unsigned int __b) {
13499 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013500}
13501#endif
13502
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013503static __inline__ float __ATTRS_o_ai vec_extract(vector float __a,
13504 unsigned int __b) {
13505 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013506}
13507
Logan Chien55afb0a2018-10-15 10:42:14 +080013508#ifdef __POWER9_VECTOR__
13509
13510#define vec_insert4b __builtin_vsx_insertword
13511#define vec_extract4b __builtin_vsx_extractuword
13512
13513/* vec_extract_exp */
13514
13515static __inline__ vector unsigned int __ATTRS_o_ai
13516vec_extract_exp(vector float __a) {
13517 return __builtin_vsx_xvxexpsp(__a);
13518}
13519
13520static __inline__ vector unsigned long long __ATTRS_o_ai
13521vec_extract_exp(vector double __a) {
13522 return __builtin_vsx_xvxexpdp(__a);
13523}
13524
13525/* vec_extract_sig */
13526
13527static __inline__ vector unsigned int __ATTRS_o_ai
13528vec_extract_sig(vector float __a) {
13529 return __builtin_vsx_xvxsigsp(__a);
13530}
13531
13532static __inline__ vector unsigned long long __ATTRS_o_ai
13533vec_extract_sig (vector double __a) {
13534 return __builtin_vsx_xvxsigdp(__a);
13535}
13536
13537static __inline__ vector float __ATTRS_o_ai
13538vec_extract_fp32_from_shorth(vector unsigned short __a) {
13539 vector unsigned short __b =
13540#ifdef __LITTLE_ENDIAN__
13541 __builtin_shufflevector(__a, __a, 0, -1, 1, -1, 2, -1, 3, -1);
13542#else
13543 __builtin_shufflevector(__a, __a, -1, 0, -1, 1, -1, 2, -1, 3);
13544#endif
13545 return __builtin_vsx_xvcvhpsp(__b);
13546}
13547
13548static __inline__ vector float __ATTRS_o_ai
13549vec_extract_fp32_from_shortl(vector unsigned short __a) {
13550 vector unsigned short __b =
13551#ifdef __LITTLE_ENDIAN__
13552 __builtin_shufflevector(__a, __a, 4, -1, 5, -1, 6, -1, 7, -1);
13553#else
13554 __builtin_shufflevector(__a, __a, -1, 4, -1, 5, -1, 6, -1, 7);
13555#endif
13556 return __builtin_vsx_xvcvhpsp(__b);
13557}
13558#endif /* __POWER9_VECTOR__ */
13559
Logan Chien2833ffb2018-10-09 10:03:24 +080013560/* vec_insert */
13561
13562static __inline__ vector signed char __ATTRS_o_ai
13563vec_insert(signed char __a, vector signed char __b, int __c) {
13564 __b[__c] = __a;
13565 return __b;
13566}
13567
13568static __inline__ vector unsigned char __ATTRS_o_ai
13569vec_insert(unsigned char __a, vector unsigned char __b, int __c) {
13570 __b[__c] = __a;
13571 return __b;
13572}
13573
13574static __inline__ vector bool char __ATTRS_o_ai vec_insert(unsigned char __a,
13575 vector bool char __b,
13576 int __c) {
13577 __b[__c] = __a;
13578 return __b;
13579}
13580
13581static __inline__ vector signed short __ATTRS_o_ai
13582vec_insert(signed short __a, vector signed short __b, int __c) {
13583 __b[__c] = __a;
13584 return __b;
13585}
13586
13587static __inline__ vector unsigned short __ATTRS_o_ai
13588vec_insert(unsigned short __a, vector unsigned short __b, int __c) {
13589 __b[__c] = __a;
13590 return __b;
13591}
13592
13593static __inline__ vector bool short __ATTRS_o_ai
13594vec_insert(unsigned short __a, vector bool short __b, int __c) {
13595 __b[__c] = __a;
13596 return __b;
13597}
13598
13599static __inline__ vector signed int __ATTRS_o_ai
13600vec_insert(signed int __a, vector signed int __b, int __c) {
13601 __b[__c] = __a;
13602 return __b;
13603}
13604
13605static __inline__ vector unsigned int __ATTRS_o_ai
13606vec_insert(unsigned int __a, vector unsigned int __b, int __c) {
13607 __b[__c] = __a;
13608 return __b;
13609}
13610
13611static __inline__ vector bool int __ATTRS_o_ai vec_insert(unsigned int __a,
13612 vector bool int __b,
13613 int __c) {
13614 __b[__c] = __a;
13615 return __b;
13616}
13617
13618#ifdef __VSX__
13619static __inline__ vector signed long long __ATTRS_o_ai
13620vec_insert(signed long long __a, vector signed long long __b, int __c) {
13621 __b[__c] = __a;
13622 return __b;
13623}
13624
13625static __inline__ vector unsigned long long __ATTRS_o_ai
13626vec_insert(unsigned long long __a, vector unsigned long long __b, int __c) {
13627 __b[__c] = __a;
13628 return __b;
13629}
13630
13631static __inline__ vector bool long long __ATTRS_o_ai
13632vec_insert(unsigned long long __a, vector bool long long __b, int __c) {
13633 __b[__c] = __a;
13634 return __b;
13635}
13636static __inline__ vector double __ATTRS_o_ai vec_insert(double __a,
13637 vector double __b,
13638 int __c) {
13639 __b[__c] = __a;
13640 return __b;
13641}
13642#endif
13643
13644static __inline__ vector float __ATTRS_o_ai vec_insert(float __a,
13645 vector float __b,
13646 int __c) {
13647 __b[__c] = __a;
13648 return __b;
13649}
13650
13651/* vec_lvlx */
13652
13653static __inline__ vector signed char __ATTRS_o_ai
13654vec_lvlx(int __a, const signed char *__b) {
13655 return vec_perm(vec_ld(__a, __b), (vector signed char)(0),
13656 vec_lvsl(__a, __b));
13657}
13658
13659static __inline__ vector signed char __ATTRS_o_ai
13660vec_lvlx(int __a, const vector signed char *__b) {
13661 return vec_perm(vec_ld(__a, __b), (vector signed char)(0),
13662 vec_lvsl(__a, (unsigned char *)__b));
13663}
13664
13665static __inline__ vector unsigned char __ATTRS_o_ai
13666vec_lvlx(int __a, const unsigned char *__b) {
13667 return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0),
13668 vec_lvsl(__a, __b));
13669}
13670
13671static __inline__ vector unsigned char __ATTRS_o_ai
13672vec_lvlx(int __a, const vector unsigned char *__b) {
13673 return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0),
13674 vec_lvsl(__a, (unsigned char *)__b));
13675}
13676
13677static __inline__ vector bool char __ATTRS_o_ai
13678vec_lvlx(int __a, const vector bool char *__b) {
13679 return vec_perm(vec_ld(__a, __b), (vector bool char)(0),
13680 vec_lvsl(__a, (unsigned char *)__b));
13681}
13682
13683static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a,
13684 const short *__b) {
13685 return vec_perm(vec_ld(__a, __b), (vector short)(0), vec_lvsl(__a, __b));
13686}
13687
13688static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a,
13689 const vector short *__b) {
13690 return vec_perm(vec_ld(__a, __b), (vector short)(0),
13691 vec_lvsl(__a, (unsigned char *)__b));
13692}
13693
13694static __inline__ vector unsigned short __ATTRS_o_ai
13695vec_lvlx(int __a, const unsigned short *__b) {
13696 return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0),
13697 vec_lvsl(__a, __b));
13698}
13699
13700static __inline__ vector unsigned short __ATTRS_o_ai
13701vec_lvlx(int __a, const vector unsigned short *__b) {
13702 return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0),
13703 vec_lvsl(__a, (unsigned char *)__b));
13704}
13705
13706static __inline__ vector bool short __ATTRS_o_ai
13707vec_lvlx(int __a, const vector bool short *__b) {
13708 return vec_perm(vec_ld(__a, __b), (vector bool short)(0),
13709 vec_lvsl(__a, (unsigned char *)__b));
13710}
13711
13712static __inline__ vector pixel __ATTRS_o_ai vec_lvlx(int __a,
13713 const vector pixel *__b) {
13714 return vec_perm(vec_ld(__a, __b), (vector pixel)(0),
13715 vec_lvsl(__a, (unsigned char *)__b));
13716}
13717
13718static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a, const int *__b) {
13719 return vec_perm(vec_ld(__a, __b), (vector int)(0), vec_lvsl(__a, __b));
13720}
13721
13722static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a,
13723 const vector int *__b) {
13724 return vec_perm(vec_ld(__a, __b), (vector int)(0),
13725 vec_lvsl(__a, (unsigned char *)__b));
13726}
13727
13728static __inline__ vector unsigned int __ATTRS_o_ai
13729vec_lvlx(int __a, const unsigned int *__b) {
13730 return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0),
13731 vec_lvsl(__a, __b));
13732}
13733
13734static __inline__ vector unsigned int __ATTRS_o_ai
13735vec_lvlx(int __a, const vector unsigned int *__b) {
13736 return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0),
13737 vec_lvsl(__a, (unsigned char *)__b));
13738}
13739
13740static __inline__ vector bool int __ATTRS_o_ai
13741vec_lvlx(int __a, const vector bool int *__b) {
13742 return vec_perm(vec_ld(__a, __b), (vector bool int)(0),
13743 vec_lvsl(__a, (unsigned char *)__b));
13744}
13745
13746static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a,
13747 const float *__b) {
13748 return vec_perm(vec_ld(__a, __b), (vector float)(0), vec_lvsl(__a, __b));
13749}
13750
13751static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a,
13752 const vector float *__b) {
13753 return vec_perm(vec_ld(__a, __b), (vector float)(0),
13754 vec_lvsl(__a, (unsigned char *)__b));
13755}
13756
13757/* vec_lvlxl */
13758
13759static __inline__ vector signed char __ATTRS_o_ai
13760vec_lvlxl(int __a, const signed char *__b) {
13761 return vec_perm(vec_ldl(__a, __b), (vector signed char)(0),
13762 vec_lvsl(__a, __b));
13763}
13764
13765static __inline__ vector signed char __ATTRS_o_ai
13766vec_lvlxl(int __a, const vector signed char *__b) {
13767 return vec_perm(vec_ldl(__a, __b), (vector signed char)(0),
13768 vec_lvsl(__a, (unsigned char *)__b));
13769}
13770
13771static __inline__ vector unsigned char __ATTRS_o_ai
13772vec_lvlxl(int __a, const unsigned char *__b) {
13773 return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0),
13774 vec_lvsl(__a, __b));
13775}
13776
13777static __inline__ vector unsigned char __ATTRS_o_ai
13778vec_lvlxl(int __a, const vector unsigned char *__b) {
13779 return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0),
13780 vec_lvsl(__a, (unsigned char *)__b));
13781}
13782
13783static __inline__ vector bool char __ATTRS_o_ai
13784vec_lvlxl(int __a, const vector bool char *__b) {
13785 return vec_perm(vec_ldl(__a, __b), (vector bool char)(0),
13786 vec_lvsl(__a, (unsigned char *)__b));
13787}
13788
13789static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a,
13790 const short *__b) {
13791 return vec_perm(vec_ldl(__a, __b), (vector short)(0), vec_lvsl(__a, __b));
13792}
13793
13794static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a,
13795 const vector short *__b) {
13796 return vec_perm(vec_ldl(__a, __b), (vector short)(0),
13797 vec_lvsl(__a, (unsigned char *)__b));
13798}
13799
13800static __inline__ vector unsigned short __ATTRS_o_ai
13801vec_lvlxl(int __a, const unsigned short *__b) {
13802 return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0),
13803 vec_lvsl(__a, __b));
13804}
13805
13806static __inline__ vector unsigned short __ATTRS_o_ai
13807vec_lvlxl(int __a, const vector unsigned short *__b) {
13808 return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0),
13809 vec_lvsl(__a, (unsigned char *)__b));
13810}
13811
13812static __inline__ vector bool short __ATTRS_o_ai
13813vec_lvlxl(int __a, const vector bool short *__b) {
13814 return vec_perm(vec_ldl(__a, __b), (vector bool short)(0),
13815 vec_lvsl(__a, (unsigned char *)__b));
13816}
13817
13818static __inline__ vector pixel __ATTRS_o_ai vec_lvlxl(int __a,
13819 const vector pixel *__b) {
13820 return vec_perm(vec_ldl(__a, __b), (vector pixel)(0),
13821 vec_lvsl(__a, (unsigned char *)__b));
13822}
13823
13824static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a, const int *__b) {
13825 return vec_perm(vec_ldl(__a, __b), (vector int)(0), vec_lvsl(__a, __b));
13826}
13827
13828static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a,
13829 const vector int *__b) {
13830 return vec_perm(vec_ldl(__a, __b), (vector int)(0),
13831 vec_lvsl(__a, (unsigned char *)__b));
13832}
13833
13834static __inline__ vector unsigned int __ATTRS_o_ai
13835vec_lvlxl(int __a, const unsigned int *__b) {
13836 return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0),
13837 vec_lvsl(__a, __b));
13838}
13839
13840static __inline__ vector unsigned int __ATTRS_o_ai
13841vec_lvlxl(int __a, const vector unsigned int *__b) {
13842 return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0),
13843 vec_lvsl(__a, (unsigned char *)__b));
13844}
13845
13846static __inline__ vector bool int __ATTRS_o_ai
13847vec_lvlxl(int __a, const vector bool int *__b) {
13848 return vec_perm(vec_ldl(__a, __b), (vector bool int)(0),
13849 vec_lvsl(__a, (unsigned char *)__b));
13850}
13851
13852static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a,
13853 const float *__b) {
13854 return vec_perm(vec_ldl(__a, __b), (vector float)(0), vec_lvsl(__a, __b));
13855}
13856
13857static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a,
13858 vector float *__b) {
13859 return vec_perm(vec_ldl(__a, __b), (vector float)(0),
13860 vec_lvsl(__a, (unsigned char *)__b));
13861}
13862
13863/* vec_lvrx */
13864
13865static __inline__ vector signed char __ATTRS_o_ai
13866vec_lvrx(int __a, const signed char *__b) {
13867 return vec_perm((vector signed char)(0), vec_ld(__a, __b),
13868 vec_lvsl(__a, __b));
13869}
13870
13871static __inline__ vector signed char __ATTRS_o_ai
13872vec_lvrx(int __a, const vector signed char *__b) {
13873 return vec_perm((vector signed char)(0), vec_ld(__a, __b),
13874 vec_lvsl(__a, (unsigned char *)__b));
13875}
13876
13877static __inline__ vector unsigned char __ATTRS_o_ai
13878vec_lvrx(int __a, const unsigned char *__b) {
13879 return vec_perm((vector unsigned char)(0), vec_ld(__a, __b),
13880 vec_lvsl(__a, __b));
13881}
13882
13883static __inline__ vector unsigned char __ATTRS_o_ai
13884vec_lvrx(int __a, const vector unsigned char *__b) {
13885 return vec_perm((vector unsigned char)(0), vec_ld(__a, __b),
13886 vec_lvsl(__a, (unsigned char *)__b));
13887}
13888
13889static __inline__ vector bool char __ATTRS_o_ai
13890vec_lvrx(int __a, const vector bool char *__b) {
13891 return vec_perm((vector bool char)(0), vec_ld(__a, __b),
13892 vec_lvsl(__a, (unsigned char *)__b));
13893}
13894
13895static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a,
13896 const short *__b) {
13897 return vec_perm((vector short)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
13898}
13899
13900static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a,
13901 const vector short *__b) {
13902 return vec_perm((vector short)(0), vec_ld(__a, __b),
13903 vec_lvsl(__a, (unsigned char *)__b));
13904}
13905
13906static __inline__ vector unsigned short __ATTRS_o_ai
13907vec_lvrx(int __a, const unsigned short *__b) {
13908 return vec_perm((vector unsigned short)(0), vec_ld(__a, __b),
13909 vec_lvsl(__a, __b));
13910}
13911
13912static __inline__ vector unsigned short __ATTRS_o_ai
13913vec_lvrx(int __a, const vector unsigned short *__b) {
13914 return vec_perm((vector unsigned short)(0), vec_ld(__a, __b),
13915 vec_lvsl(__a, (unsigned char *)__b));
13916}
13917
13918static __inline__ vector bool short __ATTRS_o_ai
13919vec_lvrx(int __a, const vector bool short *__b) {
13920 return vec_perm((vector bool short)(0), vec_ld(__a, __b),
13921 vec_lvsl(__a, (unsigned char *)__b));
13922}
13923
13924static __inline__ vector pixel __ATTRS_o_ai vec_lvrx(int __a,
13925 const vector pixel *__b) {
13926 return vec_perm((vector pixel)(0), vec_ld(__a, __b),
13927 vec_lvsl(__a, (unsigned char *)__b));
13928}
13929
13930static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a, const int *__b) {
13931 return vec_perm((vector int)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
13932}
13933
13934static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a,
13935 const vector int *__b) {
13936 return vec_perm((vector int)(0), vec_ld(__a, __b),
13937 vec_lvsl(__a, (unsigned char *)__b));
13938}
13939
13940static __inline__ vector unsigned int __ATTRS_o_ai
13941vec_lvrx(int __a, const unsigned int *__b) {
13942 return vec_perm((vector unsigned int)(0), vec_ld(__a, __b),
13943 vec_lvsl(__a, __b));
13944}
13945
13946static __inline__ vector unsigned int __ATTRS_o_ai
13947vec_lvrx(int __a, const vector unsigned int *__b) {
13948 return vec_perm((vector unsigned int)(0), vec_ld(__a, __b),
13949 vec_lvsl(__a, (unsigned char *)__b));
13950}
13951
13952static __inline__ vector bool int __ATTRS_o_ai
13953vec_lvrx(int __a, const vector bool int *__b) {
13954 return vec_perm((vector bool int)(0), vec_ld(__a, __b),
13955 vec_lvsl(__a, (unsigned char *)__b));
13956}
13957
13958static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a,
13959 const float *__b) {
13960 return vec_perm((vector float)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
13961}
13962
13963static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a,
13964 const vector float *__b) {
13965 return vec_perm((vector float)(0), vec_ld(__a, __b),
13966 vec_lvsl(__a, (unsigned char *)__b));
13967}
13968
13969/* vec_lvrxl */
13970
13971static __inline__ vector signed char __ATTRS_o_ai
13972vec_lvrxl(int __a, const signed char *__b) {
13973 return vec_perm((vector signed char)(0), vec_ldl(__a, __b),
13974 vec_lvsl(__a, __b));
13975}
13976
13977static __inline__ vector signed char __ATTRS_o_ai
13978vec_lvrxl(int __a, const vector signed char *__b) {
13979 return vec_perm((vector signed char)(0), vec_ldl(__a, __b),
13980 vec_lvsl(__a, (unsigned char *)__b));
13981}
13982
13983static __inline__ vector unsigned char __ATTRS_o_ai
13984vec_lvrxl(int __a, const unsigned char *__b) {
13985 return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b),
13986 vec_lvsl(__a, __b));
13987}
13988
13989static __inline__ vector unsigned char __ATTRS_o_ai
13990vec_lvrxl(int __a, const vector unsigned char *__b) {
13991 return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b),
13992 vec_lvsl(__a, (unsigned char *)__b));
13993}
13994
13995static __inline__ vector bool char __ATTRS_o_ai
13996vec_lvrxl(int __a, const vector bool char *__b) {
13997 return vec_perm((vector bool char)(0), vec_ldl(__a, __b),
13998 vec_lvsl(__a, (unsigned char *)__b));
13999}
14000
14001static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a,
14002 const short *__b) {
14003 return vec_perm((vector short)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
14004}
14005
14006static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a,
14007 const vector short *__b) {
14008 return vec_perm((vector short)(0), vec_ldl(__a, __b),
14009 vec_lvsl(__a, (unsigned char *)__b));
14010}
14011
14012static __inline__ vector unsigned short __ATTRS_o_ai
14013vec_lvrxl(int __a, const unsigned short *__b) {
14014 return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b),
14015 vec_lvsl(__a, __b));
14016}
14017
14018static __inline__ vector unsigned short __ATTRS_o_ai
14019vec_lvrxl(int __a, const vector unsigned short *__b) {
14020 return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b),
14021 vec_lvsl(__a, (unsigned char *)__b));
14022}
14023
14024static __inline__ vector bool short __ATTRS_o_ai
14025vec_lvrxl(int __a, const vector bool short *__b) {
14026 return vec_perm((vector bool short)(0), vec_ldl(__a, __b),
14027 vec_lvsl(__a, (unsigned char *)__b));
14028}
14029
14030static __inline__ vector pixel __ATTRS_o_ai vec_lvrxl(int __a,
14031 const vector pixel *__b) {
14032 return vec_perm((vector pixel)(0), vec_ldl(__a, __b),
14033 vec_lvsl(__a, (unsigned char *)__b));
14034}
14035
14036static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a, const int *__b) {
14037 return vec_perm((vector int)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
14038}
14039
14040static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a,
14041 const vector int *__b) {
14042 return vec_perm((vector int)(0), vec_ldl(__a, __b),
14043 vec_lvsl(__a, (unsigned char *)__b));
14044}
14045
14046static __inline__ vector unsigned int __ATTRS_o_ai
14047vec_lvrxl(int __a, const unsigned int *__b) {
14048 return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b),
14049 vec_lvsl(__a, __b));
14050}
14051
14052static __inline__ vector unsigned int __ATTRS_o_ai
14053vec_lvrxl(int __a, const vector unsigned int *__b) {
14054 return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b),
14055 vec_lvsl(__a, (unsigned char *)__b));
14056}
14057
14058static __inline__ vector bool int __ATTRS_o_ai
14059vec_lvrxl(int __a, const vector bool int *__b) {
14060 return vec_perm((vector bool int)(0), vec_ldl(__a, __b),
14061 vec_lvsl(__a, (unsigned char *)__b));
14062}
14063
14064static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a,
14065 const float *__b) {
14066 return vec_perm((vector float)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
14067}
14068
14069static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a,
14070 const vector float *__b) {
14071 return vec_perm((vector float)(0), vec_ldl(__a, __b),
14072 vec_lvsl(__a, (unsigned char *)__b));
14073}
14074
14075/* vec_stvlx */
14076
14077static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b,
14078 signed char *__c) {
14079 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14080 __c);
14081}
14082
14083static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b,
14084 vector signed char *__c) {
14085 return vec_st(
14086 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14087 __b, __c);
14088}
14089
14090static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b,
14091 unsigned char *__c) {
14092 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14093 __c);
14094}
14095
14096static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b,
14097 vector unsigned char *__c) {
14098 return vec_st(
14099 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14100 __b, __c);
14101}
14102
14103static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool char __a, int __b,
14104 vector bool char *__c) {
14105 return vec_st(
14106 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14107 __b, __c);
14108}
14109
14110static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b,
14111 short *__c) {
14112 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14113 __c);
14114}
14115
14116static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b,
14117 vector short *__c) {
14118 return vec_st(
14119 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14120 __b, __c);
14121}
14122
14123static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a,
14124 int __b, unsigned short *__c) {
14125 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14126 __c);
14127}
14128
14129static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a,
14130 int __b,
14131 vector unsigned short *__c) {
14132 return vec_st(
14133 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14134 __b, __c);
14135}
14136
14137static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool short __a, int __b,
14138 vector bool short *__c) {
14139 return vec_st(
14140 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14141 __b, __c);
14142}
14143
14144static __inline__ void __ATTRS_o_ai vec_stvlx(vector pixel __a, int __b,
14145 vector pixel *__c) {
14146 return vec_st(
14147 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14148 __b, __c);
14149}
14150
14151static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b,
14152 int *__c) {
14153 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14154 __c);
14155}
14156
14157static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b,
14158 vector int *__c) {
14159 return vec_st(
14160 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14161 __b, __c);
14162}
14163
14164static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b,
14165 unsigned int *__c) {
14166 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14167 __c);
14168}
14169
14170static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b,
14171 vector unsigned int *__c) {
14172 return vec_st(
14173 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14174 __b, __c);
14175}
14176
14177static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool int __a, int __b,
14178 vector bool int *__c) {
14179 return vec_st(
14180 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14181 __b, __c);
14182}
14183
14184static __inline__ void __ATTRS_o_ai vec_stvlx(vector float __a, int __b,
14185 vector float *__c) {
14186 return vec_st(
14187 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14188 __b, __c);
14189}
14190
14191/* vec_stvlxl */
14192
14193static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b,
14194 signed char *__c) {
14195 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14196 __c);
14197}
14198
14199static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b,
14200 vector signed char *__c) {
14201 return vec_stl(
14202 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14203 __b, __c);
14204}
14205
14206static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a,
14207 int __b, unsigned char *__c) {
14208 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14209 __c);
14210}
14211
14212static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a,
14213 int __b,
14214 vector unsigned char *__c) {
14215 return vec_stl(
14216 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14217 __b, __c);
14218}
14219
14220static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool char __a, int __b,
14221 vector bool char *__c) {
14222 return vec_stl(
14223 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14224 __b, __c);
14225}
14226
14227static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b,
14228 short *__c) {
14229 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14230 __c);
14231}
14232
14233static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b,
14234 vector short *__c) {
14235 return vec_stl(
14236 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14237 __b, __c);
14238}
14239
14240static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a,
14241 int __b, unsigned short *__c) {
14242 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14243 __c);
14244}
14245
14246static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a,
14247 int __b,
14248 vector unsigned short *__c) {
14249 return vec_stl(
14250 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14251 __b, __c);
14252}
14253
14254static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool short __a, int __b,
14255 vector bool short *__c) {
14256 return vec_stl(
14257 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14258 __b, __c);
14259}
14260
14261static __inline__ void __ATTRS_o_ai vec_stvlxl(vector pixel __a, int __b,
14262 vector pixel *__c) {
14263 return vec_stl(
14264 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14265 __b, __c);
14266}
14267
14268static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b,
14269 int *__c) {
14270 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14271 __c);
14272}
14273
14274static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b,
14275 vector int *__c) {
14276 return vec_stl(
14277 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14278 __b, __c);
14279}
14280
14281static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b,
14282 unsigned int *__c) {
14283 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14284 __c);
14285}
14286
14287static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b,
14288 vector unsigned int *__c) {
14289 return vec_stl(
14290 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14291 __b, __c);
14292}
14293
14294static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool int __a, int __b,
14295 vector bool int *__c) {
14296 return vec_stl(
14297 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14298 __b, __c);
14299}
14300
14301static __inline__ void __ATTRS_o_ai vec_stvlxl(vector float __a, int __b,
14302 vector float *__c) {
14303 return vec_stl(
14304 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14305 __b, __c);
14306}
14307
14308/* vec_stvrx */
14309
14310static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b,
14311 signed char *__c) {
14312 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14313 __c);
14314}
14315
14316static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b,
14317 vector signed char *__c) {
14318 return vec_st(
14319 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14320 __b, __c);
14321}
14322
14323static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b,
14324 unsigned char *__c) {
14325 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14326 __c);
14327}
14328
14329static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b,
14330 vector unsigned char *__c) {
14331 return vec_st(
14332 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14333 __b, __c);
14334}
14335
14336static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool char __a, int __b,
14337 vector bool char *__c) {
14338 return vec_st(
14339 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14340 __b, __c);
14341}
14342
14343static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b,
14344 short *__c) {
14345 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14346 __c);
14347}
14348
14349static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b,
14350 vector short *__c) {
14351 return vec_st(
14352 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14353 __b, __c);
14354}
14355
14356static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a,
14357 int __b, unsigned short *__c) {
14358 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14359 __c);
14360}
14361
14362static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a,
14363 int __b,
14364 vector unsigned short *__c) {
14365 return vec_st(
14366 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14367 __b, __c);
14368}
14369
14370static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool short __a, int __b,
14371 vector bool short *__c) {
14372 return vec_st(
14373 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14374 __b, __c);
14375}
14376
14377static __inline__ void __ATTRS_o_ai vec_stvrx(vector pixel __a, int __b,
14378 vector pixel *__c) {
14379 return vec_st(
14380 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14381 __b, __c);
14382}
14383
14384static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b,
14385 int *__c) {
14386 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14387 __c);
14388}
14389
14390static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b,
14391 vector int *__c) {
14392 return vec_st(
14393 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14394 __b, __c);
14395}
14396
14397static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b,
14398 unsigned int *__c) {
14399 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14400 __c);
14401}
14402
14403static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b,
14404 vector unsigned int *__c) {
14405 return vec_st(
14406 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14407 __b, __c);
14408}
14409
14410static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool int __a, int __b,
14411 vector bool int *__c) {
14412 return vec_st(
14413 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14414 __b, __c);
14415}
14416
14417static __inline__ void __ATTRS_o_ai vec_stvrx(vector float __a, int __b,
14418 vector float *__c) {
14419 return vec_st(
14420 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14421 __b, __c);
14422}
14423
14424/* vec_stvrxl */
14425
14426static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b,
14427 signed char *__c) {
14428 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14429 __c);
14430}
14431
14432static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b,
14433 vector signed char *__c) {
14434 return vec_stl(
14435 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14436 __b, __c);
14437}
14438
14439static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a,
14440 int __b, unsigned char *__c) {
14441 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14442 __c);
14443}
14444
14445static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a,
14446 int __b,
14447 vector unsigned char *__c) {
14448 return vec_stl(
14449 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14450 __b, __c);
14451}
14452
14453static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool char __a, int __b,
14454 vector bool char *__c) {
14455 return vec_stl(
14456 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14457 __b, __c);
14458}
14459
14460static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b,
14461 short *__c) {
14462 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14463 __c);
14464}
14465
14466static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b,
14467 vector short *__c) {
14468 return vec_stl(
14469 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14470 __b, __c);
14471}
14472
14473static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a,
14474 int __b, unsigned short *__c) {
14475 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14476 __c);
14477}
14478
14479static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a,
14480 int __b,
14481 vector unsigned short *__c) {
14482 return vec_stl(
14483 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14484 __b, __c);
14485}
14486
14487static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool short __a, int __b,
14488 vector bool short *__c) {
14489 return vec_stl(
14490 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14491 __b, __c);
14492}
14493
14494static __inline__ void __ATTRS_o_ai vec_stvrxl(vector pixel __a, int __b,
14495 vector pixel *__c) {
14496 return vec_stl(
14497 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14498 __b, __c);
14499}
14500
14501static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b,
14502 int *__c) {
14503 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14504 __c);
14505}
14506
14507static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b,
14508 vector int *__c) {
14509 return vec_stl(
14510 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14511 __b, __c);
14512}
14513
14514static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b,
14515 unsigned int *__c) {
14516 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14517 __c);
14518}
14519
14520static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b,
14521 vector unsigned int *__c) {
14522 return vec_stl(
14523 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14524 __b, __c);
14525}
14526
14527static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool int __a, int __b,
14528 vector bool int *__c) {
14529 return vec_stl(
14530 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14531 __b, __c);
14532}
14533
14534static __inline__ void __ATTRS_o_ai vec_stvrxl(vector float __a, int __b,
14535 vector float *__c) {
14536 return vec_stl(
14537 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14538 __b, __c);
14539}
14540
14541/* vec_promote */
14542
14543static __inline__ vector signed char __ATTRS_o_ai vec_promote(signed char __a,
14544 int __b) {
14545 vector signed char __res = (vector signed char)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014546 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014547 return __res;
14548}
14549
14550static __inline__ vector unsigned char __ATTRS_o_ai
14551vec_promote(unsigned char __a, int __b) {
14552 vector unsigned char __res = (vector unsigned char)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014553 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014554 return __res;
14555}
14556
14557static __inline__ vector short __ATTRS_o_ai vec_promote(short __a, int __b) {
14558 vector short __res = (vector short)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014559 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014560 return __res;
14561}
14562
14563static __inline__ vector unsigned short __ATTRS_o_ai
14564vec_promote(unsigned short __a, int __b) {
14565 vector unsigned short __res = (vector unsigned short)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014566 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014567 return __res;
14568}
14569
14570static __inline__ vector int __ATTRS_o_ai vec_promote(int __a, int __b) {
14571 vector int __res = (vector int)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014572 __res[__b & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014573 return __res;
14574}
14575
14576static __inline__ vector unsigned int __ATTRS_o_ai vec_promote(unsigned int __a,
14577 int __b) {
14578 vector unsigned int __res = (vector unsigned int)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014579 __res[__b & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014580 return __res;
14581}
14582
14583static __inline__ vector float __ATTRS_o_ai vec_promote(float __a, int __b) {
14584 vector float __res = (vector float)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014585 __res[__b & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014586 return __res;
14587}
14588
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014589#ifdef __VSX__
14590static __inline__ vector double __ATTRS_o_ai vec_promote(double __a, int __b) {
14591 vector double __res = (vector double)(0);
14592 __res[__b & 0x1] = __a;
14593 return __res;
14594}
14595
14596static __inline__ vector signed long long __ATTRS_o_ai
14597vec_promote(signed long long __a, int __b) {
14598 vector signed long long __res = (vector signed long long)(0);
14599 __res[__b & 0x1] = __a;
14600 return __res;
14601}
14602
14603static __inline__ vector unsigned long long __ATTRS_o_ai
14604vec_promote(unsigned long long __a, int __b) {
14605 vector unsigned long long __res = (vector unsigned long long)(0);
14606 __res[__b & 0x1] = __a;
14607 return __res;
14608}
14609#endif
14610
Logan Chien2833ffb2018-10-09 10:03:24 +080014611/* vec_splats */
14612
14613static __inline__ vector signed char __ATTRS_o_ai vec_splats(signed char __a) {
14614 return (vector signed char)(__a);
14615}
14616
14617static __inline__ vector unsigned char __ATTRS_o_ai
14618vec_splats(unsigned char __a) {
14619 return (vector unsigned char)(__a);
14620}
14621
14622static __inline__ vector short __ATTRS_o_ai vec_splats(short __a) {
14623 return (vector short)(__a);
14624}
14625
14626static __inline__ vector unsigned short __ATTRS_o_ai
14627vec_splats(unsigned short __a) {
14628 return (vector unsigned short)(__a);
14629}
14630
14631static __inline__ vector int __ATTRS_o_ai vec_splats(int __a) {
14632 return (vector int)(__a);
14633}
14634
14635static __inline__ vector unsigned int __ATTRS_o_ai
14636vec_splats(unsigned int __a) {
14637 return (vector unsigned int)(__a);
14638}
14639
14640#ifdef __VSX__
14641static __inline__ vector signed long long __ATTRS_o_ai
14642vec_splats(signed long long __a) {
14643 return (vector signed long long)(__a);
14644}
14645
14646static __inline__ vector unsigned long long __ATTRS_o_ai
14647vec_splats(unsigned long long __a) {
14648 return (vector unsigned long long)(__a);
14649}
14650
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014651#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
14652 defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080014653static __inline__ vector signed __int128 __ATTRS_o_ai
14654vec_splats(signed __int128 __a) {
14655 return (vector signed __int128)(__a);
14656}
14657
14658static __inline__ vector unsigned __int128 __ATTRS_o_ai
14659vec_splats(unsigned __int128 __a) {
14660 return (vector unsigned __int128)(__a);
14661}
14662
14663#endif
14664
14665static __inline__ vector double __ATTRS_o_ai vec_splats(double __a) {
14666 return (vector double)(__a);
14667}
14668#endif
14669
14670static __inline__ vector float __ATTRS_o_ai vec_splats(float __a) {
14671 return (vector float)(__a);
14672}
14673
14674/* ----------------------------- predicates --------------------------------- */
14675
14676/* vec_all_eq */
14677
14678static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a,
14679 vector signed char __b) {
14680 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14681 (vector char)__b);
14682}
14683
14684static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a,
14685 vector bool char __b) {
14686 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14687 (vector char)__b);
14688}
14689
14690static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a,
14691 vector unsigned char __b) {
14692 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14693 (vector char)__b);
14694}
14695
14696static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a,
14697 vector bool char __b) {
14698 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14699 (vector char)__b);
14700}
14701
14702static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
14703 vector signed char __b) {
14704 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14705 (vector char)__b);
14706}
14707
14708static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
14709 vector unsigned char __b) {
14710 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14711 (vector char)__b);
14712}
14713
14714static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
14715 vector bool char __b) {
14716 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14717 (vector char)__b);
14718}
14719
14720static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a,
14721 vector short __b) {
14722 return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, __b);
14723}
14724
14725static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a,
14726 vector bool short __b) {
14727 return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, (vector short)__b);
14728}
14729
14730static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a,
14731 vector unsigned short __b) {
14732 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14733 (vector short)__b);
14734}
14735
14736static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a,
14737 vector bool short __b) {
14738 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14739 (vector short)__b);
14740}
14741
14742static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
14743 vector short __b) {
14744 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14745 (vector short)__b);
14746}
14747
14748static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
14749 vector unsigned short __b) {
14750 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14751 (vector short)__b);
14752}
14753
14754static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
14755 vector bool short __b) {
14756 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14757 (vector short)__b);
14758}
14759
14760static __inline__ int __ATTRS_o_ai vec_all_eq(vector pixel __a,
14761 vector pixel __b) {
14762 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14763 (vector short)__b);
14764}
14765
14766static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a, vector int __b) {
14767 return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, __b);
14768}
14769
14770static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a,
14771 vector bool int __b) {
14772 return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, (vector int)__b);
14773}
14774
14775static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a,
14776 vector unsigned int __b) {
14777 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14778 (vector int)__b);
14779}
14780
14781static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a,
14782 vector bool int __b) {
14783 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14784 (vector int)__b);
14785}
14786
14787static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
14788 vector int __b) {
14789 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14790 (vector int)__b);
14791}
14792
14793static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
14794 vector unsigned int __b) {
14795 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14796 (vector int)__b);
14797}
14798
14799static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
14800 vector bool int __b) {
14801 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14802 (vector int)__b);
14803}
14804
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014805#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080014806static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed long long __a,
14807 vector signed long long __b) {
14808 return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, __b);
14809}
14810
14811static __inline__ int __ATTRS_o_ai vec_all_eq(vector long long __a,
14812 vector bool long long __b) {
14813 return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, (vector long long)__b);
14814}
14815
14816static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a,
14817 vector unsigned long long __b) {
14818 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
14819 (vector long long)__b);
14820}
14821
14822static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a,
14823 vector bool long long __b) {
14824 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
14825 (vector long long)__b);
14826}
14827
14828static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
14829 vector long long __b) {
14830 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
14831 (vector long long)__b);
14832}
14833
14834static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
14835 vector unsigned long long __b) {
14836 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
14837 (vector long long)__b);
14838}
14839
14840static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
14841 vector bool long long __b) {
14842 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
14843 (vector long long)__b);
14844}
14845#endif
14846
14847static __inline__ int __ATTRS_o_ai vec_all_eq(vector float __a,
14848 vector float __b) {
14849#ifdef __VSX__
14850 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __b);
14851#else
14852 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __b);
14853#endif
14854}
14855
14856#ifdef __VSX__
14857static __inline__ int __ATTRS_o_ai vec_all_eq(vector double __a,
14858 vector double __b) {
14859 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __b);
14860}
14861#endif
14862
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014863#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080014864static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed __int128 __a,
14865 vector signed __int128 __b) {
14866 return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
14867}
14868
14869static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned __int128 __a,
14870 vector unsigned __int128 __b) {
14871 return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
14872}
14873#endif
14874
Logan Chien2833ffb2018-10-09 10:03:24 +080014875/* vec_all_ge */
14876
14877static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a,
14878 vector signed char __b) {
14879 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, __a);
14880}
14881
14882static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a,
14883 vector bool char __b) {
14884 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b, __a);
14885}
14886
14887static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a,
14888 vector unsigned char __b) {
14889 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, __a);
14890}
14891
14892static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a,
14893 vector bool char __b) {
14894 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b, __a);
14895}
14896
14897static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
14898 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080014899 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080014900}
14901
14902static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
14903 vector unsigned char __b) {
14904 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, (vector unsigned char)__a);
14905}
14906
14907static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
14908 vector bool char __b) {
14909 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
14910 (vector unsigned char)__a);
14911}
14912
14913static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a,
14914 vector short __b) {
14915 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, __a);
14916}
14917
14918static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a,
14919 vector bool short __b) {
14920 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector short)__b, __a);
14921}
14922
14923static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a,
14924 vector unsigned short __b) {
14925 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b, __a);
14926}
14927
14928static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a,
14929 vector bool short __b) {
14930 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
14931 __a);
14932}
14933
14934static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
14935 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080014936 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080014937}
14938
14939static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
14940 vector unsigned short __b) {
14941 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b,
14942 (vector unsigned short)__a);
14943}
14944
14945static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
14946 vector bool short __b) {
14947 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
14948 (vector unsigned short)__a);
14949}
14950
14951static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a, vector int __b) {
14952 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, __a);
14953}
14954
14955static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a,
14956 vector bool int __b) {
14957 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector int)__b, __a);
14958}
14959
14960static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a,
14961 vector unsigned int __b) {
14962 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, __a);
14963}
14964
14965static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a,
14966 vector bool int __b) {
14967 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b, __a);
14968}
14969
14970static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
14971 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080014972 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080014973}
14974
14975static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
14976 vector unsigned int __b) {
14977 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, (vector unsigned int)__a);
14978}
14979
14980static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
14981 vector bool int __b) {
14982 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b,
14983 (vector unsigned int)__a);
14984}
14985
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014986#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080014987static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
14988 vector signed long long __b) {
14989 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, __a);
14990}
14991static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
14992 vector bool long long __b) {
14993 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b,
14994 __a);
14995}
14996
14997static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a,
14998 vector unsigned long long __b) {
14999 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b, __a);
15000}
15001
15002static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a,
15003 vector bool long long __b) {
15004 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
15005 __a);
15006}
15007
15008static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
15009 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015010 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b,
15011 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015012}
15013
15014static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
15015 vector unsigned long long __b) {
15016 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b,
15017 (vector unsigned long long)__a);
15018}
15019
15020static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
15021 vector bool long long __b) {
15022 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
15023 (vector unsigned long long)__a);
15024}
15025#endif
15026
15027static __inline__ int __ATTRS_o_ai vec_all_ge(vector float __a,
15028 vector float __b) {
15029#ifdef __VSX__
15030 return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __a, __b);
15031#else
15032 return __builtin_altivec_vcmpgefp_p(__CR6_LT, __a, __b);
15033#endif
15034}
15035
15036#ifdef __VSX__
15037static __inline__ int __ATTRS_o_ai vec_all_ge(vector double __a,
15038 vector double __b) {
15039 return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __a, __b);
15040}
15041#endif
15042
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015043#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015044static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed __int128 __a,
15045 vector signed __int128 __b) {
15046 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ, __b, __a);
15047}
15048
15049static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned __int128 __a,
15050 vector unsigned __int128 __b) {
15051 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ, __b, __a);
15052}
15053#endif
15054
Logan Chien2833ffb2018-10-09 10:03:24 +080015055/* vec_all_gt */
15056
15057static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a,
15058 vector signed char __b) {
15059 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, __b);
15060}
15061
15062static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a,
15063 vector bool char __b) {
15064 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, (vector signed char)__b);
15065}
15066
15067static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a,
15068 vector unsigned char __b) {
15069 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, __b);
15070}
15071
15072static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a,
15073 vector bool char __b) {
15074 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, (vector unsigned char)__b);
15075}
15076
15077static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
15078 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015079 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015080}
15081
15082static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
15083 vector unsigned char __b) {
15084 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a, __b);
15085}
15086
15087static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
15088 vector bool char __b) {
15089 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
15090 (vector unsigned char)__b);
15091}
15092
15093static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a,
15094 vector short __b) {
15095 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, __b);
15096}
15097
15098static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a,
15099 vector bool short __b) {
15100 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, (vector short)__b);
15101}
15102
15103static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a,
15104 vector unsigned short __b) {
15105 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a, __b);
15106}
15107
15108static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a,
15109 vector bool short __b) {
15110 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a,
15111 (vector unsigned short)__b);
15112}
15113
15114static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
15115 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015116 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015117}
15118
15119static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
15120 vector unsigned short __b) {
15121 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
15122 __b);
15123}
15124
15125static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
15126 vector bool short __b) {
15127 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
15128 (vector unsigned short)__b);
15129}
15130
15131static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a, vector int __b) {
15132 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, __b);
15133}
15134
15135static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a,
15136 vector bool int __b) {
15137 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, (vector int)__b);
15138}
15139
15140static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a,
15141 vector unsigned int __b) {
15142 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, __b);
15143}
15144
15145static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a,
15146 vector bool int __b) {
15147 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, (vector unsigned int)__b);
15148}
15149
15150static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
15151 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015152 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector signed int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015153}
15154
15155static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
15156 vector unsigned int __b) {
15157 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a, __b);
15158}
15159
15160static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
15161 vector bool int __b) {
15162 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a,
15163 (vector unsigned int)__b);
15164}
15165
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015166#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015167static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
15168 vector signed long long __b) {
15169 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a, __b);
15170}
15171static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
15172 vector bool long long __b) {
15173 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a,
15174 (vector signed long long)__b);
15175}
15176
15177static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a,
15178 vector unsigned long long __b) {
15179 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a, __b);
15180}
15181
15182static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a,
15183 vector bool long long __b) {
15184 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a,
15185 (vector unsigned long long)__b);
15186}
15187
15188static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
15189 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015190 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__a,
15191 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015192}
15193
15194static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
15195 vector unsigned long long __b) {
15196 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
15197 __b);
15198}
15199
15200static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
15201 vector bool long long __b) {
15202 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
15203 (vector unsigned long long)__b);
15204}
15205#endif
15206
15207static __inline__ int __ATTRS_o_ai vec_all_gt(vector float __a,
15208 vector float __b) {
15209#ifdef __VSX__
15210 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __a, __b);
15211#else
15212 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __a, __b);
15213#endif
15214}
15215
15216#ifdef __VSX__
15217static __inline__ int __ATTRS_o_ai vec_all_gt(vector double __a,
15218 vector double __b) {
15219 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __a, __b);
15220}
15221#endif
15222
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015223#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015224static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed __int128 __a,
15225 vector signed __int128 __b) {
15226 return __builtin_altivec_vcmpgtsq_p(__CR6_LT, __a, __b);
15227}
15228
15229static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned __int128 __a,
15230 vector unsigned __int128 __b) {
15231 return __builtin_altivec_vcmpgtuq_p(__CR6_LT, __a, __b);
15232}
15233#endif
15234
Logan Chien2833ffb2018-10-09 10:03:24 +080015235/* vec_all_in */
15236
15237static __inline__ int __attribute__((__always_inline__))
15238vec_all_in(vector float __a, vector float __b) {
15239 return __builtin_altivec_vcmpbfp_p(__CR6_EQ, __a, __b);
15240}
15241
15242/* vec_all_le */
15243
15244static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a,
15245 vector signed char __b) {
15246 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, __b);
15247}
15248
15249static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a,
15250 vector bool char __b) {
15251 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, (vector signed char)__b);
15252}
15253
15254static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a,
15255 vector unsigned char __b) {
15256 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, __b);
15257}
15258
15259static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a,
15260 vector bool char __b) {
15261 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, (vector unsigned char)__b);
15262}
15263
15264static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
15265 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015266 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015267}
15268
15269static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
15270 vector unsigned char __b) {
15271 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a, __b);
15272}
15273
15274static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
15275 vector bool char __b) {
15276 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a,
15277 (vector unsigned char)__b);
15278}
15279
15280static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a,
15281 vector short __b) {
15282 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, __b);
15283}
15284
15285static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a,
15286 vector bool short __b) {
15287 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, (vector short)__b);
15288}
15289
15290static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a,
15291 vector unsigned short __b) {
15292 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a, __b);
15293}
15294
15295static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a,
15296 vector bool short __b) {
15297 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a,
15298 (vector unsigned short)__b);
15299}
15300
15301static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
15302 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015303 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector signed short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015304}
15305
15306static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
15307 vector unsigned short __b) {
15308 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
15309 __b);
15310}
15311
15312static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
15313 vector bool short __b) {
15314 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
15315 (vector unsigned short)__b);
15316}
15317
15318static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a, vector int __b) {
15319 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, __b);
15320}
15321
15322static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a,
15323 vector bool int __b) {
15324 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, (vector int)__b);
15325}
15326
15327static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a,
15328 vector unsigned int __b) {
15329 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, __b);
15330}
15331
15332static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a,
15333 vector bool int __b) {
15334 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, (vector unsigned int)__b);
15335}
15336
15337static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
15338 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015339 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector signed int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015340}
15341
15342static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
15343 vector unsigned int __b) {
15344 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a, __b);
15345}
15346
15347static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
15348 vector bool int __b) {
15349 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a,
15350 (vector unsigned int)__b);
15351}
15352
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015353#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015354static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
15355 vector signed long long __b) {
15356 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a, __b);
15357}
15358
15359static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a,
15360 vector unsigned long long __b) {
15361 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a, __b);
15362}
15363
15364static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
15365 vector bool long long __b) {
15366 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a,
15367 (vector signed long long)__b);
15368}
15369
15370static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a,
15371 vector bool long long __b) {
15372 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a,
15373 (vector unsigned long long)__b);
15374}
15375
15376static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
15377 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015378 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__a,
15379 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015380}
15381
15382static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
15383 vector unsigned long long __b) {
15384 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
15385 __b);
15386}
15387
15388static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
15389 vector bool long long __b) {
15390 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
15391 (vector unsigned long long)__b);
15392}
15393#endif
15394
15395static __inline__ int __ATTRS_o_ai vec_all_le(vector float __a,
15396 vector float __b) {
15397#ifdef __VSX__
15398 return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __b, __a);
15399#else
15400 return __builtin_altivec_vcmpgefp_p(__CR6_LT, __b, __a);
15401#endif
15402}
15403
15404#ifdef __VSX__
15405static __inline__ int __ATTRS_o_ai vec_all_le(vector double __a,
15406 vector double __b) {
15407 return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __b, __a);
15408}
15409#endif
15410
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015411#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015412static __inline__ int __ATTRS_o_ai vec_all_le(vector signed __int128 __a,
15413 vector signed __int128 __b) {
15414 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ, __a, __b);
15415}
15416
15417static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned __int128 __a,
15418 vector unsigned __int128 __b) {
15419 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ, __a, __b);
15420}
15421#endif
15422
Logan Chien2833ffb2018-10-09 10:03:24 +080015423/* vec_all_lt */
15424
15425static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a,
15426 vector signed char __b) {
15427 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, __a);
15428}
15429
15430static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a,
15431 vector bool char __b) {
15432 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__b, __a);
15433}
15434
15435static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a,
15436 vector unsigned char __b) {
15437 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, __a);
15438}
15439
15440static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a,
15441 vector bool char __b) {
15442 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b, __a);
15443}
15444
15445static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
15446 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015447 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015448}
15449
15450static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
15451 vector unsigned char __b) {
15452 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, (vector unsigned char)__a);
15453}
15454
15455static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
15456 vector bool char __b) {
15457 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b,
15458 (vector unsigned char)__a);
15459}
15460
15461static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a,
15462 vector short __b) {
15463 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, __a);
15464}
15465
15466static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a,
15467 vector bool short __b) {
15468 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector short)__b, __a);
15469}
15470
15471static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a,
15472 vector unsigned short __b) {
15473 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b, __a);
15474}
15475
15476static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a,
15477 vector bool short __b) {
15478 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
15479 __a);
15480}
15481
15482static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
15483 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015484 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015485}
15486
15487static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
15488 vector unsigned short __b) {
15489 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b,
15490 (vector unsigned short)__a);
15491}
15492
15493static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
15494 vector bool short __b) {
15495 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
15496 (vector unsigned short)__a);
15497}
15498
15499static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a, vector int __b) {
15500 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, __a);
15501}
15502
15503static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a,
15504 vector bool int __b) {
15505 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector int)__b, __a);
15506}
15507
15508static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a,
15509 vector unsigned int __b) {
15510 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, __a);
15511}
15512
15513static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a,
15514 vector bool int __b) {
15515 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b, __a);
15516}
15517
15518static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
15519 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015520 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015521}
15522
15523static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
15524 vector unsigned int __b) {
15525 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, (vector unsigned int)__a);
15526}
15527
15528static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
15529 vector bool int __b) {
15530 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b,
15531 (vector unsigned int)__a);
15532}
15533
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015534#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015535static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
15536 vector signed long long __b) {
15537 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, __a);
15538}
15539
15540static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a,
15541 vector unsigned long long __b) {
15542 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b, __a);
15543}
15544
15545static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
15546 vector bool long long __b) {
15547 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__b,
15548 __a);
15549}
15550
15551static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a,
15552 vector bool long long __b) {
15553 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
15554 __a);
15555}
15556
15557static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
15558 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015559 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b,
15560 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015561}
15562
15563static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
15564 vector unsigned long long __b) {
15565 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b,
15566 (vector unsigned long long)__a);
15567}
15568
15569static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
15570 vector bool long long __b) {
15571 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
15572 (vector unsigned long long)__a);
15573}
15574#endif
15575
15576static __inline__ int __ATTRS_o_ai vec_all_lt(vector float __a,
15577 vector float __b) {
15578#ifdef __VSX__
15579 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __b, __a);
15580#else
15581 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __b, __a);
15582#endif
15583}
15584
15585#ifdef __VSX__
15586static __inline__ int __ATTRS_o_ai vec_all_lt(vector double __a,
15587 vector double __b) {
15588 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __b, __a);
15589}
15590#endif
15591
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015592#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015593static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed __int128 __a,
15594 vector signed __int128 __b) {
15595 return __builtin_altivec_vcmpgtsq_p(__CR6_LT, __b, __a);
15596}
15597
15598static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned __int128 __a,
15599 vector unsigned __int128 __b) {
15600 return __builtin_altivec_vcmpgtuq_p(__CR6_LT, __b, __a);
15601}
15602#endif
15603
Logan Chien2833ffb2018-10-09 10:03:24 +080015604/* vec_all_nan */
15605
15606static __inline__ int __ATTRS_o_ai vec_all_nan(vector float __a) {
15607#ifdef __VSX__
15608 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __a);
15609#else
15610 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __a);
15611#endif
15612}
15613
15614#ifdef __VSX__
15615static __inline__ int __ATTRS_o_ai vec_all_nan(vector double __a) {
15616 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __a);
15617}
15618#endif
15619
15620/* vec_all_ne */
15621
15622static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a,
15623 vector signed char __b) {
15624 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15625 (vector char)__b);
15626}
15627
15628static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a,
15629 vector bool char __b) {
15630 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15631 (vector char)__b);
15632}
15633
15634static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a,
15635 vector unsigned char __b) {
15636 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15637 (vector char)__b);
15638}
15639
15640static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a,
15641 vector bool char __b) {
15642 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15643 (vector char)__b);
15644}
15645
15646static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
15647 vector signed char __b) {
15648 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15649 (vector char)__b);
15650}
15651
15652static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
15653 vector unsigned char __b) {
15654 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15655 (vector char)__b);
15656}
15657
15658static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
15659 vector bool char __b) {
15660 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15661 (vector char)__b);
15662}
15663
15664static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a,
15665 vector short __b) {
15666 return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, __b);
15667}
15668
15669static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a,
15670 vector bool short __b) {
15671 return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, (vector short)__b);
15672}
15673
15674static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a,
15675 vector unsigned short __b) {
15676 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15677 (vector short)__b);
15678}
15679
15680static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a,
15681 vector bool short __b) {
15682 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15683 (vector short)__b);
15684}
15685
15686static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
15687 vector short __b) {
15688 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15689 (vector short)__b);
15690}
15691
15692static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
15693 vector unsigned short __b) {
15694 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15695 (vector short)__b);
15696}
15697
15698static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
15699 vector bool short __b) {
15700 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15701 (vector short)__b);
15702}
15703
15704static __inline__ int __ATTRS_o_ai vec_all_ne(vector pixel __a,
15705 vector pixel __b) {
15706 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15707 (vector short)__b);
15708}
15709
15710static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a, vector int __b) {
15711 return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, __b);
15712}
15713
15714static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a,
15715 vector bool int __b) {
15716 return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, (vector int)__b);
15717}
15718
15719static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a,
15720 vector unsigned int __b) {
15721 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15722 (vector int)__b);
15723}
15724
15725static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a,
15726 vector bool int __b) {
15727 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15728 (vector int)__b);
15729}
15730
15731static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
15732 vector int __b) {
15733 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15734 (vector int)__b);
15735}
15736
15737static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
15738 vector unsigned int __b) {
15739 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15740 (vector int)__b);
15741}
15742
15743static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
15744 vector bool int __b) {
15745 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15746 (vector int)__b);
15747}
15748
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015749#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015750static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
15751 vector signed long long __b) {
15752 return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a, __b);
15753}
15754
15755static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a,
15756 vector unsigned long long __b) {
15757 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector long long)__a,
15758 (vector long long)__b);
15759}
15760
15761static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
15762 vector bool long long __b) {
15763 return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a,
15764 (vector signed long long)__b);
15765}
15766
15767static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a,
15768 vector bool long long __b) {
15769 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15770 (vector signed long long)__b);
15771}
15772
15773static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
15774 vector signed long long __b) {
15775 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15776 (vector signed long long)__b);
15777}
15778
15779static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
15780 vector unsigned long long __b) {
15781 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15782 (vector signed long long)__b);
15783}
15784
15785static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
15786 vector bool long long __b) {
15787 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15788 (vector signed long long)__b);
15789}
15790#endif
15791
15792static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a,
15793 vector float __b) {
15794#ifdef __VSX__
Sasha Smundak746b0222020-02-25 09:19:04 -080015795 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015796#else
15797 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __b);
15798#endif
15799}
15800
15801#ifdef __VSX__
15802static __inline__ int __ATTRS_o_ai vec_all_ne(vector double __a,
15803 vector double __b) {
15804 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __b);
15805}
15806#endif
15807
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015808#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015809static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed __int128 __a,
15810 vector signed __int128 __b) {
15811 return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
15812}
15813
15814static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned __int128 __a,
15815 vector unsigned __int128 __b) {
15816 return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
15817}
15818#endif
15819
Logan Chien2833ffb2018-10-09 10:03:24 +080015820/* vec_all_nge */
15821
15822static __inline__ int __ATTRS_o_ai vec_all_nge(vector float __a,
15823 vector float __b) {
15824#ifdef __VSX__
15825 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __a, __b);
15826#else
15827 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __a, __b);
15828#endif
15829}
15830
15831#ifdef __VSX__
15832static __inline__ int __ATTRS_o_ai vec_all_nge(vector double __a,
15833 vector double __b) {
15834 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __a, __b);
15835}
15836#endif
15837
15838/* vec_all_ngt */
15839
15840static __inline__ int __ATTRS_o_ai vec_all_ngt(vector float __a,
15841 vector float __b) {
15842#ifdef __VSX__
15843 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __a, __b);
15844#else
15845 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __a, __b);
15846#endif
15847}
15848
15849#ifdef __VSX__
15850static __inline__ int __ATTRS_o_ai vec_all_ngt(vector double __a,
15851 vector double __b) {
15852 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __a, __b);
15853}
15854#endif
15855
15856/* vec_all_nle */
15857
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015858static __inline__ int __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080015859vec_all_nle(vector float __a, vector float __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015860#ifdef __VSX__
15861 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __b, __a);
15862#else
Logan Chien2833ffb2018-10-09 10:03:24 +080015863 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015864#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080015865}
15866
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015867#ifdef __VSX__
15868static __inline__ int __ATTRS_o_ai vec_all_nle(vector double __a,
15869 vector double __b) {
15870 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __b, __a);
15871}
15872#endif
15873
Logan Chien2833ffb2018-10-09 10:03:24 +080015874/* vec_all_nlt */
15875
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015876static __inline__ int __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080015877vec_all_nlt(vector float __a, vector float __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015878#ifdef __VSX__
15879 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __b, __a);
15880#else
Logan Chien2833ffb2018-10-09 10:03:24 +080015881 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015882#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080015883}
15884
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015885#ifdef __VSX__
15886static __inline__ int __ATTRS_o_ai vec_all_nlt(vector double __a,
15887 vector double __b) {
15888 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __b, __a);
15889}
15890#endif
15891
Logan Chien2833ffb2018-10-09 10:03:24 +080015892/* vec_all_numeric */
15893
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015894static __inline__ int __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080015895vec_all_numeric(vector float __a) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015896#ifdef __VSX__
15897 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __a);
15898#else
Logan Chien2833ffb2018-10-09 10:03:24 +080015899 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015900#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080015901}
15902
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015903#ifdef __VSX__
15904static __inline__ int __ATTRS_o_ai vec_all_numeric(vector double __a) {
15905 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __a);
15906}
15907#endif
15908
Logan Chien2833ffb2018-10-09 10:03:24 +080015909/* vec_any_eq */
15910
15911static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a,
15912 vector signed char __b) {
15913 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15914 (vector char)__b);
15915}
15916
15917static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a,
15918 vector bool char __b) {
15919 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15920 (vector char)__b);
15921}
15922
15923static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a,
15924 vector unsigned char __b) {
15925 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15926 (vector char)__b);
15927}
15928
15929static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a,
15930 vector bool char __b) {
15931 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15932 (vector char)__b);
15933}
15934
15935static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
15936 vector signed char __b) {
15937 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15938 (vector char)__b);
15939}
15940
15941static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
15942 vector unsigned char __b) {
15943 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15944 (vector char)__b);
15945}
15946
15947static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
15948 vector bool char __b) {
15949 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15950 (vector char)__b);
15951}
15952
15953static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a,
15954 vector short __b) {
15955 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, __b);
15956}
15957
15958static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a,
15959 vector bool short __b) {
15960 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, (vector short)__b);
15961}
15962
15963static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a,
15964 vector unsigned short __b) {
15965 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
15966 (vector short)__b);
15967}
15968
15969static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a,
15970 vector bool short __b) {
15971 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
15972 (vector short)__b);
15973}
15974
15975static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
15976 vector short __b) {
15977 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
15978 (vector short)__b);
15979}
15980
15981static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
15982 vector unsigned short __b) {
15983 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
15984 (vector short)__b);
15985}
15986
15987static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
15988 vector bool short __b) {
15989 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
15990 (vector short)__b);
15991}
15992
15993static __inline__ int __ATTRS_o_ai vec_any_eq(vector pixel __a,
15994 vector pixel __b) {
15995 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
15996 (vector short)__b);
15997}
15998
15999static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a, vector int __b) {
16000 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, __b);
16001}
16002
16003static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a,
16004 vector bool int __b) {
16005 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, (vector int)__b);
16006}
16007
16008static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a,
16009 vector unsigned int __b) {
16010 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16011 (vector int)__b);
16012}
16013
16014static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a,
16015 vector bool int __b) {
16016 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16017 (vector int)__b);
16018}
16019
16020static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
16021 vector int __b) {
16022 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16023 (vector int)__b);
16024}
16025
16026static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
16027 vector unsigned int __b) {
16028 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16029 (vector int)__b);
16030}
16031
16032static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
16033 vector bool int __b) {
16034 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16035 (vector int)__b);
16036}
16037
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016038#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016039static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
16040 vector signed long long __b) {
16041 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a, __b);
16042}
16043
16044static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a,
16045 vector unsigned long long __b) {
16046 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, (vector long long)__a,
16047 (vector long long)__b);
16048}
16049
16050static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
16051 vector bool long long __b) {
16052 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a,
16053 (vector signed long long)__b);
16054}
16055
16056static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a,
16057 vector bool long long __b) {
16058 return __builtin_altivec_vcmpequd_p(
16059 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16060}
16061
16062static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
16063 vector signed long long __b) {
16064 return __builtin_altivec_vcmpequd_p(
16065 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16066}
16067
16068static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
16069 vector unsigned long long __b) {
16070 return __builtin_altivec_vcmpequd_p(
16071 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16072}
16073
16074static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
16075 vector bool long long __b) {
16076 return __builtin_altivec_vcmpequd_p(
16077 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16078}
16079#endif
16080
16081static __inline__ int __ATTRS_o_ai vec_any_eq(vector float __a,
16082 vector float __b) {
16083#ifdef __VSX__
16084 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __b);
16085#else
16086 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __b);
16087#endif
16088}
16089
16090#ifdef __VSX__
16091static __inline__ int __ATTRS_o_ai vec_any_eq(vector double __a,
16092 vector double __b) {
16093 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __b);
16094}
16095#endif
16096
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016097#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016098static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed __int128 __a,
16099 vector signed __int128 __b) {
16100 return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
16101}
16102
16103static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned __int128 __a,
16104 vector unsigned __int128 __b) {
16105 return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
16106}
16107#endif
16108
Logan Chien2833ffb2018-10-09 10:03:24 +080016109/* vec_any_ge */
16110
16111static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a,
16112 vector signed char __b) {
16113 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b, __a);
16114}
16115
16116static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a,
16117 vector bool char __b) {
16118 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__b,
16119 __a);
16120}
16121
16122static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a,
16123 vector unsigned char __b) {
16124 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b, __a);
16125}
16126
16127static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a,
16128 vector bool char __b) {
16129 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
16130 __a);
16131}
16132
16133static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
16134 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016135 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b,
16136 (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016137}
16138
16139static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
16140 vector unsigned char __b) {
16141 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b,
16142 (vector unsigned char)__a);
16143}
16144
16145static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
16146 vector bool char __b) {
16147 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
16148 (vector unsigned char)__a);
16149}
16150
16151static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a,
16152 vector short __b) {
16153 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b, __a);
16154}
16155
16156static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a,
16157 vector bool short __b) {
16158 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector short)__b, __a);
16159}
16160
16161static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a,
16162 vector unsigned short __b) {
16163 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b, __a);
16164}
16165
16166static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a,
16167 vector bool short __b) {
16168 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
16169 __a);
16170}
16171
16172static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
16173 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016174 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b,
16175 (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016176}
16177
16178static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
16179 vector unsigned short __b) {
16180 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b,
16181 (vector unsigned short)__a);
16182}
16183
16184static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
16185 vector bool short __b) {
16186 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
16187 (vector unsigned short)__a);
16188}
16189
16190static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a, vector int __b) {
16191 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b, __a);
16192}
16193
16194static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a,
16195 vector bool int __b) {
16196 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector int)__b, __a);
16197}
16198
16199static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a,
16200 vector unsigned int __b) {
16201 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b, __a);
16202}
16203
16204static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a,
16205 vector bool int __b) {
16206 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
16207 __a);
16208}
16209
16210static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
16211 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016212 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b,
16213 (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016214}
16215
16216static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
16217 vector unsigned int __b) {
16218 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b,
16219 (vector unsigned int)__a);
16220}
16221
16222static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
16223 vector bool int __b) {
16224 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
16225 (vector unsigned int)__a);
16226}
16227
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016228#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016229static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
16230 vector signed long long __b) {
16231 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b, __a);
16232}
16233
16234static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a,
16235 vector unsigned long long __b) {
16236 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b, __a);
16237}
16238
16239static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
16240 vector bool long long __b) {
16241 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV,
16242 (vector signed long long)__b, __a);
16243}
16244
16245static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a,
16246 vector bool long long __b) {
16247 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16248 (vector unsigned long long)__b, __a);
16249}
16250
16251static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
16252 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016253 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b,
16254 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016255}
16256
16257static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
16258 vector unsigned long long __b) {
16259 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b,
16260 (vector unsigned long long)__a);
16261}
16262
16263static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
16264 vector bool long long __b) {
16265 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16266 (vector unsigned long long)__b,
16267 (vector unsigned long long)__a);
16268}
16269#endif
16270
16271static __inline__ int __ATTRS_o_ai vec_any_ge(vector float __a,
16272 vector float __b) {
16273#ifdef __VSX__
16274 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __a, __b);
16275#else
16276 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __a, __b);
16277#endif
16278}
16279
16280#ifdef __VSX__
16281static __inline__ int __ATTRS_o_ai vec_any_ge(vector double __a,
16282 vector double __b) {
16283 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __a, __b);
16284}
16285#endif
16286
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016287#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016288static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed __int128 __a,
16289 vector signed __int128 __b) {
16290 return __builtin_altivec_vcmpgtsq_p(__CR6_LT_REV, __b, __a);
16291}
16292
16293static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned __int128 __a,
16294 vector unsigned __int128 __b) {
16295 return __builtin_altivec_vcmpgtuq_p(__CR6_LT_REV, __b, __a);
16296}
16297#endif
16298
Logan Chien2833ffb2018-10-09 10:03:24 +080016299/* vec_any_gt */
16300
16301static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a,
16302 vector signed char __b) {
16303 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a, __b);
16304}
16305
16306static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a,
16307 vector bool char __b) {
16308 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a,
16309 (vector signed char)__b);
16310}
16311
16312static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a,
16313 vector unsigned char __b) {
16314 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a, __b);
16315}
16316
16317static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a,
16318 vector bool char __b) {
16319 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a,
16320 (vector unsigned char)__b);
16321}
16322
16323static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
16324 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016325 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__a,
16326 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016327}
16328
16329static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
16330 vector unsigned char __b) {
16331 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
16332 __b);
16333}
16334
16335static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
16336 vector bool char __b) {
16337 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
16338 (vector unsigned char)__b);
16339}
16340
16341static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a,
16342 vector short __b) {
16343 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, __b);
16344}
16345
16346static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a,
16347 vector bool short __b) {
16348 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, (vector short)__b);
16349}
16350
16351static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a,
16352 vector unsigned short __b) {
16353 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a, __b);
16354}
16355
16356static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a,
16357 vector bool short __b) {
16358 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a,
16359 (vector unsigned short)__b);
16360}
16361
16362static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
16363 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016364 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector signed short)__a,
16365 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016366}
16367
16368static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
16369 vector unsigned short __b) {
16370 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
16371 __b);
16372}
16373
16374static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
16375 vector bool short __b) {
16376 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
16377 (vector unsigned short)__b);
16378}
16379
16380static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a, vector int __b) {
16381 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, __b);
16382}
16383
16384static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a,
16385 vector bool int __b) {
16386 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, (vector int)__b);
16387}
16388
16389static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a,
16390 vector unsigned int __b) {
16391 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a, __b);
16392}
16393
16394static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a,
16395 vector bool int __b) {
16396 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a,
16397 (vector unsigned int)__b);
16398}
16399
16400static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
16401 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016402 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector signed int)__a,
16403 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016404}
16405
16406static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
16407 vector unsigned int __b) {
16408 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
16409 __b);
16410}
16411
16412static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
16413 vector bool int __b) {
16414 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
16415 (vector unsigned int)__b);
16416}
16417
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016418#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016419static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a,
16420 vector signed long long __b) {
16421 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a, __b);
16422}
16423
16424static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a,
16425 vector unsigned long long __b) {
16426 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a, __b);
16427}
16428
16429static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a,
16430 vector bool long long __b) {
16431 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a,
16432 (vector signed long long)__b);
16433}
16434
16435static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a,
16436 vector bool long long __b) {
16437 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a,
16438 (vector unsigned long long)__b);
16439}
16440
16441static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
16442 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016443 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV,
16444 (vector signed long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016445}
16446
16447static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
16448 vector unsigned long long __b) {
16449 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16450 (vector unsigned long long)__a, __b);
16451}
16452
16453static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
16454 vector bool long long __b) {
16455 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16456 (vector unsigned long long)__a,
16457 (vector unsigned long long)__b);
16458}
16459#endif
16460
16461static __inline__ int __ATTRS_o_ai vec_any_gt(vector float __a,
16462 vector float __b) {
16463#ifdef __VSX__
16464 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __a, __b);
16465#else
16466 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __a, __b);
16467#endif
16468}
16469
16470#ifdef __VSX__
16471static __inline__ int __ATTRS_o_ai vec_any_gt(vector double __a,
16472 vector double __b) {
16473 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __a, __b);
16474}
16475#endif
16476
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016477#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016478static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed __int128 __a,
16479 vector signed __int128 __b) {
16480 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ_REV, __a, __b);
16481}
16482
16483static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned __int128 __a,
16484 vector unsigned __int128 __b) {
16485 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ_REV, __a, __b);
16486}
16487#endif
16488
Logan Chien2833ffb2018-10-09 10:03:24 +080016489/* vec_any_le */
16490
16491static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a,
16492 vector signed char __b) {
16493 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a, __b);
16494}
16495
16496static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a,
16497 vector bool char __b) {
16498 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a,
16499 (vector signed char)__b);
16500}
16501
16502static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a,
16503 vector unsigned char __b) {
16504 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a, __b);
16505}
16506
16507static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a,
16508 vector bool char __b) {
16509 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a,
16510 (vector unsigned char)__b);
16511}
16512
16513static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
16514 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016515 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__a,
16516 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016517}
16518
16519static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
16520 vector unsigned char __b) {
16521 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
16522 __b);
16523}
16524
16525static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
16526 vector bool char __b) {
16527 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
16528 (vector unsigned char)__b);
16529}
16530
16531static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a,
16532 vector short __b) {
16533 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, __b);
16534}
16535
16536static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a,
16537 vector bool short __b) {
16538 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, (vector short)__b);
16539}
16540
16541static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a,
16542 vector unsigned short __b) {
16543 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a, __b);
16544}
16545
16546static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a,
16547 vector bool short __b) {
16548 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a,
16549 (vector unsigned short)__b);
16550}
16551
16552static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
16553 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016554 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector signed short)__a,
16555 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016556}
16557
16558static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
16559 vector unsigned short __b) {
16560 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
16561 __b);
16562}
16563
16564static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
16565 vector bool short __b) {
16566 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
16567 (vector unsigned short)__b);
16568}
16569
16570static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a, vector int __b) {
16571 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, __b);
16572}
16573
16574static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a,
16575 vector bool int __b) {
16576 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, (vector int)__b);
16577}
16578
16579static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a,
16580 vector unsigned int __b) {
16581 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a, __b);
16582}
16583
16584static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a,
16585 vector bool int __b) {
16586 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a,
16587 (vector unsigned int)__b);
16588}
16589
16590static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
16591 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016592 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector signed int)__a,
16593 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016594}
16595
16596static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
16597 vector unsigned int __b) {
16598 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
16599 __b);
16600}
16601
16602static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
16603 vector bool int __b) {
16604 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
16605 (vector unsigned int)__b);
16606}
16607
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016608#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016609static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a,
16610 vector signed long long __b) {
16611 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a, __b);
16612}
16613
16614static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a,
16615 vector unsigned long long __b) {
16616 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a, __b);
16617}
16618
16619static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a,
16620 vector bool long long __b) {
16621 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a,
16622 (vector signed long long)__b);
16623}
16624
16625static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a,
16626 vector bool long long __b) {
16627 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a,
16628 (vector unsigned long long)__b);
16629}
16630
16631static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
16632 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016633 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV,
16634 (vector signed long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016635}
16636
16637static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
16638 vector unsigned long long __b) {
16639 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16640 (vector unsigned long long)__a, __b);
16641}
16642
16643static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
16644 vector bool long long __b) {
16645 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16646 (vector unsigned long long)__a,
16647 (vector unsigned long long)__b);
16648}
16649#endif
16650
16651static __inline__ int __ATTRS_o_ai vec_any_le(vector float __a,
16652 vector float __b) {
16653#ifdef __VSX__
16654 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __b, __a);
16655#else
16656 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __b, __a);
16657#endif
16658}
16659
16660#ifdef __VSX__
16661static __inline__ int __ATTRS_o_ai vec_any_le(vector double __a,
16662 vector double __b) {
16663 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __b, __a);
16664}
16665#endif
16666
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016667#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016668static __inline__ int __ATTRS_o_ai vec_any_le(vector signed __int128 __a,
16669 vector signed __int128 __b) {
16670 return __builtin_altivec_vcmpgtsq_p(__CR6_LT_REV, __a, __b);
16671}
16672
16673static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned __int128 __a,
16674 vector unsigned __int128 __b) {
16675 return __builtin_altivec_vcmpgtuq_p(__CR6_LT_REV, __a, __b);
16676}
16677#endif
16678
Logan Chien2833ffb2018-10-09 10:03:24 +080016679/* vec_any_lt */
16680
16681static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a,
16682 vector signed char __b) {
16683 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b, __a);
16684}
16685
16686static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a,
16687 vector bool char __b) {
16688 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__b,
16689 __a);
16690}
16691
16692static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a,
16693 vector unsigned char __b) {
16694 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b, __a);
16695}
16696
16697static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a,
16698 vector bool char __b) {
16699 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
16700 __a);
16701}
16702
16703static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
16704 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016705 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b,
16706 (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016707}
16708
16709static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
16710 vector unsigned char __b) {
16711 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b,
16712 (vector unsigned char)__a);
16713}
16714
16715static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
16716 vector bool char __b) {
16717 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
16718 (vector unsigned char)__a);
16719}
16720
16721static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a,
16722 vector short __b) {
16723 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b, __a);
16724}
16725
16726static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a,
16727 vector bool short __b) {
16728 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector short)__b, __a);
16729}
16730
16731static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a,
16732 vector unsigned short __b) {
16733 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b, __a);
16734}
16735
16736static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a,
16737 vector bool short __b) {
16738 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
16739 __a);
16740}
16741
16742static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
16743 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016744 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b,
16745 (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016746}
16747
16748static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
16749 vector unsigned short __b) {
16750 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b,
16751 (vector unsigned short)__a);
16752}
16753
16754static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
16755 vector bool short __b) {
16756 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
16757 (vector unsigned short)__a);
16758}
16759
16760static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a, vector int __b) {
16761 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b, __a);
16762}
16763
16764static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a,
16765 vector bool int __b) {
16766 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector int)__b, __a);
16767}
16768
16769static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a,
16770 vector unsigned int __b) {
16771 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b, __a);
16772}
16773
16774static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a,
16775 vector bool int __b) {
16776 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
16777 __a);
16778}
16779
16780static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
16781 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016782 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b,
16783 (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016784}
16785
16786static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
16787 vector unsigned int __b) {
16788 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b,
16789 (vector unsigned int)__a);
16790}
16791
16792static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
16793 vector bool int __b) {
16794 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
16795 (vector unsigned int)__a);
16796}
16797
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016798#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016799static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a,
16800 vector signed long long __b) {
16801 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b, __a);
16802}
16803
16804static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a,
16805 vector unsigned long long __b) {
16806 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b, __a);
16807}
16808
16809static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a,
16810 vector bool long long __b) {
16811 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV,
16812 (vector signed long long)__b, __a);
16813}
16814
16815static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a,
16816 vector bool long long __b) {
16817 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16818 (vector unsigned long long)__b, __a);
16819}
16820
16821static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
16822 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016823 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b,
16824 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016825}
16826
16827static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
16828 vector unsigned long long __b) {
16829 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b,
16830 (vector unsigned long long)__a);
16831}
16832
16833static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
16834 vector bool long long __b) {
16835 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16836 (vector unsigned long long)__b,
16837 (vector unsigned long long)__a);
16838}
16839#endif
16840
16841static __inline__ int __ATTRS_o_ai vec_any_lt(vector float __a,
16842 vector float __b) {
16843#ifdef __VSX__
16844 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __b, __a);
16845#else
16846 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __b, __a);
16847#endif
16848}
16849
16850#ifdef __VSX__
16851static __inline__ int __ATTRS_o_ai vec_any_lt(vector double __a,
16852 vector double __b) {
16853 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __b, __a);
16854}
16855#endif
16856
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016857#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016858static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed __int128 __a,
16859 vector signed __int128 __b) {
16860 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ_REV, __b, __a);
16861}
16862
16863static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned __int128 __a,
16864 vector unsigned __int128 __b) {
16865 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ_REV, __b, __a);
16866}
16867#endif
16868
Logan Chien2833ffb2018-10-09 10:03:24 +080016869/* vec_any_nan */
16870
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016871static __inline__ int __ATTRS_o_ai vec_any_nan(vector float __a) {
16872#ifdef __VSX__
16873 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __a);
16874#else
Logan Chien2833ffb2018-10-09 10:03:24 +080016875 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016876#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080016877}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016878#ifdef __VSX__
16879static __inline__ int __ATTRS_o_ai vec_any_nan(vector double __a) {
16880 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __a);
16881}
16882#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080016883
16884/* vec_any_ne */
16885
16886static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a,
16887 vector signed char __b) {
16888 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16889 (vector char)__b);
16890}
16891
16892static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a,
16893 vector bool char __b) {
16894 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16895 (vector char)__b);
16896}
16897
16898static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a,
16899 vector unsigned char __b) {
16900 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16901 (vector char)__b);
16902}
16903
16904static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a,
16905 vector bool char __b) {
16906 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16907 (vector char)__b);
16908}
16909
16910static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
16911 vector signed char __b) {
16912 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16913 (vector char)__b);
16914}
16915
16916static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
16917 vector unsigned char __b) {
16918 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16919 (vector char)__b);
16920}
16921
16922static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
16923 vector bool char __b) {
16924 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16925 (vector char)__b);
16926}
16927
16928static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a,
16929 vector short __b) {
16930 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, __b);
16931}
16932
16933static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a,
16934 vector bool short __b) {
16935 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, (vector short)__b);
16936}
16937
16938static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a,
16939 vector unsigned short __b) {
16940 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16941 (vector short)__b);
16942}
16943
16944static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a,
16945 vector bool short __b) {
16946 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16947 (vector short)__b);
16948}
16949
16950static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
16951 vector short __b) {
16952 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16953 (vector short)__b);
16954}
16955
16956static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
16957 vector unsigned short __b) {
16958 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16959 (vector short)__b);
16960}
16961
16962static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
16963 vector bool short __b) {
16964 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16965 (vector short)__b);
16966}
16967
16968static __inline__ int __ATTRS_o_ai vec_any_ne(vector pixel __a,
16969 vector pixel __b) {
16970 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16971 (vector short)__b);
16972}
16973
16974static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a, vector int __b) {
16975 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, __b);
16976}
16977
16978static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a,
16979 vector bool int __b) {
16980 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, (vector int)__b);
16981}
16982
16983static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a,
16984 vector unsigned int __b) {
16985 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
16986 (vector int)__b);
16987}
16988
16989static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a,
16990 vector bool int __b) {
16991 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
16992 (vector int)__b);
16993}
16994
16995static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
16996 vector int __b) {
16997 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
16998 (vector int)__b);
16999}
17000
17001static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
17002 vector unsigned int __b) {
17003 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17004 (vector int)__b);
17005}
17006
17007static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
17008 vector bool int __b) {
17009 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17010 (vector int)__b);
17011}
17012
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017013#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080017014static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a,
17015 vector signed long long __b) {
17016 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, __a, __b);
17017}
17018
17019static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a,
17020 vector unsigned long long __b) {
17021 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, (vector long long)__a,
17022 (vector long long)__b);
17023}
17024
17025static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a,
17026 vector bool long long __b) {
17027 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, __a,
17028 (vector signed long long)__b);
17029}
17030
17031static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a,
17032 vector bool long long __b) {
17033 return __builtin_altivec_vcmpequd_p(
17034 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
17035}
17036
17037static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
17038 vector signed long long __b) {
17039 return __builtin_altivec_vcmpequd_p(
17040 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
17041}
17042
17043static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
17044 vector unsigned long long __b) {
17045 return __builtin_altivec_vcmpequd_p(
17046 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
17047}
17048
17049static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
17050 vector bool long long __b) {
17051 return __builtin_altivec_vcmpequd_p(
17052 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
17053}
17054#endif
17055
17056static __inline__ int __ATTRS_o_ai vec_any_ne(vector float __a,
17057 vector float __b) {
17058#ifdef __VSX__
17059 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __b);
17060#else
17061 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __b);
17062#endif
17063}
17064
17065#ifdef __VSX__
17066static __inline__ int __ATTRS_o_ai vec_any_ne(vector double __a,
17067 vector double __b) {
17068 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __b);
17069}
17070#endif
17071
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017072#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017073static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed __int128 __a,
17074 vector signed __int128 __b) {
17075 return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
17076}
17077
17078static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned __int128 __a,
17079 vector unsigned __int128 __b) {
17080 return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
17081}
17082#endif
17083
Logan Chien2833ffb2018-10-09 10:03:24 +080017084/* vec_any_nge */
17085
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017086static __inline__ int __ATTRS_o_ai vec_any_nge(vector float __a,
17087 vector float __b) {
17088#ifdef __VSX__
17089 return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __a, __b);
17090#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017091 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __a, __b);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017092#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017093}
17094
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017095#ifdef __VSX__
17096static __inline__ int __ATTRS_o_ai vec_any_nge(vector double __a,
17097 vector double __b) {
17098 return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __a, __b);
17099}
17100#endif
17101
Logan Chien2833ffb2018-10-09 10:03:24 +080017102/* vec_any_ngt */
17103
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017104static __inline__ int __ATTRS_o_ai vec_any_ngt(vector float __a,
17105 vector float __b) {
17106#ifdef __VSX__
17107 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __a, __b);
17108#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017109 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __a, __b);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017110#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017111}
17112
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017113#ifdef __VSX__
17114static __inline__ int __ATTRS_o_ai vec_any_ngt(vector double __a,
17115 vector double __b) {
17116 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __a, __b);
17117}
17118#endif
17119
Logan Chien2833ffb2018-10-09 10:03:24 +080017120/* vec_any_nle */
17121
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017122static __inline__ int __ATTRS_o_ai vec_any_nle(vector float __a,
17123 vector float __b) {
17124#ifdef __VSX__
17125 return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __b, __a);
17126#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017127 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017128#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017129}
17130
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017131#ifdef __VSX__
17132static __inline__ int __ATTRS_o_ai vec_any_nle(vector double __a,
17133 vector double __b) {
17134 return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __b, __a);
17135}
17136#endif
17137
Logan Chien2833ffb2018-10-09 10:03:24 +080017138/* vec_any_nlt */
17139
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017140static __inline__ int __ATTRS_o_ai vec_any_nlt(vector float __a,
17141 vector float __b) {
17142#ifdef __VSX__
17143 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __b, __a);
17144#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017145 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017146#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017147}
17148
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017149#ifdef __VSX__
17150static __inline__ int __ATTRS_o_ai vec_any_nlt(vector double __a,
17151 vector double __b) {
17152 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __b, __a);
17153}
17154#endif
17155
Logan Chien2833ffb2018-10-09 10:03:24 +080017156/* vec_any_numeric */
17157
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017158static __inline__ int __ATTRS_o_ai vec_any_numeric(vector float __a) {
17159#ifdef __VSX__
17160 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __a);
17161#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017162 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017163#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017164}
17165
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017166#ifdef __VSX__
17167static __inline__ int __ATTRS_o_ai vec_any_numeric(vector double __a) {
17168 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __a);
17169}
17170#endif
17171
Logan Chien2833ffb2018-10-09 10:03:24 +080017172/* vec_any_out */
17173
17174static __inline__ int __attribute__((__always_inline__))
17175vec_any_out(vector float __a, vector float __b) {
17176 return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, __a, __b);
17177}
17178
17179/* Power 8 Crypto functions
17180Note: We diverge from the current GCC implementation with regard
17181to cryptography and related functions as follows:
17182- Only the SHA and AES instructions and builtins are disabled by -mno-crypto
17183- The remaining ones are only available on Power8 and up so
17184 require -mpower8-vector
17185The justification for this is that export requirements require that
17186Category:Vector.Crypto is optional (i.e. compliant hardware may not provide
17187support). As a result, we need to be able to turn off support for those.
17188The remaining ones (currently controlled by -mcrypto for GCC) still
17189need to be provided on compliant hardware even if Vector.Crypto is not
17190provided.
17191*/
17192#ifdef __CRYPTO__
17193#define vec_sbox_be __builtin_altivec_crypto_vsbox
17194#define vec_cipher_be __builtin_altivec_crypto_vcipher
17195#define vec_cipherlast_be __builtin_altivec_crypto_vcipherlast
17196#define vec_ncipher_be __builtin_altivec_crypto_vncipher
17197#define vec_ncipherlast_be __builtin_altivec_crypto_vncipherlast
17198
17199static __inline__ vector unsigned long long __attribute__((__always_inline__))
17200__builtin_crypto_vsbox(vector unsigned long long __a) {
17201 return __builtin_altivec_crypto_vsbox(__a);
17202}
17203
17204static __inline__ vector unsigned long long __attribute__((__always_inline__))
17205__builtin_crypto_vcipher(vector unsigned long long __a,
17206 vector unsigned long long __b) {
17207 return __builtin_altivec_crypto_vcipher(__a, __b);
17208}
17209
17210static __inline__ vector unsigned long long __attribute__((__always_inline__))
17211__builtin_crypto_vcipherlast(vector unsigned long long __a,
17212 vector unsigned long long __b) {
17213 return __builtin_altivec_crypto_vcipherlast(__a, __b);
17214}
17215
17216static __inline__ vector unsigned long long __attribute__((__always_inline__))
17217__builtin_crypto_vncipher(vector unsigned long long __a,
17218 vector unsigned long long __b) {
17219 return __builtin_altivec_crypto_vncipher(__a, __b);
17220}
17221
17222static __inline__ vector unsigned long long __attribute__((__always_inline__))
17223__builtin_crypto_vncipherlast(vector unsigned long long __a,
17224 vector unsigned long long __b) {
17225 return __builtin_altivec_crypto_vncipherlast(__a, __b);
17226}
17227
17228#define __builtin_crypto_vshasigmad __builtin_altivec_crypto_vshasigmad
17229#define __builtin_crypto_vshasigmaw __builtin_altivec_crypto_vshasigmaw
17230
17231#define vec_shasigma_be(X, Y, Z) \
17232 _Generic((X), vector unsigned int \
17233 : __builtin_crypto_vshasigmaw, vector unsigned long long \
17234 : __builtin_crypto_vshasigmad)((X), (Y), (Z))
17235#endif
17236
17237#ifdef __POWER8_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +080017238static __inline__ vector bool char __ATTRS_o_ai
17239vec_permxor(vector bool char __a, vector bool char __b,
17240 vector bool char __c) {
17241 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17242}
17243
17244static __inline__ vector signed char __ATTRS_o_ai
17245vec_permxor(vector signed char __a, vector signed char __b,
17246 vector signed char __c) {
17247 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17248}
17249
17250static __inline__ vector unsigned char __ATTRS_o_ai
17251vec_permxor(vector unsigned char __a, vector unsigned char __b,
17252 vector unsigned char __c) {
17253 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17254}
17255
Logan Chien2833ffb2018-10-09 10:03:24 +080017256static __inline__ vector unsigned char __ATTRS_o_ai
17257__builtin_crypto_vpermxor(vector unsigned char __a, vector unsigned char __b,
17258 vector unsigned char __c) {
17259 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17260}
17261
17262static __inline__ vector unsigned short __ATTRS_o_ai
17263__builtin_crypto_vpermxor(vector unsigned short __a, vector unsigned short __b,
17264 vector unsigned short __c) {
17265 return (vector unsigned short)__builtin_altivec_crypto_vpermxor(
17266 (vector unsigned char)__a, (vector unsigned char)__b,
17267 (vector unsigned char)__c);
17268}
17269
17270static __inline__ vector unsigned int __ATTRS_o_ai __builtin_crypto_vpermxor(
17271 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
17272 return (vector unsigned int)__builtin_altivec_crypto_vpermxor(
17273 (vector unsigned char)__a, (vector unsigned char)__b,
17274 (vector unsigned char)__c);
17275}
17276
17277static __inline__ vector unsigned long long __ATTRS_o_ai
17278__builtin_crypto_vpermxor(vector unsigned long long __a,
17279 vector unsigned long long __b,
17280 vector unsigned long long __c) {
17281 return (vector unsigned long long)__builtin_altivec_crypto_vpermxor(
17282 (vector unsigned char)__a, (vector unsigned char)__b,
17283 (vector unsigned char)__c);
17284}
17285
17286static __inline__ vector unsigned char __ATTRS_o_ai
17287__builtin_crypto_vpmsumb(vector unsigned char __a, vector unsigned char __b) {
17288 return __builtin_altivec_crypto_vpmsumb(__a, __b);
17289}
17290
17291static __inline__ vector unsigned short __ATTRS_o_ai
17292__builtin_crypto_vpmsumb(vector unsigned short __a, vector unsigned short __b) {
17293 return __builtin_altivec_crypto_vpmsumh(__a, __b);
17294}
17295
17296static __inline__ vector unsigned int __ATTRS_o_ai
17297__builtin_crypto_vpmsumb(vector unsigned int __a, vector unsigned int __b) {
17298 return __builtin_altivec_crypto_vpmsumw(__a, __b);
17299}
17300
17301static __inline__ vector unsigned long long __ATTRS_o_ai
17302__builtin_crypto_vpmsumb(vector unsigned long long __a,
17303 vector unsigned long long __b) {
17304 return __builtin_altivec_crypto_vpmsumd(__a, __b);
17305}
17306
17307static __inline__ vector signed char __ATTRS_o_ai
17308vec_vgbbd(vector signed char __a) {
17309 return __builtin_altivec_vgbbd((vector unsigned char)__a);
17310}
17311
17312#define vec_pmsum_be __builtin_crypto_vpmsumb
17313#define vec_gb __builtin_altivec_vgbbd
17314
17315static __inline__ vector unsigned char __ATTRS_o_ai
17316vec_vgbbd(vector unsigned char __a) {
17317 return __builtin_altivec_vgbbd(__a);
17318}
17319
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017320static __inline__ vector signed long long __ATTRS_o_ai
17321vec_gbb(vector signed long long __a) {
17322 return __builtin_altivec_vgbbd((vector unsigned char)__a);
17323}
17324
17325static __inline__ vector unsigned long long __ATTRS_o_ai
17326vec_gbb(vector unsigned long long __a) {
17327 return __builtin_altivec_vgbbd((vector unsigned char)__a);
17328}
17329
Logan Chien2833ffb2018-10-09 10:03:24 +080017330static __inline__ vector long long __ATTRS_o_ai
17331vec_vbpermq(vector signed char __a, vector signed char __b) {
17332 return __builtin_altivec_vbpermq((vector unsigned char)__a,
17333 (vector unsigned char)__b);
17334}
17335
17336static __inline__ vector long long __ATTRS_o_ai
17337vec_vbpermq(vector unsigned char __a, vector unsigned char __b) {
17338 return __builtin_altivec_vbpermq(__a, __b);
17339}
17340
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017341#if defined(__powerpc64__) && defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080017342static __inline__ vector unsigned long long __attribute__((__always_inline__))
17343vec_bperm(vector unsigned __int128 __a, vector unsigned char __b) {
17344 return __builtin_altivec_vbpermq((vector unsigned char)__a,
17345 (vector unsigned char)__b);
17346}
17347#endif
17348#endif
17349
Logan Chien55afb0a2018-10-15 10:42:14 +080017350
17351/* vec_reve */
17352
17353static inline __ATTRS_o_ai vector bool char vec_reve(vector bool char __a) {
17354 return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
17355 5, 4, 3, 2, 1, 0);
17356}
17357
17358static inline __ATTRS_o_ai vector signed char vec_reve(vector signed char __a) {
17359 return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
17360 5, 4, 3, 2, 1, 0);
17361}
17362
17363static inline __ATTRS_o_ai vector unsigned char
17364vec_reve(vector unsigned char __a) {
17365 return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
17366 5, 4, 3, 2, 1, 0);
17367}
17368
17369static inline __ATTRS_o_ai vector bool int vec_reve(vector bool int __a) {
17370 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17371}
17372
17373static inline __ATTRS_o_ai vector signed int vec_reve(vector signed int __a) {
17374 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17375}
17376
17377static inline __ATTRS_o_ai vector unsigned int
17378vec_reve(vector unsigned int __a) {
17379 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17380}
17381
17382static inline __ATTRS_o_ai vector bool short vec_reve(vector bool short __a) {
17383 return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
17384}
17385
17386static inline __ATTRS_o_ai vector signed short
17387vec_reve(vector signed short __a) {
17388 return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
17389}
17390
17391static inline __ATTRS_o_ai vector unsigned short
17392vec_reve(vector unsigned short __a) {
17393 return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
17394}
17395
17396static inline __ATTRS_o_ai vector float vec_reve(vector float __a) {
17397 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17398}
17399
17400#ifdef __VSX__
17401static inline __ATTRS_o_ai vector bool long long
17402vec_reve(vector bool long long __a) {
17403 return __builtin_shufflevector(__a, __a, 1, 0);
17404}
17405
17406static inline __ATTRS_o_ai vector signed long long
17407vec_reve(vector signed long long __a) {
17408 return __builtin_shufflevector(__a, __a, 1, 0);
17409}
17410
17411static inline __ATTRS_o_ai vector unsigned long long
17412vec_reve(vector unsigned long long __a) {
17413 return __builtin_shufflevector(__a, __a, 1, 0);
17414}
17415
17416static inline __ATTRS_o_ai vector double vec_reve(vector double __a) {
17417 return __builtin_shufflevector(__a, __a, 1, 0);
17418}
17419#endif
17420
17421/* vec_revb */
17422static __inline__ vector bool char __ATTRS_o_ai
17423vec_revb(vector bool char __a) {
17424 return __a;
17425}
17426
17427static __inline__ vector signed char __ATTRS_o_ai
17428vec_revb(vector signed char __a) {
17429 return __a;
17430}
17431
17432static __inline__ vector unsigned char __ATTRS_o_ai
17433vec_revb(vector unsigned char __a) {
17434 return __a;
17435}
17436
17437static __inline__ vector bool short __ATTRS_o_ai
17438vec_revb(vector bool short __a) {
17439 vector unsigned char __indices =
17440 { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 };
17441 return vec_perm(__a, __a, __indices);
17442}
17443
17444static __inline__ vector signed short __ATTRS_o_ai
17445vec_revb(vector signed short __a) {
17446 vector unsigned char __indices =
17447 { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 };
17448 return vec_perm(__a, __a, __indices);
17449}
17450
17451static __inline__ vector unsigned short __ATTRS_o_ai
17452vec_revb(vector unsigned short __a) {
17453 vector unsigned char __indices =
17454 { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 };
17455 return vec_perm(__a, __a, __indices);
17456}
17457
17458static __inline__ vector bool int __ATTRS_o_ai
17459vec_revb(vector bool int __a) {
17460 vector unsigned char __indices =
17461 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17462 return vec_perm(__a, __a, __indices);
17463}
17464
17465static __inline__ vector signed int __ATTRS_o_ai
17466vec_revb(vector signed int __a) {
17467 vector unsigned char __indices =
17468 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17469 return vec_perm(__a, __a, __indices);
17470}
17471
17472static __inline__ vector unsigned int __ATTRS_o_ai
17473vec_revb(vector unsigned int __a) {
17474 vector unsigned char __indices =
17475 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17476 return vec_perm(__a, __a, __indices);
17477}
17478
17479static __inline__ vector float __ATTRS_o_ai
17480vec_revb(vector float __a) {
17481 vector unsigned char __indices =
17482 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17483 return vec_perm(__a, __a, __indices);
17484}
17485
17486#ifdef __VSX__
17487static __inline__ vector bool long long __ATTRS_o_ai
17488vec_revb(vector bool long long __a) {
17489 vector unsigned char __indices =
17490 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17491 return vec_perm(__a, __a, __indices);
17492}
17493
17494static __inline__ vector signed long long __ATTRS_o_ai
17495vec_revb(vector signed long long __a) {
17496 vector unsigned char __indices =
17497 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17498 return vec_perm(__a, __a, __indices);
17499}
17500
17501static __inline__ vector unsigned long long __ATTRS_o_ai
17502vec_revb(vector unsigned long long __a) {
17503 vector unsigned char __indices =
17504 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17505 return vec_perm(__a, __a, __indices);
17506}
17507
17508static __inline__ vector double __ATTRS_o_ai
17509vec_revb(vector double __a) {
17510 vector unsigned char __indices =
17511 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17512 return vec_perm(__a, __a, __indices);
17513}
17514#endif /* End __VSX__ */
17515
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017516#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17517 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080017518static __inline__ vector signed __int128 __ATTRS_o_ai
17519vec_revb(vector signed __int128 __a) {
17520 vector unsigned char __indices =
17521 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
17522 return (vector signed __int128)vec_perm((vector signed int)__a,
17523 (vector signed int)__a,
17524 __indices);
17525}
17526
17527static __inline__ vector unsigned __int128 __ATTRS_o_ai
17528vec_revb(vector unsigned __int128 __a) {
17529 vector unsigned char __indices =
17530 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
17531 return (vector unsigned __int128)vec_perm((vector signed int)__a,
17532 (vector signed int)__a,
17533 __indices);
17534}
17535#endif /* END __POWER8_VECTOR__ && __powerpc64__ */
17536
17537/* vec_xl */
17538
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017539#define vec_xld2 vec_xl
17540#define vec_xlw4 vec_xl
Logan Chiendbcf4122019-03-21 10:50:25 +080017541typedef vector signed char unaligned_vec_schar __attribute__((aligned(1)));
17542typedef vector unsigned char unaligned_vec_uchar __attribute__((aligned(1)));
17543typedef vector signed short unaligned_vec_sshort __attribute__((aligned(1)));
17544typedef vector unsigned short unaligned_vec_ushort __attribute__((aligned(1)));
17545typedef vector signed int unaligned_vec_sint __attribute__((aligned(1)));
17546typedef vector unsigned int unaligned_vec_uint __attribute__((aligned(1)));
17547typedef vector float unaligned_vec_float __attribute__((aligned(1)));
17548
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017549static inline __ATTRS_o_ai vector signed char vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017550 const signed char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017551 return *(unaligned_vec_schar *)(__ptr + __offset);
Logan Chien55afb0a2018-10-15 10:42:14 +080017552}
17553
17554static inline __ATTRS_o_ai vector unsigned char
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017555vec_xl(ptrdiff_t __offset, const unsigned char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017556 return *(unaligned_vec_uchar*)(__ptr + __offset);
Logan Chien55afb0a2018-10-15 10:42:14 +080017557}
17558
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017559static inline __ATTRS_o_ai vector signed short
17560vec_xl(ptrdiff_t __offset, const signed short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017561 signed char *__addr = (signed char *)__ptr + __offset;
17562 return *(unaligned_vec_sshort *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017563}
17564
17565static inline __ATTRS_o_ai vector unsigned short
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017566vec_xl(ptrdiff_t __offset, const unsigned short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017567 signed char *__addr = (signed char *)__ptr + __offset;
17568 return *(unaligned_vec_ushort *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017569}
17570
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017571static inline __ATTRS_o_ai vector signed int vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017572 const signed int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017573 signed char *__addr = (signed char *)__ptr + __offset;
17574 return *(unaligned_vec_sint *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017575}
17576
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017577static inline __ATTRS_o_ai vector unsigned int
17578vec_xl(ptrdiff_t __offset, const unsigned int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017579 signed char *__addr = (signed char *)__ptr + __offset;
17580 return *(unaligned_vec_uint *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017581}
17582
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017583static inline __ATTRS_o_ai vector float vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017584 const float *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017585 signed char *__addr = (signed char *)__ptr + __offset;
17586 return *(unaligned_vec_float *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017587}
17588
17589#ifdef __VSX__
Logan Chiendbcf4122019-03-21 10:50:25 +080017590typedef vector signed long long unaligned_vec_sll __attribute__((aligned(1)));
17591typedef vector unsigned long long unaligned_vec_ull __attribute__((aligned(1)));
17592typedef vector double unaligned_vec_double __attribute__((aligned(1)));
17593
Logan Chien55afb0a2018-10-15 10:42:14 +080017594static inline __ATTRS_o_ai vector signed long long
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017595vec_xl(ptrdiff_t __offset, const signed long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017596 signed char *__addr = (signed char *)__ptr + __offset;
17597 return *(unaligned_vec_sll *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017598}
17599
17600static inline __ATTRS_o_ai vector unsigned long long
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017601vec_xl(ptrdiff_t __offset, const unsigned long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017602 signed char *__addr = (signed char *)__ptr + __offset;
17603 return *(unaligned_vec_ull *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017604}
17605
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017606static inline __ATTRS_o_ai vector double vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017607 const double *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017608 signed char *__addr = (signed char *)__ptr + __offset;
17609 return *(unaligned_vec_double *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017610}
17611#endif
17612
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017613#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17614 defined(__SIZEOF_INT128__)
Logan Chiendbcf4122019-03-21 10:50:25 +080017615typedef vector signed __int128 unaligned_vec_si128 __attribute__((aligned(1)));
17616typedef vector unsigned __int128 unaligned_vec_ui128
17617 __attribute__((aligned(1)));
Logan Chien55afb0a2018-10-15 10:42:14 +080017618static inline __ATTRS_o_ai vector signed __int128
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017619vec_xl(ptrdiff_t __offset, const signed __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017620 signed char *__addr = (signed char *)__ptr + __offset;
17621 return *(unaligned_vec_si128 *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017622}
17623
17624static inline __ATTRS_o_ai vector unsigned __int128
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017625vec_xl(ptrdiff_t __offset, const unsigned __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017626 signed char *__addr = (signed char *)__ptr + __offset;
17627 return *(unaligned_vec_ui128 *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017628}
17629#endif
17630
17631/* vec_xl_be */
17632
17633#ifdef __LITTLE_ENDIAN__
17634static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017635vec_xl_be(ptrdiff_t __offset, const signed char *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017636 vector signed char __vec = (vector signed char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017637 return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
17638 13, 12, 11, 10, 9, 8);
17639}
17640
17641static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017642vec_xl_be(ptrdiff_t __offset, const unsigned char *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017643 vector unsigned char __vec = (vector unsigned char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017644 return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
17645 13, 12, 11, 10, 9, 8);
17646}
17647
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017648static __inline__ vector signed short __ATTRS_o_ai
17649vec_xl_be(ptrdiff_t __offset, const signed short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017650 vector signed short __vec = (vector signed short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017651 return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
17652}
17653
17654static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017655vec_xl_be(ptrdiff_t __offset, const unsigned short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017656 vector unsigned short __vec = (vector unsigned short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017657 return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
17658}
17659
17660static __inline__ vector signed int __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017661vec_xl_be(signed long long __offset, const signed int *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017662 return (vector signed int)__builtin_vsx_lxvw4x_be(__offset, __ptr);
17663}
17664
17665static __inline__ vector unsigned int __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017666vec_xl_be(signed long long __offset, const unsigned int *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017667 return (vector unsigned int)__builtin_vsx_lxvw4x_be(__offset, __ptr);
17668}
17669
17670static __inline__ vector float __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017671vec_xl_be(signed long long __offset, const float *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017672 return (vector float)__builtin_vsx_lxvw4x_be(__offset, __ptr);
17673}
17674
17675#ifdef __VSX__
17676static __inline__ vector signed long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017677vec_xl_be(signed long long __offset, const signed long long *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017678 return (vector signed long long)__builtin_vsx_lxvd2x_be(__offset, __ptr);
17679}
17680
17681static __inline__ vector unsigned long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017682vec_xl_be(signed long long __offset, const unsigned long long *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017683 return (vector unsigned long long)__builtin_vsx_lxvd2x_be(__offset, __ptr);
17684}
17685
17686static __inline__ vector double __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017687vec_xl_be(signed long long __offset, const double *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017688 return (vector double)__builtin_vsx_lxvd2x_be(__offset, __ptr);
17689}
17690#endif
17691
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017692#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17693 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080017694static __inline__ vector signed __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017695vec_xl_be(signed long long __offset, const signed __int128 *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017696 return vec_xl(__offset, __ptr);
17697}
17698
17699static __inline__ vector unsigned __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017700vec_xl_be(signed long long __offset, const unsigned __int128 *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017701 return vec_xl(__offset, __ptr);
17702}
17703#endif
17704#else
17705 #define vec_xl_be vec_xl
17706#endif
17707
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017708#if defined(__POWER10_VECTOR__) && defined(__VSX__) && \
17709 defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017710
17711/* vect_xl_sext */
17712
17713static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017714vec_xl_sext(ptrdiff_t __offset, const signed char *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017715 return (vector unsigned __int128)*(__pointer + __offset);
17716}
17717
17718static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017719vec_xl_sext(ptrdiff_t __offset, const signed short *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017720 return (vector unsigned __int128)*(__pointer + __offset);
17721}
17722
17723static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017724vec_xl_sext(ptrdiff_t __offset, const signed int *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017725 return (vector unsigned __int128)*(__pointer + __offset);
17726}
17727
17728static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017729vec_xl_sext(ptrdiff_t __offset, const signed long long *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017730 return (vector unsigned __int128)*(__pointer + __offset);
17731}
17732
17733/* vec_xl_zext */
17734
17735static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017736vec_xl_zext(ptrdiff_t __offset, const unsigned char *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017737 return (vector unsigned __int128)*(__pointer + __offset);
17738}
17739
17740static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017741vec_xl_zext(ptrdiff_t __offset, const unsigned short *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017742 return (vector unsigned __int128)*(__pointer + __offset);
17743}
17744
17745static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017746vec_xl_zext(ptrdiff_t __offset, const unsigned int *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017747 return (vector unsigned __int128)*(__pointer + __offset);
17748}
17749
17750static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017751vec_xl_zext(ptrdiff_t __offset, const unsigned long long *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017752 return (vector unsigned __int128)*(__pointer + __offset);
17753}
17754
17755#endif
17756
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017757/* vec_xlds */
17758#ifdef __VSX__
17759static __inline__ vector signed long long __ATTRS_o_ai
17760vec_xlds(ptrdiff_t __offset, const signed long long *__ptr) {
17761 signed long long *__addr = (signed long long*)((signed char *)__ptr + __offset);
17762 return (vector signed long long) *__addr;
17763}
17764
17765static __inline__ vector unsigned long long __ATTRS_o_ai
17766vec_xlds(ptrdiff_t __offset, const unsigned long long *__ptr) {
17767 unsigned long long *__addr = (unsigned long long *)((signed char *)__ptr + __offset);
17768 return (unaligned_vec_ull) *__addr;
17769}
17770
17771static __inline__ vector double __ATTRS_o_ai vec_xlds(ptrdiff_t __offset,
17772 const double *__ptr) {
17773 double *__addr = (double*)((signed char *)__ptr + __offset);
17774 return (unaligned_vec_double) *__addr;
17775}
17776
17777/* vec_load_splats */
17778static __inline__ vector signed int __ATTRS_o_ai
17779vec_load_splats(signed long long __offset, const signed int *__ptr) {
17780 signed int *__addr = (signed int*)((signed char *)__ptr + __offset);
17781 return (vector signed int)*__addr;
17782}
17783
17784static __inline__ vector signed int __ATTRS_o_ai
17785vec_load_splats(unsigned long long __offset, const signed int *__ptr) {
17786 signed int *__addr = (signed int*)((signed char *)__ptr + __offset);
17787 return (vector signed int)*__addr;
17788}
17789
17790static __inline__ vector unsigned int __ATTRS_o_ai
17791vec_load_splats(signed long long __offset, const unsigned int *__ptr) {
17792 unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset);
17793 return (vector unsigned int)*__addr;
17794}
17795
17796static __inline__ vector unsigned int __ATTRS_o_ai
17797vec_load_splats(unsigned long long __offset, const unsigned int *__ptr) {
17798 unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset);
17799 return (vector unsigned int)*__addr;
17800}
17801
17802static __inline__ vector float __ATTRS_o_ai
17803vec_load_splats(signed long long __offset, const float *__ptr) {
17804 float *__addr = (float*)((signed char *)__ptr + __offset);
17805 return (vector float)*__addr;
17806}
17807
17808static __inline__ vector float __ATTRS_o_ai
17809vec_load_splats(unsigned long long __offset, const float *__ptr) {
17810 float *__addr = (float*)((signed char *)__ptr + __offset);
17811 return (vector float)*__addr;
17812}
17813#endif
17814
Logan Chien55afb0a2018-10-15 10:42:14 +080017815/* vec_xst */
17816
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017817#define vec_xstd2 vec_xst
17818#define vec_xstw4 vec_xst
17819static inline __ATTRS_o_ai void
17820vec_xst(vector signed char __vec, ptrdiff_t __offset, signed char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017821 *(unaligned_vec_schar *)(__ptr + __offset) = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017822}
17823
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017824static inline __ATTRS_o_ai void
17825vec_xst(vector unsigned char __vec, ptrdiff_t __offset, unsigned char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017826 *(unaligned_vec_uchar *)(__ptr + __offset) = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017827}
17828
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017829static inline __ATTRS_o_ai void
17830vec_xst(vector signed short __vec, ptrdiff_t __offset, signed short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017831 signed char *__addr = (signed char *)__ptr + __offset;
17832 *(unaligned_vec_sshort *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017833}
17834
17835static inline __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017836 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017837 unsigned short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017838 signed char *__addr = (signed char *)__ptr + __offset;
17839 *(unaligned_vec_ushort *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017840}
17841
17842static inline __ATTRS_o_ai void vec_xst(vector signed int __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017843 ptrdiff_t __offset, signed int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017844 signed char *__addr = (signed char *)__ptr + __offset;
17845 *(unaligned_vec_sint *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017846}
17847
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017848static inline __ATTRS_o_ai void
17849vec_xst(vector unsigned int __vec, ptrdiff_t __offset, unsigned int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017850 signed char *__addr = (signed char *)__ptr + __offset;
17851 *(unaligned_vec_uint *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017852}
17853
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017854static inline __ATTRS_o_ai void vec_xst(vector float __vec, ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017855 float *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017856 signed char *__addr = (signed char *)__ptr + __offset;
17857 *(unaligned_vec_float *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017858}
17859
17860#ifdef __VSX__
17861static inline __ATTRS_o_ai void vec_xst(vector signed long long __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017862 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017863 signed long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017864 signed char *__addr = (signed char *)__ptr + __offset;
17865 *(unaligned_vec_sll *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017866}
17867
17868static inline __ATTRS_o_ai void vec_xst(vector unsigned long long __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017869 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017870 unsigned long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017871 signed char *__addr = (signed char *)__ptr + __offset;
17872 *(unaligned_vec_ull *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017873}
17874
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017875static inline __ATTRS_o_ai void vec_xst(vector double __vec, ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017876 double *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017877 signed char *__addr = (signed char *)__ptr + __offset;
17878 *(unaligned_vec_double *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017879}
17880#endif
17881
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017882#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17883 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080017884static inline __ATTRS_o_ai void vec_xst(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017885 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017886 signed __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017887 signed char *__addr = (signed char *)__ptr + __offset;
17888 *(unaligned_vec_si128 *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017889}
17890
17891static inline __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017892 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017893 unsigned __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017894 signed char *__addr = (signed char *)__ptr + __offset;
17895 *(unaligned_vec_ui128 *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017896}
17897#endif
17898
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017899/* vec_xst_trunc */
17900
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017901#if defined(__POWER10_VECTOR__) && defined(__VSX__) && \
17902 defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017903static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017904 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017905 signed char *__ptr) {
17906 *(__ptr + __offset) = (signed char)__vec[0];
17907}
17908
17909static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017910 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017911 unsigned char *__ptr) {
17912 *(__ptr + __offset) = (unsigned char)__vec[0];
17913}
17914
17915static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017916 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017917 signed short *__ptr) {
17918 *(__ptr + __offset) = (signed short)__vec[0];
17919}
17920
17921static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017922 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017923 unsigned short *__ptr) {
17924 *(__ptr + __offset) = (unsigned short)__vec[0];
17925}
17926
17927static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017928 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017929 signed int *__ptr) {
17930 *(__ptr + __offset) = (signed int)__vec[0];
17931}
17932
17933static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017934 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017935 unsigned int *__ptr) {
17936 *(__ptr + __offset) = (unsigned int)__vec[0];
17937}
17938
17939static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017940 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017941 signed long long *__ptr) {
17942 *(__ptr + __offset) = (signed long long)__vec[0];
17943}
17944
17945static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017946 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017947 unsigned long long *__ptr) {
17948 *(__ptr + __offset) = (unsigned long long)__vec[0];
17949}
17950#endif
17951
Logan Chien55afb0a2018-10-15 10:42:14 +080017952/* vec_xst_be */
17953
17954#ifdef __LITTLE_ENDIAN__
17955static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed char __vec,
17956 signed long long __offset,
17957 signed char *__ptr) {
17958 vector signed char __tmp =
17959 __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
17960 13, 12, 11, 10, 9, 8);
Sasha Smundak746b0222020-02-25 09:19:04 -080017961 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
17962 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017963}
17964
17965static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned char __vec,
17966 signed long long __offset,
17967 unsigned char *__ptr) {
17968 vector unsigned char __tmp =
17969 __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
17970 13, 12, 11, 10, 9, 8);
Sasha Smundak746b0222020-02-25 09:19:04 -080017971 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
17972 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017973}
17974
17975static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed short __vec,
17976 signed long long __offset,
17977 signed short *__ptr) {
17978 vector signed short __tmp =
17979 __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
Sasha Smundak746b0222020-02-25 09:19:04 -080017980 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
17981 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017982}
17983
17984static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned short __vec,
17985 signed long long __offset,
17986 unsigned short *__ptr) {
17987 vector unsigned short __tmp =
17988 __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
Sasha Smundak746b0222020-02-25 09:19:04 -080017989 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
17990 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017991}
17992
17993static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed int __vec,
17994 signed long long __offset,
17995 signed int *__ptr) {
17996 __builtin_vsx_stxvw4x_be(__vec, __offset, __ptr);
17997}
17998
17999static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned int __vec,
18000 signed long long __offset,
18001 unsigned int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018002 __builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018003}
18004
18005static __inline__ void __ATTRS_o_ai vec_xst_be(vector float __vec,
18006 signed long long __offset,
18007 float *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018008 __builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018009}
18010
18011#ifdef __VSX__
18012static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed long long __vec,
18013 signed long long __offset,
18014 signed long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018015 __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018016}
18017
18018static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned long long __vec,
18019 signed long long __offset,
18020 unsigned long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018021 __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018022}
18023
18024static __inline__ void __ATTRS_o_ai vec_xst_be(vector double __vec,
18025 signed long long __offset,
18026 double *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018027 __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018028}
18029#endif
18030
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018031#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
18032 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080018033static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed __int128 __vec,
18034 signed long long __offset,
18035 signed __int128 *__ptr) {
18036 vec_xst(__vec, __offset, __ptr);
18037}
18038
18039static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned __int128 __vec,
18040 signed long long __offset,
18041 unsigned __int128 *__ptr) {
18042 vec_xst(__vec, __offset, __ptr);
18043}
18044#endif
18045#else
18046 #define vec_xst_be vec_xst
18047#endif
18048
18049#ifdef __POWER9_VECTOR__
Sasha Smundak746b0222020-02-25 09:19:04 -080018050#define vec_test_data_class(__a, __b) \
18051 _Generic( \
18052 (__a), vector float \
18053 : (vector bool int)__builtin_vsx_xvtstdcsp((vector float)(__a), (__b)), \
18054 vector double \
18055 : (vector bool long long)__builtin_vsx_xvtstdcdp((vector double)(__a), \
18056 (__b)))
Logan Chien55afb0a2018-10-15 10:42:14 +080018057
18058#endif /* #ifdef __POWER9_VECTOR__ */
18059
18060static vector float __ATTRS_o_ai vec_neg(vector float __a) {
18061 return -__a;
18062}
18063
18064#ifdef __VSX__
18065static vector double __ATTRS_o_ai vec_neg(vector double __a) {
18066 return -__a;
18067}
18068
18069#endif
18070
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018071#ifdef __VSX__
Logan Chien55afb0a2018-10-15 10:42:14 +080018072static vector long long __ATTRS_o_ai vec_neg(vector long long __a) {
18073 return -__a;
18074}
18075#endif
18076
18077static vector signed int __ATTRS_o_ai vec_neg(vector signed int __a) {
18078 return -__a;
18079}
18080
18081static vector signed short __ATTRS_o_ai vec_neg(vector signed short __a) {
18082 return -__a;
18083}
18084
18085static vector signed char __ATTRS_o_ai vec_neg(vector signed char __a) {
18086 return -__a;
18087}
18088
18089static vector float __ATTRS_o_ai vec_nabs(vector float __a) {
18090 return - vec_abs(__a);
18091}
18092
18093#ifdef __VSX__
18094static vector double __ATTRS_o_ai vec_nabs(vector double __a) {
18095 return - vec_abs(__a);
18096}
18097
18098#endif
18099
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018100#ifdef __POWER8_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +080018101static vector long long __ATTRS_o_ai vec_nabs(vector long long __a) {
18102 return __builtin_altivec_vminsd(__a, -__a);
18103}
18104#endif
18105
18106static vector signed int __ATTRS_o_ai vec_nabs(vector signed int __a) {
18107 return __builtin_altivec_vminsw(__a, -__a);
18108}
18109
18110static vector signed short __ATTRS_o_ai vec_nabs(vector signed short __a) {
18111 return __builtin_altivec_vminsh(__a, -__a);
18112}
18113
18114static vector signed char __ATTRS_o_ai vec_nabs(vector signed char __a) {
18115 return __builtin_altivec_vminsb(__a, -__a);
18116}
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018117
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018118static vector float __ATTRS_o_ai vec_recipdiv(vector float __a,
18119 vector float __b) {
18120 return __builtin_ppc_recipdivf(__a, __b);
18121}
18122
18123#ifdef __VSX__
18124static vector double __ATTRS_o_ai vec_recipdiv(vector double __a,
18125 vector double __b) {
18126 return __builtin_ppc_recipdivd(__a, __b);
18127}
18128#endif
18129
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018130#ifdef __POWER10_VECTOR__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018131
18132/* vec_extractm */
18133
18134static __inline__ unsigned int __ATTRS_o_ai
18135vec_extractm(vector unsigned char __a) {
18136 return __builtin_altivec_vextractbm(__a);
18137}
18138
18139static __inline__ unsigned int __ATTRS_o_ai
18140vec_extractm(vector unsigned short __a) {
18141 return __builtin_altivec_vextracthm(__a);
18142}
18143
18144static __inline__ unsigned int __ATTRS_o_ai
18145vec_extractm(vector unsigned int __a) {
18146 return __builtin_altivec_vextractwm(__a);
18147}
18148
18149static __inline__ unsigned int __ATTRS_o_ai
18150vec_extractm(vector unsigned long long __a) {
18151 return __builtin_altivec_vextractdm(__a);
18152}
18153
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018154#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018155static __inline__ unsigned int __ATTRS_o_ai
18156vec_extractm(vector unsigned __int128 __a) {
18157 return __builtin_altivec_vextractqm(__a);
18158}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018159#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018160
18161/* vec_expandm */
18162
18163static __inline__ vector unsigned char __ATTRS_o_ai
18164vec_expandm(vector unsigned char __a) {
18165 return __builtin_altivec_vexpandbm(__a);
18166}
18167
18168static __inline__ vector unsigned short __ATTRS_o_ai
18169vec_expandm(vector unsigned short __a) {
18170 return __builtin_altivec_vexpandhm(__a);
18171}
18172
18173static __inline__ vector unsigned int __ATTRS_o_ai
18174vec_expandm(vector unsigned int __a) {
18175 return __builtin_altivec_vexpandwm(__a);
18176}
18177
18178static __inline__ vector unsigned long long __ATTRS_o_ai
18179vec_expandm(vector unsigned long long __a) {
18180 return __builtin_altivec_vexpanddm(__a);
18181}
18182
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018183#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018184static __inline__ vector unsigned __int128 __ATTRS_o_ai
18185vec_expandm(vector unsigned __int128 __a) {
18186 return __builtin_altivec_vexpandqm(__a);
18187}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018188#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018189
18190/* vec_cntm */
18191
18192#define vec_cntm(__a, __mp) \
18193 _Generic((__a), vector unsigned char \
18194 : __builtin_altivec_vcntmbb((__a), (unsigned int)(__mp)), \
18195 vector unsigned short \
18196 : __builtin_altivec_vcntmbh((__a), (unsigned int)(__mp)), \
18197 vector unsigned int \
18198 : __builtin_altivec_vcntmbw((__a), (unsigned int)(__mp)), \
18199 vector unsigned long long \
18200 : __builtin_altivec_vcntmbd((__a), (unsigned int)(__mp)))
18201
18202/* vec_gen[b|h|w|d|q]m */
18203
18204static __inline__ vector unsigned char __ATTRS_o_ai
18205vec_genbm(unsigned long long __bm) {
18206 return __builtin_altivec_mtvsrbm(__bm);
18207}
18208
18209static __inline__ vector unsigned short __ATTRS_o_ai
18210vec_genhm(unsigned long long __bm) {
18211 return __builtin_altivec_mtvsrhm(__bm);
18212}
18213
18214static __inline__ vector unsigned int __ATTRS_o_ai
18215vec_genwm(unsigned long long __bm) {
18216 return __builtin_altivec_mtvsrwm(__bm);
18217}
18218
18219static __inline__ vector unsigned long long __ATTRS_o_ai
18220vec_gendm(unsigned long long __bm) {
18221 return __builtin_altivec_mtvsrdm(__bm);
18222}
18223
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018224#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018225static __inline__ vector unsigned __int128 __ATTRS_o_ai
18226vec_genqm(unsigned long long __bm) {
18227 return __builtin_altivec_mtvsrqm(__bm);
18228}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018229#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018230
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018231/* vec_pdep */
18232
18233static __inline__ vector unsigned long long __ATTRS_o_ai
18234vec_pdep(vector unsigned long long __a, vector unsigned long long __b) {
18235 return __builtin_altivec_vpdepd(__a, __b);
18236}
18237
18238/* vec_pext */
18239
18240static __inline__ vector unsigned long long __ATTRS_o_ai
18241vec_pext(vector unsigned long long __a, vector unsigned long long __b) {
18242 return __builtin_altivec_vpextd(__a, __b);
18243}
18244
18245/* vec_cfuge */
18246
18247static __inline__ vector unsigned long long __ATTRS_o_ai
18248vec_cfuge(vector unsigned long long __a, vector unsigned long long __b) {
18249 return __builtin_altivec_vcfuged(__a, __b);
18250}
18251
18252/* vec_gnb */
18253
18254#define vec_gnb(__a, __b) __builtin_altivec_vgnb(__a, __b)
18255
18256/* vec_ternarylogic */
18257#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018258#ifdef __SIZEOF_INT128__
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018259#define vec_ternarylogic(__a, __b, __c, __imm) \
18260 _Generic((__a), vector unsigned char \
18261 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18262 (vector unsigned long long)(__b), \
18263 (vector unsigned long long)(__c), (__imm)), \
18264 vector unsigned short \
18265 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18266 (vector unsigned long long)(__b), \
18267 (vector unsigned long long)(__c), (__imm)), \
18268 vector unsigned int \
18269 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18270 (vector unsigned long long)(__b), \
18271 (vector unsigned long long)(__c), (__imm)), \
18272 vector unsigned long long \
18273 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18274 (vector unsigned long long)(__b), \
18275 (vector unsigned long long)(__c), (__imm)), \
18276 vector unsigned __int128 \
18277 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18278 (vector unsigned long long)(__b), \
18279 (vector unsigned long long)(__c), (__imm)))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018280#else
18281#define vec_ternarylogic(__a, __b, __c, __imm) \
18282 _Generic((__a), vector unsigned char \
18283 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18284 (vector unsigned long long)(__b), \
18285 (vector unsigned long long)(__c), (__imm)), \
18286 vector unsigned short \
18287 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18288 (vector unsigned long long)(__b), \
18289 (vector unsigned long long)(__c), (__imm)), \
18290 vector unsigned int \
18291 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18292 (vector unsigned long long)(__b), \
18293 (vector unsigned long long)(__c), (__imm)), \
18294 vector unsigned long long \
18295 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18296 (vector unsigned long long)(__b), \
18297 (vector unsigned long long)(__c), (__imm)))
18298#endif /* __SIZEOF_INT128__ */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018299#endif /* __VSX__ */
18300
18301/* vec_genpcvm */
18302
18303#ifdef __VSX__
18304#define vec_genpcvm(__a, __imm) \
18305 _Generic((__a), vector unsigned char \
18306 : __builtin_vsx_xxgenpcvbm((__a), (int)(__imm)), \
18307 vector unsigned short \
18308 : __builtin_vsx_xxgenpcvhm((__a), (int)(__imm)), \
18309 vector unsigned int \
18310 : __builtin_vsx_xxgenpcvwm((__a), (int)(__imm)), \
18311 vector unsigned long long \
18312 : __builtin_vsx_xxgenpcvdm((__a), (int)(__imm)))
18313#endif /* __VSX__ */
18314
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018315/* vec_clr_first */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018316
18317static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018318vec_clr_first(vector signed char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018319#ifdef __LITTLE_ENDIAN__
18320 return __builtin_altivec_vclrrb(__a, __n);
18321#else
18322 return __builtin_altivec_vclrlb( __a, __n);
18323#endif
18324}
18325
18326static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018327vec_clr_first(vector unsigned char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018328#ifdef __LITTLE_ENDIAN__
18329 return __builtin_altivec_vclrrb((vector signed char)__a, __n);
18330#else
18331 return __builtin_altivec_vclrlb((vector signed char)__a, __n);
18332#endif
18333}
18334
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018335/* vec_clr_last */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018336
18337static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018338vec_clr_last(vector signed char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018339#ifdef __LITTLE_ENDIAN__
18340 return __builtin_altivec_vclrlb(__a, __n);
18341#else
18342 return __builtin_altivec_vclrrb( __a, __n);
18343#endif
18344}
18345
18346static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018347vec_clr_last(vector unsigned char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018348#ifdef __LITTLE_ENDIAN__
18349 return __builtin_altivec_vclrlb((vector signed char)__a, __n);
18350#else
18351 return __builtin_altivec_vclrrb((vector signed char)__a, __n);
18352#endif
18353}
18354
18355/* vec_cntlzm */
18356
18357static __inline__ vector unsigned long long __ATTRS_o_ai
18358vec_cntlzm(vector unsigned long long __a, vector unsigned long long __b) {
18359 return __builtin_altivec_vclzdm(__a, __b);
18360}
18361
18362/* vec_cnttzm */
18363
18364static __inline__ vector unsigned long long __ATTRS_o_ai
18365vec_cnttzm(vector unsigned long long __a, vector unsigned long long __b) {
18366 return __builtin_altivec_vctzdm(__a, __b);
18367}
18368
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018369/* vec_mod */
18370
18371static __inline__ vector signed int __ATTRS_o_ai
18372vec_mod(vector signed int __a, vector signed int __b) {
18373 return __a % __b;
18374}
18375
18376static __inline__ vector unsigned int __ATTRS_o_ai
18377vec_mod(vector unsigned int __a, vector unsigned int __b) {
18378 return __a % __b;
18379}
18380
18381static __inline__ vector signed long long __ATTRS_o_ai
18382vec_mod(vector signed long long __a, vector signed long long __b) {
18383 return __a % __b;
18384}
18385
18386static __inline__ vector unsigned long long __ATTRS_o_ai
18387vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
18388 return __a % __b;
18389}
18390
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018391#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018392static __inline__ vector signed __int128 __ATTRS_o_ai
18393vec_mod(vector signed __int128 __a, vector signed __int128 __b) {
18394 return __a % __b;
18395}
18396
18397static __inline__ vector unsigned __int128 __ATTRS_o_ai
18398vec_mod(vector unsigned __int128 __a, vector unsigned __int128 __b) {
18399 return __a % __b;
18400}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018401#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018402
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018403/* vec_sldbi */
18404
18405#define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))
18406
18407/* vec_srdbi */
18408
18409#define vec_srdb(__a, __b, __c) __builtin_altivec_vsrdbi(__a, __b, (__c & 0x7))
18410
18411/* vec_insertl */
18412
18413static __inline__ vector unsigned char __ATTRS_o_ai
18414vec_insertl(unsigned char __a, vector unsigned char __b, unsigned int __c) {
18415#ifdef __LITTLE_ENDIAN__
18416 return __builtin_altivec_vinsbrx(__b, __c, __a);
18417#else
18418 return __builtin_altivec_vinsblx(__b, __c, __a);
18419#endif
18420}
18421
18422static __inline__ vector unsigned short __ATTRS_o_ai
18423vec_insertl(unsigned short __a, vector unsigned short __b, unsigned int __c) {
18424#ifdef __LITTLE_ENDIAN__
18425 return __builtin_altivec_vinshrx(__b, __c, __a);
18426#else
18427 return __builtin_altivec_vinshlx(__b, __c, __a);
18428#endif
18429}
18430
18431static __inline__ vector unsigned int __ATTRS_o_ai
18432vec_insertl(unsigned int __a, vector unsigned int __b, unsigned int __c) {
18433#ifdef __LITTLE_ENDIAN__
18434 return __builtin_altivec_vinswrx(__b, __c, __a);
18435#else
18436 return __builtin_altivec_vinswlx(__b, __c, __a);
18437#endif
18438}
18439
18440static __inline__ vector unsigned long long __ATTRS_o_ai
18441vec_insertl(unsigned long long __a, vector unsigned long long __b,
18442 unsigned int __c) {
18443#ifdef __LITTLE_ENDIAN__
18444 return __builtin_altivec_vinsdrx(__b, __c, __a);
18445#else
18446 return __builtin_altivec_vinsdlx(__b, __c, __a);
18447#endif
18448}
18449
18450static __inline__ vector unsigned char __ATTRS_o_ai
18451vec_insertl(vector unsigned char __a, vector unsigned char __b,
18452 unsigned int __c) {
18453#ifdef __LITTLE_ENDIAN__
18454 return __builtin_altivec_vinsbvrx(__b, __c, __a);
18455#else
18456 return __builtin_altivec_vinsbvlx(__b, __c, __a);
18457#endif
18458}
18459
18460static __inline__ vector unsigned short __ATTRS_o_ai
18461vec_insertl(vector unsigned short __a, vector unsigned short __b,
18462 unsigned int __c) {
18463#ifdef __LITTLE_ENDIAN__
18464 return __builtin_altivec_vinshvrx(__b, __c, __a);
18465#else
18466 return __builtin_altivec_vinshvlx(__b, __c, __a);
18467#endif
18468}
18469
18470static __inline__ vector unsigned int __ATTRS_o_ai
18471vec_insertl(vector unsigned int __a, vector unsigned int __b,
18472 unsigned int __c) {
18473#ifdef __LITTLE_ENDIAN__
18474 return __builtin_altivec_vinswvrx(__b, __c, __a);
18475#else
18476 return __builtin_altivec_vinswvlx(__b, __c, __a);
18477#endif
18478}
18479
18480/* vec_inserth */
18481
18482static __inline__ vector unsigned char __ATTRS_o_ai
18483vec_inserth(unsigned char __a, vector unsigned char __b, unsigned int __c) {
18484#ifdef __LITTLE_ENDIAN__
18485 return __builtin_altivec_vinsblx(__b, __c, __a);
18486#else
18487 return __builtin_altivec_vinsbrx(__b, __c, __a);
18488#endif
18489}
18490
18491static __inline__ vector unsigned short __ATTRS_o_ai
18492vec_inserth(unsigned short __a, vector unsigned short __b, unsigned int __c) {
18493#ifdef __LITTLE_ENDIAN__
18494 return __builtin_altivec_vinshlx(__b, __c, __a);
18495#else
18496 return __builtin_altivec_vinshrx(__b, __c, __a);
18497#endif
18498}
18499
18500static __inline__ vector unsigned int __ATTRS_o_ai
18501vec_inserth(unsigned int __a, vector unsigned int __b, unsigned int __c) {
18502#ifdef __LITTLE_ENDIAN__
18503 return __builtin_altivec_vinswlx(__b, __c, __a);
18504#else
18505 return __builtin_altivec_vinswrx(__b, __c, __a);
18506#endif
18507}
18508
18509static __inline__ vector unsigned long long __ATTRS_o_ai
18510vec_inserth(unsigned long long __a, vector unsigned long long __b,
18511 unsigned int __c) {
18512#ifdef __LITTLE_ENDIAN__
18513 return __builtin_altivec_vinsdlx(__b, __c, __a);
18514#else
18515 return __builtin_altivec_vinsdrx(__b, __c, __a);
18516#endif
18517}
18518
18519static __inline__ vector unsigned char __ATTRS_o_ai
18520vec_inserth(vector unsigned char __a, vector unsigned char __b,
18521 unsigned int __c) {
18522#ifdef __LITTLE_ENDIAN__
18523 return __builtin_altivec_vinsbvlx(__b, __c, __a);
18524#else
18525 return __builtin_altivec_vinsbvrx(__b, __c, __a);
18526#endif
18527}
18528
18529static __inline__ vector unsigned short __ATTRS_o_ai
18530vec_inserth(vector unsigned short __a, vector unsigned short __b,
18531 unsigned int __c) {
18532#ifdef __LITTLE_ENDIAN__
18533 return __builtin_altivec_vinshvlx(__b, __c, __a);
18534#else
18535 return __builtin_altivec_vinshvrx(__b, __c, __a);
18536#endif
18537}
18538
18539static __inline__ vector unsigned int __ATTRS_o_ai
18540vec_inserth(vector unsigned int __a, vector unsigned int __b,
18541 unsigned int __c) {
18542#ifdef __LITTLE_ENDIAN__
18543 return __builtin_altivec_vinswvlx(__b, __c, __a);
18544#else
18545 return __builtin_altivec_vinswvrx(__b, __c, __a);
18546#endif
18547}
18548
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018549/* vec_extractl */
18550
18551static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl(
18552 vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
18553#ifdef __LITTLE_ENDIAN__
18554 return __builtin_altivec_vextdubvrx(__a, __b, __c);
18555#else
18556 vector unsigned long long __ret = __builtin_altivec_vextdubvlx(__a, __b, __c);
18557 return vec_sld(__ret, __ret, 8);
18558#endif
18559}
18560
18561static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl(
18562 vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
18563#ifdef __LITTLE_ENDIAN__
18564 return __builtin_altivec_vextduhvrx(__a, __b, __c);
18565#else
18566 vector unsigned long long __ret = __builtin_altivec_vextduhvlx(__a, __b, __c);
18567 return vec_sld(__ret, __ret, 8);
18568#endif
18569}
18570
18571static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl(
18572 vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
18573#ifdef __LITTLE_ENDIAN__
18574 return __builtin_altivec_vextduwvrx(__a, __b, __c);
18575#else
18576 vector unsigned long long __ret = __builtin_altivec_vextduwvlx(__a, __b, __c);
18577 return vec_sld(__ret, __ret, 8);
18578#endif
18579}
18580
18581static __inline__ vector unsigned long long __ATTRS_o_ai
18582vec_extractl(vector unsigned long long __a, vector unsigned long long __b,
18583 unsigned int __c) {
18584#ifdef __LITTLE_ENDIAN__
18585 return __builtin_altivec_vextddvrx(__a, __b, __c);
18586#else
18587 vector unsigned long long __ret = __builtin_altivec_vextddvlx(__a, __b, __c);
18588 return vec_sld(__ret, __ret, 8);
18589#endif
18590}
18591
18592/* vec_extracth */
18593
18594static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth(
18595 vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
18596#ifdef __LITTLE_ENDIAN__
18597 return __builtin_altivec_vextdubvlx(__a, __b, __c);
18598#else
18599 vector unsigned long long __ret = __builtin_altivec_vextdubvrx(__a, __b, __c);
18600 return vec_sld(__ret, __ret, 8);
18601#endif
18602}
18603
18604static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth(
18605 vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
18606#ifdef __LITTLE_ENDIAN__
18607 return __builtin_altivec_vextduhvlx(__a, __b, __c);
18608#else
18609 vector unsigned long long __ret = __builtin_altivec_vextduhvrx(__a, __b, __c);
18610 return vec_sld(__ret, __ret, 8);
18611#endif
18612}
18613
18614static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth(
18615 vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
18616#ifdef __LITTLE_ENDIAN__
18617 return __builtin_altivec_vextduwvlx(__a, __b, __c);
18618#else
18619 vector unsigned long long __ret = __builtin_altivec_vextduwvrx(__a, __b, __c);
18620 return vec_sld(__ret, __ret, 8);
18621#endif
18622}
18623
18624static __inline__ vector unsigned long long __ATTRS_o_ai
18625vec_extracth(vector unsigned long long __a, vector unsigned long long __b,
18626 unsigned int __c) {
18627#ifdef __LITTLE_ENDIAN__
18628 return __builtin_altivec_vextddvlx(__a, __b, __c);
18629#else
18630 vector unsigned long long __ret = __builtin_altivec_vextddvrx(__a, __b, __c);
18631 return vec_sld(__ret, __ret, 8);
18632#endif
18633}
18634
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018635#ifdef __VSX__
18636
18637/* vec_permx */
18638
18639#define vec_permx(__a, __b, __c, __d) \
18640 __builtin_vsx_xxpermx((__a), (__b), (__c), (__d))
18641
18642/* vec_blendv */
18643
18644static __inline__ vector signed char __ATTRS_o_ai
18645vec_blendv(vector signed char __a, vector signed char __b,
18646 vector unsigned char __c) {
18647 return __builtin_vsx_xxblendvb(__a, __b, __c);
18648}
18649
18650static __inline__ vector unsigned char __ATTRS_o_ai
18651vec_blendv(vector unsigned char __a, vector unsigned char __b,
18652 vector unsigned char __c) {
18653 return __builtin_vsx_xxblendvb(__a, __b, __c);
18654}
18655
18656static __inline__ vector signed short __ATTRS_o_ai
18657vec_blendv(vector signed short __a, vector signed short __b,
18658 vector unsigned short __c) {
18659 return __builtin_vsx_xxblendvh(__a, __b, __c);
18660}
18661
18662static __inline__ vector unsigned short __ATTRS_o_ai
18663vec_blendv(vector unsigned short __a, vector unsigned short __b,
18664 vector unsigned short __c) {
18665 return __builtin_vsx_xxblendvh(__a, __b, __c);
18666}
18667
18668static __inline__ vector signed int __ATTRS_o_ai
18669vec_blendv(vector signed int __a, vector signed int __b,
18670 vector unsigned int __c) {
18671 return __builtin_vsx_xxblendvw(__a, __b, __c);
18672}
18673
18674static __inline__ vector unsigned int __ATTRS_o_ai
18675vec_blendv(vector unsigned int __a, vector unsigned int __b,
18676 vector unsigned int __c) {
18677 return __builtin_vsx_xxblendvw(__a, __b, __c);
18678}
18679
18680static __inline__ vector signed long long __ATTRS_o_ai
18681vec_blendv(vector signed long long __a, vector signed long long __b,
18682 vector unsigned long long __c) {
18683 return __builtin_vsx_xxblendvd(__a, __b, __c);
18684}
18685
18686static __inline__ vector unsigned long long __ATTRS_o_ai
18687vec_blendv(vector unsigned long long __a, vector unsigned long long __b,
18688 vector unsigned long long __c) {
18689 return __builtin_vsx_xxblendvd(__a, __b, __c);
18690}
18691
18692static __inline__ vector float __ATTRS_o_ai
18693vec_blendv(vector float __a, vector float __b, vector unsigned int __c) {
18694 return __builtin_vsx_xxblendvw(__a, __b, __c);
18695}
18696
18697static __inline__ vector double __ATTRS_o_ai
18698vec_blendv(vector double __a, vector double __b,
18699 vector unsigned long long __c) {
18700 return __builtin_vsx_xxblendvd(__a, __b, __c);
18701}
18702
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018703/* vec_replace_elt */
18704
18705#define vec_replace_elt __builtin_altivec_vec_replace_elt
18706
18707/* vec_replace_unaligned */
18708
18709#define vec_replace_unaligned __builtin_altivec_vec_replace_unaligned
18710
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018711/* vec_splati */
18712
18713#define vec_splati(__a) \
18714 _Generic((__a), signed int \
18715 : ((vector signed int)__a), unsigned int \
18716 : ((vector unsigned int)__a), float \
18717 : ((vector float)__a))
18718
18719/* vec_spatid */
18720
18721static __inline__ vector double __ATTRS_o_ai vec_splatid(const float __a) {
18722 return ((vector double)((double)__a));
18723}
18724
18725/* vec_splati_ins */
18726
18727static __inline__ vector signed int __ATTRS_o_ai vec_splati_ins(
18728 vector signed int __a, const unsigned int __b, const signed int __c) {
18729#ifdef __LITTLE_ENDIAN__
18730 __a[1 - __b] = __c;
18731 __a[3 - __b] = __c;
18732#else
18733 __a[__b] = __c;
18734 __a[2 + __b] = __c;
18735#endif
18736 return __a;
18737}
18738
18739static __inline__ vector unsigned int __ATTRS_o_ai vec_splati_ins(
18740 vector unsigned int __a, const unsigned int __b, const unsigned int __c) {
18741#ifdef __LITTLE_ENDIAN__
18742 __a[1 - __b] = __c;
18743 __a[3 - __b] = __c;
18744#else
18745 __a[__b] = __c;
18746 __a[2 + __b] = __c;
18747#endif
18748 return __a;
18749}
18750
18751static __inline__ vector float __ATTRS_o_ai
18752vec_splati_ins(vector float __a, const unsigned int __b, const float __c) {
18753#ifdef __LITTLE_ENDIAN__
18754 __a[1 - __b] = __c;
18755 __a[3 - __b] = __c;
18756#else
18757 __a[__b] = __c;
18758 __a[2 + __b] = __c;
18759#endif
18760 return __a;
18761}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018762
18763/* vec_test_lsbb_all_ones */
18764
18765static __inline__ int __ATTRS_o_ai
18766vec_test_lsbb_all_ones(vector unsigned char __a) {
18767 return __builtin_vsx_xvtlsbb(__a, 1);
18768}
18769
18770/* vec_test_lsbb_all_zeros */
18771
18772static __inline__ int __ATTRS_o_ai
18773vec_test_lsbb_all_zeros(vector unsigned char __a) {
18774 return __builtin_vsx_xvtlsbb(__a, 0);
18775}
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018776#endif /* __VSX__ */
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018777
18778/* vec_stril */
18779
18780static __inline__ vector unsigned char __ATTRS_o_ai
18781vec_stril(vector unsigned char __a) {
18782#ifdef __LITTLE_ENDIAN__
18783 return __builtin_altivec_vstribr((vector signed char)__a);
18784#else
18785 return __builtin_altivec_vstribl((vector signed char)__a);
18786#endif
18787}
18788
18789static __inline__ vector signed char __ATTRS_o_ai
18790vec_stril(vector signed char __a) {
18791#ifdef __LITTLE_ENDIAN__
18792 return __builtin_altivec_vstribr(__a);
18793#else
18794 return __builtin_altivec_vstribl(__a);
18795#endif
18796}
18797
18798static __inline__ vector unsigned short __ATTRS_o_ai
18799vec_stril(vector unsigned short __a) {
18800#ifdef __LITTLE_ENDIAN__
18801 return __builtin_altivec_vstrihr((vector signed short)__a);
18802#else
18803 return __builtin_altivec_vstrihl((vector signed short)__a);
18804#endif
18805}
18806
18807static __inline__ vector signed short __ATTRS_o_ai
18808vec_stril(vector signed short __a) {
18809#ifdef __LITTLE_ENDIAN__
18810 return __builtin_altivec_vstrihr(__a);
18811#else
18812 return __builtin_altivec_vstrihl(__a);
18813#endif
18814}
18815
18816/* vec_stril_p */
18817
18818static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned char __a) {
18819#ifdef __LITTLE_ENDIAN__
18820 return __builtin_altivec_vstribr_p(__CR6_EQ, (vector signed char)__a);
18821#else
18822 return __builtin_altivec_vstribl_p(__CR6_EQ, (vector signed char)__a);
18823#endif
18824}
18825
18826static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed char __a) {
18827#ifdef __LITTLE_ENDIAN__
18828 return __builtin_altivec_vstribr_p(__CR6_EQ, __a);
18829#else
18830 return __builtin_altivec_vstribl_p(__CR6_EQ, __a);
18831#endif
18832}
18833
18834static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned short __a) {
18835#ifdef __LITTLE_ENDIAN__
18836 return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a);
18837#else
18838 return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a);
18839#endif
18840}
18841
18842static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed short __a) {
18843#ifdef __LITTLE_ENDIAN__
18844 return __builtin_altivec_vstrihr_p(__CR6_EQ, __a);
18845#else
18846 return __builtin_altivec_vstrihl_p(__CR6_EQ, __a);
18847#endif
18848}
18849
18850/* vec_strir */
18851
18852static __inline__ vector unsigned char __ATTRS_o_ai
18853vec_strir(vector unsigned char __a) {
18854#ifdef __LITTLE_ENDIAN__
18855 return __builtin_altivec_vstribl((vector signed char)__a);
18856#else
18857 return __builtin_altivec_vstribr((vector signed char)__a);
18858#endif
18859}
18860
18861static __inline__ vector signed char __ATTRS_o_ai
18862vec_strir(vector signed char __a) {
18863#ifdef __LITTLE_ENDIAN__
18864 return __builtin_altivec_vstribl(__a);
18865#else
18866 return __builtin_altivec_vstribr(__a);
18867#endif
18868}
18869
18870static __inline__ vector unsigned short __ATTRS_o_ai
18871vec_strir(vector unsigned short __a) {
18872#ifdef __LITTLE_ENDIAN__
18873 return __builtin_altivec_vstrihl((vector signed short)__a);
18874#else
18875 return __builtin_altivec_vstrihr((vector signed short)__a);
18876#endif
18877}
18878
18879static __inline__ vector signed short __ATTRS_o_ai
18880vec_strir(vector signed short __a) {
18881#ifdef __LITTLE_ENDIAN__
18882 return __builtin_altivec_vstrihl(__a);
18883#else
18884 return __builtin_altivec_vstrihr(__a);
18885#endif
18886}
18887
18888/* vec_strir_p */
18889
18890static __inline__ int __ATTRS_o_ai vec_strir_p(vector unsigned char __a) {
18891#ifdef __LITTLE_ENDIAN__
18892 return __builtin_altivec_vstribl_p(__CR6_EQ, (vector signed char)__a);
18893#else
18894 return __builtin_altivec_vstribr_p(__CR6_EQ, (vector signed char)__a);
18895#endif
18896}
18897
18898static __inline__ int __ATTRS_o_ai vec_strir_p(vector signed char __a) {
18899#ifdef __LITTLE_ENDIAN__
18900 return __builtin_altivec_vstribl_p(__CR6_EQ, __a);
18901#else
18902 return __builtin_altivec_vstribr_p(__CR6_EQ, __a);
18903#endif
18904}
18905
18906static __inline__ int __ATTRS_o_ai vec_strir_p(vector unsigned short __a) {
18907#ifdef __LITTLE_ENDIAN__
18908 return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a);
18909#else
18910 return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a);
18911#endif
18912}
18913
18914static __inline__ int __ATTRS_o_ai vec_strir_p(vector signed short __a) {
18915#ifdef __LITTLE_ENDIAN__
18916 return __builtin_altivec_vstrihl_p(__CR6_EQ, __a);
18917#else
18918 return __builtin_altivec_vstrihr_p(__CR6_EQ, __a);
18919#endif
18920}
18921
18922/* vs[l | r | ra] */
18923
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018924#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018925static __inline__ vector unsigned __int128 __ATTRS_o_ai
18926vec_sl(vector unsigned __int128 __a, vector unsigned __int128 __b) {
18927 return __a << (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
18928 __CHAR_BIT__));
18929}
18930
18931static __inline__ vector signed __int128 __ATTRS_o_ai
18932vec_sl(vector signed __int128 __a, vector unsigned __int128 __b) {
18933 return __a << (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
18934 __CHAR_BIT__));
18935}
18936
18937static __inline__ vector unsigned __int128 __ATTRS_o_ai
18938vec_sr(vector unsigned __int128 __a, vector unsigned __int128 __b) {
18939 return __a >> (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
18940 __CHAR_BIT__));
18941}
18942
18943static __inline__ vector signed __int128 __ATTRS_o_ai
18944vec_sr(vector signed __int128 __a, vector unsigned __int128 __b) {
18945 return (
18946 vector signed __int128)(((vector unsigned __int128)__a) >>
18947 (__b %
18948 (vector unsigned __int128)(sizeof(
18949 unsigned __int128) *
18950 __CHAR_BIT__)));
18951}
18952
18953static __inline__ vector unsigned __int128 __ATTRS_o_ai
18954vec_sra(vector unsigned __int128 __a, vector unsigned __int128 __b) {
18955 return (
18956 vector unsigned __int128)(((vector signed __int128)__a) >>
18957 (__b %
18958 (vector unsigned __int128)(sizeof(
18959 unsigned __int128) *
18960 __CHAR_BIT__)));
18961}
18962
18963static __inline__ vector signed __int128 __ATTRS_o_ai
18964vec_sra(vector signed __int128 __a, vector unsigned __int128 __b) {
18965 return __a >> (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
18966 __CHAR_BIT__));
18967}
18968
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018969#endif /* __SIZEOF_INT128__ */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018970#endif /* __POWER10_VECTOR__ */
18971
Logan Chien2833ffb2018-10-09 10:03:24 +080018972#undef __ATTRS_o_ai
18973
18974#endif /* __ALTIVEC_H */