blob: 55195b0781fb3ba74399467108e2ae1d86ab4b85 [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
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080022#define __CR6_GT 4
23#define __CR6_GT_REV 5
24#define __CR6_SO 6
25#define __CR6_SO_REV 7
Logan Chien2833ffb2018-10-09 10:03:24 +080026
Logan Chien55afb0a2018-10-15 10:42:14 +080027/* Constants for vec_test_data_class */
28#define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0)
29#define __VEC_CLASS_FP_SUBNORMAL_P (1 << 1)
30#define __VEC_CLASS_FP_SUBNORMAL (__VEC_CLASS_FP_SUBNORMAL_P | \
31 __VEC_CLASS_FP_SUBNORMAL_N)
32#define __VEC_CLASS_FP_ZERO_N (1<<2)
33#define __VEC_CLASS_FP_ZERO_P (1<<3)
34#define __VEC_CLASS_FP_ZERO (__VEC_CLASS_FP_ZERO_P | \
35 __VEC_CLASS_FP_ZERO_N)
36#define __VEC_CLASS_FP_INFINITY_N (1<<4)
37#define __VEC_CLASS_FP_INFINITY_P (1<<5)
38#define __VEC_CLASS_FP_INFINITY (__VEC_CLASS_FP_INFINITY_P | \
39 __VEC_CLASS_FP_INFINITY_N)
40#define __VEC_CLASS_FP_NAN (1<<6)
41#define __VEC_CLASS_FP_NOT_NORMAL (__VEC_CLASS_FP_NAN | \
42 __VEC_CLASS_FP_SUBNORMAL | \
43 __VEC_CLASS_FP_ZERO | \
44 __VEC_CLASS_FP_INFINITY)
45
Logan Chien2833ffb2018-10-09 10:03:24 +080046#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
47
Logan Chien55afb0a2018-10-15 10:42:14 +080048#include <stddef.h>
Logan Chien55afb0a2018-10-15 10:42:14 +080049
Logan Chien2833ffb2018-10-09 10:03:24 +080050static __inline__ vector signed char __ATTRS_o_ai vec_perm(
51 vector signed char __a, vector signed char __b, vector unsigned char __c);
52
53static __inline__ vector unsigned char __ATTRS_o_ai
54vec_perm(vector unsigned char __a, vector unsigned char __b,
55 vector unsigned char __c);
56
57static __inline__ vector bool char __ATTRS_o_ai
58vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c);
59
60static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a,
61 vector signed short __b,
62 vector unsigned char __c);
63
64static __inline__ vector unsigned short __ATTRS_o_ai
65vec_perm(vector unsigned short __a, vector unsigned short __b,
66 vector unsigned char __c);
67
68static __inline__ vector bool short __ATTRS_o_ai vec_perm(
69 vector bool short __a, vector bool short __b, vector unsigned char __c);
70
71static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a,
72 vector pixel __b,
73 vector unsigned char __c);
74
75static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a,
76 vector signed int __b,
77 vector unsigned char __c);
78
79static __inline__ vector unsigned int __ATTRS_o_ai vec_perm(
80 vector unsigned int __a, vector unsigned int __b, vector unsigned char __c);
81
82static __inline__ vector bool int __ATTRS_o_ai
83vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c);
84
85static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a,
86 vector float __b,
87 vector unsigned char __c);
88
89#ifdef __VSX__
90static __inline__ vector long long __ATTRS_o_ai
91vec_perm(vector signed long long __a, vector signed long long __b,
92 vector unsigned char __c);
93
94static __inline__ vector unsigned long long __ATTRS_o_ai
95vec_perm(vector unsigned long long __a, vector unsigned long long __b,
96 vector unsigned char __c);
97
98static __inline__ vector bool long long __ATTRS_o_ai
99vec_perm(vector bool long long __a, vector bool long long __b,
100 vector unsigned char __c);
101
102static __inline__ vector double __ATTRS_o_ai vec_perm(vector double __a,
103 vector double __b,
104 vector unsigned char __c);
105#endif
106
107static __inline__ vector unsigned char __ATTRS_o_ai
108vec_xor(vector unsigned char __a, vector unsigned char __b);
109
110/* vec_abs */
111
112#define __builtin_altivec_abs_v16qi vec_abs
113#define __builtin_altivec_abs_v8hi vec_abs
114#define __builtin_altivec_abs_v4si vec_abs
115
116static __inline__ vector signed char __ATTRS_o_ai
117vec_abs(vector signed char __a) {
118 return __builtin_altivec_vmaxsb(__a, -__a);
119}
120
121static __inline__ vector signed short __ATTRS_o_ai
122vec_abs(vector signed short __a) {
123 return __builtin_altivec_vmaxsh(__a, -__a);
124}
125
126static __inline__ vector signed int __ATTRS_o_ai
127vec_abs(vector signed int __a) {
128 return __builtin_altivec_vmaxsw(__a, -__a);
129}
130
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800131#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800132static __inline__ vector signed long long __ATTRS_o_ai
133vec_abs(vector signed long long __a) {
134 return __builtin_altivec_vmaxsd(__a, -__a);
135}
136#endif
137
138static __inline__ vector float __ATTRS_o_ai vec_abs(vector float __a) {
139#ifdef __VSX__
140 return __builtin_vsx_xvabssp(__a);
141#else
142 vector unsigned int __res =
143 (vector unsigned int)__a & (vector unsigned int)(0x7FFFFFFF);
144 return (vector float)__res;
145#endif
146}
147
Logan Chien55afb0a2018-10-15 10:42:14 +0800148#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +0800149static __inline__ vector double __ATTRS_o_ai vec_abs(vector double __a) {
150 return __builtin_vsx_xvabsdp(__a);
151}
152#endif
153
154/* vec_abss */
155#define __builtin_altivec_abss_v16qi vec_abss
156#define __builtin_altivec_abss_v8hi vec_abss
157#define __builtin_altivec_abss_v4si vec_abss
158
159static __inline__ vector signed char __ATTRS_o_ai
160vec_abss(vector signed char __a) {
161 return __builtin_altivec_vmaxsb(
162 __a, __builtin_altivec_vsubsbs((vector signed char)(0), __a));
163}
164
165static __inline__ vector signed short __ATTRS_o_ai
166vec_abss(vector signed short __a) {
167 return __builtin_altivec_vmaxsh(
168 __a, __builtin_altivec_vsubshs((vector signed short)(0), __a));
169}
170
171static __inline__ vector signed int __ATTRS_o_ai
172vec_abss(vector signed int __a) {
173 return __builtin_altivec_vmaxsw(
174 __a, __builtin_altivec_vsubsws((vector signed int)(0), __a));
175}
176
Logan Chien55afb0a2018-10-15 10:42:14 +0800177/* vec_absd */
178#if defined(__POWER9_VECTOR__)
179
180static __inline__ vector unsigned char __ATTRS_o_ai
181vec_absd(vector unsigned char __a, vector unsigned char __b) {
182 return __builtin_altivec_vabsdub(__a, __b);
183}
184
185static __inline__ vector unsigned short __ATTRS_o_ai
186vec_absd(vector unsigned short __a, vector unsigned short __b) {
187 return __builtin_altivec_vabsduh(__a, __b);
188}
189
190static __inline__ vector unsigned int __ATTRS_o_ai
191vec_absd(vector unsigned int __a, vector unsigned int __b) {
192 return __builtin_altivec_vabsduw(__a, __b);
193}
194
195#endif /* End __POWER9_VECTOR__ */
196
Logan Chien2833ffb2018-10-09 10:03:24 +0800197/* vec_add */
198
199static __inline__ vector signed char __ATTRS_o_ai
200vec_add(vector signed char __a, vector signed char __b) {
201 return __a + __b;
202}
203
204static __inline__ vector signed char __ATTRS_o_ai
205vec_add(vector bool char __a, vector signed char __b) {
206 return (vector signed char)__a + __b;
207}
208
209static __inline__ vector signed char __ATTRS_o_ai
210vec_add(vector signed char __a, vector bool char __b) {
211 return __a + (vector signed char)__b;
212}
213
214static __inline__ vector unsigned char __ATTRS_o_ai
215vec_add(vector unsigned char __a, vector unsigned char __b) {
216 return __a + __b;
217}
218
219static __inline__ vector unsigned char __ATTRS_o_ai
220vec_add(vector bool char __a, vector unsigned char __b) {
221 return (vector unsigned char)__a + __b;
222}
223
224static __inline__ vector unsigned char __ATTRS_o_ai
225vec_add(vector unsigned char __a, vector bool char __b) {
226 return __a + (vector unsigned char)__b;
227}
228
229static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a,
230 vector short __b) {
231 return __a + __b;
232}
233
234static __inline__ vector short __ATTRS_o_ai vec_add(vector bool short __a,
235 vector short __b) {
236 return (vector short)__a + __b;
237}
238
239static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a,
240 vector bool short __b) {
241 return __a + (vector short)__b;
242}
243
244static __inline__ vector unsigned short __ATTRS_o_ai
245vec_add(vector unsigned short __a, vector unsigned short __b) {
246 return __a + __b;
247}
248
249static __inline__ vector unsigned short __ATTRS_o_ai
250vec_add(vector bool short __a, vector unsigned short __b) {
251 return (vector unsigned short)__a + __b;
252}
253
254static __inline__ vector unsigned short __ATTRS_o_ai
255vec_add(vector unsigned short __a, vector bool short __b) {
256 return __a + (vector unsigned short)__b;
257}
258
259static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a,
260 vector int __b) {
261 return __a + __b;
262}
263
264static __inline__ vector int __ATTRS_o_ai vec_add(vector bool int __a,
265 vector int __b) {
266 return (vector int)__a + __b;
267}
268
269static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a,
270 vector bool int __b) {
271 return __a + (vector int)__b;
272}
273
274static __inline__ vector unsigned int __ATTRS_o_ai
275vec_add(vector unsigned int __a, vector unsigned int __b) {
276 return __a + __b;
277}
278
279static __inline__ vector unsigned int __ATTRS_o_ai
280vec_add(vector bool int __a, vector unsigned int __b) {
281 return (vector unsigned int)__a + __b;
282}
283
284static __inline__ vector unsigned int __ATTRS_o_ai
285vec_add(vector unsigned int __a, vector bool int __b) {
286 return __a + (vector unsigned int)__b;
287}
288
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800289#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800290static __inline__ vector signed long long __ATTRS_o_ai
291vec_add(vector signed long long __a, vector signed long long __b) {
292 return __a + __b;
293}
294
295static __inline__ vector unsigned long long __ATTRS_o_ai
296vec_add(vector unsigned long long __a, vector unsigned long long __b) {
297 return __a + __b;
298}
299
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700300#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800301static __inline__ vector signed __int128 __ATTRS_o_ai
302vec_add(vector signed __int128 __a, vector signed __int128 __b) {
303 return __a + __b;
304}
305
306static __inline__ vector unsigned __int128 __ATTRS_o_ai
307vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) {
308 return __a + __b;
309}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700310#endif
311
312static __inline__ vector unsigned char __attribute__((__always_inline__))
313vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
314 return __builtin_altivec_vadduqm(__a, __b);
315}
316#elif defined(__VSX__)
317static __inline__ vector signed long long __ATTRS_o_ai
318vec_add(vector signed long long __a, vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800319#ifdef __LITTLE_ENDIAN__
320 // Little endian systems on CPU's prior to Power8 don't really exist
321 // so scalarizing is fine.
322 return __a + __b;
323#else
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700324 vector unsigned int __res =
325 (vector unsigned int)__a + (vector unsigned int)__b;
326 vector unsigned int __carry = __builtin_altivec_vaddcuw(
327 (vector unsigned int)__a, (vector unsigned int)__b);
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800328 __carry = __builtin_shufflevector((vector unsigned char)__carry,
329 (vector unsigned char)__carry, 0, 0, 0, 7,
330 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700331 return (vector signed long long)(__res + __carry);
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800332#endif
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700333}
334
335static __inline__ vector unsigned long long __ATTRS_o_ai
336vec_add(vector unsigned long long __a, vector unsigned long long __b) {
337 return (vector unsigned long long)vec_add((vector signed long long)__a,
338 (vector signed long long)__b);
339}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800340#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800341
342static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
343 vector float __b) {
344 return __a + __b;
345}
346
347#ifdef __VSX__
348static __inline__ vector double __ATTRS_o_ai vec_add(vector double __a,
349 vector double __b) {
350 return __a + __b;
351}
352#endif // __VSX__
353
354/* vec_adde */
355
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800356#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700357#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800358static __inline__ vector signed __int128 __ATTRS_o_ai
359vec_adde(vector signed __int128 __a, vector signed __int128 __b,
360 vector signed __int128 __c) {
361 return __builtin_altivec_vaddeuqm(__a, __b, __c);
362}
363
364static __inline__ vector unsigned __int128 __ATTRS_o_ai
365vec_adde(vector unsigned __int128 __a, vector unsigned __int128 __b,
366 vector unsigned __int128 __c) {
367 return __builtin_altivec_vaddeuqm(__a, __b, __c);
368}
369#endif
370
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700371static __inline__ vector unsigned char __attribute__((__always_inline__))
372vec_adde_u128(vector unsigned char __a, vector unsigned char __b,
373 vector unsigned char __c) {
374 return (vector unsigned char)__builtin_altivec_vaddeuqm(__a, __b, __c);
375}
376#endif
377
Logan Chien55afb0a2018-10-15 10:42:14 +0800378static __inline__ vector signed int __ATTRS_o_ai
379vec_adde(vector signed int __a, vector signed int __b,
380 vector signed int __c) {
381 vector signed int __mask = {1, 1, 1, 1};
382 vector signed int __carry = __c & __mask;
383 return vec_add(vec_add(__a, __b), __carry);
384}
385
386static __inline__ vector unsigned int __ATTRS_o_ai
387vec_adde(vector unsigned int __a, vector unsigned int __b,
388 vector unsigned int __c) {
389 vector unsigned int __mask = {1, 1, 1, 1};
390 vector unsigned int __carry = __c & __mask;
391 return vec_add(vec_add(__a, __b), __carry);
392}
393
Logan Chien2833ffb2018-10-09 10:03:24 +0800394/* vec_addec */
395
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800396#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700397#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800398static __inline__ vector signed __int128 __ATTRS_o_ai
399vec_addec(vector signed __int128 __a, vector signed __int128 __b,
400 vector signed __int128 __c) {
401 return __builtin_altivec_vaddecuq(__a, __b, __c);
402}
403
404static __inline__ vector unsigned __int128 __ATTRS_o_ai
405vec_addec(vector unsigned __int128 __a, vector unsigned __int128 __b,
406 vector unsigned __int128 __c) {
407 return __builtin_altivec_vaddecuq(__a, __b, __c);
408}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700409#endif
410
411static __inline__ vector unsigned char __attribute__((__always_inline__))
412vec_addec_u128(vector unsigned char __a, vector unsigned char __b,
413 vector unsigned char __c) {
414 return (vector unsigned char)__builtin_altivec_vaddecuq(__a, __b, __c);
415}
Logan Chien55afb0a2018-10-15 10:42:14 +0800416
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800417#ifdef __powerpc64__
Logan Chien55afb0a2018-10-15 10:42:14 +0800418static __inline__ vector signed int __ATTRS_o_ai
419vec_addec(vector signed int __a, vector signed int __b,
420 vector signed int __c) {
421
422 signed int __result[4];
423 for (int i = 0; i < 4; i++) {
424 unsigned int __tempa = (unsigned int) __a[i];
425 unsigned int __tempb = (unsigned int) __b[i];
426 unsigned int __tempc = (unsigned int) __c[i];
427 __tempc = __tempc & 0x00000001;
428 unsigned long long __longa = (unsigned long long) __tempa;
429 unsigned long long __longb = (unsigned long long) __tempb;
430 unsigned long long __longc = (unsigned long long) __tempc;
431 unsigned long long __sum = __longa + __longb + __longc;
432 unsigned long long __res = (__sum >> 32) & 0x01;
433 unsigned long long __tempres = (unsigned int) __res;
434 __result[i] = (signed int) __tempres;
435 }
436
437 vector signed int ret = { __result[0], __result[1], __result[2], __result[3] };
438 return ret;
439}
440
441static __inline__ vector unsigned int __ATTRS_o_ai
442vec_addec(vector unsigned int __a, vector unsigned int __b,
443 vector unsigned int __c) {
444
445 unsigned int __result[4];
446 for (int i = 0; i < 4; i++) {
447 unsigned int __tempc = __c[i] & 1;
448 unsigned long long __longa = (unsigned long long) __a[i];
449 unsigned long long __longb = (unsigned long long) __b[i];
450 unsigned long long __longc = (unsigned long long) __tempc;
451 unsigned long long __sum = __longa + __longb + __longc;
452 unsigned long long __res = (__sum >> 32) & 0x01;
453 unsigned long long __tempres = (unsigned int) __res;
454 __result[i] = (signed int) __tempres;
455 }
456
457 vector unsigned int ret = { __result[0], __result[1], __result[2], __result[3] };
458 return ret;
459}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800460#endif // __powerpc64__
461#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +0800462
463/* vec_vaddubm */
464
465#define __builtin_altivec_vaddubm vec_vaddubm
466
467static __inline__ vector signed char __ATTRS_o_ai
468vec_vaddubm(vector signed char __a, vector signed char __b) {
469 return __a + __b;
470}
471
472static __inline__ vector signed char __ATTRS_o_ai
473vec_vaddubm(vector bool char __a, vector signed char __b) {
474 return (vector signed char)__a + __b;
475}
476
477static __inline__ vector signed char __ATTRS_o_ai
478vec_vaddubm(vector signed char __a, vector bool char __b) {
479 return __a + (vector signed char)__b;
480}
481
482static __inline__ vector unsigned char __ATTRS_o_ai
483vec_vaddubm(vector unsigned char __a, vector unsigned char __b) {
484 return __a + __b;
485}
486
487static __inline__ vector unsigned char __ATTRS_o_ai
488vec_vaddubm(vector bool char __a, vector unsigned char __b) {
489 return (vector unsigned char)__a + __b;
490}
491
492static __inline__ vector unsigned char __ATTRS_o_ai
493vec_vaddubm(vector unsigned char __a, vector bool char __b) {
494 return __a + (vector unsigned char)__b;
495}
496
497/* vec_vadduhm */
498
499#define __builtin_altivec_vadduhm vec_vadduhm
500
501static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
502 vector short __b) {
503 return __a + __b;
504}
505
506static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector bool short __a,
507 vector short __b) {
508 return (vector short)__a + __b;
509}
510
511static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
512 vector bool short __b) {
513 return __a + (vector short)__b;
514}
515
516static __inline__ vector unsigned short __ATTRS_o_ai
517vec_vadduhm(vector unsigned short __a, vector unsigned short __b) {
518 return __a + __b;
519}
520
521static __inline__ vector unsigned short __ATTRS_o_ai
522vec_vadduhm(vector bool short __a, vector unsigned short __b) {
523 return (vector unsigned short)__a + __b;
524}
525
526static __inline__ vector unsigned short __ATTRS_o_ai
527vec_vadduhm(vector unsigned short __a, vector bool short __b) {
528 return __a + (vector unsigned short)__b;
529}
530
531/* vec_vadduwm */
532
533#define __builtin_altivec_vadduwm vec_vadduwm
534
535static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
536 vector int __b) {
537 return __a + __b;
538}
539
540static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector bool int __a,
541 vector int __b) {
542 return (vector int)__a + __b;
543}
544
545static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
546 vector bool int __b) {
547 return __a + (vector int)__b;
548}
549
550static __inline__ vector unsigned int __ATTRS_o_ai
551vec_vadduwm(vector unsigned int __a, vector unsigned int __b) {
552 return __a + __b;
553}
554
555static __inline__ vector unsigned int __ATTRS_o_ai
556vec_vadduwm(vector bool int __a, vector unsigned int __b) {
557 return (vector unsigned int)__a + __b;
558}
559
560static __inline__ vector unsigned int __ATTRS_o_ai
561vec_vadduwm(vector unsigned int __a, vector bool int __b) {
562 return __a + (vector unsigned int)__b;
563}
564
565/* vec_vaddfp */
566
567#define __builtin_altivec_vaddfp vec_vaddfp
568
569static __inline__ vector float __attribute__((__always_inline__))
570vec_vaddfp(vector float __a, vector float __b) {
571 return __a + __b;
572}
573
574/* vec_addc */
575
576static __inline__ vector signed int __ATTRS_o_ai
577vec_addc(vector signed int __a, vector signed int __b) {
578 return (vector signed int)__builtin_altivec_vaddcuw((vector unsigned int)__a,
579 (vector unsigned int)__b);
580}
581
582static __inline__ vector unsigned int __ATTRS_o_ai
583vec_addc(vector unsigned int __a, vector unsigned int __b) {
584 return __builtin_altivec_vaddcuw(__a, __b);
585}
586
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800587#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700588#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +0800589static __inline__ vector signed __int128 __ATTRS_o_ai
590vec_addc(vector signed __int128 __a, vector signed __int128 __b) {
591 return (vector signed __int128)__builtin_altivec_vaddcuq(
592 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
593}
594
595static __inline__ vector unsigned __int128 __ATTRS_o_ai
596vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
597 return __builtin_altivec_vaddcuq(__a, __b);
598}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700599#endif
600
601static __inline__ vector unsigned char __attribute__((__always_inline__))
602vec_addc_u128(vector unsigned char __a, vector unsigned char __b) {
603 return (vector unsigned char)__builtin_altivec_vaddcuq(__a, __b);
604}
Logan Chien2833ffb2018-10-09 10:03:24 +0800605#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
606
607/* vec_vaddcuw */
608
609static __inline__ vector unsigned int __attribute__((__always_inline__))
610vec_vaddcuw(vector unsigned int __a, vector unsigned int __b) {
611 return __builtin_altivec_vaddcuw(__a, __b);
612}
613
614/* vec_adds */
615
616static __inline__ vector signed char __ATTRS_o_ai
617vec_adds(vector signed char __a, vector signed char __b) {
618 return __builtin_altivec_vaddsbs(__a, __b);
619}
620
621static __inline__ vector signed char __ATTRS_o_ai
622vec_adds(vector bool char __a, vector signed char __b) {
623 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
624}
625
626static __inline__ vector signed char __ATTRS_o_ai
627vec_adds(vector signed char __a, vector bool char __b) {
628 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
629}
630
631static __inline__ vector unsigned char __ATTRS_o_ai
632vec_adds(vector unsigned char __a, vector unsigned char __b) {
633 return __builtin_altivec_vaddubs(__a, __b);
634}
635
636static __inline__ vector unsigned char __ATTRS_o_ai
637vec_adds(vector bool char __a, vector unsigned char __b) {
638 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
639}
640
641static __inline__ vector unsigned char __ATTRS_o_ai
642vec_adds(vector unsigned char __a, vector bool char __b) {
643 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
644}
645
646static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
647 vector short __b) {
648 return __builtin_altivec_vaddshs(__a, __b);
649}
650
651static __inline__ vector short __ATTRS_o_ai vec_adds(vector bool short __a,
652 vector short __b) {
653 return __builtin_altivec_vaddshs((vector short)__a, __b);
654}
655
656static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
657 vector bool short __b) {
658 return __builtin_altivec_vaddshs(__a, (vector short)__b);
659}
660
661static __inline__ vector unsigned short __ATTRS_o_ai
662vec_adds(vector unsigned short __a, vector unsigned short __b) {
663 return __builtin_altivec_vadduhs(__a, __b);
664}
665
666static __inline__ vector unsigned short __ATTRS_o_ai
667vec_adds(vector bool short __a, vector unsigned short __b) {
668 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
669}
670
671static __inline__ vector unsigned short __ATTRS_o_ai
672vec_adds(vector unsigned short __a, vector bool short __b) {
673 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
674}
675
676static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
677 vector int __b) {
678 return __builtin_altivec_vaddsws(__a, __b);
679}
680
681static __inline__ vector int __ATTRS_o_ai vec_adds(vector bool int __a,
682 vector int __b) {
683 return __builtin_altivec_vaddsws((vector int)__a, __b);
684}
685
686static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
687 vector bool int __b) {
688 return __builtin_altivec_vaddsws(__a, (vector int)__b);
689}
690
691static __inline__ vector unsigned int __ATTRS_o_ai
692vec_adds(vector unsigned int __a, vector unsigned int __b) {
693 return __builtin_altivec_vadduws(__a, __b);
694}
695
696static __inline__ vector unsigned int __ATTRS_o_ai
697vec_adds(vector bool int __a, vector unsigned int __b) {
698 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
699}
700
701static __inline__ vector unsigned int __ATTRS_o_ai
702vec_adds(vector unsigned int __a, vector bool int __b) {
703 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
704}
705
706/* vec_vaddsbs */
707
708static __inline__ vector signed char __ATTRS_o_ai
709vec_vaddsbs(vector signed char __a, vector signed char __b) {
710 return __builtin_altivec_vaddsbs(__a, __b);
711}
712
713static __inline__ vector signed char __ATTRS_o_ai
714vec_vaddsbs(vector bool char __a, vector signed char __b) {
715 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
716}
717
718static __inline__ vector signed char __ATTRS_o_ai
719vec_vaddsbs(vector signed char __a, vector bool char __b) {
720 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
721}
722
723/* vec_vaddubs */
724
725static __inline__ vector unsigned char __ATTRS_o_ai
726vec_vaddubs(vector unsigned char __a, vector unsigned char __b) {
727 return __builtin_altivec_vaddubs(__a, __b);
728}
729
730static __inline__ vector unsigned char __ATTRS_o_ai
731vec_vaddubs(vector bool char __a, vector unsigned char __b) {
732 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
733}
734
735static __inline__ vector unsigned char __ATTRS_o_ai
736vec_vaddubs(vector unsigned char __a, vector bool char __b) {
737 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
738}
739
740/* vec_vaddshs */
741
742static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
743 vector short __b) {
744 return __builtin_altivec_vaddshs(__a, __b);
745}
746
747static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector bool short __a,
748 vector short __b) {
749 return __builtin_altivec_vaddshs((vector short)__a, __b);
750}
751
752static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
753 vector bool short __b) {
754 return __builtin_altivec_vaddshs(__a, (vector short)__b);
755}
756
757/* vec_vadduhs */
758
759static __inline__ vector unsigned short __ATTRS_o_ai
760vec_vadduhs(vector unsigned short __a, vector unsigned short __b) {
761 return __builtin_altivec_vadduhs(__a, __b);
762}
763
764static __inline__ vector unsigned short __ATTRS_o_ai
765vec_vadduhs(vector bool short __a, vector unsigned short __b) {
766 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
767}
768
769static __inline__ vector unsigned short __ATTRS_o_ai
770vec_vadduhs(vector unsigned short __a, vector bool short __b) {
771 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
772}
773
774/* vec_vaddsws */
775
776static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
777 vector int __b) {
778 return __builtin_altivec_vaddsws(__a, __b);
779}
780
781static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector bool int __a,
782 vector int __b) {
783 return __builtin_altivec_vaddsws((vector int)__a, __b);
784}
785
786static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
787 vector bool int __b) {
788 return __builtin_altivec_vaddsws(__a, (vector int)__b);
789}
790
791/* vec_vadduws */
792
793static __inline__ vector unsigned int __ATTRS_o_ai
794vec_vadduws(vector unsigned int __a, vector unsigned int __b) {
795 return __builtin_altivec_vadduws(__a, __b);
796}
797
798static __inline__ vector unsigned int __ATTRS_o_ai
799vec_vadduws(vector bool int __a, vector unsigned int __b) {
800 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
801}
802
803static __inline__ vector unsigned int __ATTRS_o_ai
804vec_vadduws(vector unsigned int __a, vector bool int __b) {
805 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
806}
807
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700808#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
809 defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +0800810/* vec_vadduqm */
811
812static __inline__ vector signed __int128 __ATTRS_o_ai
813vec_vadduqm(vector signed __int128 __a, vector signed __int128 __b) {
814 return __a + __b;
815}
816
817static __inline__ vector unsigned __int128 __ATTRS_o_ai
818vec_vadduqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
819 return __a + __b;
820}
821
822/* vec_vaddeuqm */
823
824static __inline__ vector signed __int128 __ATTRS_o_ai
825vec_vaddeuqm(vector signed __int128 __a, vector signed __int128 __b,
826 vector signed __int128 __c) {
827 return __builtin_altivec_vaddeuqm(__a, __b, __c);
828}
829
830static __inline__ vector unsigned __int128 __ATTRS_o_ai
831vec_vaddeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
832 vector unsigned __int128 __c) {
833 return __builtin_altivec_vaddeuqm(__a, __b, __c);
834}
835
836/* vec_vaddcuq */
837
838static __inline__ vector signed __int128 __ATTRS_o_ai
839vec_vaddcuq(vector signed __int128 __a, vector signed __int128 __b) {
840 return __builtin_altivec_vaddcuq(__a, __b);
841}
842
843static __inline__ vector unsigned __int128 __ATTRS_o_ai
844vec_vaddcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
845 return __builtin_altivec_vaddcuq(__a, __b);
846}
847
848/* vec_vaddecuq */
849
850static __inline__ vector signed __int128 __ATTRS_o_ai
851vec_vaddecuq(vector signed __int128 __a, vector signed __int128 __b,
852 vector signed __int128 __c) {
853 return __builtin_altivec_vaddecuq(__a, __b, __c);
854}
855
856static __inline__ vector unsigned __int128 __ATTRS_o_ai
857vec_vaddecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
858 vector unsigned __int128 __c) {
859 return __builtin_altivec_vaddecuq(__a, __b, __c);
860}
861#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
862
863/* vec_and */
864
865#define __builtin_altivec_vand vec_and
866
867static __inline__ vector signed char __ATTRS_o_ai
868vec_and(vector signed char __a, vector signed char __b) {
869 return __a & __b;
870}
871
872static __inline__ vector signed char __ATTRS_o_ai
873vec_and(vector bool char __a, vector signed char __b) {
874 return (vector signed char)__a & __b;
875}
876
877static __inline__ vector signed char __ATTRS_o_ai
878vec_and(vector signed char __a, vector bool char __b) {
879 return __a & (vector signed char)__b;
880}
881
882static __inline__ vector unsigned char __ATTRS_o_ai
883vec_and(vector unsigned char __a, vector unsigned char __b) {
884 return __a & __b;
885}
886
887static __inline__ vector unsigned char __ATTRS_o_ai
888vec_and(vector bool char __a, vector unsigned char __b) {
889 return (vector unsigned char)__a & __b;
890}
891
892static __inline__ vector unsigned char __ATTRS_o_ai
893vec_and(vector unsigned char __a, vector bool char __b) {
894 return __a & (vector unsigned char)__b;
895}
896
897static __inline__ vector bool char __ATTRS_o_ai vec_and(vector bool char __a,
898 vector bool char __b) {
899 return __a & __b;
900}
901
902static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
903 vector short __b) {
904 return __a & __b;
905}
906
907static __inline__ vector short __ATTRS_o_ai vec_and(vector bool short __a,
908 vector short __b) {
909 return (vector short)__a & __b;
910}
911
912static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
913 vector bool short __b) {
914 return __a & (vector short)__b;
915}
916
917static __inline__ vector unsigned short __ATTRS_o_ai
918vec_and(vector unsigned short __a, vector unsigned short __b) {
919 return __a & __b;
920}
921
922static __inline__ vector unsigned short __ATTRS_o_ai
923vec_and(vector bool short __a, vector unsigned short __b) {
924 return (vector unsigned short)__a & __b;
925}
926
927static __inline__ vector unsigned short __ATTRS_o_ai
928vec_and(vector unsigned short __a, vector bool short __b) {
929 return __a & (vector unsigned short)__b;
930}
931
932static __inline__ vector bool short __ATTRS_o_ai
933vec_and(vector bool short __a, vector bool short __b) {
934 return __a & __b;
935}
936
937static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
938 vector int __b) {
939 return __a & __b;
940}
941
942static __inline__ vector int __ATTRS_o_ai vec_and(vector bool int __a,
943 vector int __b) {
944 return (vector int)__a & __b;
945}
946
947static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
948 vector bool int __b) {
949 return __a & (vector int)__b;
950}
951
952static __inline__ vector unsigned int __ATTRS_o_ai
953vec_and(vector unsigned int __a, vector unsigned int __b) {
954 return __a & __b;
955}
956
957static __inline__ vector unsigned int __ATTRS_o_ai
958vec_and(vector bool int __a, vector unsigned int __b) {
959 return (vector unsigned int)__a & __b;
960}
961
962static __inline__ vector unsigned int __ATTRS_o_ai
963vec_and(vector unsigned int __a, vector bool int __b) {
964 return __a & (vector unsigned int)__b;
965}
966
967static __inline__ vector bool int __ATTRS_o_ai vec_and(vector bool int __a,
968 vector bool int __b) {
969 return __a & __b;
970}
971
972static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
973 vector float __b) {
974 vector unsigned int __res =
975 (vector unsigned int)__a & (vector unsigned int)__b;
976 return (vector float)__res;
977}
978
979static __inline__ vector float __ATTRS_o_ai vec_and(vector bool int __a,
980 vector float __b) {
981 vector unsigned int __res =
982 (vector unsigned int)__a & (vector unsigned int)__b;
983 return (vector float)__res;
984}
985
986static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
987 vector bool int __b) {
988 vector unsigned int __res =
989 (vector unsigned int)__a & (vector unsigned int)__b;
990 return (vector float)__res;
991}
992
993#ifdef __VSX__
994static __inline__ vector double __ATTRS_o_ai vec_and(vector bool long long __a,
995 vector double __b) {
996 vector unsigned long long __res =
997 (vector unsigned long long)__a & (vector unsigned long long)__b;
998 return (vector double)__res;
999}
1000
1001static __inline__ vector double __ATTRS_o_ai
1002vec_and(vector double __a, vector bool long long __b) {
1003 vector unsigned long long __res =
1004 (vector unsigned long long)__a & (vector unsigned long long)__b;
1005 return (vector double)__res;
1006}
1007
1008static __inline__ vector double __ATTRS_o_ai vec_and(vector double __a,
1009 vector double __b) {
1010 vector unsigned long long __res =
1011 (vector unsigned long long)__a & (vector unsigned long long)__b;
1012 return (vector double)__res;
1013}
1014
1015static __inline__ vector signed long long __ATTRS_o_ai
1016vec_and(vector signed long long __a, vector signed long long __b) {
1017 return __a & __b;
1018}
1019
1020static __inline__ vector signed long long __ATTRS_o_ai
1021vec_and(vector bool long long __a, vector signed long long __b) {
1022 return (vector signed long long)__a & __b;
1023}
1024
1025static __inline__ vector signed long long __ATTRS_o_ai
1026vec_and(vector signed long long __a, vector bool long long __b) {
1027 return __a & (vector signed long long)__b;
1028}
1029
1030static __inline__ vector unsigned long long __ATTRS_o_ai
1031vec_and(vector unsigned long long __a, vector unsigned long long __b) {
1032 return __a & __b;
1033}
1034
1035static __inline__ vector unsigned long long __ATTRS_o_ai
1036vec_and(vector bool long long __a, vector unsigned long long __b) {
1037 return (vector unsigned long long)__a & __b;
1038}
1039
1040static __inline__ vector unsigned long long __ATTRS_o_ai
1041vec_and(vector unsigned long long __a, vector bool long long __b) {
1042 return __a & (vector unsigned long long)__b;
1043}
1044
1045static __inline__ vector bool long long __ATTRS_o_ai
1046vec_and(vector bool long long __a, vector bool long long __b) {
1047 return __a & __b;
1048}
1049#endif
1050
1051/* vec_vand */
1052
1053static __inline__ vector signed char __ATTRS_o_ai
1054vec_vand(vector signed char __a, vector signed char __b) {
1055 return __a & __b;
1056}
1057
1058static __inline__ vector signed char __ATTRS_o_ai
1059vec_vand(vector bool char __a, vector signed char __b) {
1060 return (vector signed char)__a & __b;
1061}
1062
1063static __inline__ vector signed char __ATTRS_o_ai
1064vec_vand(vector signed char __a, vector bool char __b) {
1065 return __a & (vector signed char)__b;
1066}
1067
1068static __inline__ vector unsigned char __ATTRS_o_ai
1069vec_vand(vector unsigned char __a, vector unsigned char __b) {
1070 return __a & __b;
1071}
1072
1073static __inline__ vector unsigned char __ATTRS_o_ai
1074vec_vand(vector bool char __a, vector unsigned char __b) {
1075 return (vector unsigned char)__a & __b;
1076}
1077
1078static __inline__ vector unsigned char __ATTRS_o_ai
1079vec_vand(vector unsigned char __a, vector bool char __b) {
1080 return __a & (vector unsigned char)__b;
1081}
1082
1083static __inline__ vector bool char __ATTRS_o_ai vec_vand(vector bool char __a,
1084 vector bool char __b) {
1085 return __a & __b;
1086}
1087
1088static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
1089 vector short __b) {
1090 return __a & __b;
1091}
1092
1093static __inline__ vector short __ATTRS_o_ai vec_vand(vector bool short __a,
1094 vector short __b) {
1095 return (vector short)__a & __b;
1096}
1097
1098static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
1099 vector bool short __b) {
1100 return __a & (vector short)__b;
1101}
1102
1103static __inline__ vector unsigned short __ATTRS_o_ai
1104vec_vand(vector unsigned short __a, vector unsigned short __b) {
1105 return __a & __b;
1106}
1107
1108static __inline__ vector unsigned short __ATTRS_o_ai
1109vec_vand(vector bool short __a, vector unsigned short __b) {
1110 return (vector unsigned short)__a & __b;
1111}
1112
1113static __inline__ vector unsigned short __ATTRS_o_ai
1114vec_vand(vector unsigned short __a, vector bool short __b) {
1115 return __a & (vector unsigned short)__b;
1116}
1117
1118static __inline__ vector bool short __ATTRS_o_ai
1119vec_vand(vector bool short __a, vector bool short __b) {
1120 return __a & __b;
1121}
1122
1123static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
1124 vector int __b) {
1125 return __a & __b;
1126}
1127
1128static __inline__ vector int __ATTRS_o_ai vec_vand(vector bool int __a,
1129 vector int __b) {
1130 return (vector int)__a & __b;
1131}
1132
1133static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
1134 vector bool int __b) {
1135 return __a & (vector int)__b;
1136}
1137
1138static __inline__ vector unsigned int __ATTRS_o_ai
1139vec_vand(vector unsigned int __a, vector unsigned int __b) {
1140 return __a & __b;
1141}
1142
1143static __inline__ vector unsigned int __ATTRS_o_ai
1144vec_vand(vector bool int __a, vector unsigned int __b) {
1145 return (vector unsigned int)__a & __b;
1146}
1147
1148static __inline__ vector unsigned int __ATTRS_o_ai
1149vec_vand(vector unsigned int __a, vector bool int __b) {
1150 return __a & (vector unsigned int)__b;
1151}
1152
1153static __inline__ vector bool int __ATTRS_o_ai vec_vand(vector bool int __a,
1154 vector bool int __b) {
1155 return __a & __b;
1156}
1157
1158static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1159 vector float __b) {
1160 vector unsigned int __res =
1161 (vector unsigned int)__a & (vector unsigned int)__b;
1162 return (vector float)__res;
1163}
1164
1165static __inline__ vector float __ATTRS_o_ai vec_vand(vector bool int __a,
1166 vector float __b) {
1167 vector unsigned int __res =
1168 (vector unsigned int)__a & (vector unsigned int)__b;
1169 return (vector float)__res;
1170}
1171
1172static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1173 vector bool int __b) {
1174 vector unsigned int __res =
1175 (vector unsigned int)__a & (vector unsigned int)__b;
1176 return (vector float)__res;
1177}
1178
1179#ifdef __VSX__
1180static __inline__ vector signed long long __ATTRS_o_ai
1181vec_vand(vector signed long long __a, vector signed long long __b) {
1182 return __a & __b;
1183}
1184
1185static __inline__ vector signed long long __ATTRS_o_ai
1186vec_vand(vector bool long long __a, vector signed long long __b) {
1187 return (vector signed long long)__a & __b;
1188}
1189
1190static __inline__ vector signed long long __ATTRS_o_ai
1191vec_vand(vector signed long long __a, vector bool long long __b) {
1192 return __a & (vector signed long long)__b;
1193}
1194
1195static __inline__ vector unsigned long long __ATTRS_o_ai
1196vec_vand(vector unsigned long long __a, vector unsigned long long __b) {
1197 return __a & __b;
1198}
1199
1200static __inline__ vector unsigned long long __ATTRS_o_ai
1201vec_vand(vector bool long long __a, vector unsigned long long __b) {
1202 return (vector unsigned long long)__a & __b;
1203}
1204
1205static __inline__ vector unsigned long long __ATTRS_o_ai
1206vec_vand(vector unsigned long long __a, vector bool long long __b) {
1207 return __a & (vector unsigned long long)__b;
1208}
1209
1210static __inline__ vector bool long long __ATTRS_o_ai
1211vec_vand(vector bool long long __a, vector bool long long __b) {
1212 return __a & __b;
1213}
1214#endif
1215
1216/* vec_andc */
1217
1218#define __builtin_altivec_vandc vec_andc
1219
1220static __inline__ vector signed char __ATTRS_o_ai
1221vec_andc(vector signed char __a, vector signed char __b) {
1222 return __a & ~__b;
1223}
1224
1225static __inline__ vector signed char __ATTRS_o_ai
1226vec_andc(vector bool char __a, vector signed char __b) {
1227 return (vector signed char)__a & ~__b;
1228}
1229
1230static __inline__ vector signed char __ATTRS_o_ai
1231vec_andc(vector signed char __a, vector bool char __b) {
1232 return __a & ~(vector signed char)__b;
1233}
1234
1235static __inline__ vector unsigned char __ATTRS_o_ai
1236vec_andc(vector unsigned char __a, vector unsigned char __b) {
1237 return __a & ~__b;
1238}
1239
1240static __inline__ vector unsigned char __ATTRS_o_ai
1241vec_andc(vector bool char __a, vector unsigned char __b) {
1242 return (vector unsigned char)__a & ~__b;
1243}
1244
1245static __inline__ vector unsigned char __ATTRS_o_ai
1246vec_andc(vector unsigned char __a, vector bool char __b) {
1247 return __a & ~(vector unsigned char)__b;
1248}
1249
1250static __inline__ vector bool char __ATTRS_o_ai vec_andc(vector bool char __a,
1251 vector bool char __b) {
1252 return __a & ~__b;
1253}
1254
1255static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1256 vector short __b) {
1257 return __a & ~__b;
1258}
1259
1260static __inline__ vector short __ATTRS_o_ai vec_andc(vector bool short __a,
1261 vector short __b) {
1262 return (vector short)__a & ~__b;
1263}
1264
1265static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1266 vector bool short __b) {
1267 return __a & ~(vector short)__b;
1268}
1269
1270static __inline__ vector unsigned short __ATTRS_o_ai
1271vec_andc(vector unsigned short __a, vector unsigned short __b) {
1272 return __a & ~__b;
1273}
1274
1275static __inline__ vector unsigned short __ATTRS_o_ai
1276vec_andc(vector bool short __a, vector unsigned short __b) {
1277 return (vector unsigned short)__a & ~__b;
1278}
1279
1280static __inline__ vector unsigned short __ATTRS_o_ai
1281vec_andc(vector unsigned short __a, vector bool short __b) {
1282 return __a & ~(vector unsigned short)__b;
1283}
1284
1285static __inline__ vector bool short __ATTRS_o_ai
1286vec_andc(vector bool short __a, vector bool short __b) {
1287 return __a & ~__b;
1288}
1289
1290static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1291 vector int __b) {
1292 return __a & ~__b;
1293}
1294
1295static __inline__ vector int __ATTRS_o_ai vec_andc(vector bool int __a,
1296 vector int __b) {
1297 return (vector int)__a & ~__b;
1298}
1299
1300static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1301 vector bool int __b) {
1302 return __a & ~(vector int)__b;
1303}
1304
1305static __inline__ vector unsigned int __ATTRS_o_ai
1306vec_andc(vector unsigned int __a, vector unsigned int __b) {
1307 return __a & ~__b;
1308}
1309
1310static __inline__ vector unsigned int __ATTRS_o_ai
1311vec_andc(vector bool int __a, vector unsigned int __b) {
1312 return (vector unsigned int)__a & ~__b;
1313}
1314
1315static __inline__ vector unsigned int __ATTRS_o_ai
1316vec_andc(vector unsigned int __a, vector bool int __b) {
1317 return __a & ~(vector unsigned int)__b;
1318}
1319
1320static __inline__ vector bool int __ATTRS_o_ai vec_andc(vector bool int __a,
1321 vector bool int __b) {
1322 return __a & ~__b;
1323}
1324
1325static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1326 vector float __b) {
1327 vector unsigned int __res =
1328 (vector unsigned int)__a & ~(vector unsigned int)__b;
1329 return (vector float)__res;
1330}
1331
1332static __inline__ vector float __ATTRS_o_ai vec_andc(vector bool int __a,
1333 vector float __b) {
1334 vector unsigned int __res =
1335 (vector unsigned int)__a & ~(vector unsigned int)__b;
1336 return (vector float)__res;
1337}
1338
1339static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1340 vector bool int __b) {
1341 vector unsigned int __res =
1342 (vector unsigned int)__a & ~(vector unsigned int)__b;
1343 return (vector float)__res;
1344}
1345
1346#ifdef __VSX__
1347static __inline__ vector double __ATTRS_o_ai vec_andc(vector bool long long __a,
1348 vector double __b) {
1349 vector unsigned long long __res =
1350 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1351 return (vector double)__res;
1352}
1353
1354static __inline__ vector double __ATTRS_o_ai
1355vec_andc(vector double __a, vector bool long long __b) {
1356 vector unsigned long long __res =
1357 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1358 return (vector double)__res;
1359}
1360
1361static __inline__ vector double __ATTRS_o_ai vec_andc(vector double __a,
1362 vector double __b) {
1363 vector unsigned long long __res =
1364 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1365 return (vector double)__res;
1366}
1367
1368static __inline__ vector signed long long __ATTRS_o_ai
1369vec_andc(vector signed long long __a, vector signed long long __b) {
1370 return __a & ~__b;
1371}
1372
1373static __inline__ vector signed long long __ATTRS_o_ai
1374vec_andc(vector bool long long __a, vector signed long long __b) {
1375 return (vector signed long long)__a & ~__b;
1376}
1377
1378static __inline__ vector signed long long __ATTRS_o_ai
1379vec_andc(vector signed long long __a, vector bool long long __b) {
1380 return __a & ~(vector signed long long)__b;
1381}
1382
1383static __inline__ vector unsigned long long __ATTRS_o_ai
1384vec_andc(vector unsigned long long __a, vector unsigned long long __b) {
1385 return __a & ~__b;
1386}
1387
1388static __inline__ vector unsigned long long __ATTRS_o_ai
1389vec_andc(vector bool long long __a, vector unsigned long long __b) {
1390 return (vector unsigned long long)__a & ~__b;
1391}
1392
1393static __inline__ vector unsigned long long __ATTRS_o_ai
1394vec_andc(vector unsigned long long __a, vector bool long long __b) {
1395 return __a & ~(vector unsigned long long)__b;
1396}
1397
1398static __inline__ vector bool long long __ATTRS_o_ai
1399vec_andc(vector bool long long __a, vector bool long long __b) {
1400 return __a & ~__b;
1401}
1402#endif
1403
1404/* vec_vandc */
1405
1406static __inline__ vector signed char __ATTRS_o_ai
1407vec_vandc(vector signed char __a, vector signed char __b) {
1408 return __a & ~__b;
1409}
1410
1411static __inline__ vector signed char __ATTRS_o_ai
1412vec_vandc(vector bool char __a, vector signed char __b) {
1413 return (vector signed char)__a & ~__b;
1414}
1415
1416static __inline__ vector signed char __ATTRS_o_ai
1417vec_vandc(vector signed char __a, vector bool char __b) {
1418 return __a & ~(vector signed char)__b;
1419}
1420
1421static __inline__ vector unsigned char __ATTRS_o_ai
1422vec_vandc(vector unsigned char __a, vector unsigned char __b) {
1423 return __a & ~__b;
1424}
1425
1426static __inline__ vector unsigned char __ATTRS_o_ai
1427vec_vandc(vector bool char __a, vector unsigned char __b) {
1428 return (vector unsigned char)__a & ~__b;
1429}
1430
1431static __inline__ vector unsigned char __ATTRS_o_ai
1432vec_vandc(vector unsigned char __a, vector bool char __b) {
1433 return __a & ~(vector unsigned char)__b;
1434}
1435
1436static __inline__ vector bool char __ATTRS_o_ai
1437vec_vandc(vector bool char __a, vector bool char __b) {
1438 return __a & ~__b;
1439}
1440
1441static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1442 vector short __b) {
1443 return __a & ~__b;
1444}
1445
1446static __inline__ vector short __ATTRS_o_ai vec_vandc(vector bool short __a,
1447 vector short __b) {
1448 return (vector short)__a & ~__b;
1449}
1450
1451static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1452 vector bool short __b) {
1453 return __a & ~(vector short)__b;
1454}
1455
1456static __inline__ vector unsigned short __ATTRS_o_ai
1457vec_vandc(vector unsigned short __a, vector unsigned short __b) {
1458 return __a & ~__b;
1459}
1460
1461static __inline__ vector unsigned short __ATTRS_o_ai
1462vec_vandc(vector bool short __a, vector unsigned short __b) {
1463 return (vector unsigned short)__a & ~__b;
1464}
1465
1466static __inline__ vector unsigned short __ATTRS_o_ai
1467vec_vandc(vector unsigned short __a, vector bool short __b) {
1468 return __a & ~(vector unsigned short)__b;
1469}
1470
1471static __inline__ vector bool short __ATTRS_o_ai
1472vec_vandc(vector bool short __a, vector bool short __b) {
1473 return __a & ~__b;
1474}
1475
1476static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1477 vector int __b) {
1478 return __a & ~__b;
1479}
1480
1481static __inline__ vector int __ATTRS_o_ai vec_vandc(vector bool int __a,
1482 vector int __b) {
1483 return (vector int)__a & ~__b;
1484}
1485
1486static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1487 vector bool int __b) {
1488 return __a & ~(vector int)__b;
1489}
1490
1491static __inline__ vector unsigned int __ATTRS_o_ai
1492vec_vandc(vector unsigned int __a, vector unsigned int __b) {
1493 return __a & ~__b;
1494}
1495
1496static __inline__ vector unsigned int __ATTRS_o_ai
1497vec_vandc(vector bool int __a, vector unsigned int __b) {
1498 return (vector unsigned int)__a & ~__b;
1499}
1500
1501static __inline__ vector unsigned int __ATTRS_o_ai
1502vec_vandc(vector unsigned int __a, vector bool int __b) {
1503 return __a & ~(vector unsigned int)__b;
1504}
1505
1506static __inline__ vector bool int __ATTRS_o_ai vec_vandc(vector bool int __a,
1507 vector bool int __b) {
1508 return __a & ~__b;
1509}
1510
1511static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1512 vector float __b) {
1513 vector unsigned int __res =
1514 (vector unsigned int)__a & ~(vector unsigned int)__b;
1515 return (vector float)__res;
1516}
1517
1518static __inline__ vector float __ATTRS_o_ai vec_vandc(vector bool int __a,
1519 vector float __b) {
1520 vector unsigned int __res =
1521 (vector unsigned int)__a & ~(vector unsigned int)__b;
1522 return (vector float)__res;
1523}
1524
1525static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1526 vector bool int __b) {
1527 vector unsigned int __res =
1528 (vector unsigned int)__a & ~(vector unsigned int)__b;
1529 return (vector float)__res;
1530}
1531
1532#ifdef __VSX__
1533static __inline__ vector signed long long __ATTRS_o_ai
1534vec_vandc(vector signed long long __a, vector signed long long __b) {
1535 return __a & ~__b;
1536}
1537
1538static __inline__ vector signed long long __ATTRS_o_ai
1539vec_vandc(vector bool long long __a, vector signed long long __b) {
1540 return (vector signed long long)__a & ~__b;
1541}
1542
1543static __inline__ vector signed long long __ATTRS_o_ai
1544vec_vandc(vector signed long long __a, vector bool long long __b) {
1545 return __a & ~(vector signed long long)__b;
1546}
1547
1548static __inline__ vector unsigned long long __ATTRS_o_ai
1549vec_vandc(vector unsigned long long __a, vector unsigned long long __b) {
1550 return __a & ~__b;
1551}
1552
1553static __inline__ vector unsigned long long __ATTRS_o_ai
1554vec_vandc(vector bool long long __a, vector unsigned long long __b) {
1555 return (vector unsigned long long)__a & ~__b;
1556}
1557
1558static __inline__ vector unsigned long long __ATTRS_o_ai
1559vec_vandc(vector unsigned long long __a, vector bool long long __b) {
1560 return __a & ~(vector unsigned long long)__b;
1561}
1562
1563static __inline__ vector bool long long __ATTRS_o_ai
1564vec_vandc(vector bool long long __a, vector bool long long __b) {
1565 return __a & ~__b;
1566}
1567#endif
1568
1569/* vec_avg */
1570
1571static __inline__ vector signed char __ATTRS_o_ai
1572vec_avg(vector signed char __a, vector signed char __b) {
1573 return __builtin_altivec_vavgsb(__a, __b);
1574}
1575
1576static __inline__ vector unsigned char __ATTRS_o_ai
1577vec_avg(vector unsigned char __a, vector unsigned char __b) {
1578 return __builtin_altivec_vavgub(__a, __b);
1579}
1580
1581static __inline__ vector short __ATTRS_o_ai vec_avg(vector short __a,
1582 vector short __b) {
1583 return __builtin_altivec_vavgsh(__a, __b);
1584}
1585
1586static __inline__ vector unsigned short __ATTRS_o_ai
1587vec_avg(vector unsigned short __a, vector unsigned short __b) {
1588 return __builtin_altivec_vavguh(__a, __b);
1589}
1590
1591static __inline__ vector int __ATTRS_o_ai vec_avg(vector int __a,
1592 vector int __b) {
1593 return __builtin_altivec_vavgsw(__a, __b);
1594}
1595
1596static __inline__ vector unsigned int __ATTRS_o_ai
1597vec_avg(vector unsigned int __a, vector unsigned int __b) {
1598 return __builtin_altivec_vavguw(__a, __b);
1599}
1600
1601/* vec_vavgsb */
1602
1603static __inline__ vector signed char __attribute__((__always_inline__))
1604vec_vavgsb(vector signed char __a, vector signed char __b) {
1605 return __builtin_altivec_vavgsb(__a, __b);
1606}
1607
1608/* vec_vavgub */
1609
1610static __inline__ vector unsigned char __attribute__((__always_inline__))
1611vec_vavgub(vector unsigned char __a, vector unsigned char __b) {
1612 return __builtin_altivec_vavgub(__a, __b);
1613}
1614
1615/* vec_vavgsh */
1616
1617static __inline__ vector short __attribute__((__always_inline__))
1618vec_vavgsh(vector short __a, vector short __b) {
1619 return __builtin_altivec_vavgsh(__a, __b);
1620}
1621
1622/* vec_vavguh */
1623
1624static __inline__ vector unsigned short __attribute__((__always_inline__))
1625vec_vavguh(vector unsigned short __a, vector unsigned short __b) {
1626 return __builtin_altivec_vavguh(__a, __b);
1627}
1628
1629/* vec_vavgsw */
1630
1631static __inline__ vector int __attribute__((__always_inline__))
1632vec_vavgsw(vector int __a, vector int __b) {
1633 return __builtin_altivec_vavgsw(__a, __b);
1634}
1635
1636/* vec_vavguw */
1637
1638static __inline__ vector unsigned int __attribute__((__always_inline__))
1639vec_vavguw(vector unsigned int __a, vector unsigned int __b) {
1640 return __builtin_altivec_vavguw(__a, __b);
1641}
1642
1643/* vec_ceil */
1644
1645static __inline__ vector float __ATTRS_o_ai vec_ceil(vector float __a) {
1646#ifdef __VSX__
1647 return __builtin_vsx_xvrspip(__a);
1648#else
1649 return __builtin_altivec_vrfip(__a);
1650#endif
1651}
1652
1653#ifdef __VSX__
1654static __inline__ vector double __ATTRS_o_ai vec_ceil(vector double __a) {
1655 return __builtin_vsx_xvrdpip(__a);
1656}
1657#endif
1658
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001659/* vec_roundp */
1660static __inline__ vector float __ATTRS_o_ai vec_roundp(vector float __a) {
1661 return vec_ceil(__a);
1662}
1663
1664#ifdef __VSX__
1665static __inline__ vector double __ATTRS_o_ai vec_roundp(vector double __a) {
1666 return vec_ceil(__a);
1667}
1668#endif
1669
Logan Chien2833ffb2018-10-09 10:03:24 +08001670/* vec_vrfip */
1671
1672static __inline__ vector float __attribute__((__always_inline__))
1673vec_vrfip(vector float __a) {
1674 return __builtin_altivec_vrfip(__a);
1675}
1676
1677/* vec_cmpb */
1678
1679static __inline__ vector int __attribute__((__always_inline__))
1680vec_cmpb(vector float __a, vector float __b) {
1681 return __builtin_altivec_vcmpbfp(__a, __b);
1682}
1683
1684/* vec_vcmpbfp */
1685
1686static __inline__ vector int __attribute__((__always_inline__))
1687vec_vcmpbfp(vector float __a, vector float __b) {
1688 return __builtin_altivec_vcmpbfp(__a, __b);
1689}
1690
1691/* vec_cmpeq */
1692
1693static __inline__ vector bool char __ATTRS_o_ai
1694vec_cmpeq(vector signed char __a, vector signed char __b) {
1695 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1696 (vector char)__b);
1697}
1698
1699static __inline__ vector bool char __ATTRS_o_ai
1700vec_cmpeq(vector unsigned char __a, vector unsigned char __b) {
1701 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1702 (vector char)__b);
1703}
1704
Logan Chien55afb0a2018-10-15 10:42:14 +08001705static __inline__ vector bool char __ATTRS_o_ai
1706vec_cmpeq(vector bool char __a, vector bool char __b) {
1707 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1708 (vector char)__b);
1709}
1710
Logan Chien2833ffb2018-10-09 10:03:24 +08001711static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
1712 vector short __b) {
1713 return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
1714}
1715
1716static __inline__ vector bool short __ATTRS_o_ai
1717vec_cmpeq(vector unsigned short __a, vector unsigned short __b) {
1718 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1719 (vector short)__b);
1720}
1721
Logan Chien55afb0a2018-10-15 10:42:14 +08001722static __inline__ vector bool short __ATTRS_o_ai
1723vec_cmpeq(vector bool short __a, vector bool short __b) {
1724 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1725 (vector short)__b);
1726}
1727
Logan Chien2833ffb2018-10-09 10:03:24 +08001728static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
1729 vector int __b) {
1730 return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
1731}
1732
1733static __inline__ vector bool int __ATTRS_o_ai
1734vec_cmpeq(vector unsigned int __a, vector unsigned int __b) {
1735 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1736 (vector int)__b);
1737}
1738
Logan Chien55afb0a2018-10-15 10:42:14 +08001739static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
1740 vector bool int __b) {
1741 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1742 (vector int)__b);
1743}
1744
Logan Chien2833ffb2018-10-09 10:03:24 +08001745#ifdef __POWER8_VECTOR__
1746static __inline__ vector bool long long __ATTRS_o_ai
1747vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1748 return (vector bool long long)__builtin_altivec_vcmpequd(__a, __b);
1749}
1750
1751static __inline__ vector bool long long __ATTRS_o_ai
1752vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1753 return (vector bool long long)__builtin_altivec_vcmpequd(
1754 (vector long long)__a, (vector long long)__b);
1755}
Logan Chien55afb0a2018-10-15 10:42:14 +08001756
1757static __inline__ vector bool long long __ATTRS_o_ai
1758vec_cmpeq(vector bool long long __a, vector bool long long __b) {
1759 return (vector bool long long)__builtin_altivec_vcmpequd(
1760 (vector long long)__a, (vector long long)__b);
1761}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001762#elif defined(__VSX__)
1763static __inline__ vector bool long long __ATTRS_o_ai
1764vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1765 vector bool int __wordcmp =
1766 vec_cmpeq((vector signed int)__a, (vector signed int)__b);
1767#ifdef __LITTLE_ENDIAN__
1768 __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
1769 return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 1,
1770 1, 3, 3);
1771#else
1772 __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
1773 return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 0,
1774 0, 2, 2);
1775#endif
1776}
Logan Chien55afb0a2018-10-15 10:42:14 +08001777
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001778static __inline__ vector bool long long __ATTRS_o_ai
1779vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1780 return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
1781}
1782
1783static __inline__ vector bool long long __ATTRS_o_ai
1784vec_cmpeq(vector bool long long __a, vector bool long long __b) {
1785 return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
1786}
Logan Chien2833ffb2018-10-09 10:03:24 +08001787#endif
1788
1789static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
1790 vector float __b) {
1791#ifdef __VSX__
1792 return (vector bool int)__builtin_vsx_xvcmpeqsp(__a, __b);
1793#else
1794 return (vector bool int)__builtin_altivec_vcmpeqfp(__a, __b);
1795#endif
1796}
1797
1798#ifdef __VSX__
1799static __inline__ vector bool long long __ATTRS_o_ai
1800vec_cmpeq(vector double __a, vector double __b) {
1801 return (vector bool long long)__builtin_vsx_xvcmpeqdp(__a, __b);
1802}
1803#endif
1804
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001805#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001806static __inline__ vector bool __int128 __ATTRS_o_ai
1807vec_cmpeq(vector signed __int128 __a, vector signed __int128 __b) {
1808 return (vector bool __int128)__builtin_altivec_vcmpequq(
1809 (vector bool __int128)__a, (vector bool __int128)__b);
1810}
1811
1812static __inline__ vector bool __int128 __ATTRS_o_ai
1813vec_cmpeq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
1814 return (vector bool __int128)__builtin_altivec_vcmpequq(
1815 (vector bool __int128)__a, (vector bool __int128)__b);
1816}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08001817
1818static __inline__ vector bool __int128 __ATTRS_o_ai
1819vec_cmpeq(vector bool __int128 __a, vector bool __int128 __b) {
1820 return (vector bool __int128)__builtin_altivec_vcmpequq(__a, __b);
1821}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001822#endif
1823
Logan Chien55afb0a2018-10-15 10:42:14 +08001824#ifdef __POWER9_VECTOR__
1825/* vec_cmpne */
1826
1827static __inline__ vector bool char __ATTRS_o_ai
1828vec_cmpne(vector bool char __a, vector bool char __b) {
1829 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1830 (vector char)__b);
1831}
1832
1833static __inline__ vector bool char __ATTRS_o_ai
1834vec_cmpne(vector signed char __a, vector signed char __b) {
1835 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1836 (vector char)__b);
1837}
1838
1839static __inline__ vector bool char __ATTRS_o_ai
1840vec_cmpne(vector unsigned char __a, vector unsigned char __b) {
1841 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1842 (vector char)__b);
1843}
1844
1845static __inline__ vector bool short __ATTRS_o_ai
1846vec_cmpne(vector bool short __a, vector bool short __b) {
1847 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1848 (vector short)__b);
1849}
1850
1851static __inline__ vector bool short __ATTRS_o_ai
1852vec_cmpne(vector signed short __a, vector signed short __b) {
1853 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1854 (vector short)__b);
1855}
1856
1857static __inline__ vector bool short __ATTRS_o_ai
1858vec_cmpne(vector unsigned short __a, vector unsigned short __b) {
1859 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1860 (vector short)__b);
1861}
1862
1863static __inline__ vector bool int __ATTRS_o_ai
1864vec_cmpne(vector bool int __a, vector bool int __b) {
1865 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1866 (vector int)__b);
1867}
1868
1869static __inline__ vector bool int __ATTRS_o_ai
1870vec_cmpne(vector signed int __a, vector signed int __b) {
1871 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1872 (vector int)__b);
1873}
1874
1875static __inline__ vector bool int __ATTRS_o_ai
1876vec_cmpne(vector unsigned int __a, vector unsigned int __b) {
1877 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1878 (vector int)__b);
1879}
1880
Logan Chien55afb0a2018-10-15 10:42:14 +08001881static __inline__ vector bool int __ATTRS_o_ai
1882vec_cmpne(vector float __a, vector float __b) {
1883 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1884 (vector int)__b);
1885}
1886
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001887#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001888static __inline__ vector bool __int128 __ATTRS_o_ai
1889vec_cmpne(vector unsigned __int128 __a, vector unsigned __int128 __b) {
1890 return (vector bool __int128) ~(__builtin_altivec_vcmpequq(
1891 (vector bool __int128)__a, (vector bool __int128)__b));
Logan Chien55afb0a2018-10-15 10:42:14 +08001892}
1893
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001894static __inline__ vector bool __int128 __ATTRS_o_ai
1895vec_cmpne(vector signed __int128 __a, vector signed __int128 __b) {
1896 return (vector bool __int128) ~(__builtin_altivec_vcmpequq(
1897 (vector bool __int128)__a, (vector bool __int128)__b));
1898}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08001899
1900static __inline__ vector bool __int128 __ATTRS_o_ai
1901vec_cmpne(vector bool __int128 __a, vector bool __int128 __b) {
1902 return (vector bool __int128) ~(__builtin_altivec_vcmpequq(__a, __b));
1903}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001904#endif
1905
Logan Chien55afb0a2018-10-15 10:42:14 +08001906/* vec_cmpnez */
1907
1908static __inline__ vector bool char __ATTRS_o_ai
1909vec_cmpnez(vector signed char __a, vector signed char __b) {
1910 return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a,
1911 (vector char)__b);
1912}
1913
1914static __inline__ vector bool char __ATTRS_o_ai
1915vec_cmpnez(vector unsigned char __a, vector unsigned char __b) {
1916 return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a,
1917 (vector char)__b);
1918}
1919
1920static __inline__ vector bool short __ATTRS_o_ai
1921vec_cmpnez(vector signed short __a, vector signed short __b) {
1922 return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a,
1923 (vector short)__b);
1924}
1925
1926static __inline__ vector bool short __ATTRS_o_ai
1927vec_cmpnez(vector unsigned short __a, vector unsigned short __b) {
1928 return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a,
1929 (vector short)__b);
1930}
1931
1932static __inline__ vector bool int __ATTRS_o_ai
1933vec_cmpnez(vector signed int __a, vector signed int __b) {
1934 return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a,
1935 (vector int)__b);
1936}
1937
1938static __inline__ vector bool int __ATTRS_o_ai
1939vec_cmpnez(vector unsigned int __a, vector unsigned int __b) {
1940 return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a,
1941 (vector int)__b);
1942}
1943
1944static __inline__ signed int __ATTRS_o_ai
1945vec_cntlz_lsbb(vector signed char __a) {
1946#ifdef __LITTLE_ENDIAN__
1947 return __builtin_altivec_vctzlsbb(__a);
1948#else
1949 return __builtin_altivec_vclzlsbb(__a);
1950#endif
1951}
1952
1953static __inline__ signed int __ATTRS_o_ai
1954vec_cntlz_lsbb(vector unsigned char __a) {
1955#ifdef __LITTLE_ENDIAN__
1956 return __builtin_altivec_vctzlsbb(__a);
1957#else
1958 return __builtin_altivec_vclzlsbb(__a);
1959#endif
1960}
1961
1962static __inline__ signed int __ATTRS_o_ai
1963vec_cnttz_lsbb(vector signed char __a) {
1964#ifdef __LITTLE_ENDIAN__
1965 return __builtin_altivec_vclzlsbb(__a);
1966#else
1967 return __builtin_altivec_vctzlsbb(__a);
1968#endif
1969}
1970
1971static __inline__ signed int __ATTRS_o_ai
1972vec_cnttz_lsbb(vector unsigned char __a) {
1973#ifdef __LITTLE_ENDIAN__
1974 return __builtin_altivec_vclzlsbb(__a);
1975#else
1976 return __builtin_altivec_vctzlsbb(__a);
1977#endif
1978}
1979
1980static __inline__ vector unsigned int __ATTRS_o_ai
1981vec_parity_lsbb(vector unsigned int __a) {
1982 return __builtin_altivec_vprtybw(__a);
1983}
1984
1985static __inline__ vector unsigned int __ATTRS_o_ai
1986vec_parity_lsbb(vector signed int __a) {
1987 return __builtin_altivec_vprtybw(__a);
1988}
1989
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07001990#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +08001991static __inline__ vector unsigned __int128 __ATTRS_o_ai
1992vec_parity_lsbb(vector unsigned __int128 __a) {
1993 return __builtin_altivec_vprtybq(__a);
1994}
1995
1996static __inline__ vector unsigned __int128 __ATTRS_o_ai
1997vec_parity_lsbb(vector signed __int128 __a) {
1998 return __builtin_altivec_vprtybq(__a);
1999}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002000#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08002001
2002static __inline__ vector unsigned long long __ATTRS_o_ai
2003vec_parity_lsbb(vector unsigned long long __a) {
2004 return __builtin_altivec_vprtybd(__a);
2005}
2006
2007static __inline__ vector unsigned long long __ATTRS_o_ai
2008vec_parity_lsbb(vector signed long long __a) {
2009 return __builtin_altivec_vprtybd(__a);
2010}
2011
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002012#else
2013/* vec_cmpne */
2014
2015static __inline__ vector bool char __ATTRS_o_ai
2016vec_cmpne(vector bool char __a, vector bool char __b) {
2017 return ~(vec_cmpeq(__a, __b));
2018}
2019
2020static __inline__ vector bool char __ATTRS_o_ai
2021vec_cmpne(vector signed char __a, vector signed char __b) {
2022 return ~(vec_cmpeq(__a, __b));
2023}
2024
2025static __inline__ vector bool char __ATTRS_o_ai
2026vec_cmpne(vector unsigned char __a, vector unsigned char __b) {
2027 return ~(vec_cmpeq(__a, __b));
2028}
2029
2030static __inline__ vector bool short __ATTRS_o_ai
2031vec_cmpne(vector bool short __a, vector bool short __b) {
2032 return ~(vec_cmpeq(__a, __b));
2033}
2034
2035static __inline__ vector bool short __ATTRS_o_ai
2036vec_cmpne(vector signed short __a, vector signed short __b) {
2037 return ~(vec_cmpeq(__a, __b));
2038}
2039
2040static __inline__ vector bool short __ATTRS_o_ai
2041vec_cmpne(vector unsigned short __a, vector unsigned short __b) {
2042 return ~(vec_cmpeq(__a, __b));
2043}
2044
2045static __inline__ vector bool int __ATTRS_o_ai
2046vec_cmpne(vector bool int __a, vector bool int __b) {
2047 return ~(vec_cmpeq(__a, __b));
2048}
2049
2050static __inline__ vector bool int __ATTRS_o_ai
2051vec_cmpne(vector signed int __a, vector signed int __b) {
2052 return ~(vec_cmpeq(__a, __b));
2053}
2054
2055static __inline__ vector bool int __ATTRS_o_ai
2056vec_cmpne(vector unsigned int __a, vector unsigned int __b) {
2057 return ~(vec_cmpeq(__a, __b));
2058}
2059
2060static __inline__ vector bool int __ATTRS_o_ai
2061vec_cmpne(vector float __a, vector float __b) {
2062 return ~(vec_cmpeq(__a, __b));
2063}
2064#endif
2065
2066#ifdef __POWER8_VECTOR__
2067static __inline__ vector bool long long __ATTRS_o_ai
2068vec_cmpne(vector bool long long __a, vector bool long long __b) {
2069 return (vector bool long long)
2070 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2071}
2072
2073static __inline__ vector bool long long __ATTRS_o_ai
2074vec_cmpne(vector signed long long __a, vector signed long long __b) {
2075 return (vector bool long long)
2076 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2077}
2078
2079static __inline__ vector bool long long __ATTRS_o_ai
2080vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
2081 return (vector bool long long)
2082 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2083}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002084#elif defined(__VSX__)
2085static __inline__ vector bool long long __ATTRS_o_ai
2086vec_cmpne(vector bool long long __a, vector bool long long __b) {
2087 return (vector bool long long)~(
2088 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2089}
2090
2091static __inline__ vector bool long long __ATTRS_o_ai
2092vec_cmpne(vector signed long long __a, vector signed long long __b) {
2093 return (vector bool long long)~(
2094 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2095}
2096
2097static __inline__ vector bool long long __ATTRS_o_ai
2098vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
2099 return (vector bool long long)~(
2100 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2101}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002102#endif
2103
2104#ifdef __VSX__
2105static __inline__ vector bool long long __ATTRS_o_ai
2106vec_cmpne(vector double __a, vector double __b) {
2107 return (vector bool long long)
2108 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2109}
Logan Chien55afb0a2018-10-15 10:42:14 +08002110#endif
2111
Logan Chien2833ffb2018-10-09 10:03:24 +08002112/* vec_cmpgt */
2113
2114static __inline__ vector bool char __ATTRS_o_ai
2115vec_cmpgt(vector signed char __a, vector signed char __b) {
2116 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
2117}
2118
2119static __inline__ vector bool char __ATTRS_o_ai
2120vec_cmpgt(vector unsigned char __a, vector unsigned char __b) {
2121 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
2122}
2123
2124static __inline__ vector bool short __ATTRS_o_ai vec_cmpgt(vector short __a,
2125 vector short __b) {
2126 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
2127}
2128
2129static __inline__ vector bool short __ATTRS_o_ai
2130vec_cmpgt(vector unsigned short __a, vector unsigned short __b) {
2131 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
2132}
2133
2134static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector int __a,
2135 vector int __b) {
2136 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
2137}
2138
2139static __inline__ vector bool int __ATTRS_o_ai
2140vec_cmpgt(vector unsigned int __a, vector unsigned int __b) {
2141 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
2142}
2143
2144#ifdef __POWER8_VECTOR__
2145static __inline__ vector bool long long __ATTRS_o_ai
2146vec_cmpgt(vector signed long long __a, vector signed long long __b) {
2147 return (vector bool long long)__builtin_altivec_vcmpgtsd(__a, __b);
2148}
2149
2150static __inline__ vector bool long long __ATTRS_o_ai
2151vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
2152 return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b);
2153}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002154#elif defined(__VSX__)
2155static __inline__ vector bool long long __ATTRS_o_ai
2156vec_cmpgt(vector signed long long __a, vector signed long long __b) {
2157 vector signed int __sgtw = (vector signed int)vec_cmpgt(
2158 (vector signed int)__a, (vector signed int)__b);
2159 vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt(
2160 (vector unsigned int)__a, (vector unsigned int)__b);
2161 vector unsigned int __eqw = (vector unsigned int)vec_cmpeq(
2162 (vector signed int)__a, (vector signed int)__b);
2163#ifdef __LITTLE_ENDIAN__
2164 __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw;
2165 __sgtw |= (vector signed int)__ugtw;
2166 return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 1, 1, 3,
2167 3);
2168#else
2169 __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw;
2170 __sgtw |= (vector signed int)__ugtw;
2171 return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 0, 0, 2,
2172 2);
2173#endif
2174}
2175
2176static __inline__ vector bool long long __ATTRS_o_ai
2177vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
2178 vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt(
2179 (vector unsigned int)__a, (vector unsigned int)__b);
2180 vector unsigned int __eqw = (vector unsigned int)vec_cmpeq(
2181 (vector signed int)__a, (vector signed int)__b);
2182#ifdef __LITTLE_ENDIAN__
2183 __eqw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw;
2184 __ugtw |= __eqw;
2185 return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 1, 1, 3,
2186 3);
2187#else
2188 __eqw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw;
2189 __ugtw |= __eqw;
2190 return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 0, 0, 2,
2191 2);
2192#endif
2193}
Logan Chien2833ffb2018-10-09 10:03:24 +08002194#endif
2195
2196static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector float __a,
2197 vector float __b) {
2198#ifdef __VSX__
2199 return (vector bool int)__builtin_vsx_xvcmpgtsp(__a, __b);
2200#else
2201 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
2202#endif
2203}
2204
2205#ifdef __VSX__
2206static __inline__ vector bool long long __ATTRS_o_ai
2207vec_cmpgt(vector double __a, vector double __b) {
2208 return (vector bool long long)__builtin_vsx_xvcmpgtdp(__a, __b);
2209}
2210#endif
2211
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002212#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002213static __inline__ vector bool __int128 __ATTRS_o_ai
2214vec_cmpgt(vector signed __int128 __a, vector signed __int128 __b) {
2215 return (vector bool __int128)__builtin_altivec_vcmpgtsq(
2216 (vector bool __int128)__a, (vector bool __int128)__b);
2217}
2218
2219static __inline__ vector bool __int128 __ATTRS_o_ai
2220vec_cmpgt(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2221 return (vector bool __int128)__builtin_altivec_vcmpgtuq(
2222 (vector bool __int128)__a, (vector bool __int128)__b);
2223}
2224#endif
2225
Logan Chien2833ffb2018-10-09 10:03:24 +08002226/* vec_cmpge */
2227
2228static __inline__ vector bool char __ATTRS_o_ai
2229vec_cmpge(vector signed char __a, vector signed char __b) {
2230 return ~(vec_cmpgt(__b, __a));
2231}
2232
2233static __inline__ vector bool char __ATTRS_o_ai
2234vec_cmpge(vector unsigned char __a, vector unsigned char __b) {
2235 return ~(vec_cmpgt(__b, __a));
2236}
2237
2238static __inline__ vector bool short __ATTRS_o_ai
2239vec_cmpge(vector signed short __a, vector signed short __b) {
2240 return ~(vec_cmpgt(__b, __a));
2241}
2242
2243static __inline__ vector bool short __ATTRS_o_ai
2244vec_cmpge(vector unsigned short __a, vector unsigned short __b) {
2245 return ~(vec_cmpgt(__b, __a));
2246}
2247
2248static __inline__ vector bool int __ATTRS_o_ai
2249vec_cmpge(vector signed int __a, vector signed int __b) {
2250 return ~(vec_cmpgt(__b, __a));
2251}
2252
2253static __inline__ vector bool int __ATTRS_o_ai
2254vec_cmpge(vector unsigned int __a, vector unsigned int __b) {
2255 return ~(vec_cmpgt(__b, __a));
2256}
2257
2258static __inline__ vector bool int __ATTRS_o_ai vec_cmpge(vector float __a,
2259 vector float __b) {
2260#ifdef __VSX__
2261 return (vector bool int)__builtin_vsx_xvcmpgesp(__a, __b);
2262#else
2263 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
2264#endif
2265}
2266
2267#ifdef __VSX__
2268static __inline__ vector bool long long __ATTRS_o_ai
2269vec_cmpge(vector double __a, vector double __b) {
2270 return (vector bool long long)__builtin_vsx_xvcmpgedp(__a, __b);
2271}
Logan Chien2833ffb2018-10-09 10:03:24 +08002272
Logan Chien2833ffb2018-10-09 10:03:24 +08002273static __inline__ vector bool long long __ATTRS_o_ai
2274vec_cmpge(vector signed long long __a, vector signed long long __b) {
2275 return ~(vec_cmpgt(__b, __a));
2276}
2277
2278static __inline__ vector bool long long __ATTRS_o_ai
2279vec_cmpge(vector unsigned long long __a, vector unsigned long long __b) {
2280 return ~(vec_cmpgt(__b, __a));
2281}
2282#endif
2283
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002284#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002285static __inline__ vector bool __int128 __ATTRS_o_ai
2286vec_cmpge(vector signed __int128 __a, vector signed __int128 __b) {
2287 return ~(vec_cmpgt(__b, __a));
2288}
2289
2290static __inline__ vector bool __int128 __ATTRS_o_ai
2291vec_cmpge(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2292 return ~(vec_cmpgt(__b, __a));
2293}
2294#endif
2295
Logan Chien2833ffb2018-10-09 10:03:24 +08002296/* vec_vcmpgefp */
2297
2298static __inline__ vector bool int __attribute__((__always_inline__))
2299vec_vcmpgefp(vector float __a, vector float __b) {
2300 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
2301}
2302
2303/* vec_vcmpgtsb */
2304
2305static __inline__ vector bool char __attribute__((__always_inline__))
2306vec_vcmpgtsb(vector signed char __a, vector signed char __b) {
2307 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
2308}
2309
2310/* vec_vcmpgtub */
2311
2312static __inline__ vector bool char __attribute__((__always_inline__))
2313vec_vcmpgtub(vector unsigned char __a, vector unsigned char __b) {
2314 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
2315}
2316
2317/* vec_vcmpgtsh */
2318
2319static __inline__ vector bool short __attribute__((__always_inline__))
2320vec_vcmpgtsh(vector short __a, vector short __b) {
2321 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
2322}
2323
2324/* vec_vcmpgtuh */
2325
2326static __inline__ vector bool short __attribute__((__always_inline__))
2327vec_vcmpgtuh(vector unsigned short __a, vector unsigned short __b) {
2328 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
2329}
2330
2331/* vec_vcmpgtsw */
2332
2333static __inline__ vector bool int __attribute__((__always_inline__))
2334vec_vcmpgtsw(vector int __a, vector int __b) {
2335 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
2336}
2337
2338/* vec_vcmpgtuw */
2339
2340static __inline__ vector bool int __attribute__((__always_inline__))
2341vec_vcmpgtuw(vector unsigned int __a, vector unsigned int __b) {
2342 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
2343}
2344
2345/* vec_vcmpgtfp */
2346
2347static __inline__ vector bool int __attribute__((__always_inline__))
2348vec_vcmpgtfp(vector float __a, vector float __b) {
2349 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
2350}
2351
2352/* vec_cmple */
2353
2354static __inline__ vector bool char __ATTRS_o_ai
2355vec_cmple(vector signed char __a, vector signed char __b) {
2356 return vec_cmpge(__b, __a);
2357}
2358
2359static __inline__ vector bool char __ATTRS_o_ai
2360vec_cmple(vector unsigned char __a, vector unsigned char __b) {
2361 return vec_cmpge(__b, __a);
2362}
2363
2364static __inline__ vector bool short __ATTRS_o_ai
2365vec_cmple(vector signed short __a, vector signed short __b) {
2366 return vec_cmpge(__b, __a);
2367}
2368
2369static __inline__ vector bool short __ATTRS_o_ai
2370vec_cmple(vector unsigned short __a, vector unsigned short __b) {
2371 return vec_cmpge(__b, __a);
2372}
2373
2374static __inline__ vector bool int __ATTRS_o_ai
2375vec_cmple(vector signed int __a, vector signed int __b) {
2376 return vec_cmpge(__b, __a);
2377}
2378
2379static __inline__ vector bool int __ATTRS_o_ai
2380vec_cmple(vector unsigned int __a, vector unsigned int __b) {
2381 return vec_cmpge(__b, __a);
2382}
2383
2384static __inline__ vector bool int __ATTRS_o_ai vec_cmple(vector float __a,
2385 vector float __b) {
2386 return vec_cmpge(__b, __a);
2387}
2388
2389#ifdef __VSX__
2390static __inline__ vector bool long long __ATTRS_o_ai
2391vec_cmple(vector double __a, vector double __b) {
2392 return vec_cmpge(__b, __a);
2393}
Logan Chien2833ffb2018-10-09 10:03:24 +08002394
Logan Chien2833ffb2018-10-09 10:03:24 +08002395static __inline__ vector bool long long __ATTRS_o_ai
2396vec_cmple(vector signed long long __a, vector signed long long __b) {
2397 return vec_cmpge(__b, __a);
2398}
2399
2400static __inline__ vector bool long long __ATTRS_o_ai
2401vec_cmple(vector unsigned long long __a, vector unsigned long long __b) {
2402 return vec_cmpge(__b, __a);
2403}
2404#endif
2405
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002406#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002407static __inline__ vector bool __int128 __ATTRS_o_ai
2408vec_cmple(vector signed __int128 __a, vector signed __int128 __b) {
2409 return vec_cmpge(__b, __a);
2410}
2411
2412static __inline__ vector bool __int128 __ATTRS_o_ai
2413vec_cmple(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2414 return vec_cmpge(__b, __a);
2415}
2416#endif
2417
Logan Chien2833ffb2018-10-09 10:03:24 +08002418/* vec_cmplt */
2419
2420static __inline__ vector bool char __ATTRS_o_ai
2421vec_cmplt(vector signed char __a, vector signed char __b) {
2422 return vec_cmpgt(__b, __a);
2423}
2424
2425static __inline__ vector bool char __ATTRS_o_ai
2426vec_cmplt(vector unsigned char __a, vector unsigned char __b) {
2427 return vec_cmpgt(__b, __a);
2428}
2429
2430static __inline__ vector bool short __ATTRS_o_ai vec_cmplt(vector short __a,
2431 vector short __b) {
2432 return vec_cmpgt(__b, __a);
2433}
2434
2435static __inline__ vector bool short __ATTRS_o_ai
2436vec_cmplt(vector unsigned short __a, vector unsigned short __b) {
2437 return vec_cmpgt(__b, __a);
2438}
2439
2440static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector int __a,
2441 vector int __b) {
2442 return vec_cmpgt(__b, __a);
2443}
2444
2445static __inline__ vector bool int __ATTRS_o_ai
2446vec_cmplt(vector unsigned int __a, vector unsigned int __b) {
2447 return vec_cmpgt(__b, __a);
2448}
2449
2450static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector float __a,
2451 vector float __b) {
2452 return vec_cmpgt(__b, __a);
2453}
2454
2455#ifdef __VSX__
2456static __inline__ vector bool long long __ATTRS_o_ai
2457vec_cmplt(vector double __a, vector double __b) {
2458 return vec_cmpgt(__b, __a);
2459}
2460#endif
2461
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002462#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08002463static __inline__ vector bool __int128 __ATTRS_o_ai
2464vec_cmplt(vector signed __int128 __a, vector signed __int128 __b) {
2465 return vec_cmpgt(__b, __a);
2466}
2467
2468static __inline__ vector bool __int128 __ATTRS_o_ai
2469vec_cmplt(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2470 return vec_cmpgt(__b, __a);
2471}
2472#endif
2473
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002474#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +08002475static __inline__ vector bool long long __ATTRS_o_ai
2476vec_cmplt(vector signed long long __a, vector signed long long __b) {
2477 return vec_cmpgt(__b, __a);
2478}
2479
2480static __inline__ vector bool long long __ATTRS_o_ai
2481vec_cmplt(vector unsigned long long __a, vector unsigned long long __b) {
2482 return vec_cmpgt(__b, __a);
2483}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002484#endif
Logan Chien2833ffb2018-10-09 10:03:24 +08002485
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002486#ifdef __POWER8_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +08002487/* vec_popcnt */
2488
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08002489static __inline__ vector unsigned char __ATTRS_o_ai
Logan Chien55afb0a2018-10-15 10:42:14 +08002490vec_popcnt(vector signed char __a) {
2491 return __builtin_altivec_vpopcntb(__a);
2492}
2493static __inline__ vector unsigned char __ATTRS_o_ai
2494vec_popcnt(vector unsigned char __a) {
2495 return __builtin_altivec_vpopcntb(__a);
2496}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08002497static __inline__ vector unsigned short __ATTRS_o_ai
Logan Chien55afb0a2018-10-15 10:42:14 +08002498vec_popcnt(vector signed short __a) {
2499 return __builtin_altivec_vpopcnth(__a);
2500}
2501static __inline__ vector unsigned short __ATTRS_o_ai
2502vec_popcnt(vector unsigned short __a) {
2503 return __builtin_altivec_vpopcnth(__a);
2504}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08002505static __inline__ vector unsigned int __ATTRS_o_ai
Logan Chien55afb0a2018-10-15 10:42:14 +08002506vec_popcnt(vector signed int __a) {
2507 return __builtin_altivec_vpopcntw(__a);
2508}
2509static __inline__ vector unsigned int __ATTRS_o_ai
2510vec_popcnt(vector unsigned int __a) {
2511 return __builtin_altivec_vpopcntw(__a);
2512}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08002513static __inline__ vector unsigned long long __ATTRS_o_ai
Logan Chien55afb0a2018-10-15 10:42:14 +08002514vec_popcnt(vector signed long long __a) {
2515 return __builtin_altivec_vpopcntd(__a);
2516}
2517static __inline__ vector unsigned long long __ATTRS_o_ai
2518vec_popcnt(vector unsigned long long __a) {
2519 return __builtin_altivec_vpopcntd(__a);
2520}
2521
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07002522#define vec_vclz vec_cntlz
Logan Chien2833ffb2018-10-09 10:03:24 +08002523/* vec_cntlz */
2524
2525static __inline__ vector signed char __ATTRS_o_ai
2526vec_cntlz(vector signed char __a) {
2527 return __builtin_altivec_vclzb(__a);
2528}
2529static __inline__ vector unsigned char __ATTRS_o_ai
2530vec_cntlz(vector unsigned char __a) {
2531 return __builtin_altivec_vclzb(__a);
2532}
2533static __inline__ vector signed short __ATTRS_o_ai
2534vec_cntlz(vector signed short __a) {
2535 return __builtin_altivec_vclzh(__a);
2536}
2537static __inline__ vector unsigned short __ATTRS_o_ai
2538vec_cntlz(vector unsigned short __a) {
2539 return __builtin_altivec_vclzh(__a);
2540}
2541static __inline__ vector signed int __ATTRS_o_ai
2542vec_cntlz(vector signed int __a) {
2543 return __builtin_altivec_vclzw(__a);
2544}
2545static __inline__ vector unsigned int __ATTRS_o_ai
2546vec_cntlz(vector unsigned int __a) {
2547 return __builtin_altivec_vclzw(__a);
2548}
2549static __inline__ vector signed long long __ATTRS_o_ai
2550vec_cntlz(vector signed long long __a) {
2551 return __builtin_altivec_vclzd(__a);
2552}
2553static __inline__ vector unsigned long long __ATTRS_o_ai
2554vec_cntlz(vector unsigned long long __a) {
2555 return __builtin_altivec_vclzd(__a);
2556}
2557#endif
2558
Logan Chien55afb0a2018-10-15 10:42:14 +08002559#ifdef __POWER9_VECTOR__
2560
2561/* vec_cnttz */
2562
2563static __inline__ vector signed char __ATTRS_o_ai
2564vec_cnttz(vector signed char __a) {
2565 return __builtin_altivec_vctzb(__a);
2566}
2567static __inline__ vector unsigned char __ATTRS_o_ai
2568vec_cnttz(vector unsigned char __a) {
2569 return __builtin_altivec_vctzb(__a);
2570}
2571static __inline__ vector signed short __ATTRS_o_ai
2572vec_cnttz(vector signed short __a) {
2573 return __builtin_altivec_vctzh(__a);
2574}
2575static __inline__ vector unsigned short __ATTRS_o_ai
2576vec_cnttz(vector unsigned short __a) {
2577 return __builtin_altivec_vctzh(__a);
2578}
2579static __inline__ vector signed int __ATTRS_o_ai
2580vec_cnttz(vector signed int __a) {
2581 return __builtin_altivec_vctzw(__a);
2582}
2583static __inline__ vector unsigned int __ATTRS_o_ai
2584vec_cnttz(vector unsigned int __a) {
2585 return __builtin_altivec_vctzw(__a);
2586}
2587static __inline__ vector signed long long __ATTRS_o_ai
2588vec_cnttz(vector signed long long __a) {
2589 return __builtin_altivec_vctzd(__a);
2590}
2591static __inline__ vector unsigned long long __ATTRS_o_ai
2592vec_cnttz(vector unsigned long long __a) {
2593 return __builtin_altivec_vctzd(__a);
2594}
2595
2596/* vec_first_match_index */
2597
2598static __inline__ unsigned __ATTRS_o_ai
2599vec_first_match_index(vector signed char __a, vector signed 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 unsigned char __a, vector unsigned char __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) >> 3;
2622 }
2623 return __res[0] >> 3;
2624}
2625
2626static __inline__ unsigned __ATTRS_o_ai
2627vec_first_match_index(vector signed short __a, vector signed 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 unsigned short __a, vector unsigned short __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) >> 4;
2650 }
2651 return __res[0] >> 4;
2652}
2653
2654static __inline__ unsigned __ATTRS_o_ai
2655vec_first_match_index(vector signed int __a, vector signed 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
2668static __inline__ unsigned __ATTRS_o_ai
2669vec_first_match_index(vector unsigned int __a, vector unsigned int __b) {
2670 vector unsigned long long __res =
2671#ifdef __LITTLE_ENDIAN__
2672 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2673#else
2674 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2675#endif
2676 if (__res[0] == 64) {
2677 return (__res[1] + 64) >> 5;
2678 }
2679 return __res[0] >> 5;
2680}
2681
2682/* vec_first_match_or_eos_index */
2683
2684static __inline__ unsigned __ATTRS_o_ai
2685vec_first_match_or_eos_index(vector signed char __a, vector signed char __b) {
2686 /* Compare the result of the comparison of two vectors with either and OR the
2687 result. Either the elements are equal or one will equal the comparison
2688 result if either is zero.
2689 */
2690 vector bool char __tmp1 = vec_cmpeq(__a, __b);
2691 vector bool char __tmp2 = __tmp1 |
2692 vec_cmpeq((vector signed char)__tmp1, __a) |
2693 vec_cmpeq((vector signed char)__tmp1, __b);
2694
2695 vector unsigned long long __res =
2696#ifdef __LITTLE_ENDIAN__
2697 vec_cnttz((vector unsigned long long)__tmp2);
2698#else
2699 vec_cntlz((vector unsigned long long)__tmp2);
2700#endif
2701 if (__res[0] == 64) {
2702 return (__res[1] + 64) >> 3;
2703 }
2704 return __res[0] >> 3;
2705}
2706
2707static __inline__ unsigned __ATTRS_o_ai
2708vec_first_match_or_eos_index(vector unsigned char __a,
2709 vector unsigned char __b) {
2710 vector bool char __tmp1 = vec_cmpeq(__a, __b);
2711 vector bool char __tmp2 = __tmp1 |
2712 vec_cmpeq((vector unsigned char)__tmp1, __a) |
2713 vec_cmpeq((vector unsigned char)__tmp1, __b);
2714
2715 vector unsigned long long __res =
2716#ifdef __LITTLE_ENDIAN__
2717 vec_cnttz((vector unsigned long long)__tmp2);
2718#else
2719 vec_cntlz((vector unsigned long long)__tmp2);
2720#endif
2721 if (__res[0] == 64) {
2722 return (__res[1] + 64) >> 3;
2723 }
2724 return __res[0] >> 3;
2725}
2726
2727static __inline__ unsigned __ATTRS_o_ai
2728vec_first_match_or_eos_index(vector signed short __a, vector signed short __b) {
2729 vector bool short __tmp1 = vec_cmpeq(__a, __b);
2730 vector bool short __tmp2 = __tmp1 |
2731 vec_cmpeq((vector signed short)__tmp1, __a) |
2732 vec_cmpeq((vector signed short)__tmp1, __b);
2733
2734 vector unsigned long long __res =
2735#ifdef __LITTLE_ENDIAN__
2736 vec_cnttz((vector unsigned long long)__tmp2);
2737#else
2738 vec_cntlz((vector unsigned long long)__tmp2);
2739#endif
2740 if (__res[0] == 64) {
2741 return (__res[1] + 64) >> 4;
2742 }
2743 return __res[0] >> 4;
2744}
2745
2746static __inline__ unsigned __ATTRS_o_ai
2747vec_first_match_or_eos_index(vector unsigned short __a,
2748 vector unsigned short __b) {
2749 vector bool short __tmp1 = vec_cmpeq(__a, __b);
2750 vector bool short __tmp2 = __tmp1 |
2751 vec_cmpeq((vector unsigned short)__tmp1, __a) |
2752 vec_cmpeq((vector unsigned short)__tmp1, __b);
2753
2754 vector unsigned long long __res =
2755#ifdef __LITTLE_ENDIAN__
2756 vec_cnttz((vector unsigned long long)__tmp2);
2757#else
2758 vec_cntlz((vector unsigned long long)__tmp2);
2759#endif
2760 if (__res[0] == 64) {
2761 return (__res[1] + 64) >> 4;
2762 }
2763 return __res[0] >> 4;
2764}
2765
2766static __inline__ unsigned __ATTRS_o_ai
2767vec_first_match_or_eos_index(vector signed int __a, vector signed int __b) {
2768 vector bool int __tmp1 = vec_cmpeq(__a, __b);
2769 vector bool int __tmp2 = __tmp1 | vec_cmpeq((vector signed int)__tmp1, __a) |
2770 vec_cmpeq((vector signed int)__tmp1, __b);
2771
2772 vector unsigned long long __res =
2773#ifdef __LITTLE_ENDIAN__
2774 vec_cnttz((vector unsigned long long)__tmp2);
2775#else
2776 vec_cntlz((vector unsigned long long)__tmp2);
2777#endif
2778 if (__res[0] == 64) {
2779 return (__res[1] + 64) >> 5;
2780 }
2781 return __res[0] >> 5;
2782}
2783
2784static __inline__ unsigned __ATTRS_o_ai
2785vec_first_match_or_eos_index(vector unsigned int __a, vector unsigned int __b) {
2786 vector bool int __tmp1 = vec_cmpeq(__a, __b);
2787 vector bool int __tmp2 = __tmp1 |
2788 vec_cmpeq((vector unsigned int)__tmp1, __a) |
2789 vec_cmpeq((vector unsigned int)__tmp1, __b);
2790
2791 vector unsigned long long __res =
2792#ifdef __LITTLE_ENDIAN__
2793 vec_cnttz((vector unsigned long long)__tmp2);
2794#else
2795 vec_cntlz((vector unsigned long long)__tmp2);
2796#endif
2797 if (__res[0] == 64) {
2798 return (__res[1] + 64) >> 5;
2799 }
2800 return __res[0] >> 5;
2801}
2802
2803/* vec_first_mismatch_index */
2804
2805static __inline__ unsigned __ATTRS_o_ai
2806vec_first_mismatch_index(vector signed char __a, vector signed 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 unsigned char __a, vector unsigned char __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) >> 3;
2829 }
2830 return __res[0] >> 3;
2831}
2832
2833static __inline__ unsigned __ATTRS_o_ai
2834vec_first_mismatch_index(vector signed short __a, vector signed 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 unsigned short __a, vector unsigned short __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) >> 4;
2857 }
2858 return __res[0] >> 4;
2859}
2860
2861static __inline__ unsigned __ATTRS_o_ai
2862vec_first_mismatch_index(vector signed int __a, vector signed 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
2875static __inline__ unsigned __ATTRS_o_ai
2876vec_first_mismatch_index(vector unsigned int __a, vector unsigned int __b) {
2877 vector unsigned long long __res =
2878#ifdef __LITTLE_ENDIAN__
2879 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2880#else
2881 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2882#endif
2883 if (__res[0] == 64) {
2884 return (__res[1] + 64) >> 5;
2885 }
2886 return __res[0] >> 5;
2887}
2888
2889/* vec_first_mismatch_or_eos_index */
2890
2891static __inline__ unsigned __ATTRS_o_ai
2892vec_first_mismatch_or_eos_index(vector signed char __a,
2893 vector signed char __b) {
2894 vector unsigned long long __res =
2895#ifdef __LITTLE_ENDIAN__
2896 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2897#else
2898 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2899#endif
2900 if (__res[0] == 64) {
2901 return (__res[1] + 64) >> 3;
2902 }
2903 return __res[0] >> 3;
2904}
2905
2906static __inline__ unsigned __ATTRS_o_ai
2907vec_first_mismatch_or_eos_index(vector unsigned char __a,
2908 vector unsigned char __b) {
2909 vector unsigned long long __res =
2910#ifdef __LITTLE_ENDIAN__
2911 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2912#else
2913 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2914#endif
2915 if (__res[0] == 64) {
2916 return (__res[1] + 64) >> 3;
2917 }
2918 return __res[0] >> 3;
2919}
2920
2921static __inline__ unsigned __ATTRS_o_ai
2922vec_first_mismatch_or_eos_index(vector signed short __a,
2923 vector signed short __b) {
2924 vector unsigned long long __res =
2925#ifdef __LITTLE_ENDIAN__
2926 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2927#else
2928 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2929#endif
2930 if (__res[0] == 64) {
2931 return (__res[1] + 64) >> 4;
2932 }
2933 return __res[0] >> 4;
2934}
2935
2936static __inline__ unsigned __ATTRS_o_ai
2937vec_first_mismatch_or_eos_index(vector unsigned short __a,
2938 vector unsigned short __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) >> 4;
2947 }
2948 return __res[0] >> 4;
2949}
2950
2951static __inline__ unsigned __ATTRS_o_ai
2952vec_first_mismatch_or_eos_index(vector signed int __a, vector signed int __b) {
2953 vector unsigned long long __res =
2954#ifdef __LITTLE_ENDIAN__
2955 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2956#else
2957 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2958#endif
2959 if (__res[0] == 64) {
2960 return (__res[1] + 64) >> 5;
2961 }
2962 return __res[0] >> 5;
2963}
2964
2965static __inline__ unsigned __ATTRS_o_ai
2966vec_first_mismatch_or_eos_index(vector unsigned int __a,
2967 vector unsigned int __b) {
2968 vector unsigned long long __res =
2969#ifdef __LITTLE_ENDIAN__
2970 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2971#else
2972 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2973#endif
2974 if (__res[0] == 64) {
2975 return (__res[1] + 64) >> 5;
2976 }
2977 return __res[0] >> 5;
2978}
2979
2980static __inline__ vector double __ATTRS_o_ai
2981vec_insert_exp(vector double __a, vector unsigned long long __b) {
2982 return __builtin_vsx_xviexpdp((vector unsigned long long)__a,__b);
2983}
2984
2985static __inline__ vector double __ATTRS_o_ai
2986vec_insert_exp(vector unsigned long long __a, vector unsigned long long __b) {
2987 return __builtin_vsx_xviexpdp(__a,__b);
2988}
2989
2990static __inline__ vector float __ATTRS_o_ai
2991vec_insert_exp(vector float __a, vector unsigned int __b) {
2992 return __builtin_vsx_xviexpsp((vector unsigned int)__a,__b);
2993}
2994
2995static __inline__ vector float __ATTRS_o_ai
2996vec_insert_exp(vector unsigned int __a, vector unsigned int __b) {
2997 return __builtin_vsx_xviexpsp(__a,__b);
2998}
2999
3000#if defined(__powerpc64__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003001static __inline__ vector signed char __ATTRS_o_ai vec_xl_len(const signed char *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003002 size_t __b) {
3003 return (vector signed char)__builtin_vsx_lxvl(__a, (__b << 56));
3004}
3005
3006static __inline__ vector unsigned char __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003007vec_xl_len(const unsigned char *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003008 return (vector unsigned char)__builtin_vsx_lxvl(__a, (__b << 56));
3009}
3010
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003011static __inline__ vector signed short __ATTRS_o_ai vec_xl_len(const signed short *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003012 size_t __b) {
3013 return (vector signed short)__builtin_vsx_lxvl(__a, (__b << 56));
3014}
3015
3016static __inline__ vector unsigned short __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003017vec_xl_len(const unsigned short *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003018 return (vector unsigned short)__builtin_vsx_lxvl(__a, (__b << 56));
3019}
3020
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003021static __inline__ vector signed int __ATTRS_o_ai vec_xl_len(const signed int *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003022 size_t __b) {
3023 return (vector signed int)__builtin_vsx_lxvl(__a, (__b << 56));
3024}
3025
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003026static __inline__ vector unsigned int __ATTRS_o_ai vec_xl_len(const unsigned int *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003027 size_t __b) {
3028 return (vector unsigned int)__builtin_vsx_lxvl(__a, (__b << 56));
3029}
3030
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003031static __inline__ vector float __ATTRS_o_ai vec_xl_len(const float *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003032 return (vector float)__builtin_vsx_lxvl(__a, (__b << 56));
3033}
3034
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003035#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +08003036static __inline__ vector signed __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003037vec_xl_len(const signed __int128 *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003038 return (vector signed __int128)__builtin_vsx_lxvl(__a, (__b << 56));
3039}
3040
3041static __inline__ vector unsigned __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003042vec_xl_len(const unsigned __int128 *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003043 return (vector unsigned __int128)__builtin_vsx_lxvl(__a, (__b << 56));
3044}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003045#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08003046
3047static __inline__ vector signed long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003048vec_xl_len(const signed long long *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003049 return (vector signed long long)__builtin_vsx_lxvl(__a, (__b << 56));
3050}
3051
3052static __inline__ vector unsigned long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003053vec_xl_len(const unsigned long long *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003054 return (vector unsigned long long)__builtin_vsx_lxvl(__a, (__b << 56));
3055}
3056
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003057static __inline__ vector double __ATTRS_o_ai vec_xl_len(const double *__a,
Logan Chien55afb0a2018-10-15 10:42:14 +08003058 size_t __b) {
3059 return (vector double)__builtin_vsx_lxvl(__a, (__b << 56));
3060}
3061
Sasha Smundak746b0222020-02-25 09:19:04 -08003062static __inline__ vector unsigned char __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003063vec_xl_len_r(const unsigned char *__a, size_t __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003064 vector unsigned char __res =
3065 (vector unsigned char)__builtin_vsx_lxvll(__a, (__b << 56));
Logan Chien55afb0a2018-10-15 10:42:14 +08003066 vector unsigned char __mask =
3067 (vector unsigned char)__builtin_altivec_lvsr(16 - __b, (int *)NULL);
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08003068 return (vector unsigned char)__builtin_altivec_vperm_4si(
Logan Chien55afb0a2018-10-15 10:42:14 +08003069 (vector int)__res, (vector int)__res, __mask);
Logan Chien55afb0a2018-10-15 10:42:14 +08003070}
3071
3072// vec_xst_len
3073static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned char __a,
3074 unsigned char *__b,
3075 size_t __c) {
3076 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3077}
3078
3079static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed char __a,
3080 signed char *__b, size_t __c) {
3081 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3082}
3083
3084static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed short __a,
3085 signed short *__b, size_t __c) {
3086 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3087}
3088
3089static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned short __a,
3090 unsigned short *__b,
3091 size_t __c) {
3092 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3093}
3094
3095static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed int __a,
3096 signed int *__b, size_t __c) {
3097 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3098}
3099
3100static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned int __a,
3101 unsigned int *__b, size_t __c) {
3102 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3103}
3104
3105static __inline__ void __ATTRS_o_ai vec_xst_len(vector float __a, float *__b,
3106 size_t __c) {
3107 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3108}
3109
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003110#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +08003111static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed __int128 __a,
3112 signed __int128 *__b,
3113 size_t __c) {
3114 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3115}
3116
3117static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned __int128 __a,
3118 unsigned __int128 *__b,
3119 size_t __c) {
3120 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3121}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003122#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08003123
3124static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed long long __a,
3125 signed long long *__b,
3126 size_t __c) {
3127 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3128}
3129
3130static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned long long __a,
3131 unsigned long long *__b,
3132 size_t __c) {
3133 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3134}
3135
3136static __inline__ void __ATTRS_o_ai vec_xst_len(vector double __a, double *__b,
3137 size_t __c) {
3138 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3139}
3140
3141static __inline__ void __ATTRS_o_ai vec_xst_len_r(vector unsigned char __a,
3142 unsigned char *__b,
3143 size_t __c) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003144 vector unsigned char __mask =
3145 (vector unsigned char)__builtin_altivec_lvsl(16 - __c, (int *)NULL);
3146 vector unsigned char __res =
3147 __builtin_altivec_vperm_4si((vector int)__a, (vector int)__a, __mask);
3148 return __builtin_vsx_stxvll((vector int)__res, __b, (__c << 56));
Logan Chien55afb0a2018-10-15 10:42:14 +08003149}
3150#endif
3151#endif
3152
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08003153#if defined(__POWER9_VECTOR__) && defined(__powerpc64__)
3154#define __vec_ldrmb(PTR, CNT) vec_xl_len_r((const unsigned char *)(PTR), (CNT))
3155#define __vec_strmb(PTR, CNT, VAL) \
3156 vec_xst_len_r((VAL), (unsigned char *)(PTR), (CNT))
3157#else
3158#define __vec_ldrmb __builtin_vsx_ldrmb
3159#define __vec_strmb __builtin_vsx_strmb
3160#endif
3161
Logan Chien2833ffb2018-10-09 10:03:24 +08003162/* vec_cpsgn */
3163
3164#ifdef __VSX__
3165static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a,
3166 vector float __b) {
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07003167 return __builtin_vsx_xvcpsgnsp(__b, __a);
Logan Chien2833ffb2018-10-09 10:03:24 +08003168}
3169
3170static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
3171 vector double __b) {
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07003172 return __builtin_vsx_xvcpsgndp(__b, __a);
Logan Chien2833ffb2018-10-09 10:03:24 +08003173}
3174#endif
3175
3176/* vec_ctf */
3177
Logan Chien2833ffb2018-10-09 10:03:24 +08003178#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003179// There are some functions that have different signatures with the XL compiler
3180// from those in Clang/GCC and documented in the PVIPR. This macro ensures that
3181// the XL-compatible signatures are used for those functions.
3182#ifdef __XL_COMPAT_ALTIVEC__
3183#define vec_ctf(__a, __b) \
3184 _Generic((__a), vector int \
3185 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
3186 vector unsigned int \
3187 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3188 (__b)), \
3189 vector unsigned long long \
3190 : (__builtin_vsx_xvcvuxdsp((vector unsigned long long)(__a)) * \
3191 (vector float)(vector unsigned)((0x7f - (__b)) << 23)), \
3192 vector signed long long \
3193 : (__builtin_vsx_xvcvsxdsp((vector signed long long)(__a)) * \
3194 (vector float)(vector unsigned)((0x7f - (__b)) << 23)))
3195#else // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003196#define vec_ctf(__a, __b) \
3197 _Generic((__a), vector int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003198 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
Logan Chien55afb0a2018-10-15 10:42:14 +08003199 vector unsigned int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003200 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3201 (__b)), \
Logan Chien55afb0a2018-10-15 10:42:14 +08003202 vector unsigned long long \
3203 : (__builtin_convertvector((vector unsigned long long)(__a), \
3204 vector double) * \
3205 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3206 << 52)), \
3207 vector signed long long \
3208 : (__builtin_convertvector((vector signed long long)(__a), \
3209 vector double) * \
3210 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3211 << 52)))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003212#endif // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003213#else
3214#define vec_ctf(__a, __b) \
3215 _Generic((__a), vector int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003216 : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)), \
Logan Chien55afb0a2018-10-15 10:42:14 +08003217 vector unsigned int \
Sasha Smundak746b0222020-02-25 09:19:04 -08003218 : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
3219 (__b)))
Logan Chien2833ffb2018-10-09 10:03:24 +08003220#endif
3221
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003222/* vec_ctd */
3223#ifdef __VSX__
3224#define vec_ctd(__a, __b) \
3225 _Generic((__a), vector signed int \
3226 : (vec_doublee((vector signed int)(__a)) * \
3227 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3228 << 52)), \
3229 vector unsigned int \
3230 : (vec_doublee((vector unsigned int)(__a)) * \
3231 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3232 << 52)), \
3233 vector unsigned long long \
3234 : (__builtin_convertvector((vector unsigned long long)(__a), \
3235 vector double) * \
3236 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3237 << 52)), \
3238 vector signed long long \
3239 : (__builtin_convertvector((vector signed long long)(__a), \
3240 vector double) * \
3241 (vector double)(vector unsigned long long)((0x3ffULL - (__b)) \
3242 << 52)))
3243#endif // __VSX__
3244
Logan Chien2833ffb2018-10-09 10:03:24 +08003245/* vec_vcfsx */
3246
Logan Chien55afb0a2018-10-15 10:42:14 +08003247#define vec_vcfux __builtin_altivec_vcfux
Logan Chien2833ffb2018-10-09 10:03:24 +08003248/* vec_vcfux */
3249
Logan Chien55afb0a2018-10-15 10:42:14 +08003250#define vec_vcfsx(__a, __b) __builtin_altivec_vcfsx((vector int)(__a), (__b))
Logan Chien2833ffb2018-10-09 10:03:24 +08003251
3252/* vec_cts */
3253
Logan Chien2833ffb2018-10-09 10:03:24 +08003254#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003255#ifdef __XL_COMPAT_ALTIVEC__
3256#define vec_cts(__a, __b) \
3257 _Generic((__a), vector float \
3258 : __builtin_altivec_vctsxs((vector float)(__a), (__b)), \
3259 vector double \
3260 : __extension__({ \
3261 vector double __ret = \
3262 (vector double)(__a) * \
3263 (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
3264 << 52); \
3265 __builtin_vsx_xvcvdpsxws(__ret); \
3266 }))
3267#else // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003268#define vec_cts(__a, __b) \
3269 _Generic((__a), vector float \
Sasha Smundak746b0222020-02-25 09:19:04 -08003270 : __builtin_altivec_vctsxs((vector float)(__a), (__b)), \
3271 vector double \
Logan Chien55afb0a2018-10-15 10:42:14 +08003272 : __extension__({ \
3273 vector double __ret = \
Sasha Smundak746b0222020-02-25 09:19:04 -08003274 (vector double)(__a) * \
Logan Chien55afb0a2018-10-15 10:42:14 +08003275 (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
3276 << 52); \
3277 __builtin_convertvector(__ret, vector signed long long); \
3278 }))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003279#endif // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003280#else
3281#define vec_cts __builtin_altivec_vctsxs
Logan Chien2833ffb2018-10-09 10:03:24 +08003282#endif
3283
3284/* vec_vctsxs */
3285
Logan Chien55afb0a2018-10-15 10:42:14 +08003286#define vec_vctsxs __builtin_altivec_vctsxs
Logan Chien2833ffb2018-10-09 10:03:24 +08003287
3288/* vec_ctu */
3289
Logan Chien2833ffb2018-10-09 10:03:24 +08003290#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003291#ifdef __XL_COMPAT_ALTIVEC__
3292#define vec_ctu(__a, __b) \
3293 _Generic((__a), vector float \
3294 : __builtin_altivec_vctuxs((vector float)(__a), (__b)), \
3295 vector double \
3296 : __extension__({ \
3297 vector double __ret = \
3298 (vector double)(__a) * \
3299 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3300 << 52); \
3301 __builtin_vsx_xvcvdpuxws(__ret); \
3302 }))
3303#else // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003304#define vec_ctu(__a, __b) \
3305 _Generic((__a), vector float \
Sasha Smundak746b0222020-02-25 09:19:04 -08003306 : __builtin_altivec_vctuxs((vector float)(__a), (__b)), \
3307 vector double \
Logan Chien55afb0a2018-10-15 10:42:14 +08003308 : __extension__({ \
3309 vector double __ret = \
Sasha Smundak746b0222020-02-25 09:19:04 -08003310 (vector double)(__a) * \
Logan Chien55afb0a2018-10-15 10:42:14 +08003311 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3312 << 52); \
3313 __builtin_convertvector(__ret, vector unsigned long long); \
3314 }))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003315#endif // __XL_COMPAT_ALTIVEC__
Logan Chien55afb0a2018-10-15 10:42:14 +08003316#else
3317#define vec_ctu __builtin_altivec_vctuxs
Logan Chien2833ffb2018-10-09 10:03:24 +08003318#endif
3319
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003320#ifdef __LITTLE_ENDIAN__
3321/* vec_ctsl */
3322
3323#ifdef __VSX__
3324#define vec_ctsl(__a, __b) \
3325 _Generic((__a), vector float \
3326 : __extension__({ \
3327 vector float __ret = \
3328 (vector float)(__a) * \
3329 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3330 __builtin_vsx_xvcvspsxds( \
3331 __builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3332 }), \
3333 vector double \
3334 : __extension__({ \
3335 vector double __ret = \
3336 (vector double)(__a) * \
3337 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3338 << 52); \
3339 __builtin_convertvector(__ret, vector signed long long); \
3340 }))
3341
3342/* vec_ctul */
3343
3344#define vec_ctul(__a, __b) \
3345 _Generic((__a), vector float \
3346 : __extension__({ \
3347 vector float __ret = \
3348 (vector float)(__a) * \
3349 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3350 __builtin_vsx_xvcvspuxds( \
3351 __builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3352 }), \
3353 vector double \
3354 : __extension__({ \
3355 vector double __ret = \
3356 (vector double)(__a) * \
3357 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3358 << 52); \
3359 __builtin_convertvector(__ret, vector unsigned long long); \
3360 }))
3361#endif
3362#else // __LITTLE_ENDIAN__
3363/* vec_ctsl */
3364
3365#ifdef __VSX__
3366#define vec_ctsl(__a, __b) \
3367 _Generic((__a), vector float \
3368 : __extension__({ \
3369 vector float __ret = \
3370 (vector float)(__a) * \
3371 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3372 __builtin_vsx_xvcvspsxds(__ret); \
3373 }), \
3374 vector double \
3375 : __extension__({ \
3376 vector double __ret = \
3377 (vector double)(__a) * \
3378 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3379 << 52); \
3380 __builtin_convertvector(__ret, vector signed long long); \
3381 }))
3382
3383/* vec_ctul */
3384
3385#define vec_ctul(__a, __b) \
3386 _Generic((__a), vector float \
3387 : __extension__({ \
3388 vector float __ret = \
3389 (vector float)(__a) * \
3390 (vector float)(vector unsigned)((0x7f + (__b)) << 23); \
3391 __builtin_vsx_xvcvspuxds(__ret); \
3392 }), \
3393 vector double \
3394 : __extension__({ \
3395 vector double __ret = \
3396 (vector double)(__a) * \
3397 (vector double)(vector unsigned long long)((0x3ffULL + __b) \
3398 << 52); \
3399 __builtin_convertvector(__ret, vector unsigned long long); \
3400 }))
3401#endif
3402#endif // __LITTLE_ENDIAN__
3403
Logan Chien2833ffb2018-10-09 10:03:24 +08003404/* vec_vctuxs */
3405
Logan Chien55afb0a2018-10-15 10:42:14 +08003406#define vec_vctuxs __builtin_altivec_vctuxs
3407
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003408/* vec_signext */
3409
3410#ifdef __POWER9_VECTOR__
3411static __inline__ vector signed int __ATTRS_o_ai
3412vec_signexti(vector signed char __a) {
3413 return __builtin_altivec_vextsb2w(__a);
3414}
3415
3416static __inline__ vector signed int __ATTRS_o_ai
3417vec_signexti(vector signed short __a) {
3418 return __builtin_altivec_vextsh2w(__a);
3419}
3420
3421static __inline__ vector signed long long __ATTRS_o_ai
3422vec_signextll(vector signed char __a) {
3423 return __builtin_altivec_vextsb2d(__a);
3424}
3425
3426static __inline__ vector signed long long __ATTRS_o_ai
3427vec_signextll(vector signed short __a) {
3428 return __builtin_altivec_vextsh2d(__a);
3429}
3430
3431static __inline__ vector signed long long __ATTRS_o_ai
3432vec_signextll(vector signed int __a) {
3433 return __builtin_altivec_vextsw2d(__a);
3434}
3435#endif
3436
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003437#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003438static __inline__ vector signed __int128 __ATTRS_o_ai
3439vec_signextq(vector signed long long __a) {
3440 return __builtin_altivec_vextsd2q(__a);
3441}
3442#endif
3443
Logan Chien55afb0a2018-10-15 10:42:14 +08003444/* vec_signed */
3445
3446static __inline__ vector signed int __ATTRS_o_ai
3447vec_sld(vector signed int, vector signed int, unsigned const int __c);
3448
3449static __inline__ vector signed int __ATTRS_o_ai
3450vec_signed(vector float __a) {
3451 return __builtin_convertvector(__a, vector signed int);
Logan Chien2833ffb2018-10-09 10:03:24 +08003452}
3453
Logan Chien55afb0a2018-10-15 10:42:14 +08003454#ifdef __VSX__
3455static __inline__ vector signed long long __ATTRS_o_ai
3456vec_signed(vector double __a) {
3457 return __builtin_convertvector(__a, vector signed long long);
3458}
3459
3460static __inline__ vector signed int __attribute__((__always_inline__))
3461vec_signed2(vector double __a, vector double __b) {
3462 return (vector signed int) { __a[0], __a[1], __b[0], __b[1] };
3463}
3464
3465static __inline__ vector signed int __ATTRS_o_ai
3466vec_signede(vector double __a) {
3467#ifdef __LITTLE_ENDIAN__
3468 vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a);
3469 return vec_sld(__ret, __ret, 12);
3470#else
3471 return __builtin_vsx_xvcvdpsxws(__a);
3472#endif
3473}
3474
3475static __inline__ vector signed int __ATTRS_o_ai
3476vec_signedo(vector double __a) {
3477#ifdef __LITTLE_ENDIAN__
3478 return __builtin_vsx_xvcvdpsxws(__a);
3479#else
3480 vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a);
3481 return vec_sld(__ret, __ret, 12);
3482#endif
3483}
3484#endif
3485
3486/* vec_unsigned */
3487
3488static __inline__ vector unsigned int __ATTRS_o_ai
3489vec_sld(vector unsigned int, vector unsigned int, unsigned const int __c);
3490
3491static __inline__ vector unsigned int __ATTRS_o_ai
3492vec_unsigned(vector float __a) {
3493 return __builtin_convertvector(__a, vector unsigned int);
3494}
3495
3496#ifdef __VSX__
3497static __inline__ vector unsigned long long __ATTRS_o_ai
3498vec_unsigned(vector double __a) {
3499 return __builtin_convertvector(__a, vector unsigned long long);
3500}
3501
3502static __inline__ vector unsigned int __attribute__((__always_inline__))
3503vec_unsigned2(vector double __a, vector double __b) {
3504 return (vector unsigned int) { __a[0], __a[1], __b[0], __b[1] };
3505}
3506
3507static __inline__ vector unsigned int __ATTRS_o_ai
3508vec_unsignede(vector double __a) {
3509#ifdef __LITTLE_ENDIAN__
3510 vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a);
3511 return vec_sld(__ret, __ret, 12);
3512#else
3513 return __builtin_vsx_xvcvdpuxws(__a);
3514#endif
3515}
3516
3517static __inline__ vector unsigned int __ATTRS_o_ai
3518vec_unsignedo(vector double __a) {
3519#ifdef __LITTLE_ENDIAN__
3520 return __builtin_vsx_xvcvdpuxws(__a);
3521#else
3522 vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a);
3523 return vec_sld(__ret, __ret, 12);
3524#endif
3525}
3526#endif
3527
3528/* vec_float */
3529
3530static __inline__ vector float __ATTRS_o_ai
3531vec_sld(vector float, vector float, unsigned const int __c);
3532
3533static __inline__ vector float __ATTRS_o_ai
3534vec_float(vector signed int __a) {
3535 return __builtin_convertvector(__a, vector float);
3536}
3537
3538static __inline__ vector float __ATTRS_o_ai
3539vec_float(vector unsigned int __a) {
3540 return __builtin_convertvector(__a, vector float);
3541}
3542
3543#ifdef __VSX__
3544static __inline__ vector float __ATTRS_o_ai
3545vec_float2(vector signed long long __a, vector signed long long __b) {
3546 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3547}
3548
3549static __inline__ vector float __ATTRS_o_ai
3550vec_float2(vector unsigned long long __a, vector unsigned long long __b) {
3551 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3552}
3553
3554static __inline__ vector float __ATTRS_o_ai
3555vec_float2(vector double __a, vector double __b) {
3556 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3557}
3558
3559static __inline__ vector float __ATTRS_o_ai
3560vec_floate(vector signed long long __a) {
3561#ifdef __LITTLE_ENDIAN__
3562 vector float __ret = __builtin_vsx_xvcvsxdsp(__a);
3563 return vec_sld(__ret, __ret, 12);
3564#else
3565 return __builtin_vsx_xvcvsxdsp(__a);
3566#endif
3567}
3568
3569static __inline__ vector float __ATTRS_o_ai
3570vec_floate(vector unsigned long long __a) {
3571#ifdef __LITTLE_ENDIAN__
3572 vector float __ret = __builtin_vsx_xvcvuxdsp(__a);
3573 return vec_sld(__ret, __ret, 12);
3574#else
3575 return __builtin_vsx_xvcvuxdsp(__a);
3576#endif
3577}
3578
3579static __inline__ vector float __ATTRS_o_ai
3580vec_floate(vector double __a) {
3581#ifdef __LITTLE_ENDIAN__
3582 vector float __ret = __builtin_vsx_xvcvdpsp(__a);
3583 return vec_sld(__ret, __ret, 12);
3584#else
3585 return __builtin_vsx_xvcvdpsp(__a);
3586#endif
3587}
3588
3589static __inline__ vector float __ATTRS_o_ai
3590vec_floato(vector signed long long __a) {
3591#ifdef __LITTLE_ENDIAN__
3592 return __builtin_vsx_xvcvsxdsp(__a);
3593#else
3594 vector float __ret = __builtin_vsx_xvcvsxdsp(__a);
3595 return vec_sld(__ret, __ret, 12);
3596#endif
3597}
3598
3599static __inline__ vector float __ATTRS_o_ai
3600vec_floato(vector unsigned long long __a) {
3601#ifdef __LITTLE_ENDIAN__
3602 return __builtin_vsx_xvcvuxdsp(__a);
3603#else
3604 vector float __ret = __builtin_vsx_xvcvuxdsp(__a);
3605 return vec_sld(__ret, __ret, 12);
3606#endif
3607}
3608
3609static __inline__ vector float __ATTRS_o_ai
3610vec_floato(vector double __a) {
3611#ifdef __LITTLE_ENDIAN__
3612 return __builtin_vsx_xvcvdpsp(__a);
3613#else
3614 vector float __ret = __builtin_vsx_xvcvdpsp(__a);
3615 return vec_sld(__ret, __ret, 12);
3616#endif
3617}
3618#endif
3619
Logan Chien2833ffb2018-10-09 10:03:24 +08003620/* vec_double */
3621
3622#ifdef __VSX__
3623static __inline__ vector double __ATTRS_o_ai
3624vec_double(vector signed long long __a) {
Logan Chien55afb0a2018-10-15 10:42:14 +08003625 return __builtin_convertvector(__a, vector double);
3626}
3627
3628static __inline__ vector double __ATTRS_o_ai
3629vec_double(vector unsigned long long __a) {
3630 return __builtin_convertvector(__a, vector double);
3631}
3632
3633static __inline__ vector double __ATTRS_o_ai
3634vec_doublee(vector signed int __a) {
3635#ifdef __LITTLE_ENDIAN__
3636 return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4));
3637#else
3638 return __builtin_vsx_xvcvsxwdp(__a);
3639#endif
3640}
3641
3642static __inline__ vector double __ATTRS_o_ai
3643vec_doublee(vector unsigned int __a) {
3644#ifdef __LITTLE_ENDIAN__
3645 return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4));
3646#else
3647 return __builtin_vsx_xvcvuxwdp(__a);
3648#endif
3649}
3650
3651static __inline__ vector double __ATTRS_o_ai
3652vec_doublee(vector float __a) {
3653#ifdef __LITTLE_ENDIAN__
3654 return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4));
3655#else
3656 return __builtin_vsx_xvcvspdp(__a);
3657#endif
3658}
3659
3660static __inline__ vector double __ATTRS_o_ai
3661vec_doubleh(vector signed int __a) {
Logan Chien2833ffb2018-10-09 10:03:24 +08003662 vector double __ret = {__a[0], __a[1]};
3663 return __ret;
3664}
3665
3666static __inline__ vector double __ATTRS_o_ai
Logan Chien55afb0a2018-10-15 10:42:14 +08003667vec_doubleh(vector unsigned int __a) {
Logan Chien2833ffb2018-10-09 10:03:24 +08003668 vector double __ret = {__a[0], __a[1]};
3669 return __ret;
3670}
Logan Chien55afb0a2018-10-15 10:42:14 +08003671
3672static __inline__ vector double __ATTRS_o_ai
3673vec_doubleh(vector float __a) {
3674 vector double __ret = {__a[0], __a[1]};
3675 return __ret;
3676}
3677
3678static __inline__ vector double __ATTRS_o_ai
3679vec_doublel(vector signed int __a) {
3680 vector double __ret = {__a[2], __a[3]};
3681 return __ret;
3682}
3683
3684static __inline__ vector double __ATTRS_o_ai
3685vec_doublel(vector unsigned int __a) {
3686 vector double __ret = {__a[2], __a[3]};
3687 return __ret;
3688}
3689
3690static __inline__ vector double __ATTRS_o_ai
3691vec_doublel(vector float __a) {
3692 vector double __ret = {__a[2], __a[3]};
3693 return __ret;
3694}
3695
3696static __inline__ vector double __ATTRS_o_ai
3697vec_doubleo(vector signed int __a) {
3698#ifdef __LITTLE_ENDIAN__
3699 return __builtin_vsx_xvcvsxwdp(__a);
3700#else
3701 return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4));
3702#endif
3703}
3704
3705static __inline__ vector double __ATTRS_o_ai
3706vec_doubleo(vector unsigned int __a) {
3707#ifdef __LITTLE_ENDIAN__
3708 return __builtin_vsx_xvcvuxwdp(__a);
3709#else
3710 return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4));
3711#endif
3712}
3713
3714static __inline__ vector double __ATTRS_o_ai
3715vec_doubleo(vector float __a) {
3716#ifdef __LITTLE_ENDIAN__
3717 return __builtin_vsx_xvcvspdp(__a);
3718#else
3719 return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4));
3720#endif
3721}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003722
3723/* vec_cvf */
3724static __inline__ vector double __ATTRS_o_ai vec_cvf(vector float __a) {
3725 return vec_doublee(__a);
3726}
3727
3728static __inline__ vector float __ATTRS_o_ai vec_cvf(vector double __a) {
3729 return vec_floate(__a);
3730}
Logan Chien2833ffb2018-10-09 10:03:24 +08003731#endif
3732
3733/* vec_div */
3734
3735/* Integer vector divides (vectors are scalarized, elements divided
3736 and the vectors reassembled).
3737*/
3738static __inline__ vector signed char __ATTRS_o_ai
3739vec_div(vector signed char __a, vector signed char __b) {
3740 return __a / __b;
3741}
3742
3743static __inline__ vector unsigned char __ATTRS_o_ai
3744vec_div(vector unsigned char __a, vector unsigned char __b) {
3745 return __a / __b;
3746}
3747
3748static __inline__ vector signed short __ATTRS_o_ai
3749vec_div(vector signed short __a, vector signed short __b) {
3750 return __a / __b;
3751}
3752
3753static __inline__ vector unsigned short __ATTRS_o_ai
3754vec_div(vector unsigned short __a, vector unsigned short __b) {
3755 return __a / __b;
3756}
3757
3758static __inline__ vector signed int __ATTRS_o_ai
3759vec_div(vector signed int __a, vector signed int __b) {
3760 return __a / __b;
3761}
3762
3763static __inline__ vector unsigned int __ATTRS_o_ai
3764vec_div(vector unsigned int __a, vector unsigned int __b) {
3765 return __a / __b;
3766}
3767
3768#ifdef __VSX__
3769static __inline__ vector signed long long __ATTRS_o_ai
3770vec_div(vector signed long long __a, vector signed long long __b) {
3771 return __a / __b;
3772}
3773
3774static __inline__ vector unsigned long long __ATTRS_o_ai
3775vec_div(vector unsigned long long __a, vector unsigned long long __b) {
3776 return __a / __b;
3777}
3778
3779static __inline__ vector float __ATTRS_o_ai vec_div(vector float __a,
3780 vector float __b) {
3781 return __a / __b;
3782}
3783
3784static __inline__ vector double __ATTRS_o_ai vec_div(vector double __a,
3785 vector double __b) {
3786 return __a / __b;
3787}
3788#endif
3789
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003790/* vec_dive */
3791
3792#ifdef __POWER10_VECTOR__
3793static __inline__ vector signed int __ATTRS_o_ai
3794vec_dive(vector signed int __a, vector signed int __b) {
3795 return __builtin_altivec_vdivesw(__a, __b);
3796}
3797
3798static __inline__ vector unsigned int __ATTRS_o_ai
3799vec_dive(vector unsigned int __a, vector unsigned int __b) {
3800 return __builtin_altivec_vdiveuw(__a, __b);
3801}
3802
3803static __inline__ vector signed long long __ATTRS_o_ai
3804vec_dive(vector signed long long __a, vector signed long long __b) {
3805 return __builtin_altivec_vdivesd(__a, __b);
3806}
3807
3808static __inline__ vector unsigned long long __ATTRS_o_ai
3809vec_dive(vector unsigned long long __a, vector unsigned long long __b) {
3810 return __builtin_altivec_vdiveud(__a, __b);
3811}
3812
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003813#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003814static __inline__ vector unsigned __int128 __ATTRS_o_ai
3815vec_dive(vector unsigned __int128 __a, vector unsigned __int128 __b) {
3816 return __builtin_altivec_vdiveuq(__a, __b);
3817}
3818
3819static __inline__ vector signed __int128 __ATTRS_o_ai
3820vec_dive(vector signed __int128 __a, vector signed __int128 __b) {
3821 return __builtin_altivec_vdivesq(__a, __b);
3822}
3823#endif
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003824#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003825
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003826#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003827static __inline__ vector unsigned __int128 __ATTRS_o_ai
3828vec_div(vector unsigned __int128 __a, vector unsigned __int128 __b) {
3829 return __a / __b;
3830}
3831
3832static __inline__ vector signed __int128 __ATTRS_o_ai
3833vec_div(vector signed __int128 __a, vector signed __int128 __b) {
3834 return __a / __b;
3835}
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07003836#endif /* __POWER10_VECTOR__ */
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003837
3838/* vec_xvtdiv */
3839
3840#ifdef __VSX__
3841static __inline__ int __ATTRS_o_ai vec_test_swdiv(vector double __a,
3842 vector double __b) {
3843 return __builtin_vsx_xvtdivdp(__a, __b);
3844}
3845
3846static __inline__ int __ATTRS_o_ai vec_test_swdivs(vector float __a,
3847 vector float __b) {
3848 return __builtin_vsx_xvtdivsp(__a, __b);
3849}
3850#endif
3851
Logan Chien2833ffb2018-10-09 10:03:24 +08003852/* vec_dss */
3853
Sasha Smundak746b0222020-02-25 09:19:04 -08003854#define vec_dss __builtin_altivec_dss
Logan Chien2833ffb2018-10-09 10:03:24 +08003855
3856/* vec_dssall */
3857
3858static __inline__ void __attribute__((__always_inline__)) vec_dssall(void) {
3859 __builtin_altivec_dssall();
3860}
3861
3862/* vec_dst */
3863#define vec_dst(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003864 __builtin_altivec_dst((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003865
3866/* vec_dstst */
3867#define vec_dstst(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003868 __builtin_altivec_dstst((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003869
3870/* vec_dststt */
3871#define vec_dststt(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003872 __builtin_altivec_dststt((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003873
3874/* vec_dstt */
3875#define vec_dstt(__PTR, __CW, __STR) \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08003876 __builtin_altivec_dstt((const void *)(__PTR), (__CW), (__STR))
Logan Chien2833ffb2018-10-09 10:03:24 +08003877
3878/* vec_eqv */
3879
3880#ifdef __POWER8_VECTOR__
3881static __inline__ vector signed char __ATTRS_o_ai
3882vec_eqv(vector signed char __a, vector signed char __b) {
3883 return (vector signed char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3884 (vector unsigned int)__b);
3885}
3886
3887static __inline__ vector unsigned char __ATTRS_o_ai
3888vec_eqv(vector unsigned char __a, vector unsigned char __b) {
3889 return (vector unsigned char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3890 (vector unsigned int)__b);
3891}
3892
3893static __inline__ vector bool char __ATTRS_o_ai vec_eqv(vector bool char __a,
3894 vector bool char __b) {
3895 return (vector bool char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3896 (vector unsigned int)__b);
3897}
3898
3899static __inline__ vector signed short __ATTRS_o_ai
3900vec_eqv(vector signed short __a, vector signed short __b) {
3901 return (vector signed short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3902 (vector unsigned int)__b);
3903}
3904
3905static __inline__ vector unsigned short __ATTRS_o_ai
3906vec_eqv(vector unsigned short __a, vector unsigned short __b) {
3907 return (vector unsigned short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3908 (vector unsigned int)__b);
3909}
3910
3911static __inline__ vector bool short __ATTRS_o_ai
3912vec_eqv(vector bool short __a, vector bool short __b) {
3913 return (vector bool short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3914 (vector unsigned int)__b);
3915}
3916
3917static __inline__ vector signed int __ATTRS_o_ai
3918vec_eqv(vector signed int __a, vector signed int __b) {
3919 return (vector signed int)__builtin_vsx_xxleqv((vector unsigned int)__a,
3920 (vector unsigned int)__b);
3921}
3922
3923static __inline__ vector unsigned int __ATTRS_o_ai
3924vec_eqv(vector unsigned int __a, vector unsigned int __b) {
3925 return __builtin_vsx_xxleqv(__a, __b);
3926}
3927
3928static __inline__ vector bool int __ATTRS_o_ai vec_eqv(vector bool int __a,
3929 vector bool int __b) {
3930 return (vector bool int)__builtin_vsx_xxleqv((vector unsigned int)__a,
3931 (vector unsigned int)__b);
3932}
3933
3934static __inline__ vector signed long long __ATTRS_o_ai
3935vec_eqv(vector signed long long __a, vector signed long long __b) {
3936 return (vector signed long long)__builtin_vsx_xxleqv(
3937 (vector unsigned int)__a, (vector unsigned int)__b);
3938}
3939
3940static __inline__ vector unsigned long long __ATTRS_o_ai
3941vec_eqv(vector unsigned long long __a, vector unsigned long long __b) {
3942 return (vector unsigned long long)__builtin_vsx_xxleqv(
3943 (vector unsigned int)__a, (vector unsigned int)__b);
3944}
3945
3946static __inline__ vector bool long long __ATTRS_o_ai
3947vec_eqv(vector bool long long __a, vector bool long long __b) {
3948 return (vector bool long long)__builtin_vsx_xxleqv((vector unsigned int)__a,
3949 (vector unsigned int)__b);
3950}
3951
3952static __inline__ vector float __ATTRS_o_ai vec_eqv(vector float __a,
3953 vector float __b) {
3954 return (vector float)__builtin_vsx_xxleqv((vector unsigned int)__a,
3955 (vector unsigned int)__b);
3956}
3957
3958static __inline__ vector double __ATTRS_o_ai vec_eqv(vector double __a,
3959 vector double __b) {
3960 return (vector double)__builtin_vsx_xxleqv((vector unsigned int)__a,
3961 (vector unsigned int)__b);
3962}
3963#endif
3964
3965/* vec_expte */
3966
3967static __inline__ vector float __attribute__((__always_inline__))
3968vec_expte(vector float __a) {
3969 return __builtin_altivec_vexptefp(__a);
3970}
3971
3972/* vec_vexptefp */
3973
3974static __inline__ vector float __attribute__((__always_inline__))
3975vec_vexptefp(vector float __a) {
3976 return __builtin_altivec_vexptefp(__a);
3977}
3978
3979/* vec_floor */
3980
3981static __inline__ vector float __ATTRS_o_ai vec_floor(vector float __a) {
3982#ifdef __VSX__
3983 return __builtin_vsx_xvrspim(__a);
3984#else
3985 return __builtin_altivec_vrfim(__a);
3986#endif
3987}
3988
3989#ifdef __VSX__
3990static __inline__ vector double __ATTRS_o_ai vec_floor(vector double __a) {
3991 return __builtin_vsx_xvrdpim(__a);
3992}
3993#endif
3994
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07003995/* vec_roundm */
3996static __inline__ vector float __ATTRS_o_ai vec_roundm(vector float __a) {
3997 return vec_floor(__a);
3998}
3999
4000#ifdef __VSX__
4001static __inline__ vector double __ATTRS_o_ai vec_roundm(vector double __a) {
4002 return vec_floor(__a);
4003}
4004#endif
4005
Logan Chien2833ffb2018-10-09 10:03:24 +08004006/* vec_vrfim */
4007
4008static __inline__ vector float __attribute__((__always_inline__))
4009vec_vrfim(vector float __a) {
4010 return __builtin_altivec_vrfim(__a);
4011}
4012
4013/* vec_ld */
4014
4015static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004016vec_ld(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004017 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4018}
4019
4020static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004021vec_ld(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004022 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4023}
4024
4025static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004026vec_ld(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004027 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4028}
4029
4030static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004031vec_ld(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004032 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4033}
4034
4035static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004036vec_ld(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004037 return (vector bool char)__builtin_altivec_lvx(__a, __b);
4038}
4039
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004040static __inline__ vector short __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004041 const vector short *__b) {
4042 return (vector short)__builtin_altivec_lvx(__a, __b);
4043}
4044
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004045static __inline__ vector short __ATTRS_o_ai vec_ld(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004046 return (vector short)__builtin_altivec_lvx(__a, __b);
4047}
4048
4049static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004050vec_ld(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004051 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4052}
4053
4054static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004055vec_ld(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004056 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4057}
4058
4059static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004060vec_ld(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004061 return (vector bool short)__builtin_altivec_lvx(__a, __b);
4062}
4063
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004064static __inline__ vector pixel __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004065 const vector pixel *__b) {
4066 return (vector pixel)__builtin_altivec_lvx(__a, __b);
4067}
4068
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004069static __inline__ vector int __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004070 const vector int *__b) {
4071 return (vector int)__builtin_altivec_lvx(__a, __b);
4072}
4073
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004074static __inline__ vector int __ATTRS_o_ai vec_ld(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004075 return (vector int)__builtin_altivec_lvx(__a, __b);
4076}
4077
4078static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004079vec_ld(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004080 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4081}
4082
4083static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004084vec_ld(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004085 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4086}
4087
4088static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004089vec_ld(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004090 return (vector bool int)__builtin_altivec_lvx(__a, __b);
4091}
4092
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004093static __inline__ vector float __ATTRS_o_ai vec_ld(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004094 const vector float *__b) {
4095 return (vector float)__builtin_altivec_lvx(__a, __b);
4096}
4097
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004098static __inline__ vector float __ATTRS_o_ai vec_ld(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004099 return (vector float)__builtin_altivec_lvx(__a, __b);
4100}
4101
4102/* vec_lvx */
4103
4104static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004105vec_lvx(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004106 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4107}
4108
4109static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004110vec_lvx(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004111 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4112}
4113
4114static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004115vec_lvx(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004116 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4117}
4118
4119static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004120vec_lvx(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004121 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4122}
4123
4124static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004125vec_lvx(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004126 return (vector bool char)__builtin_altivec_lvx(__a, __b);
4127}
4128
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004129static __inline__ vector short __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004130 const vector short *__b) {
4131 return (vector short)__builtin_altivec_lvx(__a, __b);
4132}
4133
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004134static __inline__ vector short __ATTRS_o_ai vec_lvx(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004135 return (vector short)__builtin_altivec_lvx(__a, __b);
4136}
4137
4138static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004139vec_lvx(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004140 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4141}
4142
4143static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004144vec_lvx(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004145 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
4146}
4147
4148static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004149vec_lvx(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004150 return (vector bool short)__builtin_altivec_lvx(__a, __b);
4151}
4152
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004153static __inline__ vector pixel __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004154 const vector pixel *__b) {
4155 return (vector pixel)__builtin_altivec_lvx(__a, __b);
4156}
4157
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004158static __inline__ vector int __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004159 const vector int *__b) {
4160 return (vector int)__builtin_altivec_lvx(__a, __b);
4161}
4162
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004163static __inline__ vector int __ATTRS_o_ai vec_lvx(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004164 return (vector int)__builtin_altivec_lvx(__a, __b);
4165}
4166
4167static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004168vec_lvx(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004169 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4170}
4171
4172static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004173vec_lvx(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004174 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
4175}
4176
4177static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004178vec_lvx(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004179 return (vector bool int)__builtin_altivec_lvx(__a, __b);
4180}
4181
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004182static __inline__ vector float __ATTRS_o_ai vec_lvx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004183 const vector float *__b) {
4184 return (vector float)__builtin_altivec_lvx(__a, __b);
4185}
4186
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004187static __inline__ vector float __ATTRS_o_ai vec_lvx(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004188 return (vector float)__builtin_altivec_lvx(__a, __b);
4189}
4190
4191/* vec_lde */
4192
4193static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004194vec_lde(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004195 return (vector signed char)__builtin_altivec_lvebx(__a, __b);
4196}
4197
4198static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004199vec_lde(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004200 return (vector unsigned char)__builtin_altivec_lvebx(__a, __b);
4201}
4202
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004203static __inline__ vector short __ATTRS_o_ai vec_lde(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004204 return (vector short)__builtin_altivec_lvehx(__a, __b);
4205}
4206
4207static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004208vec_lde(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004209 return (vector unsigned short)__builtin_altivec_lvehx(__a, __b);
4210}
4211
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004212static __inline__ vector int __ATTRS_o_ai vec_lde(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004213 return (vector int)__builtin_altivec_lvewx(__a, __b);
4214}
4215
4216static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004217vec_lde(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004218 return (vector unsigned int)__builtin_altivec_lvewx(__a, __b);
4219}
4220
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004221static __inline__ vector float __ATTRS_o_ai vec_lde(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004222 return (vector float)__builtin_altivec_lvewx(__a, __b);
4223}
4224
4225/* vec_lvebx */
4226
4227static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004228vec_lvebx(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004229 return (vector signed char)__builtin_altivec_lvebx(__a, __b);
4230}
4231
4232static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004233vec_lvebx(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004234 return (vector unsigned char)__builtin_altivec_lvebx(__a, __b);
4235}
4236
4237/* vec_lvehx */
4238
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004239static __inline__ vector short __ATTRS_o_ai vec_lvehx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004240 const short *__b) {
4241 return (vector short)__builtin_altivec_lvehx(__a, __b);
4242}
4243
4244static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004245vec_lvehx(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004246 return (vector unsigned short)__builtin_altivec_lvehx(__a, __b);
4247}
4248
4249/* vec_lvewx */
4250
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004251static __inline__ vector int __ATTRS_o_ai vec_lvewx(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004252 return (vector int)__builtin_altivec_lvewx(__a, __b);
4253}
4254
4255static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004256vec_lvewx(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004257 return (vector unsigned int)__builtin_altivec_lvewx(__a, __b);
4258}
4259
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004260static __inline__ vector float __ATTRS_o_ai vec_lvewx(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004261 const float *__b) {
4262 return (vector float)__builtin_altivec_lvewx(__a, __b);
4263}
4264
4265/* vec_ldl */
4266
4267static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004268vec_ldl(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004269 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4270}
4271
4272static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004273vec_ldl(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004274 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4275}
4276
4277static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004278vec_ldl(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004279 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4280}
4281
4282static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004283vec_ldl(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004284 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4285}
4286
4287static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004288vec_ldl(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004289 return (vector bool char)__builtin_altivec_lvxl(__a, __b);
4290}
4291
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004292static __inline__ vector short __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004293 const vector short *__b) {
4294 return (vector short)__builtin_altivec_lvxl(__a, __b);
4295}
4296
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004297static __inline__ vector short __ATTRS_o_ai vec_ldl(long __a, const short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004298 return (vector short)__builtin_altivec_lvxl(__a, __b);
4299}
4300
4301static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004302vec_ldl(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004303 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4304}
4305
4306static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004307vec_ldl(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004308 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4309}
4310
4311static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004312vec_ldl(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004313 return (vector bool short)__builtin_altivec_lvxl(__a, __b);
4314}
4315
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004316static __inline__ vector pixel __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004317 const vector pixel *__b) {
4318 return (vector pixel short)__builtin_altivec_lvxl(__a, __b);
4319}
4320
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004321static __inline__ vector int __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004322 const vector int *__b) {
4323 return (vector int)__builtin_altivec_lvxl(__a, __b);
4324}
4325
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004326static __inline__ vector int __ATTRS_o_ai vec_ldl(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004327 return (vector int)__builtin_altivec_lvxl(__a, __b);
4328}
4329
4330static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004331vec_ldl(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004332 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4333}
4334
4335static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004336vec_ldl(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004337 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4338}
4339
4340static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004341vec_ldl(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004342 return (vector bool int)__builtin_altivec_lvxl(__a, __b);
4343}
4344
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004345static __inline__ vector float __ATTRS_o_ai vec_ldl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004346 const vector float *__b) {
4347 return (vector float)__builtin_altivec_lvxl(__a, __b);
4348}
4349
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004350static __inline__ vector float __ATTRS_o_ai vec_ldl(long __a, const float *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004351 return (vector float)__builtin_altivec_lvxl(__a, __b);
4352}
4353
4354/* vec_lvxl */
4355
4356static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004357vec_lvxl(long __a, const vector signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004358 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4359}
4360
4361static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004362vec_lvxl(long __a, const signed char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004363 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
4364}
4365
4366static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004367vec_lvxl(long __a, const vector unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004368 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4369}
4370
4371static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004372vec_lvxl(long __a, const unsigned char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004373 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
4374}
4375
4376static __inline__ vector bool char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004377vec_lvxl(long __a, const vector bool char *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004378 return (vector bool char)__builtin_altivec_lvxl(__a, __b);
4379}
4380
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004381static __inline__ vector short __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004382 const vector short *__b) {
4383 return (vector short)__builtin_altivec_lvxl(__a, __b);
4384}
4385
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004386static __inline__ vector short __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004387 const short *__b) {
4388 return (vector short)__builtin_altivec_lvxl(__a, __b);
4389}
4390
4391static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004392vec_lvxl(long __a, const vector unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004393 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4394}
4395
4396static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004397vec_lvxl(long __a, const unsigned short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004398 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
4399}
4400
4401static __inline__ vector bool short __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004402vec_lvxl(long __a, const vector bool short *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004403 return (vector bool short)__builtin_altivec_lvxl(__a, __b);
4404}
4405
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004406static __inline__ vector pixel __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004407 const vector pixel *__b) {
4408 return (vector pixel)__builtin_altivec_lvxl(__a, __b);
4409}
4410
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004411static __inline__ vector int __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004412 const vector int *__b) {
4413 return (vector int)__builtin_altivec_lvxl(__a, __b);
4414}
4415
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004416static __inline__ vector int __ATTRS_o_ai vec_lvxl(long __a, const int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004417 return (vector int)__builtin_altivec_lvxl(__a, __b);
4418}
4419
4420static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004421vec_lvxl(long __a, const vector unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004422 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4423}
4424
4425static __inline__ vector unsigned int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004426vec_lvxl(long __a, const unsigned int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004427 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
4428}
4429
4430static __inline__ vector bool int __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004431vec_lvxl(long __a, const vector bool int *__b) {
Logan Chien2833ffb2018-10-09 10:03:24 +08004432 return (vector bool int)__builtin_altivec_lvxl(__a, __b);
4433}
4434
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004435static __inline__ vector float __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004436 const vector float *__b) {
4437 return (vector float)__builtin_altivec_lvxl(__a, __b);
4438}
4439
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -08004440static __inline__ vector float __ATTRS_o_ai vec_lvxl(long __a,
Logan Chien2833ffb2018-10-09 10:03:24 +08004441 const float *__b) {
4442 return (vector float)__builtin_altivec_lvxl(__a, __b);
4443}
4444
4445/* vec_loge */
4446
4447static __inline__ vector float __attribute__((__always_inline__))
4448vec_loge(vector float __a) {
4449 return __builtin_altivec_vlogefp(__a);
4450}
4451
4452/* vec_vlogefp */
4453
4454static __inline__ vector float __attribute__((__always_inline__))
4455vec_vlogefp(vector float __a) {
4456 return __builtin_altivec_vlogefp(__a);
4457}
4458
4459/* vec_lvsl */
4460
4461#ifdef __LITTLE_ENDIAN__
4462static __inline__ vector unsigned char __ATTRS_o_ai
4463 __attribute__((__deprecated__("use assignment for unaligned little endian \
4464loads/stores"))) vec_lvsl(int __a, const signed char *__b) {
4465 vector unsigned char mask =
4466 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4467 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4468 7, 6, 5, 4, 3, 2, 1, 0};
4469 return vec_perm(mask, mask, reverse);
4470}
4471#else
4472static __inline__ vector unsigned char __ATTRS_o_ai
4473vec_lvsl(int __a, const signed char *__b) {
4474 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4475}
4476#endif
4477
4478#ifdef __LITTLE_ENDIAN__
4479static __inline__ vector unsigned char __ATTRS_o_ai
4480 __attribute__((__deprecated__("use assignment for unaligned little endian \
4481loads/stores"))) vec_lvsl(int __a, const unsigned char *__b) {
4482 vector unsigned char mask =
4483 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4484 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4485 7, 6, 5, 4, 3, 2, 1, 0};
4486 return vec_perm(mask, mask, reverse);
4487}
4488#else
4489static __inline__ vector unsigned char __ATTRS_o_ai
4490vec_lvsl(int __a, const unsigned char *__b) {
4491 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4492}
4493#endif
4494
4495#ifdef __LITTLE_ENDIAN__
4496static __inline__ vector unsigned char __ATTRS_o_ai
4497 __attribute__((__deprecated__("use assignment for unaligned little endian \
4498loads/stores"))) vec_lvsl(int __a, const short *__b) {
4499 vector unsigned char mask =
4500 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4501 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4502 7, 6, 5, 4, 3, 2, 1, 0};
4503 return vec_perm(mask, mask, reverse);
4504}
4505#else
4506static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
4507 const short *__b) {
4508 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4509}
4510#endif
4511
4512#ifdef __LITTLE_ENDIAN__
4513static __inline__ vector unsigned char __ATTRS_o_ai
4514 __attribute__((__deprecated__("use assignment for unaligned little endian \
4515loads/stores"))) vec_lvsl(int __a, const unsigned short *__b) {
4516 vector unsigned char mask =
4517 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4518 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4519 7, 6, 5, 4, 3, 2, 1, 0};
4520 return vec_perm(mask, mask, reverse);
4521}
4522#else
4523static __inline__ vector unsigned char __ATTRS_o_ai
4524vec_lvsl(int __a, const unsigned short *__b) {
4525 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4526}
4527#endif
4528
4529#ifdef __LITTLE_ENDIAN__
4530static __inline__ vector unsigned char __ATTRS_o_ai
4531 __attribute__((__deprecated__("use assignment for unaligned little endian \
4532loads/stores"))) vec_lvsl(int __a, const int *__b) {
4533 vector unsigned char mask =
4534 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4535 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4536 7, 6, 5, 4, 3, 2, 1, 0};
4537 return vec_perm(mask, mask, reverse);
4538}
4539#else
4540static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
4541 const int *__b) {
4542 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4543}
4544#endif
4545
4546#ifdef __LITTLE_ENDIAN__
4547static __inline__ vector unsigned char __ATTRS_o_ai
4548 __attribute__((__deprecated__("use assignment for unaligned little endian \
4549loads/stores"))) vec_lvsl(int __a, const unsigned int *__b) {
4550 vector unsigned char mask =
4551 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4552 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4553 7, 6, 5, 4, 3, 2, 1, 0};
4554 return vec_perm(mask, mask, reverse);
4555}
4556#else
4557static __inline__ vector unsigned char __ATTRS_o_ai
4558vec_lvsl(int __a, const unsigned int *__b) {
4559 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4560}
4561#endif
4562
4563#ifdef __LITTLE_ENDIAN__
4564static __inline__ vector unsigned char __ATTRS_o_ai
4565 __attribute__((__deprecated__("use assignment for unaligned little endian \
4566loads/stores"))) vec_lvsl(int __a, const float *__b) {
4567 vector unsigned char mask =
4568 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4569 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4570 7, 6, 5, 4, 3, 2, 1, 0};
4571 return vec_perm(mask, mask, reverse);
4572}
4573#else
4574static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
4575 const float *__b) {
4576 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
4577}
4578#endif
4579
4580/* vec_lvsr */
4581
4582#ifdef __LITTLE_ENDIAN__
4583static __inline__ vector unsigned char __ATTRS_o_ai
4584 __attribute__((__deprecated__("use assignment for unaligned little endian \
4585loads/stores"))) vec_lvsr(int __a, const signed char *__b) {
4586 vector unsigned char mask =
4587 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4588 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4589 7, 6, 5, 4, 3, 2, 1, 0};
4590 return vec_perm(mask, mask, reverse);
4591}
4592#else
4593static __inline__ vector unsigned char __ATTRS_o_ai
4594vec_lvsr(int __a, const signed char *__b) {
4595 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4596}
4597#endif
4598
4599#ifdef __LITTLE_ENDIAN__
4600static __inline__ vector unsigned char __ATTRS_o_ai
4601 __attribute__((__deprecated__("use assignment for unaligned little endian \
4602loads/stores"))) vec_lvsr(int __a, const unsigned char *__b) {
4603 vector unsigned char mask =
4604 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4605 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4606 7, 6, 5, 4, 3, 2, 1, 0};
4607 return vec_perm(mask, mask, reverse);
4608}
4609#else
4610static __inline__ vector unsigned char __ATTRS_o_ai
4611vec_lvsr(int __a, const unsigned char *__b) {
4612 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4613}
4614#endif
4615
4616#ifdef __LITTLE_ENDIAN__
4617static __inline__ vector unsigned char __ATTRS_o_ai
4618 __attribute__((__deprecated__("use assignment for unaligned little endian \
4619loads/stores"))) vec_lvsr(int __a, const short *__b) {
4620 vector unsigned char mask =
4621 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4622 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4623 7, 6, 5, 4, 3, 2, 1, 0};
4624 return vec_perm(mask, mask, reverse);
4625}
4626#else
4627static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
4628 const short *__b) {
4629 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4630}
4631#endif
4632
4633#ifdef __LITTLE_ENDIAN__
4634static __inline__ vector unsigned char __ATTRS_o_ai
4635 __attribute__((__deprecated__("use assignment for unaligned little endian \
4636loads/stores"))) vec_lvsr(int __a, const unsigned short *__b) {
4637 vector unsigned char mask =
4638 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4639 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4640 7, 6, 5, 4, 3, 2, 1, 0};
4641 return vec_perm(mask, mask, reverse);
4642}
4643#else
4644static __inline__ vector unsigned char __ATTRS_o_ai
4645vec_lvsr(int __a, const unsigned short *__b) {
4646 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4647}
4648#endif
4649
4650#ifdef __LITTLE_ENDIAN__
4651static __inline__ vector unsigned char __ATTRS_o_ai
4652 __attribute__((__deprecated__("use assignment for unaligned little endian \
4653loads/stores"))) vec_lvsr(int __a, const int *__b) {
4654 vector unsigned char mask =
4655 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4656 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4657 7, 6, 5, 4, 3, 2, 1, 0};
4658 return vec_perm(mask, mask, reverse);
4659}
4660#else
4661static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
4662 const int *__b) {
4663 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4664}
4665#endif
4666
4667#ifdef __LITTLE_ENDIAN__
4668static __inline__ vector unsigned char __ATTRS_o_ai
4669 __attribute__((__deprecated__("use assignment for unaligned little endian \
4670loads/stores"))) vec_lvsr(int __a, const unsigned int *__b) {
4671 vector unsigned char mask =
4672 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4673 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4674 7, 6, 5, 4, 3, 2, 1, 0};
4675 return vec_perm(mask, mask, reverse);
4676}
4677#else
4678static __inline__ vector unsigned char __ATTRS_o_ai
4679vec_lvsr(int __a, const unsigned int *__b) {
4680 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4681}
4682#endif
4683
4684#ifdef __LITTLE_ENDIAN__
4685static __inline__ vector unsigned char __ATTRS_o_ai
4686 __attribute__((__deprecated__("use assignment for unaligned little endian \
4687loads/stores"))) vec_lvsr(int __a, const float *__b) {
4688 vector unsigned char mask =
4689 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4690 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
4691 7, 6, 5, 4, 3, 2, 1, 0};
4692 return vec_perm(mask, mask, reverse);
4693}
4694#else
4695static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
4696 const float *__b) {
4697 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
4698}
4699#endif
4700
4701/* vec_madd */
4702static __inline__ vector signed short __ATTRS_o_ai
4703vec_mladd(vector signed short, vector signed short, vector signed short);
4704static __inline__ vector signed short __ATTRS_o_ai
4705vec_mladd(vector signed short, vector unsigned short, vector unsigned short);
4706static __inline__ vector signed short __ATTRS_o_ai
4707vec_mladd(vector unsigned short, vector signed short, vector signed short);
4708static __inline__ vector unsigned short __ATTRS_o_ai
4709vec_mladd(vector unsigned short, vector unsigned short, vector unsigned short);
4710
4711static __inline__ vector signed short __ATTRS_o_ai vec_madd(
4712 vector signed short __a, vector signed short __b, vector signed short __c) {
4713 return vec_mladd(__a, __b, __c);
4714}
4715
4716static __inline__ vector signed short __ATTRS_o_ai
4717vec_madd(vector signed short __a, vector unsigned short __b,
4718 vector unsigned short __c) {
4719 return vec_mladd(__a, __b, __c);
4720}
4721
4722static __inline__ vector signed short __ATTRS_o_ai
4723vec_madd(vector unsigned short __a, vector signed short __b,
4724 vector signed short __c) {
4725 return vec_mladd(__a, __b, __c);
4726}
4727
4728static __inline__ vector unsigned short __ATTRS_o_ai
4729vec_madd(vector unsigned short __a, vector unsigned short __b,
4730 vector unsigned short __c) {
4731 return vec_mladd(__a, __b, __c);
4732}
4733
4734static __inline__ vector float __ATTRS_o_ai vec_madd(vector float __a,
4735 vector float __b,
4736 vector float __c) {
4737#ifdef __VSX__
4738 return __builtin_vsx_xvmaddasp(__a, __b, __c);
4739#else
4740 return __builtin_altivec_vmaddfp(__a, __b, __c);
4741#endif
4742}
4743
4744#ifdef __VSX__
4745static __inline__ vector double __ATTRS_o_ai vec_madd(vector double __a,
4746 vector double __b,
4747 vector double __c) {
4748 return __builtin_vsx_xvmaddadp(__a, __b, __c);
4749}
4750#endif
4751
4752/* vec_vmaddfp */
4753
4754static __inline__ vector float __attribute__((__always_inline__))
4755vec_vmaddfp(vector float __a, vector float __b, vector float __c) {
4756 return __builtin_altivec_vmaddfp(__a, __b, __c);
4757}
4758
4759/* vec_madds */
4760
4761static __inline__ vector signed short __attribute__((__always_inline__))
4762vec_madds(vector signed short __a, vector signed short __b,
4763 vector signed short __c) {
4764 return __builtin_altivec_vmhaddshs(__a, __b, __c);
4765}
4766
4767/* vec_vmhaddshs */
4768static __inline__ vector signed short __attribute__((__always_inline__))
4769vec_vmhaddshs(vector signed short __a, vector signed short __b,
4770 vector signed short __c) {
4771 return __builtin_altivec_vmhaddshs(__a, __b, __c);
4772}
4773
4774/* vec_msub */
4775
4776#ifdef __VSX__
4777static __inline__ vector float __ATTRS_o_ai vec_msub(vector float __a,
4778 vector float __b,
4779 vector float __c) {
4780 return __builtin_vsx_xvmsubasp(__a, __b, __c);
4781}
4782
4783static __inline__ vector double __ATTRS_o_ai vec_msub(vector double __a,
4784 vector double __b,
4785 vector double __c) {
4786 return __builtin_vsx_xvmsubadp(__a, __b, __c);
4787}
4788#endif
4789
4790/* vec_max */
4791
4792static __inline__ vector signed char __ATTRS_o_ai
4793vec_max(vector signed char __a, vector signed char __b) {
4794 return __builtin_altivec_vmaxsb(__a, __b);
4795}
4796
4797static __inline__ vector signed char __ATTRS_o_ai
4798vec_max(vector bool char __a, vector signed char __b) {
4799 return __builtin_altivec_vmaxsb((vector signed char)__a, __b);
4800}
4801
4802static __inline__ vector signed char __ATTRS_o_ai
4803vec_max(vector signed char __a, vector bool char __b) {
4804 return __builtin_altivec_vmaxsb(__a, (vector signed char)__b);
4805}
4806
4807static __inline__ vector unsigned char __ATTRS_o_ai
4808vec_max(vector unsigned char __a, vector unsigned char __b) {
4809 return __builtin_altivec_vmaxub(__a, __b);
4810}
4811
4812static __inline__ vector unsigned char __ATTRS_o_ai
4813vec_max(vector bool char __a, vector unsigned char __b) {
4814 return __builtin_altivec_vmaxub((vector unsigned char)__a, __b);
4815}
4816
4817static __inline__ vector unsigned char __ATTRS_o_ai
4818vec_max(vector unsigned char __a, vector bool char __b) {
4819 return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b);
4820}
4821
4822static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a,
4823 vector short __b) {
4824 return __builtin_altivec_vmaxsh(__a, __b);
4825}
4826
4827static __inline__ vector short __ATTRS_o_ai vec_max(vector bool short __a,
4828 vector short __b) {
4829 return __builtin_altivec_vmaxsh((vector short)__a, __b);
4830}
4831
4832static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a,
4833 vector bool short __b) {
4834 return __builtin_altivec_vmaxsh(__a, (vector short)__b);
4835}
4836
4837static __inline__ vector unsigned short __ATTRS_o_ai
4838vec_max(vector unsigned short __a, vector unsigned short __b) {
4839 return __builtin_altivec_vmaxuh(__a, __b);
4840}
4841
4842static __inline__ vector unsigned short __ATTRS_o_ai
4843vec_max(vector bool short __a, vector unsigned short __b) {
4844 return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b);
4845}
4846
4847static __inline__ vector unsigned short __ATTRS_o_ai
4848vec_max(vector unsigned short __a, vector bool short __b) {
4849 return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b);
4850}
4851
4852static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a,
4853 vector int __b) {
4854 return __builtin_altivec_vmaxsw(__a, __b);
4855}
4856
4857static __inline__ vector int __ATTRS_o_ai vec_max(vector bool int __a,
4858 vector int __b) {
4859 return __builtin_altivec_vmaxsw((vector int)__a, __b);
4860}
4861
4862static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a,
4863 vector bool int __b) {
4864 return __builtin_altivec_vmaxsw(__a, (vector int)__b);
4865}
4866
4867static __inline__ vector unsigned int __ATTRS_o_ai
4868vec_max(vector unsigned int __a, vector unsigned int __b) {
4869 return __builtin_altivec_vmaxuw(__a, __b);
4870}
4871
4872static __inline__ vector unsigned int __ATTRS_o_ai
4873vec_max(vector bool int __a, vector unsigned int __b) {
4874 return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b);
4875}
4876
4877static __inline__ vector unsigned int __ATTRS_o_ai
4878vec_max(vector unsigned int __a, vector bool int __b) {
4879 return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b);
4880}
4881
4882#ifdef __POWER8_VECTOR__
4883static __inline__ vector signed long long __ATTRS_o_ai
4884vec_max(vector signed long long __a, vector signed long long __b) {
4885 return __builtin_altivec_vmaxsd(__a, __b);
4886}
4887
4888static __inline__ vector signed long long __ATTRS_o_ai
4889vec_max(vector bool long long __a, vector signed long long __b) {
4890 return __builtin_altivec_vmaxsd((vector signed long long)__a, __b);
4891}
4892
4893static __inline__ vector signed long long __ATTRS_o_ai
4894vec_max(vector signed long long __a, vector bool long long __b) {
4895 return __builtin_altivec_vmaxsd(__a, (vector signed long long)__b);
4896}
4897
4898static __inline__ vector unsigned long long __ATTRS_o_ai
4899vec_max(vector unsigned long long __a, vector unsigned long long __b) {
4900 return __builtin_altivec_vmaxud(__a, __b);
4901}
4902
4903static __inline__ vector unsigned long long __ATTRS_o_ai
4904vec_max(vector bool long long __a, vector unsigned long long __b) {
4905 return __builtin_altivec_vmaxud((vector unsigned long long)__a, __b);
4906}
4907
4908static __inline__ vector unsigned long long __ATTRS_o_ai
4909vec_max(vector unsigned long long __a, vector bool long long __b) {
4910 return __builtin_altivec_vmaxud(__a, (vector unsigned long long)__b);
4911}
4912#endif
4913
4914static __inline__ vector float __ATTRS_o_ai vec_max(vector float __a,
4915 vector float __b) {
4916#ifdef __VSX__
4917 return __builtin_vsx_xvmaxsp(__a, __b);
4918#else
4919 return __builtin_altivec_vmaxfp(__a, __b);
4920#endif
4921}
4922
4923#ifdef __VSX__
4924static __inline__ vector double __ATTRS_o_ai vec_max(vector double __a,
4925 vector double __b) {
4926 return __builtin_vsx_xvmaxdp(__a, __b);
4927}
4928#endif
4929
4930/* vec_vmaxsb */
4931
4932static __inline__ vector signed char __ATTRS_o_ai
4933vec_vmaxsb(vector signed char __a, vector signed char __b) {
4934 return __builtin_altivec_vmaxsb(__a, __b);
4935}
4936
4937static __inline__ vector signed char __ATTRS_o_ai
4938vec_vmaxsb(vector bool char __a, vector signed char __b) {
4939 return __builtin_altivec_vmaxsb((vector signed char)__a, __b);
4940}
4941
4942static __inline__ vector signed char __ATTRS_o_ai
4943vec_vmaxsb(vector signed char __a, vector bool char __b) {
4944 return __builtin_altivec_vmaxsb(__a, (vector signed char)__b);
4945}
4946
4947/* vec_vmaxub */
4948
4949static __inline__ vector unsigned char __ATTRS_o_ai
4950vec_vmaxub(vector unsigned char __a, vector unsigned char __b) {
4951 return __builtin_altivec_vmaxub(__a, __b);
4952}
4953
4954static __inline__ vector unsigned char __ATTRS_o_ai
4955vec_vmaxub(vector bool char __a, vector unsigned char __b) {
4956 return __builtin_altivec_vmaxub((vector unsigned char)__a, __b);
4957}
4958
4959static __inline__ vector unsigned char __ATTRS_o_ai
4960vec_vmaxub(vector unsigned char __a, vector bool char __b) {
4961 return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b);
4962}
4963
4964/* vec_vmaxsh */
4965
4966static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a,
4967 vector short __b) {
4968 return __builtin_altivec_vmaxsh(__a, __b);
4969}
4970
4971static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector bool short __a,
4972 vector short __b) {
4973 return __builtin_altivec_vmaxsh((vector short)__a, __b);
4974}
4975
4976static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a,
4977 vector bool short __b) {
4978 return __builtin_altivec_vmaxsh(__a, (vector short)__b);
4979}
4980
4981/* vec_vmaxuh */
4982
4983static __inline__ vector unsigned short __ATTRS_o_ai
4984vec_vmaxuh(vector unsigned short __a, vector unsigned short __b) {
4985 return __builtin_altivec_vmaxuh(__a, __b);
4986}
4987
4988static __inline__ vector unsigned short __ATTRS_o_ai
4989vec_vmaxuh(vector bool short __a, vector unsigned short __b) {
4990 return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b);
4991}
4992
4993static __inline__ vector unsigned short __ATTRS_o_ai
4994vec_vmaxuh(vector unsigned short __a, vector bool short __b) {
4995 return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b);
4996}
4997
4998/* vec_vmaxsw */
4999
5000static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a,
5001 vector int __b) {
5002 return __builtin_altivec_vmaxsw(__a, __b);
5003}
5004
5005static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector bool int __a,
5006 vector int __b) {
5007 return __builtin_altivec_vmaxsw((vector int)__a, __b);
5008}
5009
5010static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a,
5011 vector bool int __b) {
5012 return __builtin_altivec_vmaxsw(__a, (vector int)__b);
5013}
5014
5015/* vec_vmaxuw */
5016
5017static __inline__ vector unsigned int __ATTRS_o_ai
5018vec_vmaxuw(vector unsigned int __a, vector unsigned int __b) {
5019 return __builtin_altivec_vmaxuw(__a, __b);
5020}
5021
5022static __inline__ vector unsigned int __ATTRS_o_ai
5023vec_vmaxuw(vector bool int __a, vector unsigned int __b) {
5024 return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b);
5025}
5026
5027static __inline__ vector unsigned int __ATTRS_o_ai
5028vec_vmaxuw(vector unsigned int __a, vector bool int __b) {
5029 return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b);
5030}
5031
5032/* vec_vmaxfp */
5033
5034static __inline__ vector float __attribute__((__always_inline__))
5035vec_vmaxfp(vector float __a, vector float __b) {
5036#ifdef __VSX__
5037 return __builtin_vsx_xvmaxsp(__a, __b);
5038#else
5039 return __builtin_altivec_vmaxfp(__a, __b);
5040#endif
5041}
5042
5043/* vec_mergeh */
5044
5045static __inline__ vector signed char __ATTRS_o_ai
5046vec_mergeh(vector signed char __a, vector signed char __b) {
5047 return vec_perm(__a, __b,
5048 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5049 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5050 0x06, 0x16, 0x07, 0x17));
5051}
5052
5053static __inline__ vector unsigned char __ATTRS_o_ai
5054vec_mergeh(vector unsigned char __a, vector unsigned char __b) {
5055 return vec_perm(__a, __b,
5056 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5057 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5058 0x06, 0x16, 0x07, 0x17));
5059}
5060
5061static __inline__ vector bool char __ATTRS_o_ai
5062vec_mergeh(vector bool char __a, vector bool char __b) {
5063 return vec_perm(__a, __b,
5064 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5065 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5066 0x06, 0x16, 0x07, 0x17));
5067}
5068
5069static __inline__ vector short __ATTRS_o_ai vec_mergeh(vector short __a,
5070 vector short __b) {
5071 return vec_perm(__a, __b,
5072 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5073 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5074 0x06, 0x07, 0x16, 0x17));
5075}
5076
5077static __inline__ vector unsigned short __ATTRS_o_ai
5078vec_mergeh(vector unsigned short __a, vector unsigned short __b) {
5079 return vec_perm(__a, __b,
5080 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5081 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5082 0x06, 0x07, 0x16, 0x17));
5083}
5084
5085static __inline__ vector bool short __ATTRS_o_ai
5086vec_mergeh(vector bool short __a, vector bool short __b) {
5087 return vec_perm(__a, __b,
5088 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5089 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5090 0x06, 0x07, 0x16, 0x17));
5091}
5092
5093static __inline__ vector pixel __ATTRS_o_ai vec_mergeh(vector pixel __a,
5094 vector pixel __b) {
5095 return vec_perm(__a, __b,
5096 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5097 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5098 0x06, 0x07, 0x16, 0x17));
5099}
5100
5101static __inline__ vector int __ATTRS_o_ai vec_mergeh(vector int __a,
5102 vector int __b) {
5103 return vec_perm(__a, __b,
5104 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5105 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5106 0x14, 0x15, 0x16, 0x17));
5107}
5108
5109static __inline__ vector unsigned int __ATTRS_o_ai
5110vec_mergeh(vector unsigned int __a, vector unsigned int __b) {
5111 return vec_perm(__a, __b,
5112 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5113 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5114 0x14, 0x15, 0x16, 0x17));
5115}
5116
5117static __inline__ vector bool int __ATTRS_o_ai vec_mergeh(vector bool int __a,
5118 vector bool int __b) {
5119 return vec_perm(__a, __b,
5120 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5121 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5122 0x14, 0x15, 0x16, 0x17));
5123}
5124
5125static __inline__ vector float __ATTRS_o_ai vec_mergeh(vector float __a,
5126 vector float __b) {
5127 return vec_perm(__a, __b,
5128 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5129 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5130 0x14, 0x15, 0x16, 0x17));
5131}
5132
5133#ifdef __VSX__
5134static __inline__ vector signed long long __ATTRS_o_ai
5135vec_mergeh(vector signed long long __a, vector signed long long __b) {
5136 return vec_perm(__a, __b,
5137 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5138 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5139 0x14, 0x15, 0x16, 0x17));
5140}
5141
5142static __inline__ vector signed long long __ATTRS_o_ai
5143vec_mergeh(vector signed long long __a, vector bool long long __b) {
5144 return vec_perm(__a, (vector signed long long)__b,
5145 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5146 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5147 0x14, 0x15, 0x16, 0x17));
5148}
5149
5150static __inline__ vector signed long long __ATTRS_o_ai
5151vec_mergeh(vector bool long long __a, vector signed long long __b) {
5152 return vec_perm((vector signed long long)__a, __b,
5153 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5154 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5155 0x14, 0x15, 0x16, 0x17));
5156}
5157
5158static __inline__ vector unsigned long long __ATTRS_o_ai
5159vec_mergeh(vector unsigned long long __a, vector unsigned long long __b) {
5160 return vec_perm(__a, __b,
5161 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5162 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5163 0x14, 0x15, 0x16, 0x17));
5164}
5165
5166static __inline__ vector unsigned long long __ATTRS_o_ai
5167vec_mergeh(vector unsigned long long __a, vector bool long long __b) {
5168 return vec_perm(__a, (vector unsigned long long)__b,
5169 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5170 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5171 0x14, 0x15, 0x16, 0x17));
5172}
5173
5174static __inline__ vector unsigned long long __ATTRS_o_ai
5175vec_mergeh(vector bool long long __a, vector unsigned long long __b) {
5176 return vec_perm((vector unsigned long long)__a, __b,
5177 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5178 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5179 0x14, 0x15, 0x16, 0x17));
5180}
5181
5182static __inline__ vector bool long long __ATTRS_o_ai
5183vec_mergeh(vector bool long long __a, vector bool long long __b) {
5184 return vec_perm(__a, __b,
5185 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5186 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5187 0x14, 0x15, 0x16, 0x17));
5188}
5189
5190static __inline__ vector double __ATTRS_o_ai vec_mergeh(vector double __a,
5191 vector double __b) {
5192 return vec_perm(__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}
5197static __inline__ vector double __ATTRS_o_ai
5198vec_mergeh(vector double __a, vector bool long long __b) {
5199 return vec_perm(__a, (vector double)__b,
5200 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5201 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5202 0x14, 0x15, 0x16, 0x17));
5203}
5204static __inline__ vector double __ATTRS_o_ai
5205vec_mergeh(vector bool long long __a, vector double __b) {
5206 return vec_perm((vector double)__a, __b,
5207 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
5208 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
5209 0x14, 0x15, 0x16, 0x17));
5210}
5211#endif
5212
5213/* vec_vmrghb */
5214
5215#define __builtin_altivec_vmrghb vec_vmrghb
5216
5217static __inline__ vector signed char __ATTRS_o_ai
5218vec_vmrghb(vector signed char __a, vector signed char __b) {
5219 return vec_perm(__a, __b,
5220 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5221 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5222 0x06, 0x16, 0x07, 0x17));
5223}
5224
5225static __inline__ vector unsigned char __ATTRS_o_ai
5226vec_vmrghb(vector unsigned char __a, vector unsigned char __b) {
5227 return vec_perm(__a, __b,
5228 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5229 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5230 0x06, 0x16, 0x07, 0x17));
5231}
5232
5233static __inline__ vector bool char __ATTRS_o_ai
5234vec_vmrghb(vector bool char __a, vector bool char __b) {
5235 return vec_perm(__a, __b,
5236 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
5237 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
5238 0x06, 0x16, 0x07, 0x17));
5239}
5240
5241/* vec_vmrghh */
5242
5243#define __builtin_altivec_vmrghh vec_vmrghh
5244
5245static __inline__ vector short __ATTRS_o_ai vec_vmrghh(vector short __a,
5246 vector short __b) {
5247 return vec_perm(__a, __b,
5248 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5249 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5250 0x06, 0x07, 0x16, 0x17));
5251}
5252
5253static __inline__ vector unsigned short __ATTRS_o_ai
5254vec_vmrghh(vector unsigned short __a, vector unsigned short __b) {
5255 return vec_perm(__a, __b,
5256 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5257 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5258 0x06, 0x07, 0x16, 0x17));
5259}
5260
5261static __inline__ vector bool short __ATTRS_o_ai
5262vec_vmrghh(vector bool short __a, vector bool short __b) {
5263 return vec_perm(__a, __b,
5264 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5265 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5266 0x06, 0x07, 0x16, 0x17));
5267}
5268
5269static __inline__ vector pixel __ATTRS_o_ai vec_vmrghh(vector pixel __a,
5270 vector pixel __b) {
5271 return vec_perm(__a, __b,
5272 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
5273 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
5274 0x06, 0x07, 0x16, 0x17));
5275}
5276
5277/* vec_vmrghw */
5278
5279#define __builtin_altivec_vmrghw vec_vmrghw
5280
5281static __inline__ vector int __ATTRS_o_ai vec_vmrghw(vector int __a,
5282 vector int __b) {
5283 return vec_perm(__a, __b,
5284 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5285 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5286 0x14, 0x15, 0x16, 0x17));
5287}
5288
5289static __inline__ vector unsigned int __ATTRS_o_ai
5290vec_vmrghw(vector unsigned int __a, vector unsigned int __b) {
5291 return vec_perm(__a, __b,
5292 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5293 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5294 0x14, 0x15, 0x16, 0x17));
5295}
5296
5297static __inline__ vector bool int __ATTRS_o_ai vec_vmrghw(vector bool int __a,
5298 vector bool int __b) {
5299 return vec_perm(__a, __b,
5300 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5301 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5302 0x14, 0x15, 0x16, 0x17));
5303}
5304
5305static __inline__ vector float __ATTRS_o_ai vec_vmrghw(vector float __a,
5306 vector float __b) {
5307 return vec_perm(__a, __b,
5308 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5309 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
5310 0x14, 0x15, 0x16, 0x17));
5311}
5312
5313/* vec_mergel */
5314
5315static __inline__ vector signed char __ATTRS_o_ai
5316vec_mergel(vector signed char __a, vector signed char __b) {
5317 return vec_perm(__a, __b,
5318 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5319 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5320 0x0E, 0x1E, 0x0F, 0x1F));
5321}
5322
5323static __inline__ vector unsigned char __ATTRS_o_ai
5324vec_mergel(vector unsigned char __a, vector unsigned char __b) {
5325 return vec_perm(__a, __b,
5326 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5327 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5328 0x0E, 0x1E, 0x0F, 0x1F));
5329}
5330
5331static __inline__ vector bool char __ATTRS_o_ai
5332vec_mergel(vector bool char __a, vector bool char __b) {
5333 return vec_perm(__a, __b,
5334 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5335 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5336 0x0E, 0x1E, 0x0F, 0x1F));
5337}
5338
5339static __inline__ vector short __ATTRS_o_ai vec_mergel(vector short __a,
5340 vector short __b) {
5341 return vec_perm(__a, __b,
5342 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5343 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5344 0x0E, 0x0F, 0x1E, 0x1F));
5345}
5346
5347static __inline__ vector unsigned short __ATTRS_o_ai
5348vec_mergel(vector unsigned short __a, vector unsigned short __b) {
5349 return vec_perm(__a, __b,
5350 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5351 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5352 0x0E, 0x0F, 0x1E, 0x1F));
5353}
5354
5355static __inline__ vector bool short __ATTRS_o_ai
5356vec_mergel(vector bool short __a, vector bool short __b) {
5357 return vec_perm(__a, __b,
5358 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5359 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5360 0x0E, 0x0F, 0x1E, 0x1F));
5361}
5362
5363static __inline__ vector pixel __ATTRS_o_ai vec_mergel(vector pixel __a,
5364 vector pixel __b) {
5365 return vec_perm(__a, __b,
5366 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5367 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5368 0x0E, 0x0F, 0x1E, 0x1F));
5369}
5370
5371static __inline__ vector int __ATTRS_o_ai vec_mergel(vector int __a,
5372 vector int __b) {
5373 return vec_perm(__a, __b,
5374 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5375 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5376 0x1C, 0x1D, 0x1E, 0x1F));
5377}
5378
5379static __inline__ vector unsigned int __ATTRS_o_ai
5380vec_mergel(vector unsigned int __a, vector unsigned int __b) {
5381 return vec_perm(__a, __b,
5382 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5383 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5384 0x1C, 0x1D, 0x1E, 0x1F));
5385}
5386
5387static __inline__ vector bool int __ATTRS_o_ai vec_mergel(vector bool int __a,
5388 vector bool int __b) {
5389 return vec_perm(__a, __b,
5390 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5391 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5392 0x1C, 0x1D, 0x1E, 0x1F));
5393}
5394
5395static __inline__ vector float __ATTRS_o_ai vec_mergel(vector float __a,
5396 vector float __b) {
5397 return vec_perm(__a, __b,
5398 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5399 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5400 0x1C, 0x1D, 0x1E, 0x1F));
5401}
5402
5403#ifdef __VSX__
5404static __inline__ vector signed long long __ATTRS_o_ai
5405vec_mergel(vector signed long long __a, vector signed long long __b) {
5406 return vec_perm(__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 signed long long __ATTRS_o_ai
5412vec_mergel(vector signed long long __a, vector bool long long __b) {
5413 return vec_perm(__a, (vector signed long long)__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 signed long long __ATTRS_o_ai
5419vec_mergel(vector bool long long __a, vector signed long long __b) {
5420 return vec_perm((vector signed long long)__a, __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 unsigned long long __a, vector unsigned long long __b) {
5427 return vec_perm(__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 unsigned long long __ATTRS_o_ai
5433vec_mergel(vector unsigned long long __a, vector bool long long __b) {
5434 return vec_perm(__a, (vector unsigned long long)__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 unsigned long long __ATTRS_o_ai
5440vec_mergel(vector bool long long __a, vector unsigned long long __b) {
5441 return vec_perm((vector unsigned long long)__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 bool long long __ATTRS_o_ai
5447vec_mergel(vector bool long long __a, vector bool long long __b) {
5448 return vec_perm(__a, __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 vec_mergel(vector double __a,
5454 vector double __b) {
5455 return vec_perm(__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}
5460static __inline__ vector double __ATTRS_o_ai
5461vec_mergel(vector double __a, vector bool long long __b) {
5462 return vec_perm(__a, (vector double)__b,
5463 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5464 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5465 0x1C, 0x1D, 0x1E, 0x1F));
5466}
5467static __inline__ vector double __ATTRS_o_ai
5468vec_mergel(vector bool long long __a, vector double __b) {
5469 return vec_perm((vector double)__a, __b,
5470 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
5471 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
5472 0x1C, 0x1D, 0x1E, 0x1F));
5473}
5474#endif
5475
5476/* vec_vmrglb */
5477
5478#define __builtin_altivec_vmrglb vec_vmrglb
5479
5480static __inline__ vector signed char __ATTRS_o_ai
5481vec_vmrglb(vector signed char __a, vector signed char __b) {
5482 return vec_perm(__a, __b,
5483 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5484 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5485 0x0E, 0x1E, 0x0F, 0x1F));
5486}
5487
5488static __inline__ vector unsigned char __ATTRS_o_ai
5489vec_vmrglb(vector unsigned char __a, vector unsigned char __b) {
5490 return vec_perm(__a, __b,
5491 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5492 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5493 0x0E, 0x1E, 0x0F, 0x1F));
5494}
5495
5496static __inline__ vector bool char __ATTRS_o_ai
5497vec_vmrglb(vector bool char __a, vector bool char __b) {
5498 return vec_perm(__a, __b,
5499 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
5500 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
5501 0x0E, 0x1E, 0x0F, 0x1F));
5502}
5503
5504/* vec_vmrglh */
5505
5506#define __builtin_altivec_vmrglh vec_vmrglh
5507
5508static __inline__ vector short __ATTRS_o_ai vec_vmrglh(vector short __a,
5509 vector short __b) {
5510 return vec_perm(__a, __b,
5511 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5512 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5513 0x0E, 0x0F, 0x1E, 0x1F));
5514}
5515
5516static __inline__ vector unsigned short __ATTRS_o_ai
5517vec_vmrglh(vector unsigned short __a, vector unsigned short __b) {
5518 return vec_perm(__a, __b,
5519 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5520 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5521 0x0E, 0x0F, 0x1E, 0x1F));
5522}
5523
5524static __inline__ vector bool short __ATTRS_o_ai
5525vec_vmrglh(vector bool short __a, vector bool short __b) {
5526 return vec_perm(__a, __b,
5527 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5528 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5529 0x0E, 0x0F, 0x1E, 0x1F));
5530}
5531
5532static __inline__ vector pixel __ATTRS_o_ai vec_vmrglh(vector pixel __a,
5533 vector pixel __b) {
5534 return vec_perm(__a, __b,
5535 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
5536 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
5537 0x0E, 0x0F, 0x1E, 0x1F));
5538}
5539
5540/* vec_vmrglw */
5541
5542#define __builtin_altivec_vmrglw vec_vmrglw
5543
5544static __inline__ vector int __ATTRS_o_ai vec_vmrglw(vector int __a,
5545 vector int __b) {
5546 return vec_perm(__a, __b,
5547 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5548 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5549 0x1C, 0x1D, 0x1E, 0x1F));
5550}
5551
5552static __inline__ vector unsigned int __ATTRS_o_ai
5553vec_vmrglw(vector unsigned int __a, vector unsigned int __b) {
5554 return vec_perm(__a, __b,
5555 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5556 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5557 0x1C, 0x1D, 0x1E, 0x1F));
5558}
5559
5560static __inline__ vector bool int __ATTRS_o_ai vec_vmrglw(vector bool int __a,
5561 vector bool int __b) {
5562 return vec_perm(__a, __b,
5563 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5564 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5565 0x1C, 0x1D, 0x1E, 0x1F));
5566}
5567
5568static __inline__ vector float __ATTRS_o_ai vec_vmrglw(vector float __a,
5569 vector float __b) {
5570 return vec_perm(__a, __b,
5571 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
5572 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
5573 0x1C, 0x1D, 0x1E, 0x1F));
5574}
5575
5576#ifdef __POWER8_VECTOR__
5577/* vec_mergee */
5578
5579static __inline__ vector bool int __ATTRS_o_ai vec_mergee(vector bool int __a,
5580 vector bool int __b) {
5581 return vec_perm(__a, __b,
5582 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5583 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5584 0x18, 0x19, 0x1A, 0x1B));
5585}
5586
5587static __inline__ vector signed int __ATTRS_o_ai
5588vec_mergee(vector signed int __a, vector signed int __b) {
5589 return vec_perm(__a, __b,
5590 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5591 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5592 0x18, 0x19, 0x1A, 0x1B));
5593}
5594
5595static __inline__ vector unsigned int __ATTRS_o_ai
5596vec_mergee(vector unsigned int __a, vector unsigned int __b) {
5597 return vec_perm(__a, __b,
5598 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5599 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5600 0x18, 0x19, 0x1A, 0x1B));
5601}
5602
Logan Chien55afb0a2018-10-15 10:42:14 +08005603static __inline__ vector bool long long __ATTRS_o_ai
5604vec_mergee(vector bool long long __a, vector bool long long __b) {
5605 return vec_mergeh(__a, __b);
5606}
5607
5608static __inline__ vector signed long long __ATTRS_o_ai
5609vec_mergee(vector signed long long __a, vector signed long long __b) {
5610 return vec_mergeh(__a, __b);
5611}
5612
5613static __inline__ vector unsigned long long __ATTRS_o_ai
5614vec_mergee(vector unsigned long long __a, vector unsigned long long __b) {
5615 return vec_mergeh(__a, __b);
5616}
5617
5618static __inline__ vector float __ATTRS_o_ai
5619vec_mergee(vector float __a, vector float __b) {
5620 return vec_perm(__a, __b,
5621 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
5622 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
5623 0x18, 0x19, 0x1A, 0x1B));
5624}
5625
5626static __inline__ vector double __ATTRS_o_ai
5627vec_mergee(vector double __a, vector double __b) {
5628 return vec_mergeh(__a, __b);
5629}
5630
Logan Chien2833ffb2018-10-09 10:03:24 +08005631/* vec_mergeo */
5632
5633static __inline__ vector bool int __ATTRS_o_ai vec_mergeo(vector bool int __a,
5634 vector bool int __b) {
5635 return vec_perm(__a, __b,
5636 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5637 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5638 0x1C, 0x1D, 0x1E, 0x1F));
5639}
5640
5641static __inline__ vector signed int __ATTRS_o_ai
5642vec_mergeo(vector signed int __a, vector signed int __b) {
5643 return vec_perm(__a, __b,
5644 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5645 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5646 0x1C, 0x1D, 0x1E, 0x1F));
5647}
5648
5649static __inline__ vector unsigned int __ATTRS_o_ai
5650vec_mergeo(vector unsigned int __a, vector unsigned int __b) {
5651 return vec_perm(__a, __b,
5652 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5653 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5654 0x1C, 0x1D, 0x1E, 0x1F));
5655}
5656
Logan Chien55afb0a2018-10-15 10:42:14 +08005657static __inline__ vector bool long long __ATTRS_o_ai
5658vec_mergeo(vector bool long long __a, vector bool long long __b) {
5659 return vec_mergel(__a, __b);
5660}
5661
5662static __inline__ vector signed long long __ATTRS_o_ai
5663vec_mergeo(vector signed long long __a, vector signed long long __b) {
5664 return vec_mergel(__a, __b);
5665}
5666
5667static __inline__ vector unsigned long long __ATTRS_o_ai
5668vec_mergeo(vector unsigned long long __a, vector unsigned long long __b) {
5669 return vec_mergel(__a, __b);
5670}
5671
5672static __inline__ vector float __ATTRS_o_ai
5673vec_mergeo(vector float __a, vector float __b) {
5674 return vec_perm(__a, __b,
5675 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
5676 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
5677 0x1C, 0x1D, 0x1E, 0x1F));
5678}
5679
5680static __inline__ vector double __ATTRS_o_ai
5681vec_mergeo(vector double __a, vector double __b) {
5682 return vec_mergel(__a, __b);
5683}
5684
Logan Chien2833ffb2018-10-09 10:03:24 +08005685#endif
5686
5687/* vec_mfvscr */
5688
5689static __inline__ vector unsigned short __attribute__((__always_inline__))
5690vec_mfvscr(void) {
5691 return __builtin_altivec_mfvscr();
5692}
5693
5694/* vec_min */
5695
5696static __inline__ vector signed char __ATTRS_o_ai
5697vec_min(vector signed char __a, vector signed char __b) {
5698 return __builtin_altivec_vminsb(__a, __b);
5699}
5700
5701static __inline__ vector signed char __ATTRS_o_ai
5702vec_min(vector bool char __a, vector signed char __b) {
5703 return __builtin_altivec_vminsb((vector signed char)__a, __b);
5704}
5705
5706static __inline__ vector signed char __ATTRS_o_ai
5707vec_min(vector signed char __a, vector bool char __b) {
5708 return __builtin_altivec_vminsb(__a, (vector signed char)__b);
5709}
5710
5711static __inline__ vector unsigned char __ATTRS_o_ai
5712vec_min(vector unsigned char __a, vector unsigned char __b) {
5713 return __builtin_altivec_vminub(__a, __b);
5714}
5715
5716static __inline__ vector unsigned char __ATTRS_o_ai
5717vec_min(vector bool char __a, vector unsigned char __b) {
5718 return __builtin_altivec_vminub((vector unsigned char)__a, __b);
5719}
5720
5721static __inline__ vector unsigned char __ATTRS_o_ai
5722vec_min(vector unsigned char __a, vector bool char __b) {
5723 return __builtin_altivec_vminub(__a, (vector unsigned char)__b);
5724}
5725
5726static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a,
5727 vector short __b) {
5728 return __builtin_altivec_vminsh(__a, __b);
5729}
5730
5731static __inline__ vector short __ATTRS_o_ai vec_min(vector bool short __a,
5732 vector short __b) {
5733 return __builtin_altivec_vminsh((vector short)__a, __b);
5734}
5735
5736static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a,
5737 vector bool short __b) {
5738 return __builtin_altivec_vminsh(__a, (vector short)__b);
5739}
5740
5741static __inline__ vector unsigned short __ATTRS_o_ai
5742vec_min(vector unsigned short __a, vector unsigned short __b) {
5743 return __builtin_altivec_vminuh(__a, __b);
5744}
5745
5746static __inline__ vector unsigned short __ATTRS_o_ai
5747vec_min(vector bool short __a, vector unsigned short __b) {
5748 return __builtin_altivec_vminuh((vector unsigned short)__a, __b);
5749}
5750
5751static __inline__ vector unsigned short __ATTRS_o_ai
5752vec_min(vector unsigned short __a, vector bool short __b) {
5753 return __builtin_altivec_vminuh(__a, (vector unsigned short)__b);
5754}
5755
5756static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a,
5757 vector int __b) {
5758 return __builtin_altivec_vminsw(__a, __b);
5759}
5760
5761static __inline__ vector int __ATTRS_o_ai vec_min(vector bool int __a,
5762 vector int __b) {
5763 return __builtin_altivec_vminsw((vector int)__a, __b);
5764}
5765
5766static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a,
5767 vector bool int __b) {
5768 return __builtin_altivec_vminsw(__a, (vector int)__b);
5769}
5770
5771static __inline__ vector unsigned int __ATTRS_o_ai
5772vec_min(vector unsigned int __a, vector unsigned int __b) {
5773 return __builtin_altivec_vminuw(__a, __b);
5774}
5775
5776static __inline__ vector unsigned int __ATTRS_o_ai
5777vec_min(vector bool int __a, vector unsigned int __b) {
5778 return __builtin_altivec_vminuw((vector unsigned int)__a, __b);
5779}
5780
5781static __inline__ vector unsigned int __ATTRS_o_ai
5782vec_min(vector unsigned int __a, vector bool int __b) {
5783 return __builtin_altivec_vminuw(__a, (vector unsigned int)__b);
5784}
5785
5786#ifdef __POWER8_VECTOR__
5787static __inline__ vector signed long long __ATTRS_o_ai
5788vec_min(vector signed long long __a, vector signed long long __b) {
5789 return __builtin_altivec_vminsd(__a, __b);
5790}
5791
5792static __inline__ vector signed long long __ATTRS_o_ai
5793vec_min(vector bool long long __a, vector signed long long __b) {
5794 return __builtin_altivec_vminsd((vector signed long long)__a, __b);
5795}
5796
5797static __inline__ vector signed long long __ATTRS_o_ai
5798vec_min(vector signed long long __a, vector bool long long __b) {
5799 return __builtin_altivec_vminsd(__a, (vector signed long long)__b);
5800}
5801
5802static __inline__ vector unsigned long long __ATTRS_o_ai
5803vec_min(vector unsigned long long __a, vector unsigned long long __b) {
5804 return __builtin_altivec_vminud(__a, __b);
5805}
5806
5807static __inline__ vector unsigned long long __ATTRS_o_ai
5808vec_min(vector bool long long __a, vector unsigned long long __b) {
5809 return __builtin_altivec_vminud((vector unsigned long long)__a, __b);
5810}
5811
5812static __inline__ vector unsigned long long __ATTRS_o_ai
5813vec_min(vector unsigned long long __a, vector bool long long __b) {
5814 return __builtin_altivec_vminud(__a, (vector unsigned long long)__b);
5815}
5816#endif
5817
5818static __inline__ vector float __ATTRS_o_ai vec_min(vector float __a,
5819 vector float __b) {
5820#ifdef __VSX__
5821 return __builtin_vsx_xvminsp(__a, __b);
5822#else
5823 return __builtin_altivec_vminfp(__a, __b);
5824#endif
5825}
5826
5827#ifdef __VSX__
5828static __inline__ vector double __ATTRS_o_ai vec_min(vector double __a,
5829 vector double __b) {
5830 return __builtin_vsx_xvmindp(__a, __b);
5831}
5832#endif
5833
5834/* vec_vminsb */
5835
5836static __inline__ vector signed char __ATTRS_o_ai
5837vec_vminsb(vector signed char __a, vector signed char __b) {
5838 return __builtin_altivec_vminsb(__a, __b);
5839}
5840
5841static __inline__ vector signed char __ATTRS_o_ai
5842vec_vminsb(vector bool char __a, vector signed char __b) {
5843 return __builtin_altivec_vminsb((vector signed char)__a, __b);
5844}
5845
5846static __inline__ vector signed char __ATTRS_o_ai
5847vec_vminsb(vector signed char __a, vector bool char __b) {
5848 return __builtin_altivec_vminsb(__a, (vector signed char)__b);
5849}
5850
5851/* vec_vminub */
5852
5853static __inline__ vector unsigned char __ATTRS_o_ai
5854vec_vminub(vector unsigned char __a, vector unsigned char __b) {
5855 return __builtin_altivec_vminub(__a, __b);
5856}
5857
5858static __inline__ vector unsigned char __ATTRS_o_ai
5859vec_vminub(vector bool char __a, vector unsigned char __b) {
5860 return __builtin_altivec_vminub((vector unsigned char)__a, __b);
5861}
5862
5863static __inline__ vector unsigned char __ATTRS_o_ai
5864vec_vminub(vector unsigned char __a, vector bool char __b) {
5865 return __builtin_altivec_vminub(__a, (vector unsigned char)__b);
5866}
5867
5868/* vec_vminsh */
5869
5870static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a,
5871 vector short __b) {
5872 return __builtin_altivec_vminsh(__a, __b);
5873}
5874
5875static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector bool short __a,
5876 vector short __b) {
5877 return __builtin_altivec_vminsh((vector short)__a, __b);
5878}
5879
5880static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a,
5881 vector bool short __b) {
5882 return __builtin_altivec_vminsh(__a, (vector short)__b);
5883}
5884
5885/* vec_vminuh */
5886
5887static __inline__ vector unsigned short __ATTRS_o_ai
5888vec_vminuh(vector unsigned short __a, vector unsigned short __b) {
5889 return __builtin_altivec_vminuh(__a, __b);
5890}
5891
5892static __inline__ vector unsigned short __ATTRS_o_ai
5893vec_vminuh(vector bool short __a, vector unsigned short __b) {
5894 return __builtin_altivec_vminuh((vector unsigned short)__a, __b);
5895}
5896
5897static __inline__ vector unsigned short __ATTRS_o_ai
5898vec_vminuh(vector unsigned short __a, vector bool short __b) {
5899 return __builtin_altivec_vminuh(__a, (vector unsigned short)__b);
5900}
5901
5902/* vec_vminsw */
5903
5904static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a,
5905 vector int __b) {
5906 return __builtin_altivec_vminsw(__a, __b);
5907}
5908
5909static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector bool int __a,
5910 vector int __b) {
5911 return __builtin_altivec_vminsw((vector int)__a, __b);
5912}
5913
5914static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a,
5915 vector bool int __b) {
5916 return __builtin_altivec_vminsw(__a, (vector int)__b);
5917}
5918
5919/* vec_vminuw */
5920
5921static __inline__ vector unsigned int __ATTRS_o_ai
5922vec_vminuw(vector unsigned int __a, vector unsigned int __b) {
5923 return __builtin_altivec_vminuw(__a, __b);
5924}
5925
5926static __inline__ vector unsigned int __ATTRS_o_ai
5927vec_vminuw(vector bool int __a, vector unsigned int __b) {
5928 return __builtin_altivec_vminuw((vector unsigned int)__a, __b);
5929}
5930
5931static __inline__ vector unsigned int __ATTRS_o_ai
5932vec_vminuw(vector unsigned int __a, vector bool int __b) {
5933 return __builtin_altivec_vminuw(__a, (vector unsigned int)__b);
5934}
5935
5936/* vec_vminfp */
5937
5938static __inline__ vector float __attribute__((__always_inline__))
5939vec_vminfp(vector float __a, vector float __b) {
5940#ifdef __VSX__
5941 return __builtin_vsx_xvminsp(__a, __b);
5942#else
5943 return __builtin_altivec_vminfp(__a, __b);
5944#endif
5945}
5946
5947/* vec_mladd */
5948
5949#define __builtin_altivec_vmladduhm vec_mladd
5950
5951static __inline__ vector short __ATTRS_o_ai vec_mladd(vector short __a,
5952 vector short __b,
5953 vector short __c) {
5954 return __a * __b + __c;
5955}
5956
5957static __inline__ vector short __ATTRS_o_ai vec_mladd(
5958 vector short __a, vector unsigned short __b, vector unsigned short __c) {
5959 return __a * (vector short)__b + (vector short)__c;
5960}
5961
5962static __inline__ vector short __ATTRS_o_ai vec_mladd(vector unsigned short __a,
5963 vector short __b,
5964 vector short __c) {
5965 return (vector short)__a * __b + __c;
5966}
5967
5968static __inline__ vector unsigned short __ATTRS_o_ai
5969vec_mladd(vector unsigned short __a, vector unsigned short __b,
5970 vector unsigned short __c) {
5971 return __a * __b + __c;
5972}
5973
5974/* vec_vmladduhm */
5975
5976static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(vector short __a,
5977 vector short __b,
5978 vector short __c) {
5979 return __a * __b + __c;
5980}
5981
5982static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(
5983 vector short __a, vector unsigned short __b, vector unsigned short __c) {
5984 return __a * (vector short)__b + (vector short)__c;
5985}
5986
5987static __inline__ vector short __ATTRS_o_ai
5988vec_vmladduhm(vector unsigned short __a, vector short __b, vector short __c) {
5989 return (vector short)__a * __b + __c;
5990}
5991
5992static __inline__ vector unsigned short __ATTRS_o_ai
5993vec_vmladduhm(vector unsigned short __a, vector unsigned short __b,
5994 vector unsigned short __c) {
5995 return __a * __b + __c;
5996}
5997
5998/* vec_mradds */
5999
6000static __inline__ vector short __attribute__((__always_inline__))
6001vec_mradds(vector short __a, vector short __b, vector short __c) {
6002 return __builtin_altivec_vmhraddshs(__a, __b, __c);
6003}
6004
6005/* vec_vmhraddshs */
6006
6007static __inline__ vector short __attribute__((__always_inline__))
6008vec_vmhraddshs(vector short __a, vector short __b, vector short __c) {
6009 return __builtin_altivec_vmhraddshs(__a, __b, __c);
6010}
6011
6012/* vec_msum */
6013
6014static __inline__ vector int __ATTRS_o_ai vec_msum(vector signed char __a,
6015 vector unsigned char __b,
6016 vector int __c) {
6017 return __builtin_altivec_vmsummbm(__a, __b, __c);
6018}
6019
6020static __inline__ vector unsigned int __ATTRS_o_ai
6021vec_msum(vector unsigned char __a, vector unsigned char __b,
6022 vector unsigned int __c) {
6023 return __builtin_altivec_vmsumubm(__a, __b, __c);
6024}
6025
6026static __inline__ vector int __ATTRS_o_ai vec_msum(vector short __a,
6027 vector short __b,
6028 vector int __c) {
6029 return __builtin_altivec_vmsumshm(__a, __b, __c);
6030}
6031
6032static __inline__ vector unsigned int __ATTRS_o_ai
6033vec_msum(vector unsigned short __a, vector unsigned short __b,
6034 vector unsigned int __c) {
6035 return __builtin_altivec_vmsumuhm(__a, __b, __c);
6036}
6037
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006038/* vec_msumc */
6039
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07006040#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006041static __inline__ vector unsigned __int128 __ATTRS_o_ai
6042vec_msumc(vector unsigned long long __a, vector unsigned long long __b,
6043 vector unsigned __int128 __c) {
6044 return __builtin_altivec_vmsumcud(__a, __b, __c);
6045}
6046#endif
6047
Logan Chien2833ffb2018-10-09 10:03:24 +08006048/* vec_vmsummbm */
6049
6050static __inline__ vector int __attribute__((__always_inline__))
6051vec_vmsummbm(vector signed char __a, vector unsigned char __b, vector int __c) {
6052 return __builtin_altivec_vmsummbm(__a, __b, __c);
6053}
6054
6055/* vec_vmsumubm */
6056
6057static __inline__ vector unsigned int __attribute__((__always_inline__))
6058vec_vmsumubm(vector unsigned char __a, vector unsigned char __b,
6059 vector unsigned int __c) {
6060 return __builtin_altivec_vmsumubm(__a, __b, __c);
6061}
6062
6063/* vec_vmsumshm */
6064
6065static __inline__ vector int __attribute__((__always_inline__))
6066vec_vmsumshm(vector short __a, vector short __b, vector int __c) {
6067 return __builtin_altivec_vmsumshm(__a, __b, __c);
6068}
6069
6070/* vec_vmsumuhm */
6071
6072static __inline__ vector unsigned int __attribute__((__always_inline__))
6073vec_vmsumuhm(vector unsigned short __a, vector unsigned short __b,
6074 vector unsigned int __c) {
6075 return __builtin_altivec_vmsumuhm(__a, __b, __c);
6076}
6077
6078/* vec_msums */
6079
6080static __inline__ vector int __ATTRS_o_ai vec_msums(vector short __a,
6081 vector short __b,
6082 vector int __c) {
6083 return __builtin_altivec_vmsumshs(__a, __b, __c);
6084}
6085
6086static __inline__ vector unsigned int __ATTRS_o_ai
6087vec_msums(vector unsigned short __a, vector unsigned short __b,
6088 vector unsigned int __c) {
6089 return __builtin_altivec_vmsumuhs(__a, __b, __c);
6090}
6091
6092/* vec_vmsumshs */
6093
6094static __inline__ vector int __attribute__((__always_inline__))
6095vec_vmsumshs(vector short __a, vector short __b, vector int __c) {
6096 return __builtin_altivec_vmsumshs(__a, __b, __c);
6097}
6098
6099/* vec_vmsumuhs */
6100
6101static __inline__ vector unsigned int __attribute__((__always_inline__))
6102vec_vmsumuhs(vector unsigned short __a, vector unsigned short __b,
6103 vector unsigned int __c) {
6104 return __builtin_altivec_vmsumuhs(__a, __b, __c);
6105}
6106
6107/* vec_mtvscr */
6108
6109static __inline__ void __ATTRS_o_ai vec_mtvscr(vector signed char __a) {
6110 __builtin_altivec_mtvscr((vector int)__a);
6111}
6112
6113static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned char __a) {
6114 __builtin_altivec_mtvscr((vector int)__a);
6115}
6116
6117static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool char __a) {
6118 __builtin_altivec_mtvscr((vector int)__a);
6119}
6120
6121static __inline__ void __ATTRS_o_ai vec_mtvscr(vector short __a) {
6122 __builtin_altivec_mtvscr((vector int)__a);
6123}
6124
6125static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned short __a) {
6126 __builtin_altivec_mtvscr((vector int)__a);
6127}
6128
6129static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool short __a) {
6130 __builtin_altivec_mtvscr((vector int)__a);
6131}
6132
6133static __inline__ void __ATTRS_o_ai vec_mtvscr(vector pixel __a) {
6134 __builtin_altivec_mtvscr((vector int)__a);
6135}
6136
6137static __inline__ void __ATTRS_o_ai vec_mtvscr(vector int __a) {
6138 __builtin_altivec_mtvscr((vector int)__a);
6139}
6140
6141static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned int __a) {
6142 __builtin_altivec_mtvscr((vector int)__a);
6143}
6144
6145static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool int __a) {
6146 __builtin_altivec_mtvscr((vector int)__a);
6147}
6148
6149static __inline__ void __ATTRS_o_ai vec_mtvscr(vector float __a) {
6150 __builtin_altivec_mtvscr((vector int)__a);
6151}
6152
6153/* vec_mul */
6154
6155/* Integer vector multiplication will involve multiplication of the odd/even
6156 elements separately, then truncating the results and moving to the
6157 result vector.
6158*/
6159static __inline__ vector signed char __ATTRS_o_ai
6160vec_mul(vector signed char __a, vector signed char __b) {
6161 return __a * __b;
6162}
6163
6164static __inline__ vector unsigned char __ATTRS_o_ai
6165vec_mul(vector unsigned char __a, vector unsigned char __b) {
6166 return __a * __b;
6167}
6168
6169static __inline__ vector signed short __ATTRS_o_ai
6170vec_mul(vector signed short __a, vector signed short __b) {
6171 return __a * __b;
6172}
6173
6174static __inline__ vector unsigned short __ATTRS_o_ai
6175vec_mul(vector unsigned short __a, vector unsigned short __b) {
6176 return __a * __b;
6177}
6178
6179static __inline__ vector signed int __ATTRS_o_ai
6180vec_mul(vector signed int __a, vector signed int __b) {
6181 return __a * __b;
6182}
6183
6184static __inline__ vector unsigned int __ATTRS_o_ai
6185vec_mul(vector unsigned int __a, vector unsigned int __b) {
6186 return __a * __b;
6187}
6188
6189#ifdef __VSX__
6190static __inline__ vector signed long long __ATTRS_o_ai
6191vec_mul(vector signed long long __a, vector signed long long __b) {
6192 return __a * __b;
6193}
6194
6195static __inline__ vector unsigned long long __ATTRS_o_ai
6196vec_mul(vector unsigned long long __a, vector unsigned long long __b) {
6197 return __a * __b;
6198}
6199#endif
6200
6201static __inline__ vector float __ATTRS_o_ai vec_mul(vector float __a,
6202 vector float __b) {
6203 return __a * __b;
6204}
6205
6206#ifdef __VSX__
6207static __inline__ vector double __ATTRS_o_ai vec_mul(vector double __a,
6208 vector double __b) {
6209 return __a * __b;
6210}
6211#endif
6212
6213/* The vmulos* and vmules* instructions have a big endian bias, so
6214 we must reverse the meaning of "even" and "odd" for little endian. */
6215
6216/* vec_mule */
6217
6218static __inline__ vector short __ATTRS_o_ai vec_mule(vector signed char __a,
6219 vector signed char __b) {
6220#ifdef __LITTLE_ENDIAN__
6221 return __builtin_altivec_vmulosb(__a, __b);
6222#else
6223 return __builtin_altivec_vmulesb(__a, __b);
6224#endif
6225}
6226
6227static __inline__ vector unsigned short __ATTRS_o_ai
6228vec_mule(vector unsigned char __a, vector unsigned char __b) {
6229#ifdef __LITTLE_ENDIAN__
6230 return __builtin_altivec_vmuloub(__a, __b);
6231#else
6232 return __builtin_altivec_vmuleub(__a, __b);
6233#endif
6234}
6235
6236static __inline__ vector int __ATTRS_o_ai vec_mule(vector short __a,
6237 vector short __b) {
6238#ifdef __LITTLE_ENDIAN__
6239 return __builtin_altivec_vmulosh(__a, __b);
6240#else
6241 return __builtin_altivec_vmulesh(__a, __b);
6242#endif
6243}
6244
6245static __inline__ vector unsigned int __ATTRS_o_ai
6246vec_mule(vector unsigned short __a, vector unsigned short __b) {
6247#ifdef __LITTLE_ENDIAN__
6248 return __builtin_altivec_vmulouh(__a, __b);
6249#else
6250 return __builtin_altivec_vmuleuh(__a, __b);
6251#endif
6252}
6253
6254#ifdef __POWER8_VECTOR__
6255static __inline__ vector signed long long __ATTRS_o_ai
6256vec_mule(vector signed int __a, vector signed int __b) {
6257#ifdef __LITTLE_ENDIAN__
6258 return __builtin_altivec_vmulosw(__a, __b);
6259#else
6260 return __builtin_altivec_vmulesw(__a, __b);
6261#endif
6262}
6263
6264static __inline__ vector unsigned long long __ATTRS_o_ai
6265vec_mule(vector unsigned int __a, vector unsigned int __b) {
6266#ifdef __LITTLE_ENDIAN__
6267 return __builtin_altivec_vmulouw(__a, __b);
6268#else
6269 return __builtin_altivec_vmuleuw(__a, __b);
6270#endif
6271}
6272#endif
6273
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07006274#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006275static __inline__ vector signed __int128 __ATTRS_o_ai
6276vec_mule(vector signed long long __a, vector signed long long __b) {
6277#ifdef __LITTLE_ENDIAN__
6278 return __builtin_altivec_vmulosd(__a, __b);
6279#else
6280 return __builtin_altivec_vmulesd(__a, __b);
6281#endif
6282}
6283
6284static __inline__ vector unsigned __int128 __ATTRS_o_ai
6285vec_mule(vector unsigned long long __a, vector unsigned long long __b) {
6286#ifdef __LITTLE_ENDIAN__
6287 return __builtin_altivec_vmuloud(__a, __b);
6288#else
6289 return __builtin_altivec_vmuleud(__a, __b);
6290#endif
6291}
6292#endif
6293
Logan Chien2833ffb2018-10-09 10:03:24 +08006294/* vec_vmulesb */
6295
6296static __inline__ vector short __attribute__((__always_inline__))
6297vec_vmulesb(vector signed char __a, vector signed char __b) {
6298#ifdef __LITTLE_ENDIAN__
6299 return __builtin_altivec_vmulosb(__a, __b);
6300#else
6301 return __builtin_altivec_vmulesb(__a, __b);
6302#endif
6303}
6304
6305/* vec_vmuleub */
6306
6307static __inline__ vector unsigned short __attribute__((__always_inline__))
6308vec_vmuleub(vector unsigned char __a, vector unsigned char __b) {
6309#ifdef __LITTLE_ENDIAN__
6310 return __builtin_altivec_vmuloub(__a, __b);
6311#else
6312 return __builtin_altivec_vmuleub(__a, __b);
6313#endif
6314}
6315
6316/* vec_vmulesh */
6317
6318static __inline__ vector int __attribute__((__always_inline__))
6319vec_vmulesh(vector short __a, vector short __b) {
6320#ifdef __LITTLE_ENDIAN__
6321 return __builtin_altivec_vmulosh(__a, __b);
6322#else
6323 return __builtin_altivec_vmulesh(__a, __b);
6324#endif
6325}
6326
6327/* vec_vmuleuh */
6328
6329static __inline__ vector unsigned int __attribute__((__always_inline__))
6330vec_vmuleuh(vector unsigned short __a, vector unsigned short __b) {
6331#ifdef __LITTLE_ENDIAN__
6332 return __builtin_altivec_vmulouh(__a, __b);
6333#else
6334 return __builtin_altivec_vmuleuh(__a, __b);
6335#endif
6336}
6337
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006338/* vec_mulh */
6339
6340#ifdef __POWER10_VECTOR__
6341static __inline__ vector signed int __ATTRS_o_ai
6342vec_mulh(vector signed int __a, vector signed int __b) {
6343 return __builtin_altivec_vmulhsw(__a, __b);
6344}
6345
6346static __inline__ vector unsigned int __ATTRS_o_ai
6347vec_mulh(vector unsigned int __a, vector unsigned int __b) {
6348 return __builtin_altivec_vmulhuw(__a, __b);
6349}
6350
6351static __inline__ vector signed long long __ATTRS_o_ai
6352vec_mulh(vector signed long long __a, vector signed long long __b) {
6353 return __builtin_altivec_vmulhsd(__a, __b);
6354}
6355
6356static __inline__ vector unsigned long long __ATTRS_o_ai
6357vec_mulh(vector unsigned long long __a, vector unsigned long long __b) {
6358 return __builtin_altivec_vmulhud(__a, __b);
6359}
6360#endif
6361
Logan Chien2833ffb2018-10-09 10:03:24 +08006362/* vec_mulo */
6363
6364static __inline__ vector short __ATTRS_o_ai vec_mulo(vector signed char __a,
6365 vector signed char __b) {
6366#ifdef __LITTLE_ENDIAN__
6367 return __builtin_altivec_vmulesb(__a, __b);
6368#else
6369 return __builtin_altivec_vmulosb(__a, __b);
6370#endif
6371}
6372
6373static __inline__ vector unsigned short __ATTRS_o_ai
6374vec_mulo(vector unsigned char __a, vector unsigned char __b) {
6375#ifdef __LITTLE_ENDIAN__
6376 return __builtin_altivec_vmuleub(__a, __b);
6377#else
6378 return __builtin_altivec_vmuloub(__a, __b);
6379#endif
6380}
6381
6382static __inline__ vector int __ATTRS_o_ai vec_mulo(vector short __a,
6383 vector short __b) {
6384#ifdef __LITTLE_ENDIAN__
6385 return __builtin_altivec_vmulesh(__a, __b);
6386#else
6387 return __builtin_altivec_vmulosh(__a, __b);
6388#endif
6389}
6390
6391static __inline__ vector unsigned int __ATTRS_o_ai
6392vec_mulo(vector unsigned short __a, vector unsigned short __b) {
6393#ifdef __LITTLE_ENDIAN__
6394 return __builtin_altivec_vmuleuh(__a, __b);
6395#else
6396 return __builtin_altivec_vmulouh(__a, __b);
6397#endif
6398}
6399
6400#ifdef __POWER8_VECTOR__
6401static __inline__ vector signed long long __ATTRS_o_ai
6402vec_mulo(vector signed int __a, vector signed int __b) {
6403#ifdef __LITTLE_ENDIAN__
6404 return __builtin_altivec_vmulesw(__a, __b);
6405#else
6406 return __builtin_altivec_vmulosw(__a, __b);
6407#endif
6408}
6409
6410static __inline__ vector unsigned long long __ATTRS_o_ai
6411vec_mulo(vector unsigned int __a, vector unsigned int __b) {
6412#ifdef __LITTLE_ENDIAN__
6413 return __builtin_altivec_vmuleuw(__a, __b);
6414#else
6415 return __builtin_altivec_vmulouw(__a, __b);
6416#endif
6417}
6418#endif
6419
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07006420#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08006421static __inline__ vector signed __int128 __ATTRS_o_ai
6422vec_mulo(vector signed long long __a, vector signed long long __b) {
6423#ifdef __LITTLE_ENDIAN__
6424 return __builtin_altivec_vmulesd(__a, __b);
6425#else
6426 return __builtin_altivec_vmulosd(__a, __b);
6427#endif
6428}
6429
6430static __inline__ vector unsigned __int128 __ATTRS_o_ai
6431vec_mulo(vector unsigned long long __a, vector unsigned long long __b) {
6432#ifdef __LITTLE_ENDIAN__
6433 return __builtin_altivec_vmuleud(__a, __b);
6434#else
6435 return __builtin_altivec_vmuloud(__a, __b);
6436#endif
6437}
6438#endif
6439
Logan Chien2833ffb2018-10-09 10:03:24 +08006440/* vec_vmulosb */
6441
6442static __inline__ vector short __attribute__((__always_inline__))
6443vec_vmulosb(vector signed char __a, vector signed char __b) {
6444#ifdef __LITTLE_ENDIAN__
6445 return __builtin_altivec_vmulesb(__a, __b);
6446#else
6447 return __builtin_altivec_vmulosb(__a, __b);
6448#endif
6449}
6450
6451/* vec_vmuloub */
6452
6453static __inline__ vector unsigned short __attribute__((__always_inline__))
6454vec_vmuloub(vector unsigned char __a, vector unsigned char __b) {
6455#ifdef __LITTLE_ENDIAN__
6456 return __builtin_altivec_vmuleub(__a, __b);
6457#else
6458 return __builtin_altivec_vmuloub(__a, __b);
6459#endif
6460}
6461
6462/* vec_vmulosh */
6463
6464static __inline__ vector int __attribute__((__always_inline__))
6465vec_vmulosh(vector short __a, vector short __b) {
6466#ifdef __LITTLE_ENDIAN__
6467 return __builtin_altivec_vmulesh(__a, __b);
6468#else
6469 return __builtin_altivec_vmulosh(__a, __b);
6470#endif
6471}
6472
6473/* vec_vmulouh */
6474
6475static __inline__ vector unsigned int __attribute__((__always_inline__))
6476vec_vmulouh(vector unsigned short __a, vector unsigned short __b) {
6477#ifdef __LITTLE_ENDIAN__
6478 return __builtin_altivec_vmuleuh(__a, __b);
6479#else
6480 return __builtin_altivec_vmulouh(__a, __b);
6481#endif
6482}
6483
6484/* vec_nand */
6485
6486#ifdef __POWER8_VECTOR__
6487static __inline__ vector signed char __ATTRS_o_ai
6488vec_nand(vector signed char __a, vector signed char __b) {
6489 return ~(__a & __b);
6490}
6491
6492static __inline__ vector signed char __ATTRS_o_ai
6493vec_nand(vector signed char __a, vector bool char __b) {
6494 return ~(__a & __b);
6495}
6496
6497static __inline__ vector signed char __ATTRS_o_ai
6498vec_nand(vector bool char __a, vector signed char __b) {
6499 return ~(__a & __b);
6500}
6501
6502static __inline__ vector unsigned char __ATTRS_o_ai
6503vec_nand(vector unsigned char __a, vector unsigned char __b) {
6504 return ~(__a & __b);
6505}
6506
6507static __inline__ vector unsigned char __ATTRS_o_ai
6508vec_nand(vector unsigned char __a, vector bool char __b) {
6509 return ~(__a & __b);
6510}
6511
6512static __inline__ vector unsigned char __ATTRS_o_ai
6513vec_nand(vector bool char __a, vector unsigned char __b) {
6514 return ~(__a & __b);
6515}
6516
6517static __inline__ vector bool char __ATTRS_o_ai vec_nand(vector bool char __a,
6518 vector bool char __b) {
6519 return ~(__a & __b);
6520}
6521
6522static __inline__ vector signed short __ATTRS_o_ai
6523vec_nand(vector signed short __a, vector signed short __b) {
6524 return ~(__a & __b);
6525}
6526
6527static __inline__ vector signed short __ATTRS_o_ai
6528vec_nand(vector signed short __a, vector bool short __b) {
6529 return ~(__a & __b);
6530}
6531
6532static __inline__ vector signed short __ATTRS_o_ai
6533vec_nand(vector bool short __a, vector signed short __b) {
6534 return ~(__a & __b);
6535}
6536
6537static __inline__ vector unsigned short __ATTRS_o_ai
6538vec_nand(vector unsigned short __a, vector unsigned short __b) {
6539 return ~(__a & __b);
6540}
6541
6542static __inline__ vector unsigned short __ATTRS_o_ai
6543vec_nand(vector unsigned short __a, vector bool short __b) {
6544 return ~(__a & __b);
6545}
6546
6547static __inline__ vector bool short __ATTRS_o_ai
6548vec_nand(vector bool short __a, vector bool short __b) {
6549 return ~(__a & __b);
6550}
6551
6552static __inline__ vector signed int __ATTRS_o_ai
6553vec_nand(vector signed int __a, vector signed int __b) {
6554 return ~(__a & __b);
6555}
6556
6557static __inline__ vector signed int __ATTRS_o_ai vec_nand(vector signed int __a,
6558 vector bool int __b) {
6559 return ~(__a & __b);
6560}
6561
6562static __inline__ vector signed int __ATTRS_o_ai
6563vec_nand(vector bool int __a, vector signed int __b) {
6564 return ~(__a & __b);
6565}
6566
6567static __inline__ vector unsigned int __ATTRS_o_ai
6568vec_nand(vector unsigned int __a, vector unsigned int __b) {
6569 return ~(__a & __b);
6570}
6571
6572static __inline__ vector unsigned int __ATTRS_o_ai
6573vec_nand(vector unsigned int __a, vector bool int __b) {
6574 return ~(__a & __b);
6575}
6576
6577static __inline__ vector unsigned int __ATTRS_o_ai
6578vec_nand(vector bool int __a, vector unsigned int __b) {
6579 return ~(__a & __b);
6580}
6581
6582static __inline__ vector bool int __ATTRS_o_ai vec_nand(vector bool int __a,
6583 vector bool int __b) {
6584 return ~(__a & __b);
6585}
6586
Logan Chien55afb0a2018-10-15 10:42:14 +08006587static __inline__ vector float __ATTRS_o_ai
6588vec_nand(vector float __a, vector float __b) {
6589 return (vector float)(~((vector unsigned int)__a &
6590 (vector unsigned int)__b));
6591}
6592
Logan Chien2833ffb2018-10-09 10:03:24 +08006593static __inline__ vector signed long long __ATTRS_o_ai
6594vec_nand(vector signed long long __a, vector signed long long __b) {
6595 return ~(__a & __b);
6596}
6597
6598static __inline__ vector signed long long __ATTRS_o_ai
6599vec_nand(vector signed long long __a, vector bool long long __b) {
6600 return ~(__a & __b);
6601}
6602
6603static __inline__ vector signed long long __ATTRS_o_ai
6604vec_nand(vector bool long long __a, vector signed long long __b) {
6605 return ~(__a & __b);
6606}
6607
6608static __inline__ vector unsigned long long __ATTRS_o_ai
6609vec_nand(vector unsigned long long __a, vector unsigned long long __b) {
6610 return ~(__a & __b);
6611}
6612
6613static __inline__ vector unsigned long long __ATTRS_o_ai
6614vec_nand(vector unsigned long long __a, vector bool long long __b) {
6615 return ~(__a & __b);
6616}
6617
6618static __inline__ vector unsigned long long __ATTRS_o_ai
6619vec_nand(vector bool long long __a, vector unsigned long long __b) {
6620 return ~(__a & __b);
6621}
6622
6623static __inline__ vector bool long long __ATTRS_o_ai
6624vec_nand(vector bool long long __a, vector bool long long __b) {
6625 return ~(__a & __b);
6626}
6627
Logan Chien55afb0a2018-10-15 10:42:14 +08006628static __inline__ vector double __ATTRS_o_ai
6629vec_nand(vector double __a, vector double __b) {
6630 return (vector double)(~((vector unsigned long long)__a &
6631 (vector unsigned long long)__b));
6632}
6633
Logan Chien2833ffb2018-10-09 10:03:24 +08006634#endif
6635
6636/* vec_nmadd */
6637
6638#ifdef __VSX__
6639static __inline__ vector float __ATTRS_o_ai vec_nmadd(vector float __a,
6640 vector float __b,
6641 vector float __c) {
6642 return __builtin_vsx_xvnmaddasp(__a, __b, __c);
6643}
6644
6645static __inline__ vector double __ATTRS_o_ai vec_nmadd(vector double __a,
6646 vector double __b,
6647 vector double __c) {
6648 return __builtin_vsx_xvnmaddadp(__a, __b, __c);
6649}
6650#endif
6651
6652/* vec_nmsub */
6653
6654static __inline__ vector float __ATTRS_o_ai vec_nmsub(vector float __a,
6655 vector float __b,
6656 vector float __c) {
6657#ifdef __VSX__
6658 return __builtin_vsx_xvnmsubasp(__a, __b, __c);
6659#else
6660 return __builtin_altivec_vnmsubfp(__a, __b, __c);
6661#endif
6662}
6663
6664#ifdef __VSX__
6665static __inline__ vector double __ATTRS_o_ai vec_nmsub(vector double __a,
6666 vector double __b,
6667 vector double __c) {
6668 return __builtin_vsx_xvnmsubadp(__a, __b, __c);
6669}
6670#endif
6671
6672/* vec_vnmsubfp */
6673
6674static __inline__ vector float __attribute__((__always_inline__))
6675vec_vnmsubfp(vector float __a, vector float __b, vector float __c) {
6676 return __builtin_altivec_vnmsubfp(__a, __b, __c);
6677}
6678
6679/* vec_nor */
6680
6681#define __builtin_altivec_vnor vec_nor
6682
6683static __inline__ vector signed char __ATTRS_o_ai
6684vec_nor(vector signed char __a, vector signed char __b) {
6685 return ~(__a | __b);
6686}
6687
6688static __inline__ vector unsigned char __ATTRS_o_ai
6689vec_nor(vector unsigned char __a, vector unsigned char __b) {
6690 return ~(__a | __b);
6691}
6692
6693static __inline__ vector bool char __ATTRS_o_ai vec_nor(vector bool char __a,
6694 vector bool char __b) {
6695 return ~(__a | __b);
6696}
6697
6698static __inline__ vector short __ATTRS_o_ai vec_nor(vector short __a,
6699 vector short __b) {
6700 return ~(__a | __b);
6701}
6702
6703static __inline__ vector unsigned short __ATTRS_o_ai
6704vec_nor(vector unsigned short __a, vector unsigned short __b) {
6705 return ~(__a | __b);
6706}
6707
6708static __inline__ vector bool short __ATTRS_o_ai
6709vec_nor(vector bool short __a, vector bool short __b) {
6710 return ~(__a | __b);
6711}
6712
6713static __inline__ vector int __ATTRS_o_ai vec_nor(vector int __a,
6714 vector int __b) {
6715 return ~(__a | __b);
6716}
6717
6718static __inline__ vector unsigned int __ATTRS_o_ai
6719vec_nor(vector unsigned int __a, vector unsigned int __b) {
6720 return ~(__a | __b);
6721}
6722
6723static __inline__ vector bool int __ATTRS_o_ai vec_nor(vector bool int __a,
6724 vector bool int __b) {
6725 return ~(__a | __b);
6726}
6727
6728static __inline__ vector float __ATTRS_o_ai vec_nor(vector float __a,
6729 vector float __b) {
6730 vector unsigned int __res =
6731 ~((vector unsigned int)__a | (vector unsigned int)__b);
6732 return (vector float)__res;
6733}
6734
6735#ifdef __VSX__
6736static __inline__ vector double __ATTRS_o_ai vec_nor(vector double __a,
6737 vector double __b) {
6738 vector unsigned long long __res =
6739 ~((vector unsigned long long)__a | (vector unsigned long long)__b);
6740 return (vector double)__res;
6741}
6742#endif
6743
6744/* vec_vnor */
6745
6746static __inline__ vector signed char __ATTRS_o_ai
6747vec_vnor(vector signed char __a, vector signed char __b) {
6748 return ~(__a | __b);
6749}
6750
6751static __inline__ vector unsigned char __ATTRS_o_ai
6752vec_vnor(vector unsigned char __a, vector unsigned char __b) {
6753 return ~(__a | __b);
6754}
6755
6756static __inline__ vector bool char __ATTRS_o_ai vec_vnor(vector bool char __a,
6757 vector bool char __b) {
6758 return ~(__a | __b);
6759}
6760
6761static __inline__ vector short __ATTRS_o_ai vec_vnor(vector short __a,
6762 vector short __b) {
6763 return ~(__a | __b);
6764}
6765
6766static __inline__ vector unsigned short __ATTRS_o_ai
6767vec_vnor(vector unsigned short __a, vector unsigned short __b) {
6768 return ~(__a | __b);
6769}
6770
6771static __inline__ vector bool short __ATTRS_o_ai
6772vec_vnor(vector bool short __a, vector bool short __b) {
6773 return ~(__a | __b);
6774}
6775
6776static __inline__ vector int __ATTRS_o_ai vec_vnor(vector int __a,
6777 vector int __b) {
6778 return ~(__a | __b);
6779}
6780
6781static __inline__ vector unsigned int __ATTRS_o_ai
6782vec_vnor(vector unsigned int __a, vector unsigned int __b) {
6783 return ~(__a | __b);
6784}
6785
6786static __inline__ vector bool int __ATTRS_o_ai vec_vnor(vector bool int __a,
6787 vector bool int __b) {
6788 return ~(__a | __b);
6789}
6790
6791static __inline__ vector float __ATTRS_o_ai vec_vnor(vector float __a,
6792 vector float __b) {
6793 vector unsigned int __res =
6794 ~((vector unsigned int)__a | (vector unsigned int)__b);
6795 return (vector float)__res;
6796}
6797
6798#ifdef __VSX__
6799static __inline__ vector signed long long __ATTRS_o_ai
6800vec_nor(vector signed long long __a, vector signed long long __b) {
6801 return ~(__a | __b);
6802}
6803
6804static __inline__ vector unsigned long long __ATTRS_o_ai
6805vec_nor(vector unsigned long long __a, vector unsigned long long __b) {
6806 return ~(__a | __b);
6807}
6808
6809static __inline__ vector bool long long __ATTRS_o_ai
6810vec_nor(vector bool long long __a, vector bool long long __b) {
6811 return ~(__a | __b);
6812}
6813#endif
6814
6815/* vec_or */
6816
6817#define __builtin_altivec_vor vec_or
6818
6819static __inline__ vector signed char __ATTRS_o_ai
6820vec_or(vector signed char __a, vector signed char __b) {
6821 return __a | __b;
6822}
6823
6824static __inline__ vector signed char __ATTRS_o_ai
6825vec_or(vector bool char __a, vector signed char __b) {
6826 return (vector signed char)__a | __b;
6827}
6828
6829static __inline__ vector signed char __ATTRS_o_ai vec_or(vector signed char __a,
6830 vector bool char __b) {
6831 return __a | (vector signed char)__b;
6832}
6833
6834static __inline__ vector unsigned char __ATTRS_o_ai
6835vec_or(vector unsigned char __a, vector unsigned char __b) {
6836 return __a | __b;
6837}
6838
6839static __inline__ vector unsigned char __ATTRS_o_ai
6840vec_or(vector bool char __a, vector unsigned char __b) {
6841 return (vector unsigned char)__a | __b;
6842}
6843
6844static __inline__ vector unsigned char __ATTRS_o_ai
6845vec_or(vector unsigned char __a, vector bool char __b) {
6846 return __a | (vector unsigned char)__b;
6847}
6848
6849static __inline__ vector bool char __ATTRS_o_ai vec_or(vector bool char __a,
6850 vector bool char __b) {
6851 return __a | __b;
6852}
6853
6854static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a,
6855 vector short __b) {
6856 return __a | __b;
6857}
6858
6859static __inline__ vector short __ATTRS_o_ai vec_or(vector bool short __a,
6860 vector short __b) {
6861 return (vector short)__a | __b;
6862}
6863
6864static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a,
6865 vector bool short __b) {
6866 return __a | (vector short)__b;
6867}
6868
6869static __inline__ vector unsigned short __ATTRS_o_ai
6870vec_or(vector unsigned short __a, vector unsigned short __b) {
6871 return __a | __b;
6872}
6873
6874static __inline__ vector unsigned short __ATTRS_o_ai
6875vec_or(vector bool short __a, vector unsigned short __b) {
6876 return (vector unsigned short)__a | __b;
6877}
6878
6879static __inline__ vector unsigned short __ATTRS_o_ai
6880vec_or(vector unsigned short __a, vector bool short __b) {
6881 return __a | (vector unsigned short)__b;
6882}
6883
6884static __inline__ vector bool short __ATTRS_o_ai vec_or(vector bool short __a,
6885 vector bool short __b) {
6886 return __a | __b;
6887}
6888
6889static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a,
6890 vector int __b) {
6891 return __a | __b;
6892}
6893
6894static __inline__ vector int __ATTRS_o_ai vec_or(vector bool int __a,
6895 vector int __b) {
6896 return (vector int)__a | __b;
6897}
6898
6899static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a,
6900 vector bool int __b) {
6901 return __a | (vector int)__b;
6902}
6903
6904static __inline__ vector unsigned int __ATTRS_o_ai
6905vec_or(vector unsigned int __a, vector unsigned int __b) {
6906 return __a | __b;
6907}
6908
6909static __inline__ vector unsigned int __ATTRS_o_ai
6910vec_or(vector bool int __a, vector unsigned int __b) {
6911 return (vector unsigned int)__a | __b;
6912}
6913
6914static __inline__ vector unsigned int __ATTRS_o_ai
6915vec_or(vector unsigned int __a, vector bool int __b) {
6916 return __a | (vector unsigned int)__b;
6917}
6918
6919static __inline__ vector bool int __ATTRS_o_ai vec_or(vector bool int __a,
6920 vector bool int __b) {
6921 return __a | __b;
6922}
6923
6924static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a,
6925 vector float __b) {
6926 vector unsigned int __res =
6927 (vector unsigned int)__a | (vector unsigned int)__b;
6928 return (vector float)__res;
6929}
6930
6931static __inline__ vector float __ATTRS_o_ai vec_or(vector bool int __a,
6932 vector float __b) {
6933 vector unsigned int __res =
6934 (vector unsigned int)__a | (vector unsigned int)__b;
6935 return (vector float)__res;
6936}
6937
6938static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a,
6939 vector bool int __b) {
6940 vector unsigned int __res =
6941 (vector unsigned int)__a | (vector unsigned int)__b;
6942 return (vector float)__res;
6943}
6944
6945#ifdef __VSX__
6946static __inline__ vector double __ATTRS_o_ai vec_or(vector bool long long __a,
6947 vector double __b) {
Sasha Smundak746b0222020-02-25 09:19:04 -08006948 return (vector double)((vector unsigned long long)__a |
6949 (vector unsigned long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +08006950}
6951
6952static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a,
6953 vector bool long long __b) {
Sasha Smundak746b0222020-02-25 09:19:04 -08006954 return (vector double)((vector unsigned long long)__a |
6955 (vector unsigned long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +08006956}
6957
6958static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a,
6959 vector double __b) {
Sasha Smundak746b0222020-02-25 09:19:04 -08006960 return (vector double)((vector unsigned long long)__a |
6961 (vector unsigned long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +08006962}
6963
6964static __inline__ vector signed long long __ATTRS_o_ai
6965vec_or(vector signed long long __a, vector signed long long __b) {
6966 return __a | __b;
6967}
6968
6969static __inline__ vector signed long long __ATTRS_o_ai
6970vec_or(vector bool long long __a, vector signed long long __b) {
6971 return (vector signed long long)__a | __b;
6972}
6973
6974static __inline__ vector signed long long __ATTRS_o_ai
6975vec_or(vector signed long long __a, vector bool long long __b) {
6976 return __a | (vector signed long long)__b;
6977}
6978
6979static __inline__ vector unsigned long long __ATTRS_o_ai
6980vec_or(vector unsigned long long __a, vector unsigned long long __b) {
6981 return __a | __b;
6982}
6983
6984static __inline__ vector unsigned long long __ATTRS_o_ai
6985vec_or(vector bool long long __a, vector unsigned long long __b) {
6986 return (vector unsigned long long)__a | __b;
6987}
6988
6989static __inline__ vector unsigned long long __ATTRS_o_ai
6990vec_or(vector unsigned long long __a, vector bool long long __b) {
6991 return __a | (vector unsigned long long)__b;
6992}
6993
6994static __inline__ vector bool long long __ATTRS_o_ai
6995vec_or(vector bool long long __a, vector bool long long __b) {
6996 return __a | __b;
6997}
6998#endif
6999
7000#ifdef __POWER8_VECTOR__
7001static __inline__ vector signed char __ATTRS_o_ai
7002vec_orc(vector signed char __a, vector signed char __b) {
7003 return __a | ~__b;
7004}
7005
7006static __inline__ vector signed char __ATTRS_o_ai
7007vec_orc(vector signed char __a, vector bool char __b) {
7008 return __a | ~__b;
7009}
7010
7011static __inline__ vector signed char __ATTRS_o_ai
7012vec_orc(vector bool char __a, vector signed char __b) {
7013 return __a | ~__b;
7014}
7015
7016static __inline__ vector unsigned char __ATTRS_o_ai
7017vec_orc(vector unsigned char __a, vector unsigned char __b) {
7018 return __a | ~__b;
7019}
7020
7021static __inline__ vector unsigned char __ATTRS_o_ai
7022vec_orc(vector unsigned char __a, vector bool char __b) {
7023 return __a | ~__b;
7024}
7025
7026static __inline__ vector unsigned char __ATTRS_o_ai
7027vec_orc(vector bool char __a, vector unsigned char __b) {
7028 return __a | ~__b;
7029}
7030
7031static __inline__ vector bool char __ATTRS_o_ai vec_orc(vector bool char __a,
7032 vector bool char __b) {
7033 return __a | ~__b;
7034}
7035
7036static __inline__ vector signed short __ATTRS_o_ai
7037vec_orc(vector signed short __a, vector signed short __b) {
7038 return __a | ~__b;
7039}
7040
7041static __inline__ vector signed short __ATTRS_o_ai
7042vec_orc(vector signed short __a, vector bool short __b) {
7043 return __a | ~__b;
7044}
7045
7046static __inline__ vector signed short __ATTRS_o_ai
7047vec_orc(vector bool short __a, vector signed short __b) {
7048 return __a | ~__b;
7049}
7050
7051static __inline__ vector unsigned short __ATTRS_o_ai
7052vec_orc(vector unsigned short __a, vector unsigned short __b) {
7053 return __a | ~__b;
7054}
7055
7056static __inline__ vector unsigned short __ATTRS_o_ai
7057vec_orc(vector unsigned short __a, vector bool short __b) {
7058 return __a | ~__b;
7059}
7060
7061static __inline__ vector unsigned short __ATTRS_o_ai
7062vec_orc(vector bool short __a, vector unsigned short __b) {
7063 return __a | ~__b;
7064}
7065
7066static __inline__ vector bool short __ATTRS_o_ai
7067vec_orc(vector bool short __a, vector bool short __b) {
7068 return __a | ~__b;
7069}
7070
7071static __inline__ vector signed int __ATTRS_o_ai
7072vec_orc(vector signed int __a, vector signed int __b) {
7073 return __a | ~__b;
7074}
7075
7076static __inline__ vector signed int __ATTRS_o_ai vec_orc(vector signed int __a,
7077 vector bool int __b) {
7078 return __a | ~__b;
7079}
7080
7081static __inline__ vector signed int __ATTRS_o_ai
7082vec_orc(vector bool int __a, vector signed int __b) {
7083 return __a | ~__b;
7084}
7085
7086static __inline__ vector unsigned int __ATTRS_o_ai
7087vec_orc(vector unsigned int __a, vector unsigned int __b) {
7088 return __a | ~__b;
7089}
7090
7091static __inline__ vector unsigned int __ATTRS_o_ai
7092vec_orc(vector unsigned int __a, vector bool int __b) {
7093 return __a | ~__b;
7094}
7095
7096static __inline__ vector unsigned int __ATTRS_o_ai
7097vec_orc(vector bool int __a, vector unsigned int __b) {
7098 return __a | ~__b;
7099}
7100
7101static __inline__ vector bool int __ATTRS_o_ai vec_orc(vector bool int __a,
7102 vector bool int __b) {
7103 return __a | ~__b;
7104}
7105
Logan Chien55afb0a2018-10-15 10:42:14 +08007106static __inline__ vector float __ATTRS_o_ai
7107vec_orc(vector bool int __a, vector float __b) {
7108 return (vector float)(__a | ~(vector unsigned int)__b);
7109}
7110
7111static __inline__ vector float __ATTRS_o_ai
7112vec_orc(vector float __a, vector bool int __b) {
7113 return (vector float)((vector unsigned int)__a | ~__b);
7114}
7115
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08007116static __inline__ vector float __ATTRS_o_ai vec_orc(vector float __a,
7117 vector float __b) {
7118 return (vector float)((vector unsigned int)__a | ~(vector unsigned int)__b);
7119}
7120
Logan Chien2833ffb2018-10-09 10:03:24 +08007121static __inline__ vector signed long long __ATTRS_o_ai
7122vec_orc(vector signed long long __a, vector signed long long __b) {
7123 return __a | ~__b;
7124}
7125
7126static __inline__ vector signed long long __ATTRS_o_ai
7127vec_orc(vector signed long long __a, vector bool long long __b) {
7128 return __a | ~__b;
7129}
7130
7131static __inline__ vector signed long long __ATTRS_o_ai
7132vec_orc(vector bool long long __a, vector signed long long __b) {
7133 return __a | ~__b;
7134}
7135
7136static __inline__ vector unsigned long long __ATTRS_o_ai
7137vec_orc(vector unsigned long long __a, vector unsigned long long __b) {
7138 return __a | ~__b;
7139}
7140
7141static __inline__ vector unsigned long long __ATTRS_o_ai
7142vec_orc(vector unsigned long long __a, vector bool long long __b) {
7143 return __a | ~__b;
7144}
7145
7146static __inline__ vector unsigned long long __ATTRS_o_ai
7147vec_orc(vector bool long long __a, vector unsigned long long __b) {
7148 return __a | ~__b;
7149}
7150
7151static __inline__ vector bool long long __ATTRS_o_ai
7152vec_orc(vector bool long long __a, vector bool long long __b) {
7153 return __a | ~__b;
7154}
Logan Chien55afb0a2018-10-15 10:42:14 +08007155
7156static __inline__ vector double __ATTRS_o_ai
7157vec_orc(vector double __a, vector bool long long __b) {
7158 return (vector double)((vector unsigned long long)__a | ~__b);
7159}
7160
7161static __inline__ vector double __ATTRS_o_ai
7162vec_orc(vector bool long long __a, vector double __b) {
7163 return (vector double)(__a | ~(vector unsigned long long)__b);
7164}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08007165
7166static __inline__ vector double __ATTRS_o_ai vec_orc(vector double __a,
7167 vector double __b) {
7168 return (vector double)((vector bool long long)__a |
7169 ~(vector unsigned long long)__b);
7170}
Logan Chien2833ffb2018-10-09 10:03:24 +08007171#endif
7172
7173/* vec_vor */
7174
7175static __inline__ vector signed char __ATTRS_o_ai
7176vec_vor(vector signed char __a, vector signed char __b) {
7177 return __a | __b;
7178}
7179
7180static __inline__ vector signed char __ATTRS_o_ai
7181vec_vor(vector bool char __a, vector signed char __b) {
7182 return (vector signed char)__a | __b;
7183}
7184
7185static __inline__ vector signed char __ATTRS_o_ai
7186vec_vor(vector signed char __a, vector bool char __b) {
7187 return __a | (vector signed char)__b;
7188}
7189
7190static __inline__ vector unsigned char __ATTRS_o_ai
7191vec_vor(vector unsigned char __a, vector unsigned char __b) {
7192 return __a | __b;
7193}
7194
7195static __inline__ vector unsigned char __ATTRS_o_ai
7196vec_vor(vector bool char __a, vector unsigned char __b) {
7197 return (vector unsigned char)__a | __b;
7198}
7199
7200static __inline__ vector unsigned char __ATTRS_o_ai
7201vec_vor(vector unsigned char __a, vector bool char __b) {
7202 return __a | (vector unsigned char)__b;
7203}
7204
7205static __inline__ vector bool char __ATTRS_o_ai vec_vor(vector bool char __a,
7206 vector bool char __b) {
7207 return __a | __b;
7208}
7209
7210static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a,
7211 vector short __b) {
7212 return __a | __b;
7213}
7214
7215static __inline__ vector short __ATTRS_o_ai vec_vor(vector bool short __a,
7216 vector short __b) {
7217 return (vector short)__a | __b;
7218}
7219
7220static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a,
7221 vector bool short __b) {
7222 return __a | (vector short)__b;
7223}
7224
7225static __inline__ vector unsigned short __ATTRS_o_ai
7226vec_vor(vector unsigned short __a, vector unsigned short __b) {
7227 return __a | __b;
7228}
7229
7230static __inline__ vector unsigned short __ATTRS_o_ai
7231vec_vor(vector bool short __a, vector unsigned short __b) {
7232 return (vector unsigned short)__a | __b;
7233}
7234
7235static __inline__ vector unsigned short __ATTRS_o_ai
7236vec_vor(vector unsigned short __a, vector bool short __b) {
7237 return __a | (vector unsigned short)__b;
7238}
7239
7240static __inline__ vector bool short __ATTRS_o_ai
7241vec_vor(vector bool short __a, vector bool short __b) {
7242 return __a | __b;
7243}
7244
7245static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a,
7246 vector int __b) {
7247 return __a | __b;
7248}
7249
7250static __inline__ vector int __ATTRS_o_ai vec_vor(vector bool int __a,
7251 vector int __b) {
7252 return (vector int)__a | __b;
7253}
7254
7255static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a,
7256 vector bool int __b) {
7257 return __a | (vector int)__b;
7258}
7259
7260static __inline__ vector unsigned int __ATTRS_o_ai
7261vec_vor(vector unsigned int __a, vector unsigned int __b) {
7262 return __a | __b;
7263}
7264
7265static __inline__ vector unsigned int __ATTRS_o_ai
7266vec_vor(vector bool int __a, vector unsigned int __b) {
7267 return (vector unsigned int)__a | __b;
7268}
7269
7270static __inline__ vector unsigned int __ATTRS_o_ai
7271vec_vor(vector unsigned int __a, vector bool int __b) {
7272 return __a | (vector unsigned int)__b;
7273}
7274
7275static __inline__ vector bool int __ATTRS_o_ai vec_vor(vector bool int __a,
7276 vector bool int __b) {
7277 return __a | __b;
7278}
7279
7280static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a,
7281 vector float __b) {
7282 vector unsigned int __res =
7283 (vector unsigned int)__a | (vector unsigned int)__b;
7284 return (vector float)__res;
7285}
7286
7287static __inline__ vector float __ATTRS_o_ai vec_vor(vector bool int __a,
7288 vector float __b) {
7289 vector unsigned int __res =
7290 (vector unsigned int)__a | (vector unsigned int)__b;
7291 return (vector float)__res;
7292}
7293
7294static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a,
7295 vector bool int __b) {
7296 vector unsigned int __res =
7297 (vector unsigned int)__a | (vector unsigned int)__b;
7298 return (vector float)__res;
7299}
7300
7301#ifdef __VSX__
7302static __inline__ vector signed long long __ATTRS_o_ai
7303vec_vor(vector signed long long __a, vector signed long long __b) {
7304 return __a | __b;
7305}
7306
7307static __inline__ vector signed long long __ATTRS_o_ai
7308vec_vor(vector bool long long __a, vector signed long long __b) {
7309 return (vector signed long long)__a | __b;
7310}
7311
7312static __inline__ vector signed long long __ATTRS_o_ai
7313vec_vor(vector signed long long __a, vector bool long long __b) {
7314 return __a | (vector signed long long)__b;
7315}
7316
7317static __inline__ vector unsigned long long __ATTRS_o_ai
7318vec_vor(vector unsigned long long __a, vector unsigned long long __b) {
7319 return __a | __b;
7320}
7321
7322static __inline__ vector unsigned long long __ATTRS_o_ai
7323vec_vor(vector bool long long __a, vector unsigned long long __b) {
7324 return (vector unsigned long long)__a | __b;
7325}
7326
7327static __inline__ vector unsigned long long __ATTRS_o_ai
7328vec_vor(vector unsigned long long __a, vector bool long long __b) {
7329 return __a | (vector unsigned long long)__b;
7330}
7331
7332static __inline__ vector bool long long __ATTRS_o_ai
7333vec_vor(vector bool long long __a, vector bool long long __b) {
7334 return __a | __b;
7335}
7336#endif
7337
7338/* vec_pack */
7339
7340/* The various vector pack instructions have a big-endian bias, so for
7341 little endian we must handle reversed element numbering. */
7342
7343static __inline__ vector signed char __ATTRS_o_ai
7344vec_pack(vector signed short __a, vector signed short __b) {
7345#ifdef __LITTLE_ENDIAN__
7346 return (vector signed char)vec_perm(
7347 __a, __b,
7348 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7349 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7350#else
7351 return (vector signed char)vec_perm(
7352 __a, __b,
7353 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7354 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7355#endif
7356}
7357
7358static __inline__ vector unsigned char __ATTRS_o_ai
7359vec_pack(vector unsigned short __a, vector unsigned short __b) {
7360#ifdef __LITTLE_ENDIAN__
7361 return (vector unsigned char)vec_perm(
7362 __a, __b,
7363 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7364 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7365#else
7366 return (vector unsigned char)vec_perm(
7367 __a, __b,
7368 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7369 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7370#endif
7371}
7372
7373static __inline__ vector bool char __ATTRS_o_ai
7374vec_pack(vector bool short __a, vector bool short __b) {
7375#ifdef __LITTLE_ENDIAN__
7376 return (vector bool char)vec_perm(
7377 __a, __b,
7378 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7379 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7380#else
7381 return (vector bool char)vec_perm(
7382 __a, __b,
7383 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7384 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7385#endif
7386}
7387
7388static __inline__ vector short __ATTRS_o_ai vec_pack(vector int __a,
7389 vector int __b) {
7390#ifdef __LITTLE_ENDIAN__
7391 return (vector short)vec_perm(
7392 __a, __b,
7393 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7394 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7395#else
7396 return (vector short)vec_perm(
7397 __a, __b,
7398 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7399 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7400#endif
7401}
7402
7403static __inline__ vector unsigned short __ATTRS_o_ai
7404vec_pack(vector unsigned int __a, vector unsigned int __b) {
7405#ifdef __LITTLE_ENDIAN__
7406 return (vector unsigned short)vec_perm(
7407 __a, __b,
7408 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7409 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7410#else
7411 return (vector unsigned short)vec_perm(
7412 __a, __b,
7413 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7414 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7415#endif
7416}
7417
7418static __inline__ vector bool short __ATTRS_o_ai vec_pack(vector bool int __a,
7419 vector bool int __b) {
7420#ifdef __LITTLE_ENDIAN__
7421 return (vector bool short)vec_perm(
7422 __a, __b,
7423 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7424 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7425#else
7426 return (vector bool short)vec_perm(
7427 __a, __b,
7428 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7429 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7430#endif
7431}
7432
7433#ifdef __VSX__
7434static __inline__ vector signed int __ATTRS_o_ai
7435vec_pack(vector signed long long __a, vector signed long long __b) {
7436#ifdef __LITTLE_ENDIAN__
7437 return (vector signed int)vec_perm(
7438 __a, __b,
7439 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7440 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7441#else
7442 return (vector signed int)vec_perm(
7443 __a, __b,
7444 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7445 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7446#endif
7447}
7448static __inline__ vector unsigned int __ATTRS_o_ai
7449vec_pack(vector unsigned long long __a, vector unsigned long long __b) {
7450#ifdef __LITTLE_ENDIAN__
7451 return (vector unsigned int)vec_perm(
7452 __a, __b,
7453 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7454 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7455#else
7456 return (vector unsigned int)vec_perm(
7457 __a, __b,
7458 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7459 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7460#endif
7461}
7462
7463static __inline__ vector bool int __ATTRS_o_ai
7464vec_pack(vector bool long long __a, vector bool long long __b) {
7465#ifdef __LITTLE_ENDIAN__
7466 return (vector bool int)vec_perm(
7467 __a, __b,
7468 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7469 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7470#else
7471 return (vector bool int)vec_perm(
7472 __a, __b,
7473 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7474 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7475#endif
7476}
7477
Logan Chien55afb0a2018-10-15 10:42:14 +08007478static __inline__ vector float __ATTRS_o_ai
7479vec_pack(vector double __a, vector double __b) {
7480 return (vector float) (__a[0], __a[1], __b[0], __b[1]);
7481}
Logan Chien2833ffb2018-10-09 10:03:24 +08007482#endif
7483
Logan Chien55afb0a2018-10-15 10:42:14 +08007484#ifdef __POWER9_VECTOR__
7485static __inline__ vector unsigned short __ATTRS_o_ai
7486vec_pack_to_short_fp32(vector float __a, vector float __b) {
7487 vector float __resa = __builtin_vsx_xvcvsphp(__a);
7488 vector float __resb = __builtin_vsx_xvcvsphp(__b);
7489#ifdef __LITTLE_ENDIAN__
7490 return (vector unsigned short)vec_mergee(__resa, __resb);
7491#else
7492 return (vector unsigned short)vec_mergeo(__resa, __resb);
7493#endif
7494}
7495
7496#endif
Logan Chien2833ffb2018-10-09 10:03:24 +08007497/* vec_vpkuhum */
7498
7499#define __builtin_altivec_vpkuhum vec_vpkuhum
7500
7501static __inline__ vector signed char __ATTRS_o_ai
7502vec_vpkuhum(vector signed short __a, vector signed short __b) {
7503#ifdef __LITTLE_ENDIAN__
7504 return (vector signed char)vec_perm(
7505 __a, __b,
7506 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7507 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7508#else
7509 return (vector signed char)vec_perm(
7510 __a, __b,
7511 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7512 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7513#endif
7514}
7515
7516static __inline__ vector unsigned char __ATTRS_o_ai
7517vec_vpkuhum(vector unsigned short __a, vector unsigned short __b) {
7518#ifdef __LITTLE_ENDIAN__
7519 return (vector unsigned char)vec_perm(
7520 __a, __b,
7521 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7522 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7523#else
7524 return (vector unsigned char)vec_perm(
7525 __a, __b,
7526 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7527 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7528#endif
7529}
7530
7531static __inline__ vector bool char __ATTRS_o_ai
7532vec_vpkuhum(vector bool short __a, vector bool short __b) {
7533#ifdef __LITTLE_ENDIAN__
7534 return (vector bool char)vec_perm(
7535 __a, __b,
7536 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
7537 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
7538#else
7539 return (vector bool char)vec_perm(
7540 __a, __b,
7541 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
7542 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
7543#endif
7544}
7545
7546/* vec_vpkuwum */
7547
7548#define __builtin_altivec_vpkuwum vec_vpkuwum
7549
7550static __inline__ vector short __ATTRS_o_ai vec_vpkuwum(vector int __a,
7551 vector int __b) {
7552#ifdef __LITTLE_ENDIAN__
7553 return (vector short)vec_perm(
7554 __a, __b,
7555 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7556 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7557#else
7558 return (vector short)vec_perm(
7559 __a, __b,
7560 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7561 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7562#endif
7563}
7564
7565static __inline__ vector unsigned short __ATTRS_o_ai
7566vec_vpkuwum(vector unsigned int __a, vector unsigned int __b) {
7567#ifdef __LITTLE_ENDIAN__
7568 return (vector unsigned short)vec_perm(
7569 __a, __b,
7570 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7571 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7572#else
7573 return (vector unsigned short)vec_perm(
7574 __a, __b,
7575 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7576 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7577#endif
7578}
7579
7580static __inline__ vector bool short __ATTRS_o_ai
7581vec_vpkuwum(vector bool int __a, vector bool int __b) {
7582#ifdef __LITTLE_ENDIAN__
7583 return (vector bool short)vec_perm(
7584 __a, __b,
7585 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
7586 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
7587#else
7588 return (vector bool short)vec_perm(
7589 __a, __b,
7590 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
7591 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
7592#endif
7593}
7594
7595/* vec_vpkudum */
7596
7597#ifdef __POWER8_VECTOR__
7598#define __builtin_altivec_vpkudum vec_vpkudum
7599
7600static __inline__ vector int __ATTRS_o_ai vec_vpkudum(vector long long __a,
7601 vector long long __b) {
7602#ifdef __LITTLE_ENDIAN__
7603 return (vector int)vec_perm(
7604 __a, __b,
7605 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7606 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7607#else
7608 return (vector int)vec_perm(
7609 __a, __b,
7610 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7611 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7612#endif
7613}
7614
7615static __inline__ vector unsigned int __ATTRS_o_ai
7616vec_vpkudum(vector unsigned long long __a, vector unsigned long long __b) {
7617#ifdef __LITTLE_ENDIAN__
7618 return (vector unsigned int)vec_perm(
7619 __a, __b,
7620 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7621 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7622#else
7623 return (vector unsigned int)vec_perm(
7624 __a, __b,
7625 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7626 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7627#endif
7628}
7629
7630static __inline__ vector bool int __ATTRS_o_ai
7631vec_vpkudum(vector bool long long __a, vector bool long long __b) {
7632#ifdef __LITTLE_ENDIAN__
7633 return (vector bool int)vec_perm(
7634 (vector long long)__a, (vector long long)__b,
7635 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
7636 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
7637#else
7638 return (vector bool int)vec_perm(
7639 (vector long long)__a, (vector long long)__b,
7640 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
7641 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
7642#endif
7643}
7644#endif
7645
7646/* vec_packpx */
7647
7648static __inline__ vector pixel __attribute__((__always_inline__))
7649vec_packpx(vector unsigned int __a, vector unsigned int __b) {
7650#ifdef __LITTLE_ENDIAN__
7651 return (vector pixel)__builtin_altivec_vpkpx(__b, __a);
7652#else
7653 return (vector pixel)__builtin_altivec_vpkpx(__a, __b);
7654#endif
7655}
7656
7657/* vec_vpkpx */
7658
7659static __inline__ vector pixel __attribute__((__always_inline__))
7660vec_vpkpx(vector unsigned int __a, vector unsigned int __b) {
7661#ifdef __LITTLE_ENDIAN__
7662 return (vector pixel)__builtin_altivec_vpkpx(__b, __a);
7663#else
7664 return (vector pixel)__builtin_altivec_vpkpx(__a, __b);
7665#endif
7666}
7667
7668/* vec_packs */
7669
7670static __inline__ vector signed char __ATTRS_o_ai vec_packs(vector short __a,
7671 vector short __b) {
7672#ifdef __LITTLE_ENDIAN__
7673 return __builtin_altivec_vpkshss(__b, __a);
7674#else
7675 return __builtin_altivec_vpkshss(__a, __b);
7676#endif
7677}
7678
7679static __inline__ vector unsigned char __ATTRS_o_ai
7680vec_packs(vector unsigned short __a, vector unsigned short __b) {
7681#ifdef __LITTLE_ENDIAN__
7682 return __builtin_altivec_vpkuhus(__b, __a);
7683#else
7684 return __builtin_altivec_vpkuhus(__a, __b);
7685#endif
7686}
7687
7688static __inline__ vector signed short __ATTRS_o_ai vec_packs(vector int __a,
7689 vector int __b) {
7690#ifdef __LITTLE_ENDIAN__
7691 return __builtin_altivec_vpkswss(__b, __a);
7692#else
7693 return __builtin_altivec_vpkswss(__a, __b);
7694#endif
7695}
7696
7697static __inline__ vector unsigned short __ATTRS_o_ai
7698vec_packs(vector unsigned int __a, vector unsigned int __b) {
7699#ifdef __LITTLE_ENDIAN__
7700 return __builtin_altivec_vpkuwus(__b, __a);
7701#else
7702 return __builtin_altivec_vpkuwus(__a, __b);
7703#endif
7704}
7705
7706#ifdef __POWER8_VECTOR__
7707static __inline__ vector int __ATTRS_o_ai vec_packs(vector long long __a,
7708 vector long long __b) {
7709#ifdef __LITTLE_ENDIAN__
7710 return __builtin_altivec_vpksdss(__b, __a);
7711#else
7712 return __builtin_altivec_vpksdss(__a, __b);
7713#endif
7714}
7715
7716static __inline__ vector unsigned int __ATTRS_o_ai
7717vec_packs(vector unsigned long long __a, vector unsigned long long __b) {
7718#ifdef __LITTLE_ENDIAN__
7719 return __builtin_altivec_vpkudus(__b, __a);
7720#else
7721 return __builtin_altivec_vpkudus(__a, __b);
7722#endif
7723}
7724#endif
7725
7726/* vec_vpkshss */
7727
7728static __inline__ vector signed char __attribute__((__always_inline__))
7729vec_vpkshss(vector short __a, vector short __b) {
7730#ifdef __LITTLE_ENDIAN__
7731 return __builtin_altivec_vpkshss(__b, __a);
7732#else
7733 return __builtin_altivec_vpkshss(__a, __b);
7734#endif
7735}
7736
7737/* vec_vpksdss */
7738
7739#ifdef __POWER8_VECTOR__
7740static __inline__ vector int __ATTRS_o_ai vec_vpksdss(vector long long __a,
7741 vector long long __b) {
7742#ifdef __LITTLE_ENDIAN__
7743 return __builtin_altivec_vpksdss(__b, __a);
7744#else
7745 return __builtin_altivec_vpksdss(__a, __b);
7746#endif
7747}
7748#endif
7749
7750/* vec_vpkuhus */
7751
7752static __inline__ vector unsigned char __attribute__((__always_inline__))
7753vec_vpkuhus(vector unsigned short __a, vector unsigned short __b) {
7754#ifdef __LITTLE_ENDIAN__
7755 return __builtin_altivec_vpkuhus(__b, __a);
7756#else
7757 return __builtin_altivec_vpkuhus(__a, __b);
7758#endif
7759}
7760
7761/* vec_vpkudus */
7762
7763#ifdef __POWER8_VECTOR__
7764static __inline__ vector unsigned int __attribute__((__always_inline__))
7765vec_vpkudus(vector unsigned long long __a, vector unsigned long long __b) {
7766#ifdef __LITTLE_ENDIAN__
7767 return __builtin_altivec_vpkudus(__b, __a);
7768#else
7769 return __builtin_altivec_vpkudus(__a, __b);
7770#endif
7771}
7772#endif
7773
7774/* vec_vpkswss */
7775
7776static __inline__ vector signed short __attribute__((__always_inline__))
7777vec_vpkswss(vector int __a, vector int __b) {
7778#ifdef __LITTLE_ENDIAN__
7779 return __builtin_altivec_vpkswss(__b, __a);
7780#else
7781 return __builtin_altivec_vpkswss(__a, __b);
7782#endif
7783}
7784
7785/* vec_vpkuwus */
7786
7787static __inline__ vector unsigned short __attribute__((__always_inline__))
7788vec_vpkuwus(vector unsigned int __a, vector unsigned int __b) {
7789#ifdef __LITTLE_ENDIAN__
7790 return __builtin_altivec_vpkuwus(__b, __a);
7791#else
7792 return __builtin_altivec_vpkuwus(__a, __b);
7793#endif
7794}
7795
7796/* vec_packsu */
7797
7798static __inline__ vector unsigned char __ATTRS_o_ai
7799vec_packsu(vector short __a, vector short __b) {
7800#ifdef __LITTLE_ENDIAN__
7801 return __builtin_altivec_vpkshus(__b, __a);
7802#else
7803 return __builtin_altivec_vpkshus(__a, __b);
7804#endif
7805}
7806
7807static __inline__ vector unsigned char __ATTRS_o_ai
7808vec_packsu(vector unsigned short __a, vector unsigned short __b) {
7809#ifdef __LITTLE_ENDIAN__
7810 return __builtin_altivec_vpkuhus(__b, __a);
7811#else
7812 return __builtin_altivec_vpkuhus(__a, __b);
7813#endif
7814}
7815
7816static __inline__ vector unsigned short __ATTRS_o_ai
7817vec_packsu(vector int __a, vector int __b) {
7818#ifdef __LITTLE_ENDIAN__
7819 return __builtin_altivec_vpkswus(__b, __a);
7820#else
7821 return __builtin_altivec_vpkswus(__a, __b);
7822#endif
7823}
7824
7825static __inline__ vector unsigned short __ATTRS_o_ai
7826vec_packsu(vector unsigned int __a, vector unsigned int __b) {
7827#ifdef __LITTLE_ENDIAN__
7828 return __builtin_altivec_vpkuwus(__b, __a);
7829#else
7830 return __builtin_altivec_vpkuwus(__a, __b);
7831#endif
7832}
7833
7834#ifdef __POWER8_VECTOR__
7835static __inline__ vector unsigned int __ATTRS_o_ai
7836vec_packsu(vector long long __a, vector long long __b) {
7837#ifdef __LITTLE_ENDIAN__
7838 return __builtin_altivec_vpksdus(__b, __a);
7839#else
7840 return __builtin_altivec_vpksdus(__a, __b);
7841#endif
7842}
7843
7844static __inline__ vector unsigned int __ATTRS_o_ai
7845vec_packsu(vector unsigned long long __a, vector unsigned long long __b) {
7846#ifdef __LITTLE_ENDIAN__
7847 return __builtin_altivec_vpkudus(__b, __a);
7848#else
7849 return __builtin_altivec_vpkudus(__a, __b);
7850#endif
7851}
7852#endif
7853
7854/* vec_vpkshus */
7855
7856static __inline__ vector unsigned char __ATTRS_o_ai
7857vec_vpkshus(vector short __a, vector short __b) {
7858#ifdef __LITTLE_ENDIAN__
7859 return __builtin_altivec_vpkshus(__b, __a);
7860#else
7861 return __builtin_altivec_vpkshus(__a, __b);
7862#endif
7863}
7864
7865static __inline__ vector unsigned char __ATTRS_o_ai
7866vec_vpkshus(vector unsigned short __a, vector unsigned short __b) {
7867#ifdef __LITTLE_ENDIAN__
7868 return __builtin_altivec_vpkuhus(__b, __a);
7869#else
7870 return __builtin_altivec_vpkuhus(__a, __b);
7871#endif
7872}
7873
7874/* vec_vpkswus */
7875
7876static __inline__ vector unsigned short __ATTRS_o_ai
7877vec_vpkswus(vector int __a, vector int __b) {
7878#ifdef __LITTLE_ENDIAN__
7879 return __builtin_altivec_vpkswus(__b, __a);
7880#else
7881 return __builtin_altivec_vpkswus(__a, __b);
7882#endif
7883}
7884
7885static __inline__ vector unsigned short __ATTRS_o_ai
7886vec_vpkswus(vector unsigned int __a, vector unsigned int __b) {
7887#ifdef __LITTLE_ENDIAN__
7888 return __builtin_altivec_vpkuwus(__b, __a);
7889#else
7890 return __builtin_altivec_vpkuwus(__a, __b);
7891#endif
7892}
7893
7894/* vec_vpksdus */
7895
7896#ifdef __POWER8_VECTOR__
7897static __inline__ vector unsigned int __ATTRS_o_ai
7898vec_vpksdus(vector long long __a, vector long long __b) {
7899#ifdef __LITTLE_ENDIAN__
7900 return __builtin_altivec_vpksdus(__b, __a);
7901#else
7902 return __builtin_altivec_vpksdus(__a, __b);
7903#endif
7904}
7905#endif
7906
7907/* vec_perm */
7908
7909// The vperm instruction is defined architecturally with a big-endian bias.
7910// For little endian, we swap the input operands and invert the permute
7911// control vector. Only the rightmost 5 bits matter, so we could use
7912// a vector of all 31s instead of all 255s to perform the inversion.
7913// However, when the PCV is not a constant, using 255 has an advantage
7914// in that the vec_xor can be recognized as a vec_nor (and for P8 and
7915// later, possibly a vec_nand).
7916
7917static __inline__ vector signed char __ATTRS_o_ai vec_perm(
7918 vector signed char __a, vector signed char __b, vector unsigned char __c) {
7919#ifdef __LITTLE_ENDIAN__
7920 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7921 255, 255, 255, 255, 255, 255, 255, 255};
7922 __d = vec_xor(__c, __d);
7923 return (vector signed char)__builtin_altivec_vperm_4si((vector int)__b,
7924 (vector int)__a, __d);
7925#else
7926 return (vector signed char)__builtin_altivec_vperm_4si((vector int)__a,
7927 (vector int)__b, __c);
7928#endif
7929}
7930
7931static __inline__ vector unsigned char __ATTRS_o_ai
7932vec_perm(vector unsigned char __a, vector unsigned char __b,
7933 vector unsigned char __c) {
7934#ifdef __LITTLE_ENDIAN__
7935 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7936 255, 255, 255, 255, 255, 255, 255, 255};
7937 __d = vec_xor(__c, __d);
7938 return (vector unsigned char)__builtin_altivec_vperm_4si(
7939 (vector int)__b, (vector int)__a, __d);
7940#else
7941 return (vector unsigned char)__builtin_altivec_vperm_4si(
7942 (vector int)__a, (vector int)__b, __c);
7943#endif
7944}
7945
7946static __inline__ vector bool char __ATTRS_o_ai
7947vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c) {
7948#ifdef __LITTLE_ENDIAN__
7949 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7950 255, 255, 255, 255, 255, 255, 255, 255};
7951 __d = vec_xor(__c, __d);
7952 return (vector bool char)__builtin_altivec_vperm_4si((vector int)__b,
7953 (vector int)__a, __d);
7954#else
7955 return (vector bool char)__builtin_altivec_vperm_4si((vector int)__a,
7956 (vector int)__b, __c);
7957#endif
7958}
7959
7960static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a,
7961 vector signed short __b,
7962 vector unsigned char __c) {
7963#ifdef __LITTLE_ENDIAN__
7964 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7965 255, 255, 255, 255, 255, 255, 255, 255};
7966 __d = vec_xor(__c, __d);
7967 return (vector signed short)__builtin_altivec_vperm_4si((vector int)__b,
7968 (vector int)__a, __d);
7969#else
7970 return (vector signed short)__builtin_altivec_vperm_4si((vector int)__a,
7971 (vector int)__b, __c);
7972#endif
7973}
7974
7975static __inline__ vector unsigned short __ATTRS_o_ai
7976vec_perm(vector unsigned short __a, vector unsigned short __b,
7977 vector unsigned char __c) {
7978#ifdef __LITTLE_ENDIAN__
7979 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7980 255, 255, 255, 255, 255, 255, 255, 255};
7981 __d = vec_xor(__c, __d);
7982 return (vector unsigned short)__builtin_altivec_vperm_4si(
7983 (vector int)__b, (vector int)__a, __d);
7984#else
7985 return (vector unsigned short)__builtin_altivec_vperm_4si(
7986 (vector int)__a, (vector int)__b, __c);
7987#endif
7988}
7989
7990static __inline__ vector bool short __ATTRS_o_ai vec_perm(
7991 vector bool short __a, vector bool short __b, vector unsigned char __c) {
7992#ifdef __LITTLE_ENDIAN__
7993 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
7994 255, 255, 255, 255, 255, 255, 255, 255};
7995 __d = vec_xor(__c, __d);
7996 return (vector bool short)__builtin_altivec_vperm_4si((vector int)__b,
7997 (vector int)__a, __d);
7998#else
7999 return (vector bool short)__builtin_altivec_vperm_4si((vector int)__a,
8000 (vector int)__b, __c);
8001#endif
8002}
8003
8004static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a,
8005 vector pixel __b,
8006 vector unsigned char __c) {
8007#ifdef __LITTLE_ENDIAN__
8008 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8009 255, 255, 255, 255, 255, 255, 255, 255};
8010 __d = vec_xor(__c, __d);
8011 return (vector pixel)__builtin_altivec_vperm_4si((vector int)__b,
8012 (vector int)__a, __d);
8013#else
8014 return (vector pixel)__builtin_altivec_vperm_4si((vector int)__a,
8015 (vector int)__b, __c);
8016#endif
8017}
8018
8019static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a,
8020 vector signed int __b,
8021 vector unsigned char __c) {
8022#ifdef __LITTLE_ENDIAN__
8023 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8024 255, 255, 255, 255, 255, 255, 255, 255};
8025 __d = vec_xor(__c, __d);
8026 return (vector signed int)__builtin_altivec_vperm_4si(__b, __a, __d);
8027#else
8028 return (vector signed int)__builtin_altivec_vperm_4si(__a, __b, __c);
8029#endif
8030}
8031
8032static __inline__ vector unsigned int __ATTRS_o_ai
8033vec_perm(vector unsigned int __a, vector unsigned int __b,
8034 vector unsigned char __c) {
8035#ifdef __LITTLE_ENDIAN__
8036 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8037 255, 255, 255, 255, 255, 255, 255, 255};
8038 __d = vec_xor(__c, __d);
8039 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__b,
8040 (vector int)__a, __d);
8041#else
8042 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__a,
8043 (vector int)__b, __c);
8044#endif
8045}
8046
8047static __inline__ vector bool int __ATTRS_o_ai
8048vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c) {
8049#ifdef __LITTLE_ENDIAN__
8050 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8051 255, 255, 255, 255, 255, 255, 255, 255};
8052 __d = vec_xor(__c, __d);
8053 return (vector bool int)__builtin_altivec_vperm_4si((vector int)__b,
8054 (vector int)__a, __d);
8055#else
8056 return (vector bool int)__builtin_altivec_vperm_4si((vector int)__a,
8057 (vector int)__b, __c);
8058#endif
8059}
8060
8061static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a,
8062 vector float __b,
8063 vector unsigned char __c) {
8064#ifdef __LITTLE_ENDIAN__
8065 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8066 255, 255, 255, 255, 255, 255, 255, 255};
8067 __d = vec_xor(__c, __d);
8068 return (vector float)__builtin_altivec_vperm_4si((vector int)__b,
8069 (vector int)__a, __d);
8070#else
8071 return (vector float)__builtin_altivec_vperm_4si((vector int)__a,
8072 (vector int)__b, __c);
8073#endif
8074}
8075
8076#ifdef __VSX__
8077static __inline__ vector long long __ATTRS_o_ai
8078vec_perm(vector signed long long __a, vector signed long long __b,
8079 vector unsigned char __c) {
8080#ifdef __LITTLE_ENDIAN__
8081 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8082 255, 255, 255, 255, 255, 255, 255, 255};
8083 __d = vec_xor(__c, __d);
8084 return (vector signed long long)__builtin_altivec_vperm_4si(
8085 (vector int)__b, (vector int)__a, __d);
8086#else
8087 return (vector signed long long)__builtin_altivec_vperm_4si(
8088 (vector int)__a, (vector int)__b, __c);
8089#endif
8090}
8091
8092static __inline__ vector unsigned long long __ATTRS_o_ai
8093vec_perm(vector unsigned long long __a, vector unsigned long long __b,
8094 vector unsigned char __c) {
8095#ifdef __LITTLE_ENDIAN__
8096 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8097 255, 255, 255, 255, 255, 255, 255, 255};
8098 __d = vec_xor(__c, __d);
8099 return (vector unsigned long long)__builtin_altivec_vperm_4si(
8100 (vector int)__b, (vector int)__a, __d);
8101#else
8102 return (vector unsigned long long)__builtin_altivec_vperm_4si(
8103 (vector int)__a, (vector int)__b, __c);
8104#endif
8105}
8106
8107static __inline__ vector bool long long __ATTRS_o_ai
8108vec_perm(vector bool long long __a, vector bool long long __b,
8109 vector unsigned char __c) {
8110#ifdef __LITTLE_ENDIAN__
8111 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8112 255, 255, 255, 255, 255, 255, 255, 255};
8113 __d = vec_xor(__c, __d);
8114 return (vector bool long long)__builtin_altivec_vperm_4si(
8115 (vector int)__b, (vector int)__a, __d);
8116#else
8117 return (vector bool long long)__builtin_altivec_vperm_4si(
8118 (vector int)__a, (vector int)__b, __c);
8119#endif
8120}
8121
8122static __inline__ vector double __ATTRS_o_ai
8123vec_perm(vector double __a, vector double __b, vector unsigned char __c) {
8124#ifdef __LITTLE_ENDIAN__
8125 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
8126 255, 255, 255, 255, 255, 255, 255, 255};
8127 __d = vec_xor(__c, __d);
8128 return (vector double)__builtin_altivec_vperm_4si((vector int)__b,
8129 (vector int)__a, __d);
8130#else
8131 return (vector double)__builtin_altivec_vperm_4si((vector int)__a,
8132 (vector int)__b, __c);
8133#endif
8134}
8135#endif
8136
8137/* vec_vperm */
8138
8139static __inline__ vector signed char __ATTRS_o_ai vec_vperm(
8140 vector signed char __a, vector signed char __b, vector unsigned char __c) {
8141 return vec_perm(__a, __b, __c);
8142}
8143
8144static __inline__ vector unsigned char __ATTRS_o_ai
8145vec_vperm(vector unsigned char __a, vector unsigned char __b,
8146 vector unsigned char __c) {
8147 return vec_perm(__a, __b, __c);
8148}
8149
8150static __inline__ vector bool char __ATTRS_o_ai vec_vperm(
8151 vector bool char __a, vector bool char __b, vector unsigned char __c) {
8152 return vec_perm(__a, __b, __c);
8153}
8154
8155static __inline__ vector short __ATTRS_o_ai
8156vec_vperm(vector short __a, vector short __b, vector unsigned char __c) {
8157 return vec_perm(__a, __b, __c);
8158}
8159
8160static __inline__ vector unsigned short __ATTRS_o_ai
8161vec_vperm(vector unsigned short __a, vector unsigned short __b,
8162 vector unsigned char __c) {
8163 return vec_perm(__a, __b, __c);
8164}
8165
8166static __inline__ vector bool short __ATTRS_o_ai vec_vperm(
8167 vector bool short __a, vector bool short __b, vector unsigned char __c) {
8168 return vec_perm(__a, __b, __c);
8169}
8170
8171static __inline__ vector pixel __ATTRS_o_ai
8172vec_vperm(vector pixel __a, vector pixel __b, vector unsigned char __c) {
8173 return vec_perm(__a, __b, __c);
8174}
8175
8176static __inline__ vector int __ATTRS_o_ai vec_vperm(vector int __a,
8177 vector int __b,
8178 vector unsigned char __c) {
8179 return vec_perm(__a, __b, __c);
8180}
8181
8182static __inline__ vector unsigned int __ATTRS_o_ai
8183vec_vperm(vector unsigned int __a, vector unsigned int __b,
8184 vector unsigned char __c) {
8185 return vec_perm(__a, __b, __c);
8186}
8187
8188static __inline__ vector bool int __ATTRS_o_ai
8189vec_vperm(vector bool int __a, vector bool int __b, vector unsigned char __c) {
8190 return vec_perm(__a, __b, __c);
8191}
8192
8193static __inline__ vector float __ATTRS_o_ai
8194vec_vperm(vector float __a, vector float __b, vector unsigned char __c) {
8195 return vec_perm(__a, __b, __c);
8196}
8197
8198#ifdef __VSX__
8199static __inline__ vector long long __ATTRS_o_ai vec_vperm(
8200 vector long long __a, vector long long __b, vector unsigned char __c) {
8201 return vec_perm(__a, __b, __c);
8202}
8203
8204static __inline__ vector unsigned long long __ATTRS_o_ai
8205vec_vperm(vector unsigned long long __a, vector unsigned long long __b,
8206 vector unsigned char __c) {
8207 return vec_perm(__a, __b, __c);
8208}
8209
8210static __inline__ vector double __ATTRS_o_ai
8211vec_vperm(vector double __a, vector double __b, vector unsigned char __c) {
8212 return vec_perm(__a, __b, __c);
8213}
8214#endif
8215
8216/* vec_re */
8217
8218static __inline__ vector float __ATTRS_o_ai vec_re(vector float __a) {
8219#ifdef __VSX__
8220 return __builtin_vsx_xvresp(__a);
8221#else
8222 return __builtin_altivec_vrefp(__a);
8223#endif
8224}
8225
8226#ifdef __VSX__
8227static __inline__ vector double __ATTRS_o_ai vec_re(vector double __a) {
8228 return __builtin_vsx_xvredp(__a);
8229}
8230#endif
8231
8232/* vec_vrefp */
8233
8234static __inline__ vector float __attribute__((__always_inline__))
8235vec_vrefp(vector float __a) {
8236 return __builtin_altivec_vrefp(__a);
8237}
8238
8239/* vec_rl */
8240
8241static __inline__ vector signed char __ATTRS_o_ai
8242vec_rl(vector signed char __a, vector unsigned char __b) {
8243 return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b);
8244}
8245
8246static __inline__ vector unsigned char __ATTRS_o_ai
8247vec_rl(vector unsigned char __a, vector unsigned char __b) {
8248 return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b);
8249}
8250
8251static __inline__ vector short __ATTRS_o_ai vec_rl(vector short __a,
8252 vector unsigned short __b) {
8253 return __builtin_altivec_vrlh(__a, __b);
8254}
8255
8256static __inline__ vector unsigned short __ATTRS_o_ai
8257vec_rl(vector unsigned short __a, vector unsigned short __b) {
8258 return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b);
8259}
8260
8261static __inline__ vector int __ATTRS_o_ai vec_rl(vector int __a,
8262 vector unsigned int __b) {
8263 return __builtin_altivec_vrlw(__a, __b);
8264}
8265
8266static __inline__ vector unsigned int __ATTRS_o_ai
8267vec_rl(vector unsigned int __a, vector unsigned int __b) {
8268 return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b);
8269}
8270
8271#ifdef __POWER8_VECTOR__
8272static __inline__ vector signed long long __ATTRS_o_ai
8273vec_rl(vector signed long long __a, vector unsigned long long __b) {
8274 return __builtin_altivec_vrld(__a, __b);
8275}
8276
8277static __inline__ vector unsigned long long __ATTRS_o_ai
8278vec_rl(vector unsigned long long __a, vector unsigned long long __b) {
8279 return __builtin_altivec_vrld(__a, __b);
8280}
8281#endif
8282
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008283#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008284static __inline__ vector signed __int128 __ATTRS_o_ai
8285vec_rl(vector signed __int128 __a, vector unsigned __int128 __b) {
8286 return (__b << __a)|(__b >> ((__CHAR_BIT__ * sizeof(vector signed __int128)) - __a));
8287}
8288
8289static __inline__ vector unsigned __int128 __ATTRS_o_ai
8290vec_rl(vector unsigned __int128 __a, vector unsigned __int128 __b) {
8291 return (__b << __a)|(__b >> ((__CHAR_BIT__ * sizeof(vector unsigned __int128)) - __a));
8292}
8293#endif
8294
Logan Chien55afb0a2018-10-15 10:42:14 +08008295/* vec_rlmi */
8296#ifdef __POWER9_VECTOR__
8297static __inline__ vector unsigned int __ATTRS_o_ai
8298vec_rlmi(vector unsigned int __a, vector unsigned int __b,
8299 vector unsigned int __c) {
8300 return __builtin_altivec_vrlwmi(__a, __c, __b);
8301}
8302
8303static __inline__ vector unsigned long long __ATTRS_o_ai
8304vec_rlmi(vector unsigned long long __a, vector unsigned long long __b,
8305 vector unsigned long long __c) {
8306 return __builtin_altivec_vrldmi(__a, __c, __b);
8307}
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008308#endif
8309
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008310#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008311static __inline__ vector unsigned __int128 __ATTRS_o_ai
8312vec_rlmi(vector unsigned __int128 __a, vector unsigned __int128 __b,
8313 vector unsigned __int128 __c) {
8314 return __builtin_altivec_vrlqmi(__a, __c, __b);
8315}
8316
8317static __inline__ vector signed __int128 __ATTRS_o_ai
8318vec_rlmi(vector signed __int128 __a, vector signed __int128 __b,
8319 vector signed __int128 __c) {
8320 return __builtin_altivec_vrlqmi(__a, __c, __b);
8321}
8322#endif
Logan Chien55afb0a2018-10-15 10:42:14 +08008323
8324/* vec_rlnm */
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008325#ifdef __POWER9_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +08008326static __inline__ vector unsigned int __ATTRS_o_ai
8327vec_rlnm(vector unsigned int __a, vector unsigned int __b,
8328 vector unsigned int __c) {
8329 vector unsigned int OneByte = { 0x8, 0x8, 0x8, 0x8 };
8330 return __builtin_altivec_vrlwnm(__a, ((__c << OneByte) | __b));
8331}
8332
8333static __inline__ vector unsigned long long __ATTRS_o_ai
8334vec_rlnm(vector unsigned long long __a, vector unsigned long long __b,
8335 vector unsigned long long __c) {
8336 vector unsigned long long OneByte = { 0x8, 0x8 };
8337 return __builtin_altivec_vrldnm(__a, ((__c << OneByte) | __b));
8338}
8339#endif
8340
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008341#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008342static __inline__ vector unsigned __int128 __ATTRS_o_ai
8343vec_rlnm(vector unsigned __int128 __a, vector unsigned __int128 __b,
8344 vector unsigned __int128 __c) {
8345 // Merge __b and __c using an appropriate shuffle.
8346 vector unsigned char TmpB = (vector unsigned char)__b;
8347 vector unsigned char TmpC = (vector unsigned char)__c;
8348 vector unsigned char MaskAndShift =
8349#ifdef __LITTLE_ENDIAN__
8350 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0,
8351 1, -1, -1, -1, -1, -1);
8352#else
8353 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 31, 30, 15, -1,
8354 -1, -1, -1, -1, -1, -1, -1);
8355#endif
8356 return __builtin_altivec_vrlqnm(__a, (vector unsigned __int128) MaskAndShift);
8357}
8358
8359static __inline__ vector signed __int128 __ATTRS_o_ai
8360vec_rlnm(vector signed __int128 __a, vector signed __int128 __b,
8361 vector signed __int128 __c) {
8362 // Merge __b and __c using an appropriate shuffle.
8363 vector unsigned char TmpB = (vector unsigned char)__b;
8364 vector unsigned char TmpC = (vector unsigned char)__c;
8365 vector unsigned char MaskAndShift =
8366#ifdef __LITTLE_ENDIAN__
8367 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0,
8368 1, -1, -1, -1, -1, -1);
8369#else
8370 __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 31, 30, 15, -1,
8371 -1, -1, -1, -1, -1, -1, -1);
8372#endif
8373 return __builtin_altivec_vrlqnm(__a, (vector unsigned __int128) MaskAndShift);
8374}
8375#endif
8376
Logan Chien2833ffb2018-10-09 10:03:24 +08008377/* vec_vrlb */
8378
8379static __inline__ vector signed char __ATTRS_o_ai
8380vec_vrlb(vector signed char __a, vector unsigned char __b) {
8381 return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b);
8382}
8383
8384static __inline__ vector unsigned char __ATTRS_o_ai
8385vec_vrlb(vector unsigned char __a, vector unsigned char __b) {
8386 return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b);
8387}
8388
8389/* vec_vrlh */
8390
8391static __inline__ vector short __ATTRS_o_ai
8392vec_vrlh(vector short __a, vector unsigned short __b) {
8393 return __builtin_altivec_vrlh(__a, __b);
8394}
8395
8396static __inline__ vector unsigned short __ATTRS_o_ai
8397vec_vrlh(vector unsigned short __a, vector unsigned short __b) {
8398 return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b);
8399}
8400
8401/* vec_vrlw */
8402
8403static __inline__ vector int __ATTRS_o_ai vec_vrlw(vector int __a,
8404 vector unsigned int __b) {
8405 return __builtin_altivec_vrlw(__a, __b);
8406}
8407
8408static __inline__ vector unsigned int __ATTRS_o_ai
8409vec_vrlw(vector unsigned int __a, vector unsigned int __b) {
8410 return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b);
8411}
8412
8413/* vec_round */
8414
8415static __inline__ vector float __ATTRS_o_ai vec_round(vector float __a) {
Logan Chien2833ffb2018-10-09 10:03:24 +08008416 return __builtin_altivec_vrfin(__a);
Logan Chien2833ffb2018-10-09 10:03:24 +08008417}
8418
8419#ifdef __VSX__
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08008420#ifdef __XL_COMPAT_ALTIVEC__
8421static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a);
8422static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) {
8423 double __fpscr = __builtin_readflm();
8424 __builtin_setrnd(0);
8425 vector double __rounded = vec_rint(__a);
8426 __builtin_setflm(__fpscr);
8427 return __rounded;
8428}
8429#else
Logan Chien2833ffb2018-10-09 10:03:24 +08008430static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) {
8431 return __builtin_vsx_xvrdpi(__a);
8432}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08008433#endif
Logan Chien2833ffb2018-10-09 10:03:24 +08008434
8435/* vec_rint */
8436
8437static __inline__ vector float __ATTRS_o_ai vec_rint(vector float __a) {
8438 return __builtin_vsx_xvrspic(__a);
8439}
8440
8441static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a) {
8442 return __builtin_vsx_xvrdpic(__a);
8443}
8444
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008445/* vec_roundc */
8446
8447static __inline__ vector float __ATTRS_o_ai vec_roundc(vector float __a) {
8448 return __builtin_vsx_xvrspic(__a);
8449}
8450
8451static __inline__ vector double __ATTRS_o_ai vec_roundc(vector double __a) {
8452 return __builtin_vsx_xvrdpic(__a);
8453}
8454
Logan Chien2833ffb2018-10-09 10:03:24 +08008455/* vec_nearbyint */
8456
8457static __inline__ vector float __ATTRS_o_ai vec_nearbyint(vector float __a) {
8458 return __builtin_vsx_xvrspi(__a);
8459}
8460
8461static __inline__ vector double __ATTRS_o_ai vec_nearbyint(vector double __a) {
8462 return __builtin_vsx_xvrdpi(__a);
8463}
8464#endif
8465
8466/* vec_vrfin */
8467
8468static __inline__ vector float __attribute__((__always_inline__))
8469vec_vrfin(vector float __a) {
8470 return __builtin_altivec_vrfin(__a);
8471}
8472
8473/* vec_sqrt */
8474
8475#ifdef __VSX__
8476static __inline__ vector float __ATTRS_o_ai vec_sqrt(vector float __a) {
8477 return __builtin_vsx_xvsqrtsp(__a);
8478}
8479
8480static __inline__ vector double __ATTRS_o_ai vec_sqrt(vector double __a) {
8481 return __builtin_vsx_xvsqrtdp(__a);
8482}
8483#endif
8484
8485/* vec_rsqrte */
8486
8487static __inline__ vector float __ATTRS_o_ai vec_rsqrte(vector float __a) {
8488#ifdef __VSX__
8489 return __builtin_vsx_xvrsqrtesp(__a);
8490#else
8491 return __builtin_altivec_vrsqrtefp(__a);
8492#endif
8493}
8494
8495#ifdef __VSX__
8496static __inline__ vector double __ATTRS_o_ai vec_rsqrte(vector double __a) {
8497 return __builtin_vsx_xvrsqrtedp(__a);
8498}
8499#endif
8500
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008501static vector float __ATTRS_o_ai vec_rsqrt(vector float __a) {
8502 return __builtin_ppc_rsqrtf(__a);
8503}
8504
8505#ifdef __VSX__
8506static vector double __ATTRS_o_ai vec_rsqrt(vector double __a) {
8507 return __builtin_ppc_rsqrtd(__a);
8508}
8509#endif
8510
Logan Chien2833ffb2018-10-09 10:03:24 +08008511/* vec_vrsqrtefp */
8512
8513static __inline__ __vector float __attribute__((__always_inline__))
8514vec_vrsqrtefp(vector float __a) {
8515 return __builtin_altivec_vrsqrtefp(__a);
8516}
8517
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08008518/* vec_xvtsqrt */
8519
8520#ifdef __VSX__
8521static __inline__ int __ATTRS_o_ai vec_test_swsqrt(vector double __a) {
8522 return __builtin_vsx_xvtsqrtdp(__a);
8523}
8524
8525static __inline__ int __ATTRS_o_ai vec_test_swsqrts(vector float __a) {
8526 return __builtin_vsx_xvtsqrtsp(__a);
8527}
8528#endif
8529
Logan Chien2833ffb2018-10-09 10:03:24 +08008530/* vec_sel */
8531
8532#define __builtin_altivec_vsel_4si vec_sel
8533
8534static __inline__ vector signed char __ATTRS_o_ai vec_sel(
8535 vector signed char __a, vector signed char __b, vector unsigned char __c) {
8536 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8537}
8538
8539static __inline__ vector signed char __ATTRS_o_ai
8540vec_sel(vector signed char __a, vector signed char __b, vector bool char __c) {
8541 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8542}
8543
8544static __inline__ vector unsigned char __ATTRS_o_ai
8545vec_sel(vector unsigned char __a, vector unsigned char __b,
8546 vector unsigned char __c) {
8547 return (__a & ~__c) | (__b & __c);
8548}
8549
8550static __inline__ vector unsigned char __ATTRS_o_ai vec_sel(
8551 vector unsigned char __a, vector unsigned char __b, vector bool char __c) {
8552 return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c);
8553}
8554
8555static __inline__ vector bool char __ATTRS_o_ai
8556vec_sel(vector bool char __a, vector bool char __b, vector unsigned char __c) {
8557 return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c);
8558}
8559
8560static __inline__ vector bool char __ATTRS_o_ai vec_sel(vector bool char __a,
8561 vector bool char __b,
8562 vector bool char __c) {
8563 return (__a & ~__c) | (__b & __c);
8564}
8565
8566static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a,
8567 vector short __b,
8568 vector unsigned short __c) {
8569 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8570}
8571
8572static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a,
8573 vector short __b,
8574 vector bool short __c) {
8575 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8576}
8577
8578static __inline__ vector unsigned short __ATTRS_o_ai
8579vec_sel(vector unsigned short __a, vector unsigned short __b,
8580 vector unsigned short __c) {
8581 return (__a & ~__c) | (__b & __c);
8582}
8583
8584static __inline__ vector unsigned short __ATTRS_o_ai
8585vec_sel(vector unsigned short __a, vector unsigned short __b,
8586 vector bool short __c) {
8587 return (__a & ~(vector unsigned short)__c) |
8588 (__b & (vector unsigned short)__c);
8589}
8590
8591static __inline__ vector bool short __ATTRS_o_ai vec_sel(
8592 vector bool short __a, vector bool short __b, vector unsigned short __c) {
8593 return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c);
8594}
8595
8596static __inline__ vector bool short __ATTRS_o_ai
8597vec_sel(vector bool short __a, vector bool short __b, vector bool short __c) {
8598 return (__a & ~__c) | (__b & __c);
8599}
8600
8601static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a,
8602 vector int __b,
8603 vector unsigned int __c) {
8604 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8605}
8606
8607static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a,
8608 vector int __b,
8609 vector bool int __c) {
8610 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8611}
8612
8613static __inline__ vector unsigned int __ATTRS_o_ai vec_sel(
8614 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
8615 return (__a & ~__c) | (__b & __c);
8616}
8617
8618static __inline__ vector unsigned int __ATTRS_o_ai
8619vec_sel(vector unsigned int __a, vector unsigned int __b, vector bool int __c) {
8620 return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c);
8621}
8622
8623static __inline__ vector bool int __ATTRS_o_ai
8624vec_sel(vector bool int __a, vector bool int __b, vector unsigned int __c) {
8625 return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c);
8626}
8627
8628static __inline__ vector bool int __ATTRS_o_ai vec_sel(vector bool int __a,
8629 vector bool int __b,
8630 vector bool int __c) {
8631 return (__a & ~__c) | (__b & __c);
8632}
8633
8634static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a,
8635 vector float __b,
8636 vector unsigned int __c) {
8637 vector int __res = ((vector int)__a & ~(vector int)__c) |
8638 ((vector int)__b & (vector int)__c);
8639 return (vector float)__res;
8640}
8641
8642static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a,
8643 vector float __b,
8644 vector bool int __c) {
8645 vector int __res = ((vector int)__a & ~(vector int)__c) |
8646 ((vector int)__b & (vector int)__c);
8647 return (vector float)__res;
8648}
8649
8650#ifdef __VSX__
8651static __inline__ vector double __ATTRS_o_ai
8652vec_sel(vector double __a, vector double __b, vector bool long long __c) {
8653 vector long long __res = ((vector long long)__a & ~(vector long long)__c) |
8654 ((vector long long)__b & (vector long long)__c);
8655 return (vector double)__res;
8656}
8657
8658static __inline__ vector double __ATTRS_o_ai
8659vec_sel(vector double __a, vector double __b, vector unsigned long long __c) {
8660 vector long long __res = ((vector long long)__a & ~(vector long long)__c) |
8661 ((vector long long)__b & (vector long long)__c);
8662 return (vector double)__res;
8663}
Pirama Arumuga Nainar986b8802021-06-03 16:00:34 -07008664
8665static __inline__ vector bool long long __ATTRS_o_ai
8666vec_sel(vector bool long long __a, vector bool long long __b,
8667 vector bool long long __c) {
8668 return (__a & ~__c) | (__b & __c);
8669}
8670
8671static __inline__ vector bool long long __ATTRS_o_ai
8672vec_sel(vector bool long long __a, vector bool long long __b,
8673 vector unsigned long long __c) {
8674 return (__a & ~(vector bool long long)__c) |
8675 (__b & (vector bool long long)__c);
8676}
8677
8678static __inline__ vector signed long long __ATTRS_o_ai
8679vec_sel(vector signed long long __a, vector signed long long __b,
8680 vector bool long long __c) {
8681 return (__a & ~(vector signed long long)__c) |
8682 (__b & (vector signed long long)__c);
8683}
8684
8685static __inline__ vector signed long long __ATTRS_o_ai
8686vec_sel(vector signed long long __a, vector signed long long __b,
8687 vector unsigned long long __c) {
8688 return (__a & ~(vector signed long long)__c) |
8689 (__b & (vector signed long long)__c);
8690}
8691
8692static __inline__ vector unsigned long long __ATTRS_o_ai
8693vec_sel(vector unsigned long long __a, vector unsigned long long __b,
8694 vector bool long long __c) {
8695 return (__a & ~(vector unsigned long long)__c) |
8696 (__b & (vector unsigned long long)__c);
8697}
8698
8699static __inline__ vector unsigned long long __ATTRS_o_ai
8700vec_sel(vector unsigned long long __a, vector unsigned long long __b,
8701 vector unsigned long long __c) {
8702 return (__a & ~__c) | (__b & __c);
8703}
Logan Chien2833ffb2018-10-09 10:03:24 +08008704#endif
8705
8706/* vec_vsel */
8707
8708static __inline__ vector signed char __ATTRS_o_ai vec_vsel(
8709 vector signed char __a, vector signed char __b, vector unsigned char __c) {
8710 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8711}
8712
8713static __inline__ vector signed char __ATTRS_o_ai
8714vec_vsel(vector signed char __a, vector signed char __b, vector bool char __c) {
8715 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
8716}
8717
8718static __inline__ vector unsigned char __ATTRS_o_ai
8719vec_vsel(vector unsigned char __a, vector unsigned char __b,
8720 vector unsigned char __c) {
8721 return (__a & ~__c) | (__b & __c);
8722}
8723
8724static __inline__ vector unsigned char __ATTRS_o_ai vec_vsel(
8725 vector unsigned char __a, vector unsigned char __b, vector bool char __c) {
8726 return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c);
8727}
8728
8729static __inline__ vector bool char __ATTRS_o_ai
8730vec_vsel(vector bool char __a, vector bool char __b, vector unsigned char __c) {
8731 return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c);
8732}
8733
8734static __inline__ vector bool char __ATTRS_o_ai vec_vsel(vector bool char __a,
8735 vector bool char __b,
8736 vector bool char __c) {
8737 return (__a & ~__c) | (__b & __c);
8738}
8739
8740static __inline__ vector short __ATTRS_o_ai
8741vec_vsel(vector short __a, vector short __b, vector unsigned short __c) {
8742 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8743}
8744
8745static __inline__ vector short __ATTRS_o_ai vec_vsel(vector short __a,
8746 vector short __b,
8747 vector bool short __c) {
8748 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
8749}
8750
8751static __inline__ vector unsigned short __ATTRS_o_ai
8752vec_vsel(vector unsigned short __a, vector unsigned short __b,
8753 vector unsigned short __c) {
8754 return (__a & ~__c) | (__b & __c);
8755}
8756
8757static __inline__ vector unsigned short __ATTRS_o_ai
8758vec_vsel(vector unsigned short __a, vector unsigned short __b,
8759 vector bool short __c) {
8760 return (__a & ~(vector unsigned short)__c) |
8761 (__b & (vector unsigned short)__c);
8762}
8763
8764static __inline__ vector bool short __ATTRS_o_ai vec_vsel(
8765 vector bool short __a, vector bool short __b, vector unsigned short __c) {
8766 return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c);
8767}
8768
8769static __inline__ vector bool short __ATTRS_o_ai
8770vec_vsel(vector bool short __a, vector bool short __b, vector bool short __c) {
8771 return (__a & ~__c) | (__b & __c);
8772}
8773
8774static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a,
8775 vector int __b,
8776 vector unsigned int __c) {
8777 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8778}
8779
8780static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a,
8781 vector int __b,
8782 vector bool int __c) {
8783 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
8784}
8785
8786static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel(
8787 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
8788 return (__a & ~__c) | (__b & __c);
8789}
8790
8791static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel(
8792 vector unsigned int __a, vector unsigned int __b, vector bool int __c) {
8793 return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c);
8794}
8795
8796static __inline__ vector bool int __ATTRS_o_ai
8797vec_vsel(vector bool int __a, vector bool int __b, vector unsigned int __c) {
8798 return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c);
8799}
8800
8801static __inline__ vector bool int __ATTRS_o_ai vec_vsel(vector bool int __a,
8802 vector bool int __b,
8803 vector bool int __c) {
8804 return (__a & ~__c) | (__b & __c);
8805}
8806
8807static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a,
8808 vector float __b,
8809 vector unsigned int __c) {
8810 vector int __res = ((vector int)__a & ~(vector int)__c) |
8811 ((vector int)__b & (vector int)__c);
8812 return (vector float)__res;
8813}
8814
8815static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a,
8816 vector float __b,
8817 vector bool int __c) {
8818 vector int __res = ((vector int)__a & ~(vector int)__c) |
8819 ((vector int)__b & (vector int)__c);
8820 return (vector float)__res;
8821}
8822
8823/* vec_sl */
8824
Logan Chien55afb0a2018-10-15 10:42:14 +08008825// vec_sl does modulo arithmetic on __b first, so __b is allowed to be more
8826// than the length of __a.
Logan Chien2833ffb2018-10-09 10:03:24 +08008827static __inline__ vector unsigned char __ATTRS_o_ai
8828vec_sl(vector unsigned char __a, vector unsigned char __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008829 return __a << (__b %
8830 (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +08008831}
8832
Logan Chien55afb0a2018-10-15 10:42:14 +08008833static __inline__ vector signed char __ATTRS_o_ai
8834vec_sl(vector signed char __a, vector unsigned char __b) {
8835 return (vector signed char)vec_sl((vector unsigned char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008836}
8837
8838static __inline__ vector unsigned short __ATTRS_o_ai
8839vec_sl(vector unsigned short __a, vector unsigned short __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008840 return __a << (__b % (vector unsigned short)(sizeof(unsigned short) *
8841 __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +08008842}
8843
Logan Chien55afb0a2018-10-15 10:42:14 +08008844static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
8845 vector unsigned short __b) {
8846 return (vector short)vec_sl((vector unsigned short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008847}
8848
8849static __inline__ vector unsigned int __ATTRS_o_ai
8850vec_sl(vector unsigned int __a, vector unsigned int __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008851 return __a << (__b %
8852 (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
8853}
8854
8855static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
8856 vector unsigned int __b) {
8857 return (vector int)vec_sl((vector unsigned int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008858}
8859
8860#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +08008861static __inline__ vector unsigned long long __ATTRS_o_ai
8862vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
Logan Chien55afb0a2018-10-15 10:42:14 +08008863 return __a << (__b % (vector unsigned long long)(sizeof(unsigned long long) *
8864 __CHAR_BIT__));
8865}
8866
8867static __inline__ vector long long __ATTRS_o_ai
8868vec_sl(vector long long __a, vector unsigned long long __b) {
8869 return (vector long long)vec_sl((vector unsigned long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +08008870}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08008871#elif defined(__VSX__)
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07008872static __inline__ vector unsigned char __ATTRS_o_ai
8873vec_vspltb(vector unsigned char __a, unsigned char __b);
8874static __inline__ vector unsigned long long __ATTRS_o_ai
8875vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
8876 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
8877
8878 // Big endian element one (the right doubleword) can be left shifted as-is.
8879 // The other element needs to be swapped into the right doubleword and
8880 // shifted. Then the right doublewords of the two result vectors are merged.
8881 vector signed long long __rightelt =
8882 (vector signed long long)__builtin_altivec_vslo((vector signed int)__a,
8883 (vector signed int)__b);
8884#ifdef __LITTLE_ENDIAN__
8885 __rightelt = (vector signed long long)__builtin_altivec_vsl(
8886 (vector signed int)__rightelt,
8887 (vector signed int)vec_vspltb((vector unsigned char)__b, 0));
8888#else
8889 __rightelt = (vector signed long long)__builtin_altivec_vsl(
8890 (vector signed int)__rightelt,
8891 (vector signed int)vec_vspltb((vector unsigned char)__b, 15));
8892#endif
8893 __a = __builtin_shufflevector(__a, __a, 1, 0);
8894 __b = __builtin_shufflevector(__b, __b, 1, 0);
8895 vector signed long long __leftelt =
8896 (vector signed long long)__builtin_altivec_vslo((vector signed int)__a,
8897 (vector signed int)__b);
8898#ifdef __LITTLE_ENDIAN__
8899 __leftelt = (vector signed long long)__builtin_altivec_vsl(
8900 (vector signed int)__leftelt,
8901 (vector signed int)vec_vspltb((vector unsigned char)__b, 0));
8902 return (vector unsigned long long)__builtin_shufflevector(__rightelt,
8903 __leftelt, 0, 2);
8904#else
8905 __leftelt = (vector signed long long)__builtin_altivec_vsl(
8906 (vector signed int)__leftelt,
8907 (vector signed int)vec_vspltb((vector unsigned char)__b, 15));
8908 return (vector unsigned long long)__builtin_shufflevector(__leftelt,
8909 __rightelt, 1, 3);
8910#endif
8911}
8912
8913static __inline__ vector long long __ATTRS_o_ai
8914vec_sl(vector long long __a, vector unsigned long long __b) {
8915 return (vector long long)vec_sl((vector unsigned long long)__a, __b);
8916}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -08008917#endif /* __VSX__ */
Logan Chien2833ffb2018-10-09 10:03:24 +08008918
8919/* vec_vslb */
8920
8921#define __builtin_altivec_vslb vec_vslb
8922
8923static __inline__ vector signed char __ATTRS_o_ai
8924vec_vslb(vector signed char __a, vector unsigned char __b) {
8925 return vec_sl(__a, __b);
8926}
8927
8928static __inline__ vector unsigned char __ATTRS_o_ai
8929vec_vslb(vector unsigned char __a, vector unsigned char __b) {
8930 return vec_sl(__a, __b);
8931}
8932
8933/* vec_vslh */
8934
8935#define __builtin_altivec_vslh vec_vslh
8936
8937static __inline__ vector short __ATTRS_o_ai
8938vec_vslh(vector short __a, vector unsigned short __b) {
8939 return vec_sl(__a, __b);
8940}
8941
8942static __inline__ vector unsigned short __ATTRS_o_ai
8943vec_vslh(vector unsigned short __a, vector unsigned short __b) {
8944 return vec_sl(__a, __b);
8945}
8946
8947/* vec_vslw */
8948
8949#define __builtin_altivec_vslw vec_vslw
8950
8951static __inline__ vector int __ATTRS_o_ai vec_vslw(vector int __a,
8952 vector unsigned int __b) {
8953 return vec_sl(__a, __b);
8954}
8955
8956static __inline__ vector unsigned int __ATTRS_o_ai
8957vec_vslw(vector unsigned int __a, vector unsigned int __b) {
8958 return vec_sl(__a, __b);
8959}
8960
8961/* vec_sld */
8962
8963#define __builtin_altivec_vsldoi_4si vec_sld
8964
8965static __inline__ vector signed char __ATTRS_o_ai vec_sld(
8966 vector signed char __a, vector signed char __b, unsigned const int __c) {
8967 unsigned char __d = __c & 0x0F;
8968#ifdef __LITTLE_ENDIAN__
8969 return vec_perm(
8970 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
8971 20 - __d, 21 - __d, 22 - __d, 23 - __d,
8972 24 - __d, 25 - __d, 26 - __d, 27 - __d,
8973 28 - __d, 29 - __d, 30 - __d, 31 - __d));
8974#else
8975 return vec_perm(
8976 __a, __b,
8977 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
8978 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
8979 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
8980#endif
8981}
8982
8983static __inline__ vector unsigned char __ATTRS_o_ai
8984vec_sld(vector unsigned char __a, vector unsigned char __b,
8985 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 bool char __ATTRS_o_ai
9003vec_sld(vector bool char __a, vector bool char __b, unsigned const int __c) {
9004 unsigned char __d = __c & 0x0F;
9005#ifdef __LITTLE_ENDIAN__
9006 return vec_perm(
9007 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9008 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9009 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9010 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9011#else
9012 return vec_perm(
9013 __a, __b,
9014 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9015 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9016 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9017#endif
9018}
9019
9020static __inline__ vector signed short __ATTRS_o_ai vec_sld(
9021 vector signed short __a, vector signed short __b, unsigned const int __c) {
9022 unsigned char __d = __c & 0x0F;
9023#ifdef __LITTLE_ENDIAN__
9024 return vec_perm(
9025 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9026 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9027 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9028 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9029#else
9030 return vec_perm(
9031 __a, __b,
9032 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9033 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9034 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9035#endif
9036}
9037
9038static __inline__ vector unsigned short __ATTRS_o_ai
9039vec_sld(vector unsigned short __a, vector unsigned short __b,
9040 unsigned const int __c) {
9041 unsigned char __d = __c & 0x0F;
9042#ifdef __LITTLE_ENDIAN__
9043 return vec_perm(
9044 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9045 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9046 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9047 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9048#else
9049 return vec_perm(
9050 __a, __b,
9051 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9052 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9053 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9054#endif
9055}
9056
9057static __inline__ vector bool short __ATTRS_o_ai
9058vec_sld(vector bool short __a, vector bool short __b, unsigned const int __c) {
9059 unsigned char __d = __c & 0x0F;
9060#ifdef __LITTLE_ENDIAN__
9061 return vec_perm(
9062 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9063 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9064 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9065 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9066#else
9067 return vec_perm(
9068 __a, __b,
9069 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9070 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9071 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9072#endif
9073}
9074
9075static __inline__ vector pixel __ATTRS_o_ai vec_sld(vector pixel __a,
9076 vector pixel __b,
9077 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 signed int __ATTRS_o_ai
9095vec_sld(vector signed int __a, vector signed int __b, unsigned const int __c) {
9096 unsigned char __d = __c & 0x0F;
9097#ifdef __LITTLE_ENDIAN__
9098 return vec_perm(
9099 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9100 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9101 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9102 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9103#else
9104 return vec_perm(
9105 __a, __b,
9106 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9107 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9108 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9109#endif
9110}
9111
9112static __inline__ vector unsigned int __ATTRS_o_ai vec_sld(
9113 vector unsigned int __a, vector unsigned int __b, unsigned const int __c) {
9114 unsigned char __d = __c & 0x0F;
9115#ifdef __LITTLE_ENDIAN__
9116 return vec_perm(
9117 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9118 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9119 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9120 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9121#else
9122 return vec_perm(
9123 __a, __b,
9124 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9125 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9126 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9127#endif
9128}
9129
9130static __inline__ vector bool int __ATTRS_o_ai vec_sld(vector bool int __a,
9131 vector bool int __b,
9132 unsigned const int __c) {
9133 unsigned char __d = __c & 0x0F;
9134#ifdef __LITTLE_ENDIAN__
9135 return vec_perm(
9136 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9137 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9138 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9139 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9140#else
9141 return vec_perm(
9142 __a, __b,
9143 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9144 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9145 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9146#endif
9147}
9148
9149static __inline__ vector float __ATTRS_o_ai vec_sld(vector float __a,
9150 vector float __b,
9151 unsigned const int __c) {
9152 unsigned char __d = __c & 0x0F;
9153#ifdef __LITTLE_ENDIAN__
9154 return vec_perm(
9155 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9156 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9157 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9158 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9159#else
9160 return vec_perm(
9161 __a, __b,
9162 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9163 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9164 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9165#endif
9166}
9167
Logan Chien55afb0a2018-10-15 10:42:14 +08009168#ifdef __VSX__
9169static __inline__ vector bool long long __ATTRS_o_ai
9170vec_sld(vector bool long long __a, vector bool long long __b,
9171 unsigned const int __c) {
9172 unsigned char __d = __c & 0x0F;
9173#ifdef __LITTLE_ENDIAN__
9174 return vec_perm(
9175 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9176 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9177 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9178 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9179#else
9180 return vec_perm(
9181 __a, __b,
9182 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9183 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9184 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9185#endif
9186}
9187
9188static __inline__ vector signed long long __ATTRS_o_ai
9189vec_sld(vector signed long long __a, vector signed long long __b,
9190 unsigned const int __c) {
9191 unsigned char __d = __c & 0x0F;
9192#ifdef __LITTLE_ENDIAN__
9193 return vec_perm(
9194 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9195 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9196 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9197 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9198#else
9199 return vec_perm(
9200 __a, __b,
9201 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9202 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9203 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9204#endif
9205}
9206
9207static __inline__ vector unsigned long long __ATTRS_o_ai
9208vec_sld(vector unsigned long long __a, vector unsigned long long __b,
9209 unsigned const int __c) {
9210 unsigned char __d = __c & 0x0F;
9211#ifdef __LITTLE_ENDIAN__
9212 return vec_perm(
9213 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9214 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9215 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9216 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9217#else
9218 return vec_perm(
9219 __a, __b,
9220 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9221 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9222 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9223#endif
9224}
9225
9226static __inline__ vector double __ATTRS_o_ai vec_sld(vector double __a,
9227 vector double __b,
9228 unsigned const int __c) {
9229 unsigned char __d = __c & 0x0F;
9230#ifdef __LITTLE_ENDIAN__
9231 return vec_perm(
9232 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9233 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9234 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9235 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9236#else
9237 return vec_perm(
9238 __a, __b,
9239 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9240 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9241 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9242#endif
9243}
9244#endif
9245
9246/* vec_sldw */
9247static __inline__ vector signed char __ATTRS_o_ai vec_sldw(
9248 vector signed char __a, vector signed char __b, unsigned const int __c) {
9249 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9250}
9251
9252static __inline__ vector unsigned char __ATTRS_o_ai
9253vec_sldw(vector unsigned char __a, vector unsigned char __b,
9254 unsigned const int __c) {
9255 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9256}
9257
9258static __inline__ vector signed short __ATTRS_o_ai vec_sldw(
9259 vector signed short __a, vector signed short __b, unsigned const int __c) {
9260 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9261}
9262
9263static __inline__ vector unsigned short __ATTRS_o_ai
9264vec_sldw(vector unsigned short __a, vector unsigned short __b,
9265 unsigned const int __c) {
9266 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9267}
9268
9269static __inline__ vector signed int __ATTRS_o_ai
9270vec_sldw(vector signed int __a, vector signed int __b, unsigned const int __c) {
9271 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9272}
9273
9274static __inline__ vector unsigned int __ATTRS_o_ai vec_sldw(
9275 vector unsigned int __a, vector unsigned int __b, unsigned const int __c) {
9276 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9277}
9278
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07009279static __inline__ vector float __ATTRS_o_ai vec_sldw(
9280 vector float __a, vector float __b, unsigned const int __c) {
9281 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9282}
9283
Logan Chien55afb0a2018-10-15 10:42:14 +08009284#ifdef __VSX__
9285static __inline__ vector signed long long __ATTRS_o_ai
9286vec_sldw(vector signed long long __a, vector signed long long __b,
9287 unsigned const int __c) {
9288 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9289}
9290
9291static __inline__ vector unsigned long long __ATTRS_o_ai
9292vec_sldw(vector unsigned long long __a, vector unsigned long long __b,
9293 unsigned const int __c) {
9294 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9295}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -07009296
9297static __inline__ vector double __ATTRS_o_ai vec_sldw(
9298 vector double __a, vector double __b, unsigned const int __c) {
9299 return vec_sld(__a, __b, ((__c << 2) & 0x0F));
9300}
Logan Chien55afb0a2018-10-15 10:42:14 +08009301#endif
9302
9303#ifdef __POWER9_VECTOR__
9304/* vec_slv */
9305static __inline__ vector unsigned char __ATTRS_o_ai
9306vec_slv(vector unsigned char __a, vector unsigned char __b) {
9307 return __builtin_altivec_vslv(__a, __b);
9308}
9309
9310/* vec_srv */
9311static __inline__ vector unsigned char __ATTRS_o_ai
9312vec_srv(vector unsigned char __a, vector unsigned char __b) {
9313 return __builtin_altivec_vsrv(__a, __b);
9314}
9315#endif
9316
Logan Chien2833ffb2018-10-09 10:03:24 +08009317/* vec_vsldoi */
9318
9319static __inline__ vector signed char __ATTRS_o_ai
9320vec_vsldoi(vector signed char __a, vector signed char __b, unsigned char __c) {
9321 unsigned char __d = __c & 0x0F;
9322#ifdef __LITTLE_ENDIAN__
9323 return vec_perm(
9324 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9325 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9326 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9327 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9328#else
9329 return vec_perm(
9330 __a, __b,
9331 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9332 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9333 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9334#endif
9335}
9336
9337static __inline__ vector unsigned char __ATTRS_o_ai vec_vsldoi(
9338 vector unsigned char __a, vector unsigned char __b, unsigned char __c) {
9339 unsigned char __d = __c & 0x0F;
9340#ifdef __LITTLE_ENDIAN__
9341 return vec_perm(
9342 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9343 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9344 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9345 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9346#else
9347 return vec_perm(
9348 __a, __b,
9349 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9350 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9351 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9352#endif
9353}
9354
9355static __inline__ vector short __ATTRS_o_ai vec_vsldoi(vector short __a,
9356 vector short __b,
9357 unsigned char __c) {
9358 unsigned char __d = __c & 0x0F;
9359#ifdef __LITTLE_ENDIAN__
9360 return vec_perm(
9361 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9362 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9363 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9364 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9365#else
9366 return vec_perm(
9367 __a, __b,
9368 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9369 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9370 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9371#endif
9372}
9373
9374static __inline__ vector unsigned short __ATTRS_o_ai vec_vsldoi(
9375 vector unsigned short __a, vector unsigned short __b, unsigned char __c) {
9376 unsigned char __d = __c & 0x0F;
9377#ifdef __LITTLE_ENDIAN__
9378 return vec_perm(
9379 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9380 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9381 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9382 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9383#else
9384 return vec_perm(
9385 __a, __b,
9386 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9387 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9388 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9389#endif
9390}
9391
9392static __inline__ vector pixel __ATTRS_o_ai vec_vsldoi(vector pixel __a,
9393 vector pixel __b,
9394 unsigned char __c) {
9395 unsigned char __d = __c & 0x0F;
9396#ifdef __LITTLE_ENDIAN__
9397 return vec_perm(
9398 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9399 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9400 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9401 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9402#else
9403 return vec_perm(
9404 __a, __b,
9405 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9406 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9407 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9408#endif
9409}
9410
9411static __inline__ vector int __ATTRS_o_ai vec_vsldoi(vector int __a,
9412 vector int __b,
9413 unsigned char __c) {
9414 unsigned char __d = __c & 0x0F;
9415#ifdef __LITTLE_ENDIAN__
9416 return vec_perm(
9417 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9418 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9419 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9420 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9421#else
9422 return vec_perm(
9423 __a, __b,
9424 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9425 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9426 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9427#endif
9428}
9429
9430static __inline__ vector unsigned int __ATTRS_o_ai vec_vsldoi(
9431 vector unsigned int __a, vector unsigned int __b, unsigned char __c) {
9432 unsigned char __d = __c & 0x0F;
9433#ifdef __LITTLE_ENDIAN__
9434 return vec_perm(
9435 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9436 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9437 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9438 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9439#else
9440 return vec_perm(
9441 __a, __b,
9442 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9443 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9444 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9445#endif
9446}
9447
9448static __inline__ vector float __ATTRS_o_ai vec_vsldoi(vector float __a,
9449 vector float __b,
9450 unsigned char __c) {
9451 unsigned char __d = __c & 0x0F;
9452#ifdef __LITTLE_ENDIAN__
9453 return vec_perm(
9454 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
9455 20 - __d, 21 - __d, 22 - __d, 23 - __d,
9456 24 - __d, 25 - __d, 26 - __d, 27 - __d,
9457 28 - __d, 29 - __d, 30 - __d, 31 - __d));
9458#else
9459 return vec_perm(
9460 __a, __b,
9461 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
9462 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
9463 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
9464#endif
9465}
9466
9467/* vec_sll */
9468
9469static __inline__ vector signed char __ATTRS_o_ai
9470vec_sll(vector signed char __a, vector unsigned char __b) {
9471 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9472 (vector int)__b);
9473}
9474
9475static __inline__ vector signed char __ATTRS_o_ai
9476vec_sll(vector signed char __a, vector unsigned short __b) {
9477 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9478 (vector int)__b);
9479}
9480
9481static __inline__ vector signed char __ATTRS_o_ai
9482vec_sll(vector signed char __a, vector unsigned int __b) {
9483 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9484 (vector int)__b);
9485}
9486
9487static __inline__ vector unsigned char __ATTRS_o_ai
9488vec_sll(vector unsigned char __a, vector unsigned char __b) {
9489 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9490 (vector int)__b);
9491}
9492
9493static __inline__ vector unsigned char __ATTRS_o_ai
9494vec_sll(vector unsigned char __a, vector unsigned short __b) {
9495 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9496 (vector int)__b);
9497}
9498
9499static __inline__ vector unsigned char __ATTRS_o_ai
9500vec_sll(vector unsigned char __a, vector unsigned int __b) {
9501 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9502 (vector int)__b);
9503}
9504
9505static __inline__ vector bool char __ATTRS_o_ai
9506vec_sll(vector bool char __a, vector unsigned char __b) {
9507 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9508 (vector int)__b);
9509}
9510
9511static __inline__ vector bool char __ATTRS_o_ai
9512vec_sll(vector bool char __a, vector unsigned short __b) {
9513 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9514 (vector int)__b);
9515}
9516
9517static __inline__ vector bool char __ATTRS_o_ai
9518vec_sll(vector bool char __a, vector unsigned int __b) {
9519 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9520 (vector int)__b);
9521}
9522
9523static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
9524 vector unsigned char __b) {
9525 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9526}
9527
9528static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
9529 vector unsigned short __b) {
9530 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9531}
9532
9533static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
9534 vector unsigned int __b) {
9535 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9536}
9537
9538static __inline__ vector unsigned short __ATTRS_o_ai
9539vec_sll(vector unsigned short __a, vector unsigned char __b) {
9540 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9541 (vector int)__b);
9542}
9543
9544static __inline__ vector unsigned short __ATTRS_o_ai
9545vec_sll(vector unsigned short __a, vector unsigned short __b) {
9546 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9547 (vector int)__b);
9548}
9549
9550static __inline__ vector unsigned short __ATTRS_o_ai
9551vec_sll(vector unsigned short __a, vector unsigned int __b) {
9552 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9553 (vector int)__b);
9554}
9555
9556static __inline__ vector bool short __ATTRS_o_ai
9557vec_sll(vector bool short __a, vector unsigned char __b) {
9558 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9559 (vector int)__b);
9560}
9561
9562static __inline__ vector bool short __ATTRS_o_ai
9563vec_sll(vector bool short __a, vector unsigned short __b) {
9564 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9565 (vector int)__b);
9566}
9567
9568static __inline__ vector bool short __ATTRS_o_ai
9569vec_sll(vector bool short __a, vector unsigned int __b) {
9570 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9571 (vector int)__b);
9572}
9573
9574static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
9575 vector unsigned char __b) {
9576 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9577}
9578
9579static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
9580 vector unsigned short __b) {
9581 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9582}
9583
9584static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
9585 vector unsigned int __b) {
9586 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9587}
9588
9589static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
9590 vector unsigned char __b) {
9591 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9592}
9593
9594static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
9595 vector unsigned short __b) {
9596 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9597}
9598
9599static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
9600 vector unsigned int __b) {
9601 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9602}
9603
9604static __inline__ vector unsigned int __ATTRS_o_ai
9605vec_sll(vector unsigned int __a, vector unsigned char __b) {
9606 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9607 (vector int)__b);
9608}
9609
9610static __inline__ vector unsigned int __ATTRS_o_ai
9611vec_sll(vector unsigned int __a, vector unsigned short __b) {
9612 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9613 (vector int)__b);
9614}
9615
9616static __inline__ vector unsigned int __ATTRS_o_ai
9617vec_sll(vector unsigned int __a, vector unsigned int __b) {
9618 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9619 (vector int)__b);
9620}
9621
9622static __inline__ vector bool int __ATTRS_o_ai
9623vec_sll(vector bool int __a, vector unsigned char __b) {
9624 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9625 (vector int)__b);
9626}
9627
9628static __inline__ vector bool int __ATTRS_o_ai
9629vec_sll(vector bool int __a, vector unsigned short __b) {
9630 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9631 (vector int)__b);
9632}
9633
9634static __inline__ vector bool int __ATTRS_o_ai
9635vec_sll(vector bool int __a, vector unsigned int __b) {
9636 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9637 (vector int)__b);
9638}
9639
Logan Chien55afb0a2018-10-15 10:42:14 +08009640#ifdef __VSX__
9641static __inline__ vector signed long long __ATTRS_o_ai
9642vec_sll(vector signed long long __a, vector unsigned char __b) {
9643 return (vector signed long long)__builtin_altivec_vsl((vector int)__a,
9644 (vector int)__b);
9645}
9646
9647static __inline__ vector unsigned long long __ATTRS_o_ai
9648vec_sll(vector unsigned long long __a, vector unsigned char __b) {
9649 return (vector unsigned long long)__builtin_altivec_vsl((vector int)__a,
9650 (vector int)__b);
9651}
9652#endif
9653
Logan Chien2833ffb2018-10-09 10:03:24 +08009654/* vec_vsl */
9655
9656static __inline__ vector signed char __ATTRS_o_ai
9657vec_vsl(vector signed char __a, vector unsigned char __b) {
9658 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9659 (vector int)__b);
9660}
9661
9662static __inline__ vector signed char __ATTRS_o_ai
9663vec_vsl(vector signed char __a, vector unsigned short __b) {
9664 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9665 (vector int)__b);
9666}
9667
9668static __inline__ vector signed char __ATTRS_o_ai
9669vec_vsl(vector signed char __a, vector unsigned int __b) {
9670 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
9671 (vector int)__b);
9672}
9673
9674static __inline__ vector unsigned char __ATTRS_o_ai
9675vec_vsl(vector unsigned char __a, vector unsigned char __b) {
9676 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9677 (vector int)__b);
9678}
9679
9680static __inline__ vector unsigned char __ATTRS_o_ai
9681vec_vsl(vector unsigned char __a, vector unsigned short __b) {
9682 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9683 (vector int)__b);
9684}
9685
9686static __inline__ vector unsigned char __ATTRS_o_ai
9687vec_vsl(vector unsigned char __a, vector unsigned int __b) {
9688 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
9689 (vector int)__b);
9690}
9691
9692static __inline__ vector bool char __ATTRS_o_ai
9693vec_vsl(vector bool char __a, vector unsigned char __b) {
9694 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9695 (vector int)__b);
9696}
9697
9698static __inline__ vector bool char __ATTRS_o_ai
9699vec_vsl(vector bool char __a, vector unsigned short __b) {
9700 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9701 (vector int)__b);
9702}
9703
9704static __inline__ vector bool char __ATTRS_o_ai
9705vec_vsl(vector bool char __a, vector unsigned int __b) {
9706 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
9707 (vector int)__b);
9708}
9709
9710static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
9711 vector unsigned char __b) {
9712 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9713}
9714
9715static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
9716 vector unsigned short __b) {
9717 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9718}
9719
9720static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
9721 vector unsigned int __b) {
9722 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9723}
9724
9725static __inline__ vector unsigned short __ATTRS_o_ai
9726vec_vsl(vector unsigned short __a, vector unsigned char __b) {
9727 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9728 (vector int)__b);
9729}
9730
9731static __inline__ vector unsigned short __ATTRS_o_ai
9732vec_vsl(vector unsigned short __a, vector unsigned short __b) {
9733 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9734 (vector int)__b);
9735}
9736
9737static __inline__ vector unsigned short __ATTRS_o_ai
9738vec_vsl(vector unsigned short __a, vector unsigned int __b) {
9739 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
9740 (vector int)__b);
9741}
9742
9743static __inline__ vector bool short __ATTRS_o_ai
9744vec_vsl(vector bool short __a, vector unsigned char __b) {
9745 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9746 (vector int)__b);
9747}
9748
9749static __inline__ vector bool short __ATTRS_o_ai
9750vec_vsl(vector bool short __a, vector unsigned short __b) {
9751 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9752 (vector int)__b);
9753}
9754
9755static __inline__ vector bool short __ATTRS_o_ai
9756vec_vsl(vector bool short __a, vector unsigned int __b) {
9757 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
9758 (vector int)__b);
9759}
9760
9761static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
9762 vector unsigned char __b) {
9763 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9764}
9765
9766static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
9767 vector unsigned short __b) {
9768 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9769}
9770
9771static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
9772 vector unsigned int __b) {
9773 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
9774}
9775
9776static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
9777 vector unsigned char __b) {
9778 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9779}
9780
9781static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
9782 vector unsigned short __b) {
9783 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9784}
9785
9786static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
9787 vector unsigned int __b) {
9788 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
9789}
9790
9791static __inline__ vector unsigned int __ATTRS_o_ai
9792vec_vsl(vector unsigned int __a, vector unsigned char __b) {
9793 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9794 (vector int)__b);
9795}
9796
9797static __inline__ vector unsigned int __ATTRS_o_ai
9798vec_vsl(vector unsigned int __a, vector unsigned short __b) {
9799 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9800 (vector int)__b);
9801}
9802
9803static __inline__ vector unsigned int __ATTRS_o_ai
9804vec_vsl(vector unsigned int __a, vector unsigned int __b) {
9805 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
9806 (vector int)__b);
9807}
9808
9809static __inline__ vector bool int __ATTRS_o_ai
9810vec_vsl(vector bool int __a, vector unsigned char __b) {
9811 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9812 (vector int)__b);
9813}
9814
9815static __inline__ vector bool int __ATTRS_o_ai
9816vec_vsl(vector bool int __a, vector unsigned short __b) {
9817 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9818 (vector int)__b);
9819}
9820
9821static __inline__ vector bool int __ATTRS_o_ai
9822vec_vsl(vector bool int __a, vector unsigned int __b) {
9823 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
9824 (vector int)__b);
9825}
9826
9827/* vec_slo */
9828
9829static __inline__ vector signed char __ATTRS_o_ai
9830vec_slo(vector signed char __a, vector signed char __b) {
9831 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9832 (vector int)__b);
9833}
9834
9835static __inline__ vector signed char __ATTRS_o_ai
9836vec_slo(vector signed char __a, vector unsigned char __b) {
9837 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9838 (vector int)__b);
9839}
9840
9841static __inline__ vector unsigned char __ATTRS_o_ai
9842vec_slo(vector unsigned char __a, vector signed char __b) {
9843 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9844 (vector int)__b);
9845}
9846
9847static __inline__ vector unsigned char __ATTRS_o_ai
9848vec_slo(vector unsigned char __a, vector unsigned char __b) {
9849 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9850 (vector int)__b);
9851}
9852
9853static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a,
9854 vector signed char __b) {
9855 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9856}
9857
9858static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a,
9859 vector unsigned char __b) {
9860 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9861}
9862
9863static __inline__ vector unsigned short __ATTRS_o_ai
9864vec_slo(vector unsigned short __a, vector signed char __b) {
9865 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9866 (vector int)__b);
9867}
9868
9869static __inline__ vector unsigned short __ATTRS_o_ai
9870vec_slo(vector unsigned short __a, vector unsigned char __b) {
9871 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9872 (vector int)__b);
9873}
9874
9875static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a,
9876 vector signed char __b) {
9877 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9878}
9879
9880static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a,
9881 vector unsigned char __b) {
9882 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9883}
9884
9885static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a,
9886 vector signed char __b) {
9887 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
9888}
9889
9890static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a,
9891 vector unsigned char __b) {
9892 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
9893}
9894
9895static __inline__ vector unsigned int __ATTRS_o_ai
9896vec_slo(vector unsigned int __a, vector signed char __b) {
9897 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
9898 (vector int)__b);
9899}
9900
9901static __inline__ vector unsigned int __ATTRS_o_ai
9902vec_slo(vector unsigned int __a, vector unsigned char __b) {
9903 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
9904 (vector int)__b);
9905}
9906
9907static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a,
9908 vector signed char __b) {
9909 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9910}
9911
9912static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a,
9913 vector unsigned char __b) {
9914 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9915}
9916
Logan Chien55afb0a2018-10-15 10:42:14 +08009917#ifdef __VSX__
9918static __inline__ vector signed long long __ATTRS_o_ai
9919vec_slo(vector signed long long __a, vector signed char __b) {
9920 return (vector signed long long)__builtin_altivec_vslo((vector int)__a,
9921 (vector int)__b);
9922}
9923
9924static __inline__ vector signed long long __ATTRS_o_ai
9925vec_slo(vector signed long long __a, vector unsigned char __b) {
9926 return (vector signed long long)__builtin_altivec_vslo((vector int)__a,
9927 (vector int)__b);
9928}
9929
9930static __inline__ vector unsigned long long __ATTRS_o_ai
9931vec_slo(vector unsigned long long __a, vector signed char __b) {
9932 return (vector unsigned long long)__builtin_altivec_vslo((vector int)__a,
9933 (vector int)__b);
9934}
9935
9936static __inline__ vector unsigned long long __ATTRS_o_ai
9937vec_slo(vector unsigned long long __a, vector unsigned char __b) {
9938 return (vector unsigned long long)__builtin_altivec_vslo((vector int)__a,
9939 (vector int)__b);
9940}
9941#endif
9942
Logan Chien2833ffb2018-10-09 10:03:24 +08009943/* vec_vslo */
9944
9945static __inline__ vector signed char __ATTRS_o_ai
9946vec_vslo(vector signed char __a, vector signed char __b) {
9947 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9948 (vector int)__b);
9949}
9950
9951static __inline__ vector signed char __ATTRS_o_ai
9952vec_vslo(vector signed char __a, vector unsigned char __b) {
9953 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
9954 (vector int)__b);
9955}
9956
9957static __inline__ vector unsigned char __ATTRS_o_ai
9958vec_vslo(vector unsigned char __a, vector signed char __b) {
9959 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9960 (vector int)__b);
9961}
9962
9963static __inline__ vector unsigned char __ATTRS_o_ai
9964vec_vslo(vector unsigned char __a, vector unsigned char __b) {
9965 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
9966 (vector int)__b);
9967}
9968
9969static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a,
9970 vector signed char __b) {
9971 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9972}
9973
9974static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a,
9975 vector unsigned char __b) {
9976 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9977}
9978
9979static __inline__ vector unsigned short __ATTRS_o_ai
9980vec_vslo(vector unsigned short __a, vector signed char __b) {
9981 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9982 (vector int)__b);
9983}
9984
9985static __inline__ vector unsigned short __ATTRS_o_ai
9986vec_vslo(vector unsigned short __a, vector unsigned char __b) {
9987 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
9988 (vector int)__b);
9989}
9990
9991static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a,
9992 vector signed char __b) {
9993 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9994}
9995
9996static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a,
9997 vector unsigned char __b) {
9998 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
9999}
10000
10001static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a,
10002 vector signed char __b) {
10003 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
10004}
10005
10006static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a,
10007 vector unsigned char __b) {
10008 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
10009}
10010
10011static __inline__ vector unsigned int __ATTRS_o_ai
10012vec_vslo(vector unsigned int __a, vector signed char __b) {
10013 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
10014 (vector int)__b);
10015}
10016
10017static __inline__ vector unsigned int __ATTRS_o_ai
10018vec_vslo(vector unsigned int __a, vector unsigned char __b) {
10019 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
10020 (vector int)__b);
10021}
10022
10023static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a,
10024 vector signed char __b) {
10025 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
10026}
10027
10028static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a,
10029 vector unsigned char __b) {
10030 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
10031}
10032
10033/* vec_splat */
10034
10035static __inline__ vector signed char __ATTRS_o_ai
10036vec_splat(vector signed char __a, unsigned const int __b) {
10037 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
10038}
10039
10040static __inline__ vector unsigned char __ATTRS_o_ai
10041vec_splat(vector unsigned char __a, unsigned const int __b) {
10042 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
10043}
10044
10045static __inline__ vector bool char __ATTRS_o_ai
10046vec_splat(vector bool char __a, unsigned const int __b) {
10047 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
10048}
10049
10050static __inline__ vector signed short __ATTRS_o_ai
10051vec_splat(vector signed short __a, unsigned const int __b) {
10052 unsigned char b0 = (__b & 0x07) * 2;
10053 unsigned char b1 = b0 + 1;
10054 return vec_perm(__a, __a,
10055 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10056 b0, b1, b0, b1, b0, b1));
10057}
10058
10059static __inline__ vector unsigned short __ATTRS_o_ai
10060vec_splat(vector unsigned short __a, unsigned const int __b) {
10061 unsigned char b0 = (__b & 0x07) * 2;
10062 unsigned char b1 = b0 + 1;
10063 return vec_perm(__a, __a,
10064 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10065 b0, b1, b0, b1, b0, b1));
10066}
10067
10068static __inline__ vector bool short __ATTRS_o_ai
10069vec_splat(vector bool short __a, unsigned const int __b) {
10070 unsigned char b0 = (__b & 0x07) * 2;
10071 unsigned char b1 = b0 + 1;
10072 return vec_perm(__a, __a,
10073 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10074 b0, b1, b0, b1, b0, b1));
10075}
10076
10077static __inline__ vector pixel __ATTRS_o_ai vec_splat(vector pixel __a,
10078 unsigned const int __b) {
10079 unsigned char b0 = (__b & 0x07) * 2;
10080 unsigned char b1 = b0 + 1;
10081 return vec_perm(__a, __a,
10082 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
10083 b0, b1, b0, b1, b0, b1));
10084}
10085
10086static __inline__ vector signed int __ATTRS_o_ai
10087vec_splat(vector signed int __a, unsigned const int __b) {
10088 unsigned char b0 = (__b & 0x03) * 4;
10089 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10090 return vec_perm(__a, __a,
10091 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10092 b2, b3, b0, b1, b2, b3));
10093}
10094
10095static __inline__ vector unsigned int __ATTRS_o_ai
10096vec_splat(vector unsigned int __a, unsigned const int __b) {
10097 unsigned char b0 = (__b & 0x03) * 4;
10098 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10099 return vec_perm(__a, __a,
10100 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10101 b2, b3, b0, b1, b2, b3));
10102}
10103
10104static __inline__ vector bool int __ATTRS_o_ai
10105vec_splat(vector bool int __a, unsigned const int __b) {
10106 unsigned char b0 = (__b & 0x03) * 4;
10107 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10108 return vec_perm(__a, __a,
10109 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10110 b2, b3, b0, b1, b2, b3));
10111}
10112
10113static __inline__ vector float __ATTRS_o_ai vec_splat(vector float __a,
10114 unsigned const int __b) {
10115 unsigned char b0 = (__b & 0x03) * 4;
10116 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
10117 return vec_perm(__a, __a,
10118 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
10119 b2, b3, b0, b1, b2, b3));
10120}
10121
10122#ifdef __VSX__
10123static __inline__ vector double __ATTRS_o_ai vec_splat(vector double __a,
10124 unsigned const int __b) {
10125 unsigned char b0 = (__b & 0x01) * 8;
10126 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10127 b6 = b0 + 6, b7 = b0 + 7;
10128 return vec_perm(__a, __a,
10129 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10130 b2, b3, b4, b5, b6, b7));
10131}
10132static __inline__ vector bool long long __ATTRS_o_ai
10133vec_splat(vector bool long long __a, unsigned const int __b) {
10134 unsigned char b0 = (__b & 0x01) * 8;
10135 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10136 b6 = b0 + 6, b7 = b0 + 7;
10137 return vec_perm(__a, __a,
10138 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10139 b2, b3, b4, b5, b6, b7));
10140}
10141static __inline__ vector signed long long __ATTRS_o_ai
10142vec_splat(vector signed long long __a, unsigned const int __b) {
10143 unsigned char b0 = (__b & 0x01) * 8;
10144 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10145 b6 = b0 + 6, b7 = b0 + 7;
10146 return vec_perm(__a, __a,
10147 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10148 b2, b3, b4, b5, b6, b7));
10149}
10150static __inline__ vector unsigned long long __ATTRS_o_ai
10151vec_splat(vector unsigned long long __a, unsigned const int __b) {
10152 unsigned char b0 = (__b & 0x01) * 8;
10153 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
10154 b6 = b0 + 6, b7 = b0 + 7;
10155 return vec_perm(__a, __a,
10156 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
10157 b2, b3, b4, b5, b6, b7));
10158}
10159#endif
10160
10161/* vec_vspltb */
10162
10163#define __builtin_altivec_vspltb vec_vspltb
10164
10165static __inline__ vector signed char __ATTRS_o_ai
10166vec_vspltb(vector signed char __a, unsigned char __b) {
10167 return vec_perm(__a, __a, (vector unsigned char)(__b));
10168}
10169
10170static __inline__ vector unsigned char __ATTRS_o_ai
10171vec_vspltb(vector unsigned char __a, unsigned char __b) {
10172 return vec_perm(__a, __a, (vector unsigned char)(__b));
10173}
10174
10175static __inline__ vector bool char __ATTRS_o_ai vec_vspltb(vector bool char __a,
10176 unsigned char __b) {
10177 return vec_perm(__a, __a, (vector unsigned char)(__b));
10178}
10179
10180/* vec_vsplth */
10181
10182#define __builtin_altivec_vsplth vec_vsplth
10183
10184static __inline__ vector short __ATTRS_o_ai vec_vsplth(vector short __a,
10185 unsigned char __b) {
10186 __b *= 2;
10187 unsigned char b1 = __b + 1;
10188 return vec_perm(__a, __a,
10189 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10190 __b, b1, __b, b1, __b, b1, __b, b1));
10191}
10192
10193static __inline__ vector unsigned short __ATTRS_o_ai
10194vec_vsplth(vector unsigned short __a, unsigned char __b) {
10195 __b *= 2;
10196 unsigned char b1 = __b + 1;
10197 return vec_perm(__a, __a,
10198 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10199 __b, b1, __b, b1, __b, b1, __b, b1));
10200}
10201
10202static __inline__ vector bool short __ATTRS_o_ai
10203vec_vsplth(vector bool short __a, unsigned char __b) {
10204 __b *= 2;
10205 unsigned char b1 = __b + 1;
10206 return vec_perm(__a, __a,
10207 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10208 __b, b1, __b, b1, __b, b1, __b, b1));
10209}
10210
10211static __inline__ vector pixel __ATTRS_o_ai vec_vsplth(vector pixel __a,
10212 unsigned char __b) {
10213 __b *= 2;
10214 unsigned char b1 = __b + 1;
10215 return vec_perm(__a, __a,
10216 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
10217 __b, b1, __b, b1, __b, b1, __b, b1));
10218}
10219
10220/* vec_vspltw */
10221
10222#define __builtin_altivec_vspltw vec_vspltw
10223
10224static __inline__ vector int __ATTRS_o_ai vec_vspltw(vector int __a,
10225 unsigned char __b) {
10226 __b *= 4;
10227 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10228 return vec_perm(__a, __a,
10229 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10230 b1, b2, b3, __b, b1, b2, b3));
10231}
10232
10233static __inline__ vector unsigned int __ATTRS_o_ai
10234vec_vspltw(vector unsigned int __a, unsigned char __b) {
10235 __b *= 4;
10236 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10237 return vec_perm(__a, __a,
10238 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10239 b1, b2, b3, __b, b1, b2, b3));
10240}
10241
10242static __inline__ vector bool int __ATTRS_o_ai vec_vspltw(vector bool int __a,
10243 unsigned char __b) {
10244 __b *= 4;
10245 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10246 return vec_perm(__a, __a,
10247 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10248 b1, b2, b3, __b, b1, b2, b3));
10249}
10250
10251static __inline__ vector float __ATTRS_o_ai vec_vspltw(vector float __a,
10252 unsigned char __b) {
10253 __b *= 4;
10254 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
10255 return vec_perm(__a, __a,
10256 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
10257 b1, b2, b3, __b, b1, b2, b3));
10258}
10259
10260/* vec_splat_s8 */
10261
10262#define __builtin_altivec_vspltisb vec_splat_s8
10263
10264// FIXME: parameter should be treated as 5-bit signed literal
10265static __inline__ vector signed char __ATTRS_o_ai
10266vec_splat_s8(signed char __a) {
10267 return (vector signed char)(__a);
10268}
10269
10270/* vec_vspltisb */
10271
10272// FIXME: parameter should be treated as 5-bit signed literal
10273static __inline__ vector signed char __ATTRS_o_ai
10274vec_vspltisb(signed char __a) {
10275 return (vector signed char)(__a);
10276}
10277
10278/* vec_splat_s16 */
10279
10280#define __builtin_altivec_vspltish vec_splat_s16
10281
10282// FIXME: parameter should be treated as 5-bit signed literal
10283static __inline__ vector short __ATTRS_o_ai vec_splat_s16(signed char __a) {
10284 return (vector short)(__a);
10285}
10286
10287/* vec_vspltish */
10288
10289// FIXME: parameter should be treated as 5-bit signed literal
10290static __inline__ vector short __ATTRS_o_ai vec_vspltish(signed char __a) {
10291 return (vector short)(__a);
10292}
10293
10294/* vec_splat_s32 */
10295
10296#define __builtin_altivec_vspltisw vec_splat_s32
10297
10298// FIXME: parameter should be treated as 5-bit signed literal
10299static __inline__ vector int __ATTRS_o_ai vec_splat_s32(signed char __a) {
10300 return (vector int)(__a);
10301}
10302
10303/* vec_vspltisw */
10304
10305// FIXME: parameter should be treated as 5-bit signed literal
10306static __inline__ vector int __ATTRS_o_ai vec_vspltisw(signed char __a) {
10307 return (vector int)(__a);
10308}
10309
10310/* vec_splat_u8 */
10311
10312// FIXME: parameter should be treated as 5-bit signed literal
10313static __inline__ vector unsigned char __ATTRS_o_ai
10314vec_splat_u8(unsigned char __a) {
10315 return (vector unsigned char)(__a);
10316}
10317
10318/* vec_splat_u16 */
10319
10320// FIXME: parameter should be treated as 5-bit signed literal
10321static __inline__ vector unsigned short __ATTRS_o_ai
10322vec_splat_u16(signed char __a) {
10323 return (vector unsigned short)(__a);
10324}
10325
10326/* vec_splat_u32 */
10327
10328// FIXME: parameter should be treated as 5-bit signed literal
10329static __inline__ vector unsigned int __ATTRS_o_ai
10330vec_splat_u32(signed char __a) {
10331 return (vector unsigned int)(__a);
10332}
10333
10334/* vec_sr */
10335
Logan Chiendbcf4122019-03-21 10:50:25 +080010336// vec_sr does modulo arithmetic on __b first, so __b is allowed to be more
10337// than the length of __a.
Logan Chien2833ffb2018-10-09 10:03:24 +080010338static __inline__ vector unsigned char __ATTRS_o_ai
10339vec_sr(vector unsigned char __a, vector unsigned char __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010340 return __a >>
10341 (__b % (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +080010342}
10343
Logan Chiendbcf4122019-03-21 10:50:25 +080010344static __inline__ vector signed char __ATTRS_o_ai
10345vec_sr(vector signed char __a, vector unsigned char __b) {
10346 return (vector signed char)vec_sr((vector unsigned char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010347}
10348
10349static __inline__ vector unsigned short __ATTRS_o_ai
10350vec_sr(vector unsigned short __a, vector unsigned short __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010351 return __a >>
10352 (__b % (vector unsigned short)(sizeof(unsigned short) * __CHAR_BIT__));
Logan Chien2833ffb2018-10-09 10:03:24 +080010353}
10354
Logan Chiendbcf4122019-03-21 10:50:25 +080010355static __inline__ vector short __ATTRS_o_ai vec_sr(vector short __a,
10356 vector unsigned short __b) {
10357 return (vector short)vec_sr((vector unsigned short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010358}
10359
10360static __inline__ vector unsigned int __ATTRS_o_ai
10361vec_sr(vector unsigned int __a, vector unsigned int __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010362 return __a >>
10363 (__b % (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
10364}
10365
10366static __inline__ vector int __ATTRS_o_ai vec_sr(vector int __a,
10367 vector unsigned int __b) {
10368 return (vector int)vec_sr((vector unsigned int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010369}
10370
10371#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080010372static __inline__ vector unsigned long long __ATTRS_o_ai
10373vec_sr(vector unsigned long long __a, vector unsigned long long __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010374 return __a >> (__b % (vector unsigned long long)(sizeof(unsigned long long) *
10375 __CHAR_BIT__));
10376}
10377
10378static __inline__ vector long long __ATTRS_o_ai
10379vec_sr(vector long long __a, vector unsigned long long __b) {
10380 return (vector long long)vec_sr((vector unsigned long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010381}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080010382#elif defined(__VSX__)
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070010383static __inline__ vector unsigned long long __ATTRS_o_ai
10384vec_sr(vector unsigned long long __a, vector unsigned long long __b) {
10385 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
10386
10387 // Big endian element zero (the left doubleword) can be right shifted as-is.
10388 // However the shift amount must be in the right doubleword.
10389 // The other element needs to be swapped into the left doubleword and
10390 // shifted. Then the left doublewords of the two result vectors are merged.
10391 vector unsigned long long __swapshift =
10392 __builtin_shufflevector(__b, __b, 1, 0);
10393 vector unsigned long long __leftelt =
10394 (vector unsigned long long)__builtin_altivec_vsro(
10395 (vector signed int)__a, (vector signed int)__swapshift);
10396#ifdef __LITTLE_ENDIAN__
10397 __leftelt = (vector unsigned long long)__builtin_altivec_vsr(
10398 (vector signed int)__leftelt,
10399 (vector signed int)vec_vspltb((vector unsigned char)__swapshift, 0));
10400#else
10401 __leftelt = (vector unsigned long long)__builtin_altivec_vsr(
10402 (vector signed int)__leftelt,
10403 (vector signed int)vec_vspltb((vector unsigned char)__swapshift, 15));
10404#endif
10405 __a = __builtin_shufflevector(__a, __a, 1, 0);
10406 vector unsigned long long __rightelt =
10407 (vector unsigned long long)__builtin_altivec_vsro((vector signed int)__a,
10408 (vector signed int)__b);
10409#ifdef __LITTLE_ENDIAN__
10410 __rightelt = (vector unsigned long long)__builtin_altivec_vsr(
10411 (vector signed int)__rightelt,
10412 (vector signed int)vec_vspltb((vector unsigned char)__b, 0));
10413 return __builtin_shufflevector(__rightelt, __leftelt, 1, 3);
10414#else
10415 __rightelt = (vector unsigned long long)__builtin_altivec_vsr(
10416 (vector signed int)__rightelt,
10417 (vector signed int)vec_vspltb((vector unsigned char)__b, 15));
10418 return __builtin_shufflevector(__leftelt, __rightelt, 0, 2);
10419#endif
10420}
10421
10422static __inline__ vector long long __ATTRS_o_ai
10423vec_sr(vector long long __a, vector unsigned long long __b) {
10424 return (vector long long)vec_sr((vector unsigned long long)__a, __b);
10425}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080010426#endif /* __VSX__ */
Logan Chien2833ffb2018-10-09 10:03:24 +080010427
10428/* vec_vsrb */
10429
10430#define __builtin_altivec_vsrb vec_vsrb
10431
10432static __inline__ vector signed char __ATTRS_o_ai
10433vec_vsrb(vector signed char __a, vector unsigned char __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010434 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010435}
10436
10437static __inline__ vector unsigned char __ATTRS_o_ai
10438vec_vsrb(vector unsigned char __a, vector unsigned char __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010439 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010440}
10441
10442/* vec_vsrh */
10443
10444#define __builtin_altivec_vsrh vec_vsrh
10445
10446static __inline__ vector short __ATTRS_o_ai
10447vec_vsrh(vector short __a, vector unsigned short __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010448 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010449}
10450
10451static __inline__ vector unsigned short __ATTRS_o_ai
10452vec_vsrh(vector unsigned short __a, vector unsigned short __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010453 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010454}
10455
10456/* vec_vsrw */
10457
10458#define __builtin_altivec_vsrw vec_vsrw
10459
10460static __inline__ vector int __ATTRS_o_ai vec_vsrw(vector int __a,
10461 vector unsigned int __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010462 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010463}
10464
10465static __inline__ vector unsigned int __ATTRS_o_ai
10466vec_vsrw(vector unsigned int __a, vector unsigned int __b) {
Logan Chiendbcf4122019-03-21 10:50:25 +080010467 return vec_sr(__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080010468}
10469
10470/* vec_sra */
10471
10472static __inline__ vector signed char __ATTRS_o_ai
10473vec_sra(vector signed char __a, vector unsigned char __b) {
10474 return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b);
10475}
10476
10477static __inline__ vector unsigned char __ATTRS_o_ai
10478vec_sra(vector unsigned char __a, vector unsigned char __b) {
10479 return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b);
10480}
10481
10482static __inline__ vector short __ATTRS_o_ai vec_sra(vector short __a,
10483 vector unsigned short __b) {
10484 return __builtin_altivec_vsrah(__a, (vector unsigned short)__b);
10485}
10486
10487static __inline__ vector unsigned short __ATTRS_o_ai
10488vec_sra(vector unsigned short __a, vector unsigned short __b) {
10489 return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b);
10490}
10491
10492static __inline__ vector int __ATTRS_o_ai vec_sra(vector int __a,
10493 vector unsigned int __b) {
10494 return __builtin_altivec_vsraw(__a, __b);
10495}
10496
10497static __inline__ vector unsigned int __ATTRS_o_ai
10498vec_sra(vector unsigned int __a, vector unsigned int __b) {
10499 return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b);
10500}
10501
10502#ifdef __POWER8_VECTOR__
10503static __inline__ vector signed long long __ATTRS_o_ai
10504vec_sra(vector signed long long __a, vector unsigned long long __b) {
10505 return __a >> __b;
10506}
10507
10508static __inline__ vector unsigned long long __ATTRS_o_ai
10509vec_sra(vector unsigned long long __a, vector unsigned long long __b) {
10510 return (vector unsigned long long)((vector signed long long)__a >> __b);
10511}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080010512#elif defined(__VSX__)
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070010513static __inline__ vector signed long long __ATTRS_o_ai
10514vec_sra(vector signed long long __a, vector unsigned long long __b) {
10515 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
10516 return __a >> __b;
10517}
10518
10519static __inline__ vector unsigned long long __ATTRS_o_ai
10520vec_sra(vector unsigned long long __a, vector unsigned long long __b) {
10521 __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__);
10522 return (vector unsigned long long)((vector signed long long)__a >> __b);
10523}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080010524#endif /* __VSX__ */
Logan Chien2833ffb2018-10-09 10:03:24 +080010525
10526/* vec_vsrab */
10527
10528static __inline__ vector signed char __ATTRS_o_ai
10529vec_vsrab(vector signed char __a, vector unsigned char __b) {
10530 return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b);
10531}
10532
10533static __inline__ vector unsigned char __ATTRS_o_ai
10534vec_vsrab(vector unsigned char __a, vector unsigned char __b) {
10535 return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b);
10536}
10537
10538/* vec_vsrah */
10539
10540static __inline__ vector short __ATTRS_o_ai
10541vec_vsrah(vector short __a, vector unsigned short __b) {
10542 return __builtin_altivec_vsrah(__a, (vector unsigned short)__b);
10543}
10544
10545static __inline__ vector unsigned short __ATTRS_o_ai
10546vec_vsrah(vector unsigned short __a, vector unsigned short __b) {
10547 return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b);
10548}
10549
10550/* vec_vsraw */
10551
10552static __inline__ vector int __ATTRS_o_ai vec_vsraw(vector int __a,
10553 vector unsigned int __b) {
10554 return __builtin_altivec_vsraw(__a, __b);
10555}
10556
10557static __inline__ vector unsigned int __ATTRS_o_ai
10558vec_vsraw(vector unsigned int __a, vector unsigned int __b) {
10559 return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b);
10560}
10561
10562/* vec_srl */
10563
10564static __inline__ vector signed char __ATTRS_o_ai
10565vec_srl(vector signed char __a, vector unsigned char __b) {
10566 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10567 (vector int)__b);
10568}
10569
10570static __inline__ vector signed char __ATTRS_o_ai
10571vec_srl(vector signed char __a, vector unsigned short __b) {
10572 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10573 (vector int)__b);
10574}
10575
10576static __inline__ vector signed char __ATTRS_o_ai
10577vec_srl(vector signed char __a, vector unsigned int __b) {
10578 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10579 (vector int)__b);
10580}
10581
10582static __inline__ vector unsigned char __ATTRS_o_ai
10583vec_srl(vector unsigned char __a, vector unsigned char __b) {
10584 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10585 (vector int)__b);
10586}
10587
10588static __inline__ vector unsigned char __ATTRS_o_ai
10589vec_srl(vector unsigned char __a, vector unsigned short __b) {
10590 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10591 (vector int)__b);
10592}
10593
10594static __inline__ vector unsigned char __ATTRS_o_ai
10595vec_srl(vector unsigned char __a, vector unsigned int __b) {
10596 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10597 (vector int)__b);
10598}
10599
10600static __inline__ vector bool char __ATTRS_o_ai
10601vec_srl(vector bool char __a, vector unsigned char __b) {
10602 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10603 (vector int)__b);
10604}
10605
10606static __inline__ vector bool char __ATTRS_o_ai
10607vec_srl(vector bool char __a, vector unsigned short __b) {
10608 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10609 (vector int)__b);
10610}
10611
10612static __inline__ vector bool char __ATTRS_o_ai
10613vec_srl(vector bool char __a, vector unsigned int __b) {
10614 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10615 (vector int)__b);
10616}
10617
10618static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
10619 vector unsigned char __b) {
10620 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10621}
10622
10623static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
10624 vector unsigned short __b) {
10625 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10626}
10627
10628static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
10629 vector unsigned int __b) {
10630 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10631}
10632
10633static __inline__ vector unsigned short __ATTRS_o_ai
10634vec_srl(vector unsigned short __a, vector unsigned char __b) {
10635 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10636 (vector int)__b);
10637}
10638
10639static __inline__ vector unsigned short __ATTRS_o_ai
10640vec_srl(vector unsigned short __a, vector unsigned short __b) {
10641 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10642 (vector int)__b);
10643}
10644
10645static __inline__ vector unsigned short __ATTRS_o_ai
10646vec_srl(vector unsigned short __a, vector unsigned int __b) {
10647 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10648 (vector int)__b);
10649}
10650
10651static __inline__ vector bool short __ATTRS_o_ai
10652vec_srl(vector bool short __a, vector unsigned char __b) {
10653 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10654 (vector int)__b);
10655}
10656
10657static __inline__ vector bool short __ATTRS_o_ai
10658vec_srl(vector bool short __a, vector unsigned short __b) {
10659 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10660 (vector int)__b);
10661}
10662
10663static __inline__ vector bool short __ATTRS_o_ai
10664vec_srl(vector bool short __a, vector unsigned int __b) {
10665 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10666 (vector int)__b);
10667}
10668
10669static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
10670 vector unsigned char __b) {
10671 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10672}
10673
10674static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
10675 vector unsigned short __b) {
10676 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10677}
10678
10679static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
10680 vector unsigned int __b) {
10681 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10682}
10683
10684static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
10685 vector unsigned char __b) {
10686 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10687}
10688
10689static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
10690 vector unsigned short __b) {
10691 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10692}
10693
10694static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
10695 vector unsigned int __b) {
10696 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10697}
10698
10699static __inline__ vector unsigned int __ATTRS_o_ai
10700vec_srl(vector unsigned int __a, vector unsigned char __b) {
10701 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10702 (vector int)__b);
10703}
10704
10705static __inline__ vector unsigned int __ATTRS_o_ai
10706vec_srl(vector unsigned int __a, vector unsigned short __b) {
10707 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10708 (vector int)__b);
10709}
10710
10711static __inline__ vector unsigned int __ATTRS_o_ai
10712vec_srl(vector unsigned int __a, vector unsigned int __b) {
10713 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10714 (vector int)__b);
10715}
10716
10717static __inline__ vector bool int __ATTRS_o_ai
10718vec_srl(vector bool int __a, vector unsigned char __b) {
10719 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10720 (vector int)__b);
10721}
10722
10723static __inline__ vector bool int __ATTRS_o_ai
10724vec_srl(vector bool int __a, vector unsigned short __b) {
10725 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10726 (vector int)__b);
10727}
10728
10729static __inline__ vector bool int __ATTRS_o_ai
10730vec_srl(vector bool int __a, vector unsigned int __b) {
10731 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10732 (vector int)__b);
10733}
10734
Logan Chien55afb0a2018-10-15 10:42:14 +080010735#ifdef __VSX__
10736static __inline__ vector signed long long __ATTRS_o_ai
10737vec_srl(vector signed long long __a, vector unsigned char __b) {
10738 return (vector signed long long)__builtin_altivec_vsr((vector int)__a,
10739 (vector int)__b);
10740}
10741
10742static __inline__ vector unsigned long long __ATTRS_o_ai
10743vec_srl(vector unsigned long long __a, vector unsigned char __b) {
10744 return (vector unsigned long long)__builtin_altivec_vsr((vector int)__a,
10745 (vector int)__b);
10746}
10747#endif
10748
Logan Chien2833ffb2018-10-09 10:03:24 +080010749/* vec_vsr */
10750
10751static __inline__ vector signed char __ATTRS_o_ai
10752vec_vsr(vector signed char __a, vector unsigned char __b) {
10753 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10754 (vector int)__b);
10755}
10756
10757static __inline__ vector signed char __ATTRS_o_ai
10758vec_vsr(vector signed char __a, vector unsigned short __b) {
10759 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10760 (vector int)__b);
10761}
10762
10763static __inline__ vector signed char __ATTRS_o_ai
10764vec_vsr(vector signed char __a, vector unsigned int __b) {
10765 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
10766 (vector int)__b);
10767}
10768
10769static __inline__ vector unsigned char __ATTRS_o_ai
10770vec_vsr(vector unsigned char __a, vector unsigned char __b) {
10771 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10772 (vector int)__b);
10773}
10774
10775static __inline__ vector unsigned char __ATTRS_o_ai
10776vec_vsr(vector unsigned char __a, vector unsigned short __b) {
10777 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10778 (vector int)__b);
10779}
10780
10781static __inline__ vector unsigned char __ATTRS_o_ai
10782vec_vsr(vector unsigned char __a, vector unsigned int __b) {
10783 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
10784 (vector int)__b);
10785}
10786
10787static __inline__ vector bool char __ATTRS_o_ai
10788vec_vsr(vector bool char __a, vector unsigned char __b) {
10789 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10790 (vector int)__b);
10791}
10792
10793static __inline__ vector bool char __ATTRS_o_ai
10794vec_vsr(vector bool char __a, vector unsigned short __b) {
10795 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10796 (vector int)__b);
10797}
10798
10799static __inline__ vector bool char __ATTRS_o_ai
10800vec_vsr(vector bool char __a, vector unsigned int __b) {
10801 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
10802 (vector int)__b);
10803}
10804
10805static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
10806 vector unsigned char __b) {
10807 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10808}
10809
10810static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
10811 vector unsigned short __b) {
10812 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10813}
10814
10815static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
10816 vector unsigned int __b) {
10817 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10818}
10819
10820static __inline__ vector unsigned short __ATTRS_o_ai
10821vec_vsr(vector unsigned short __a, vector unsigned char __b) {
10822 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10823 (vector int)__b);
10824}
10825
10826static __inline__ vector unsigned short __ATTRS_o_ai
10827vec_vsr(vector unsigned short __a, vector unsigned short __b) {
10828 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10829 (vector int)__b);
10830}
10831
10832static __inline__ vector unsigned short __ATTRS_o_ai
10833vec_vsr(vector unsigned short __a, vector unsigned int __b) {
10834 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
10835 (vector int)__b);
10836}
10837
10838static __inline__ vector bool short __ATTRS_o_ai
10839vec_vsr(vector bool short __a, vector unsigned char __b) {
10840 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10841 (vector int)__b);
10842}
10843
10844static __inline__ vector bool short __ATTRS_o_ai
10845vec_vsr(vector bool short __a, vector unsigned short __b) {
10846 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10847 (vector int)__b);
10848}
10849
10850static __inline__ vector bool short __ATTRS_o_ai
10851vec_vsr(vector bool short __a, vector unsigned int __b) {
10852 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
10853 (vector int)__b);
10854}
10855
10856static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
10857 vector unsigned char __b) {
10858 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10859}
10860
10861static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
10862 vector unsigned short __b) {
10863 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10864}
10865
10866static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
10867 vector unsigned int __b) {
10868 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
10869}
10870
10871static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
10872 vector unsigned char __b) {
10873 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10874}
10875
10876static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
10877 vector unsigned short __b) {
10878 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10879}
10880
10881static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
10882 vector unsigned int __b) {
10883 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
10884}
10885
10886static __inline__ vector unsigned int __ATTRS_o_ai
10887vec_vsr(vector unsigned int __a, vector unsigned char __b) {
10888 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10889 (vector int)__b);
10890}
10891
10892static __inline__ vector unsigned int __ATTRS_o_ai
10893vec_vsr(vector unsigned int __a, vector unsigned short __b) {
10894 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10895 (vector int)__b);
10896}
10897
10898static __inline__ vector unsigned int __ATTRS_o_ai
10899vec_vsr(vector unsigned int __a, vector unsigned int __b) {
10900 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
10901 (vector int)__b);
10902}
10903
10904static __inline__ vector bool int __ATTRS_o_ai
10905vec_vsr(vector bool int __a, vector unsigned char __b) {
10906 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10907 (vector int)__b);
10908}
10909
10910static __inline__ vector bool int __ATTRS_o_ai
10911vec_vsr(vector bool int __a, vector unsigned short __b) {
10912 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10913 (vector int)__b);
10914}
10915
10916static __inline__ vector bool int __ATTRS_o_ai
10917vec_vsr(vector bool int __a, vector unsigned int __b) {
10918 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
10919 (vector int)__b);
10920}
10921
10922/* vec_sro */
10923
10924static __inline__ vector signed char __ATTRS_o_ai
10925vec_sro(vector signed char __a, vector signed char __b) {
10926 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
10927 (vector int)__b);
10928}
10929
10930static __inline__ vector signed char __ATTRS_o_ai
10931vec_sro(vector signed char __a, vector unsigned char __b) {
10932 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
10933 (vector int)__b);
10934}
10935
10936static __inline__ vector unsigned char __ATTRS_o_ai
10937vec_sro(vector unsigned char __a, vector signed char __b) {
10938 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
10939 (vector int)__b);
10940}
10941
10942static __inline__ vector unsigned char __ATTRS_o_ai
10943vec_sro(vector unsigned char __a, vector unsigned char __b) {
10944 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
10945 (vector int)__b);
10946}
10947
10948static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a,
10949 vector signed char __b) {
10950 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10951}
10952
10953static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a,
10954 vector unsigned char __b) {
10955 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10956}
10957
10958static __inline__ vector unsigned short __ATTRS_o_ai
10959vec_sro(vector unsigned short __a, vector signed char __b) {
10960 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
10961 (vector int)__b);
10962}
10963
10964static __inline__ vector unsigned short __ATTRS_o_ai
10965vec_sro(vector unsigned short __a, vector unsigned char __b) {
10966 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
10967 (vector int)__b);
10968}
10969
10970static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a,
10971 vector signed char __b) {
10972 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10973}
10974
10975static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a,
10976 vector unsigned char __b) {
10977 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
10978}
10979
10980static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a,
10981 vector signed char __b) {
10982 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
10983}
10984
10985static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a,
10986 vector unsigned char __b) {
10987 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
10988}
10989
10990static __inline__ vector unsigned int __ATTRS_o_ai
10991vec_sro(vector unsigned int __a, vector signed char __b) {
10992 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
10993 (vector int)__b);
10994}
10995
10996static __inline__ vector unsigned int __ATTRS_o_ai
10997vec_sro(vector unsigned int __a, vector unsigned char __b) {
10998 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
10999 (vector int)__b);
11000}
11001
11002static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a,
11003 vector signed char __b) {
11004 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11005}
11006
11007static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a,
11008 vector unsigned char __b) {
11009 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11010}
11011
Logan Chien55afb0a2018-10-15 10:42:14 +080011012#ifdef __VSX__
11013static __inline__ vector signed long long __ATTRS_o_ai
11014vec_sro(vector signed long long __a, vector signed char __b) {
11015 return (vector signed long long)__builtin_altivec_vsro((vector int)__a,
11016 (vector int)__b);
11017}
11018
11019static __inline__ vector signed long long __ATTRS_o_ai
11020vec_sro(vector signed long long __a, vector unsigned char __b) {
11021 return (vector signed long long)__builtin_altivec_vsro((vector int)__a,
11022 (vector int)__b);
11023}
11024
11025static __inline__ vector unsigned long long __ATTRS_o_ai
11026vec_sro(vector unsigned long long __a, vector signed char __b) {
11027 return (vector unsigned long long)__builtin_altivec_vsro((vector int)__a,
11028 (vector int)__b);
11029}
11030
11031static __inline__ vector unsigned long long __ATTRS_o_ai
11032vec_sro(vector unsigned long long __a, vector unsigned char __b) {
11033 return (vector unsigned long long)__builtin_altivec_vsro((vector int)__a,
11034 (vector int)__b);
11035}
11036#endif
11037
Logan Chien2833ffb2018-10-09 10:03:24 +080011038/* vec_vsro */
11039
11040static __inline__ vector signed char __ATTRS_o_ai
11041vec_vsro(vector signed char __a, vector signed char __b) {
11042 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
11043 (vector int)__b);
11044}
11045
11046static __inline__ vector signed char __ATTRS_o_ai
11047vec_vsro(vector signed char __a, vector unsigned char __b) {
11048 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
11049 (vector int)__b);
11050}
11051
11052static __inline__ vector unsigned char __ATTRS_o_ai
11053vec_vsro(vector unsigned char __a, vector signed char __b) {
11054 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
11055 (vector int)__b);
11056}
11057
11058static __inline__ vector unsigned char __ATTRS_o_ai
11059vec_vsro(vector unsigned char __a, vector unsigned char __b) {
11060 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
11061 (vector int)__b);
11062}
11063
11064static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a,
11065 vector signed char __b) {
11066 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11067}
11068
11069static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a,
11070 vector unsigned char __b) {
11071 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11072}
11073
11074static __inline__ vector unsigned short __ATTRS_o_ai
11075vec_vsro(vector unsigned short __a, vector signed char __b) {
11076 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
11077 (vector int)__b);
11078}
11079
11080static __inline__ vector unsigned short __ATTRS_o_ai
11081vec_vsro(vector unsigned short __a, vector unsigned char __b) {
11082 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
11083 (vector int)__b);
11084}
11085
11086static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a,
11087 vector signed char __b) {
11088 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11089}
11090
11091static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a,
11092 vector unsigned char __b) {
11093 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11094}
11095
11096static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a,
11097 vector signed char __b) {
11098 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
11099}
11100
11101static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a,
11102 vector unsigned char __b) {
11103 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
11104}
11105
11106static __inline__ vector unsigned int __ATTRS_o_ai
11107vec_vsro(vector unsigned int __a, vector signed char __b) {
11108 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
11109 (vector int)__b);
11110}
11111
11112static __inline__ vector unsigned int __ATTRS_o_ai
11113vec_vsro(vector unsigned int __a, vector unsigned char __b) {
11114 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
11115 (vector int)__b);
11116}
11117
11118static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a,
11119 vector signed char __b) {
11120 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11121}
11122
11123static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a,
11124 vector unsigned char __b) {
11125 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
11126}
11127
11128/* vec_st */
11129
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011130static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011131 vector signed char *__c) {
11132 __builtin_altivec_stvx((vector int)__a, __b, __c);
11133}
11134
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011135static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011136 signed char *__c) {
11137 __builtin_altivec_stvx((vector int)__a, __b, __c);
11138}
11139
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011140static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011141 vector unsigned char *__c) {
11142 __builtin_altivec_stvx((vector int)__a, __b, __c);
11143}
11144
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011145static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011146 unsigned char *__c) {
11147 __builtin_altivec_stvx((vector int)__a, __b, __c);
11148}
11149
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011150static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011151 signed char *__c) {
11152 __builtin_altivec_stvx((vector int)__a, __b, __c);
11153}
11154
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011155static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011156 unsigned char *__c) {
11157 __builtin_altivec_stvx((vector int)__a, __b, __c);
11158}
11159
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011160static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011161 vector bool char *__c) {
11162 __builtin_altivec_stvx((vector int)__a, __b, __c);
11163}
11164
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011165static __inline__ void __ATTRS_o_ai vec_st(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011166 vector short *__c) {
11167 __builtin_altivec_stvx((vector int)__a, __b, __c);
11168}
11169
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011170static __inline__ void __ATTRS_o_ai vec_st(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011171 short *__c) {
11172 __builtin_altivec_stvx((vector int)__a, __b, __c);
11173}
11174
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011175static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011176 vector unsigned short *__c) {
11177 __builtin_altivec_stvx((vector int)__a, __b, __c);
11178}
11179
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011180static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011181 unsigned short *__c) {
11182 __builtin_altivec_stvx((vector int)__a, __b, __c);
11183}
11184
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011185static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011186 short *__c) {
11187 __builtin_altivec_stvx((vector int)__a, __b, __c);
11188}
11189
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011190static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011191 unsigned short *__c) {
11192 __builtin_altivec_stvx((vector int)__a, __b, __c);
11193}
11194
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011195static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011196 vector bool short *__c) {
11197 __builtin_altivec_stvx((vector int)__a, __b, __c);
11198}
11199
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011200static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011201 short *__c) {
11202 __builtin_altivec_stvx((vector int)__a, __b, __c);
11203}
11204
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011205static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011206 unsigned short *__c) {
11207 __builtin_altivec_stvx((vector int)__a, __b, __c);
11208}
11209
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011210static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011211 vector pixel *__c) {
11212 __builtin_altivec_stvx((vector int)__a, __b, __c);
11213}
11214
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011215static __inline__ void __ATTRS_o_ai vec_st(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011216 vector int *__c) {
11217 __builtin_altivec_stvx(__a, __b, __c);
11218}
11219
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011220static __inline__ void __ATTRS_o_ai vec_st(vector int __a, long __b, int *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011221 __builtin_altivec_stvx(__a, __b, __c);
11222}
11223
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011224static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011225 vector unsigned int *__c) {
11226 __builtin_altivec_stvx((vector int)__a, __b, __c);
11227}
11228
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011229static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011230 unsigned int *__c) {
11231 __builtin_altivec_stvx((vector int)__a, __b, __c);
11232}
11233
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011234static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011235 int *__c) {
11236 __builtin_altivec_stvx((vector int)__a, __b, __c);
11237}
11238
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011239static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011240 unsigned int *__c) {
11241 __builtin_altivec_stvx((vector int)__a, __b, __c);
11242}
11243
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011244static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011245 vector bool int *__c) {
11246 __builtin_altivec_stvx((vector int)__a, __b, __c);
11247}
11248
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011249static __inline__ void __ATTRS_o_ai vec_st(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011250 vector float *__c) {
11251 __builtin_altivec_stvx((vector int)__a, __b, __c);
11252}
11253
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011254static __inline__ void __ATTRS_o_ai vec_st(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011255 float *__c) {
11256 __builtin_altivec_stvx((vector int)__a, __b, __c);
11257}
11258
11259/* vec_stvx */
11260
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011261static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011262 vector signed char *__c) {
11263 __builtin_altivec_stvx((vector int)__a, __b, __c);
11264}
11265
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011266static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011267 signed char *__c) {
11268 __builtin_altivec_stvx((vector int)__a, __b, __c);
11269}
11270
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011271static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011272 vector unsigned char *__c) {
11273 __builtin_altivec_stvx((vector int)__a, __b, __c);
11274}
11275
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011276static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011277 unsigned char *__c) {
11278 __builtin_altivec_stvx((vector int)__a, __b, __c);
11279}
11280
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011281static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011282 signed char *__c) {
11283 __builtin_altivec_stvx((vector int)__a, __b, __c);
11284}
11285
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011286static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011287 unsigned char *__c) {
11288 __builtin_altivec_stvx((vector int)__a, __b, __c);
11289}
11290
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011291static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011292 vector bool char *__c) {
11293 __builtin_altivec_stvx((vector int)__a, __b, __c);
11294}
11295
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011296static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011297 vector short *__c) {
11298 __builtin_altivec_stvx((vector int)__a, __b, __c);
11299}
11300
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011301static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011302 short *__c) {
11303 __builtin_altivec_stvx((vector int)__a, __b, __c);
11304}
11305
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011306static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011307 vector unsigned short *__c) {
11308 __builtin_altivec_stvx((vector int)__a, __b, __c);
11309}
11310
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011311static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011312 unsigned short *__c) {
11313 __builtin_altivec_stvx((vector int)__a, __b, __c);
11314}
11315
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011316static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011317 short *__c) {
11318 __builtin_altivec_stvx((vector int)__a, __b, __c);
11319}
11320
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011321static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011322 unsigned short *__c) {
11323 __builtin_altivec_stvx((vector int)__a, __b, __c);
11324}
11325
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011326static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011327 vector bool short *__c) {
11328 __builtin_altivec_stvx((vector int)__a, __b, __c);
11329}
11330
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011331static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011332 short *__c) {
11333 __builtin_altivec_stvx((vector int)__a, __b, __c);
11334}
11335
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011336static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011337 unsigned short *__c) {
11338 __builtin_altivec_stvx((vector int)__a, __b, __c);
11339}
11340
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011341static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011342 vector pixel *__c) {
11343 __builtin_altivec_stvx((vector int)__a, __b, __c);
11344}
11345
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011346static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011347 vector int *__c) {
11348 __builtin_altivec_stvx(__a, __b, __c);
11349}
11350
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011351static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011352 int *__c) {
11353 __builtin_altivec_stvx(__a, __b, __c);
11354}
11355
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011356static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011357 vector unsigned int *__c) {
11358 __builtin_altivec_stvx((vector int)__a, __b, __c);
11359}
11360
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011361static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011362 unsigned int *__c) {
11363 __builtin_altivec_stvx((vector int)__a, __b, __c);
11364}
11365
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011366static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011367 int *__c) {
11368 __builtin_altivec_stvx((vector int)__a, __b, __c);
11369}
11370
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011371static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011372 unsigned int *__c) {
11373 __builtin_altivec_stvx((vector int)__a, __b, __c);
11374}
11375
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011376static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011377 vector bool int *__c) {
11378 __builtin_altivec_stvx((vector int)__a, __b, __c);
11379}
11380
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011381static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011382 vector float *__c) {
11383 __builtin_altivec_stvx((vector int)__a, __b, __c);
11384}
11385
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011386static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011387 float *__c) {
11388 __builtin_altivec_stvx((vector int)__a, __b, __c);
11389}
11390
11391/* vec_ste */
11392
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011393static __inline__ void __ATTRS_o_ai vec_ste(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011394 signed char *__c) {
11395 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11396}
11397
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011398static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011399 unsigned char *__c) {
11400 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11401}
11402
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011403static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011404 signed char *__c) {
11405 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11406}
11407
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011408static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011409 unsigned char *__c) {
11410 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11411}
11412
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011413static __inline__ void __ATTRS_o_ai vec_ste(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011414 short *__c) {
11415 __builtin_altivec_stvehx(__a, __b, __c);
11416}
11417
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011418static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011419 unsigned short *__c) {
11420 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11421}
11422
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011423static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011424 short *__c) {
11425 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11426}
11427
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011428static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011429 unsigned short *__c) {
11430 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11431}
11432
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011433static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011434 short *__c) {
11435 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11436}
11437
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011438static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011439 unsigned short *__c) {
11440 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11441}
11442
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011443static __inline__ void __ATTRS_o_ai vec_ste(vector int __a, long __b, int *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011444 __builtin_altivec_stvewx(__a, __b, __c);
11445}
11446
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011447static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011448 unsigned int *__c) {
11449 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11450}
11451
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011452static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011453 int *__c) {
11454 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11455}
11456
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011457static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011458 unsigned int *__c) {
11459 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11460}
11461
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011462static __inline__ void __ATTRS_o_ai vec_ste(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011463 float *__c) {
11464 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11465}
11466
11467/* vec_stvebx */
11468
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011469static __inline__ void __ATTRS_o_ai vec_stvebx(vector signed char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011470 signed char *__c) {
11471 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11472}
11473
11474static __inline__ void __ATTRS_o_ai vec_stvebx(vector unsigned char __a,
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011475 long __b, unsigned char *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011476 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11477}
11478
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011479static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011480 signed char *__c) {
11481 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11482}
11483
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011484static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011485 unsigned char *__c) {
11486 __builtin_altivec_stvebx((vector char)__a, __b, __c);
11487}
11488
11489/* vec_stvehx */
11490
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011491static __inline__ void __ATTRS_o_ai vec_stvehx(vector short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011492 short *__c) {
11493 __builtin_altivec_stvehx(__a, __b, __c);
11494}
11495
11496static __inline__ void __ATTRS_o_ai vec_stvehx(vector unsigned short __a,
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011497 long __b, unsigned short *__c) {
Logan Chien2833ffb2018-10-09 10:03:24 +080011498 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11499}
11500
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011501static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011502 short *__c) {
11503 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11504}
11505
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011506static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011507 unsigned short *__c) {
11508 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11509}
11510
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011511static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011512 short *__c) {
11513 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11514}
11515
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011516static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011517 unsigned short *__c) {
11518 __builtin_altivec_stvehx((vector short)__a, __b, __c);
11519}
11520
11521/* vec_stvewx */
11522
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011523static __inline__ void __ATTRS_o_ai vec_stvewx(vector int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011524 int *__c) {
11525 __builtin_altivec_stvewx(__a, __b, __c);
11526}
11527
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011528static __inline__ void __ATTRS_o_ai vec_stvewx(vector unsigned int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011529 unsigned int *__c) {
11530 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11531}
11532
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011533static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011534 int *__c) {
11535 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11536}
11537
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011538static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011539 unsigned int *__c) {
11540 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11541}
11542
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080011543static __inline__ void __ATTRS_o_ai vec_stvewx(vector float __a, long __b,
Logan Chien2833ffb2018-10-09 10:03:24 +080011544 float *__c) {
11545 __builtin_altivec_stvewx((vector int)__a, __b, __c);
11546}
11547
11548/* vec_stl */
11549
11550static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b,
11551 vector signed char *__c) {
11552 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11553}
11554
11555static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b,
11556 signed char *__c) {
11557 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11558}
11559
11560static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b,
11561 vector unsigned char *__c) {
11562 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11563}
11564
11565static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b,
11566 unsigned char *__c) {
11567 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11568}
11569
11570static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
11571 signed char *__c) {
11572 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11573}
11574
11575static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
11576 unsigned char *__c) {
11577 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11578}
11579
11580static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
11581 vector bool char *__c) {
11582 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11583}
11584
11585static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b,
11586 vector short *__c) {
11587 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11588}
11589
11590static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b,
11591 short *__c) {
11592 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11593}
11594
11595static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b,
11596 vector unsigned short *__c) {
11597 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11598}
11599
11600static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b,
11601 unsigned short *__c) {
11602 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11603}
11604
11605static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
11606 short *__c) {
11607 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11608}
11609
11610static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
11611 unsigned short *__c) {
11612 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11613}
11614
11615static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
11616 vector bool short *__c) {
11617 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11618}
11619
11620static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
11621 short *__c) {
11622 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11623}
11624
11625static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
11626 unsigned short *__c) {
11627 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11628}
11629
11630static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
11631 vector pixel *__c) {
11632 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11633}
11634
11635static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b,
11636 vector int *__c) {
11637 __builtin_altivec_stvxl(__a, __b, __c);
11638}
11639
11640static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b, int *__c) {
11641 __builtin_altivec_stvxl(__a, __b, __c);
11642}
11643
11644static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b,
11645 vector unsigned int *__c) {
11646 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11647}
11648
11649static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b,
11650 unsigned int *__c) {
11651 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11652}
11653
11654static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
11655 int *__c) {
11656 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11657}
11658
11659static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
11660 unsigned int *__c) {
11661 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11662}
11663
11664static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
11665 vector bool int *__c) {
11666 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11667}
11668
11669static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b,
11670 vector float *__c) {
11671 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11672}
11673
11674static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b,
11675 float *__c) {
11676 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11677}
11678
11679/* vec_stvxl */
11680
11681static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b,
11682 vector signed char *__c) {
11683 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11684}
11685
11686static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b,
11687 signed char *__c) {
11688 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11689}
11690
11691static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b,
11692 vector unsigned char *__c) {
11693 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11694}
11695
11696static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b,
11697 unsigned char *__c) {
11698 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11699}
11700
11701static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
11702 signed char *__c) {
11703 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11704}
11705
11706static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
11707 unsigned char *__c) {
11708 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11709}
11710
11711static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
11712 vector bool char *__c) {
11713 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11714}
11715
11716static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b,
11717 vector short *__c) {
11718 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11719}
11720
11721static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b,
11722 short *__c) {
11723 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11724}
11725
11726static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a,
11727 int __b,
11728 vector unsigned short *__c) {
11729 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11730}
11731
11732static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a,
11733 int __b, unsigned short *__c) {
11734 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11735}
11736
11737static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
11738 short *__c) {
11739 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11740}
11741
11742static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
11743 unsigned short *__c) {
11744 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11745}
11746
11747static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
11748 vector bool short *__c) {
11749 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11750}
11751
11752static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
11753 short *__c) {
11754 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11755}
11756
11757static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
11758 unsigned short *__c) {
11759 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11760}
11761
11762static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
11763 vector pixel *__c) {
11764 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11765}
11766
11767static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b,
11768 vector int *__c) {
11769 __builtin_altivec_stvxl(__a, __b, __c);
11770}
11771
11772static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b,
11773 int *__c) {
11774 __builtin_altivec_stvxl(__a, __b, __c);
11775}
11776
11777static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b,
11778 vector unsigned int *__c) {
11779 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11780}
11781
11782static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b,
11783 unsigned int *__c) {
11784 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11785}
11786
11787static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
11788 int *__c) {
11789 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11790}
11791
11792static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
11793 unsigned int *__c) {
11794 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11795}
11796
11797static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
11798 vector bool int *__c) {
11799 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11800}
11801
11802static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b,
11803 vector float *__c) {
11804 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11805}
11806
11807static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b,
11808 float *__c) {
11809 __builtin_altivec_stvxl((vector int)__a, __b, __c);
11810}
11811
11812/* vec_sub */
11813
11814static __inline__ vector signed char __ATTRS_o_ai
11815vec_sub(vector signed char __a, vector signed char __b) {
11816 return __a - __b;
11817}
11818
11819static __inline__ vector signed char __ATTRS_o_ai
11820vec_sub(vector bool char __a, vector signed char __b) {
11821 return (vector signed char)__a - __b;
11822}
11823
11824static __inline__ vector signed char __ATTRS_o_ai
11825vec_sub(vector signed char __a, vector bool char __b) {
11826 return __a - (vector signed char)__b;
11827}
11828
11829static __inline__ vector unsigned char __ATTRS_o_ai
11830vec_sub(vector unsigned char __a, vector unsigned char __b) {
11831 return __a - __b;
11832}
11833
11834static __inline__ vector unsigned char __ATTRS_o_ai
11835vec_sub(vector bool char __a, vector unsigned char __b) {
11836 return (vector unsigned char)__a - __b;
11837}
11838
11839static __inline__ vector unsigned char __ATTRS_o_ai
11840vec_sub(vector unsigned char __a, vector bool char __b) {
11841 return __a - (vector unsigned char)__b;
11842}
11843
11844static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a,
11845 vector short __b) {
11846 return __a - __b;
11847}
11848
11849static __inline__ vector short __ATTRS_o_ai vec_sub(vector bool short __a,
11850 vector short __b) {
11851 return (vector short)__a - __b;
11852}
11853
11854static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a,
11855 vector bool short __b) {
11856 return __a - (vector short)__b;
11857}
11858
11859static __inline__ vector unsigned short __ATTRS_o_ai
11860vec_sub(vector unsigned short __a, vector unsigned short __b) {
11861 return __a - __b;
11862}
11863
11864static __inline__ vector unsigned short __ATTRS_o_ai
11865vec_sub(vector bool short __a, vector unsigned short __b) {
11866 return (vector unsigned short)__a - __b;
11867}
11868
11869static __inline__ vector unsigned short __ATTRS_o_ai
11870vec_sub(vector unsigned short __a, vector bool short __b) {
11871 return __a - (vector unsigned short)__b;
11872}
11873
11874static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a,
11875 vector int __b) {
11876 return __a - __b;
11877}
11878
11879static __inline__ vector int __ATTRS_o_ai vec_sub(vector bool int __a,
11880 vector int __b) {
11881 return (vector int)__a - __b;
11882}
11883
11884static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a,
11885 vector bool int __b) {
11886 return __a - (vector int)__b;
11887}
11888
11889static __inline__ vector unsigned int __ATTRS_o_ai
11890vec_sub(vector unsigned int __a, vector unsigned int __b) {
11891 return __a - __b;
11892}
11893
11894static __inline__ vector unsigned int __ATTRS_o_ai
11895vec_sub(vector bool int __a, vector unsigned int __b) {
11896 return (vector unsigned int)__a - __b;
11897}
11898
11899static __inline__ vector unsigned int __ATTRS_o_ai
11900vec_sub(vector unsigned int __a, vector bool int __b) {
11901 return __a - (vector unsigned int)__b;
11902}
11903
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070011904#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
11905 defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080011906static __inline__ vector signed __int128 __ATTRS_o_ai
11907vec_sub(vector signed __int128 __a, vector signed __int128 __b) {
11908 return __a - __b;
11909}
11910
11911static __inline__ vector unsigned __int128 __ATTRS_o_ai
11912vec_sub(vector unsigned __int128 __a, vector unsigned __int128 __b) {
11913 return __a - __b;
11914}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070011915#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) &&
11916 // defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080011917
11918#ifdef __VSX__
11919static __inline__ vector signed long long __ATTRS_o_ai
11920vec_sub(vector signed long long __a, vector signed long long __b) {
11921 return __a - __b;
11922}
11923
11924static __inline__ vector unsigned long long __ATTRS_o_ai
11925vec_sub(vector unsigned long long __a, vector unsigned long long __b) {
11926 return __a - __b;
11927}
11928
11929static __inline__ vector double __ATTRS_o_ai vec_sub(vector double __a,
11930 vector double __b) {
11931 return __a - __b;
11932}
11933#endif
11934
11935static __inline__ vector float __ATTRS_o_ai vec_sub(vector float __a,
11936 vector float __b) {
11937 return __a - __b;
11938}
11939
11940/* vec_vsububm */
11941
11942#define __builtin_altivec_vsububm vec_vsububm
11943
11944static __inline__ vector signed char __ATTRS_o_ai
11945vec_vsububm(vector signed char __a, vector signed char __b) {
11946 return __a - __b;
11947}
11948
11949static __inline__ vector signed char __ATTRS_o_ai
11950vec_vsububm(vector bool char __a, vector signed char __b) {
11951 return (vector signed char)__a - __b;
11952}
11953
11954static __inline__ vector signed char __ATTRS_o_ai
11955vec_vsububm(vector signed char __a, vector bool char __b) {
11956 return __a - (vector signed char)__b;
11957}
11958
11959static __inline__ vector unsigned char __ATTRS_o_ai
11960vec_vsububm(vector unsigned char __a, vector unsigned char __b) {
11961 return __a - __b;
11962}
11963
11964static __inline__ vector unsigned char __ATTRS_o_ai
11965vec_vsububm(vector bool char __a, vector unsigned char __b) {
11966 return (vector unsigned char)__a - __b;
11967}
11968
11969static __inline__ vector unsigned char __ATTRS_o_ai
11970vec_vsububm(vector unsigned char __a, vector bool char __b) {
11971 return __a - (vector unsigned char)__b;
11972}
11973
11974/* vec_vsubuhm */
11975
11976#define __builtin_altivec_vsubuhm vec_vsubuhm
11977
11978static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a,
11979 vector short __b) {
11980 return __a - __b;
11981}
11982
11983static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector bool short __a,
11984 vector short __b) {
11985 return (vector short)__a - __b;
11986}
11987
11988static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a,
11989 vector bool short __b) {
11990 return __a - (vector short)__b;
11991}
11992
11993static __inline__ vector unsigned short __ATTRS_o_ai
11994vec_vsubuhm(vector unsigned short __a, vector unsigned short __b) {
11995 return __a - __b;
11996}
11997
11998static __inline__ vector unsigned short __ATTRS_o_ai
11999vec_vsubuhm(vector bool short __a, vector unsigned short __b) {
12000 return (vector unsigned short)__a - __b;
12001}
12002
12003static __inline__ vector unsigned short __ATTRS_o_ai
12004vec_vsubuhm(vector unsigned short __a, vector bool short __b) {
12005 return __a - (vector unsigned short)__b;
12006}
12007
12008/* vec_vsubuwm */
12009
12010#define __builtin_altivec_vsubuwm vec_vsubuwm
12011
12012static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a,
12013 vector int __b) {
12014 return __a - __b;
12015}
12016
12017static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector bool int __a,
12018 vector int __b) {
12019 return (vector int)__a - __b;
12020}
12021
12022static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a,
12023 vector bool int __b) {
12024 return __a - (vector int)__b;
12025}
12026
12027static __inline__ vector unsigned int __ATTRS_o_ai
12028vec_vsubuwm(vector unsigned int __a, vector unsigned int __b) {
12029 return __a - __b;
12030}
12031
12032static __inline__ vector unsigned int __ATTRS_o_ai
12033vec_vsubuwm(vector bool int __a, vector unsigned int __b) {
12034 return (vector unsigned int)__a - __b;
12035}
12036
12037static __inline__ vector unsigned int __ATTRS_o_ai
12038vec_vsubuwm(vector unsigned int __a, vector bool int __b) {
12039 return __a - (vector unsigned int)__b;
12040}
12041
12042/* vec_vsubfp */
12043
12044#define __builtin_altivec_vsubfp vec_vsubfp
12045
12046static __inline__ vector float __attribute__((__always_inline__))
12047vec_vsubfp(vector float __a, vector float __b) {
12048 return __a - __b;
12049}
12050
12051/* vec_subc */
12052
Logan Chien55afb0a2018-10-15 10:42:14 +080012053static __inline__ vector signed int __ATTRS_o_ai
12054vec_subc(vector signed int __a, vector signed int __b) {
12055 return (vector signed int)__builtin_altivec_vsubcuw((vector unsigned int)__a,
12056 (vector unsigned int) __b);
12057}
12058
Logan Chien2833ffb2018-10-09 10:03:24 +080012059static __inline__ vector unsigned int __ATTRS_o_ai
12060vec_subc(vector unsigned int __a, vector unsigned int __b) {
12061 return __builtin_altivec_vsubcuw(__a, __b);
12062}
12063
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012064#ifdef __POWER8_VECTOR__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012065#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012066static __inline__ vector unsigned __int128 __ATTRS_o_ai
12067vec_subc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
12068 return __builtin_altivec_vsubcuq(__a, __b);
12069}
12070
12071static __inline__ vector signed __int128 __ATTRS_o_ai
12072vec_subc(vector signed __int128 __a, vector signed __int128 __b) {
12073 return __builtin_altivec_vsubcuq(__a, __b);
12074}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012075#endif
12076
12077static __inline__ vector unsigned char __attribute__((__always_inline__))
12078vec_subc_u128(vector unsigned char __a, vector unsigned char __b) {
12079 return (vector unsigned char)__builtin_altivec_vsubcuq(__a, __b);
12080}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012081#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080012082
12083/* vec_vsubcuw */
12084
12085static __inline__ vector unsigned int __attribute__((__always_inline__))
12086vec_vsubcuw(vector unsigned int __a, vector unsigned int __b) {
12087 return __builtin_altivec_vsubcuw(__a, __b);
12088}
12089
12090/* vec_subs */
12091
12092static __inline__ vector signed char __ATTRS_o_ai
12093vec_subs(vector signed char __a, vector signed char __b) {
12094 return __builtin_altivec_vsubsbs(__a, __b);
12095}
12096
12097static __inline__ vector signed char __ATTRS_o_ai
12098vec_subs(vector bool char __a, vector signed char __b) {
12099 return __builtin_altivec_vsubsbs((vector signed char)__a, __b);
12100}
12101
12102static __inline__ vector signed char __ATTRS_o_ai
12103vec_subs(vector signed char __a, vector bool char __b) {
12104 return __builtin_altivec_vsubsbs(__a, (vector signed char)__b);
12105}
12106
12107static __inline__ vector unsigned char __ATTRS_o_ai
12108vec_subs(vector unsigned char __a, vector unsigned char __b) {
12109 return __builtin_altivec_vsububs(__a, __b);
12110}
12111
12112static __inline__ vector unsigned char __ATTRS_o_ai
12113vec_subs(vector bool char __a, vector unsigned char __b) {
12114 return __builtin_altivec_vsububs((vector unsigned char)__a, __b);
12115}
12116
12117static __inline__ vector unsigned char __ATTRS_o_ai
12118vec_subs(vector unsigned char __a, vector bool char __b) {
12119 return __builtin_altivec_vsububs(__a, (vector unsigned char)__b);
12120}
12121
12122static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a,
12123 vector short __b) {
12124 return __builtin_altivec_vsubshs(__a, __b);
12125}
12126
12127static __inline__ vector short __ATTRS_o_ai vec_subs(vector bool short __a,
12128 vector short __b) {
12129 return __builtin_altivec_vsubshs((vector short)__a, __b);
12130}
12131
12132static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a,
12133 vector bool short __b) {
12134 return __builtin_altivec_vsubshs(__a, (vector short)__b);
12135}
12136
12137static __inline__ vector unsigned short __ATTRS_o_ai
12138vec_subs(vector unsigned short __a, vector unsigned short __b) {
12139 return __builtin_altivec_vsubuhs(__a, __b);
12140}
12141
12142static __inline__ vector unsigned short __ATTRS_o_ai
12143vec_subs(vector bool short __a, vector unsigned short __b) {
12144 return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b);
12145}
12146
12147static __inline__ vector unsigned short __ATTRS_o_ai
12148vec_subs(vector unsigned short __a, vector bool short __b) {
12149 return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b);
12150}
12151
12152static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a,
12153 vector int __b) {
12154 return __builtin_altivec_vsubsws(__a, __b);
12155}
12156
12157static __inline__ vector int __ATTRS_o_ai vec_subs(vector bool int __a,
12158 vector int __b) {
12159 return __builtin_altivec_vsubsws((vector int)__a, __b);
12160}
12161
12162static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a,
12163 vector bool int __b) {
12164 return __builtin_altivec_vsubsws(__a, (vector int)__b);
12165}
12166
12167static __inline__ vector unsigned int __ATTRS_o_ai
12168vec_subs(vector unsigned int __a, vector unsigned int __b) {
12169 return __builtin_altivec_vsubuws(__a, __b);
12170}
12171
12172static __inline__ vector unsigned int __ATTRS_o_ai
12173vec_subs(vector bool int __a, vector unsigned int __b) {
12174 return __builtin_altivec_vsubuws((vector unsigned int)__a, __b);
12175}
12176
12177static __inline__ vector unsigned int __ATTRS_o_ai
12178vec_subs(vector unsigned int __a, vector bool int __b) {
12179 return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
12180}
12181
12182/* vec_vsubsbs */
12183
12184static __inline__ vector signed char __ATTRS_o_ai
12185vec_vsubsbs(vector signed char __a, vector signed char __b) {
12186 return __builtin_altivec_vsubsbs(__a, __b);
12187}
12188
12189static __inline__ vector signed char __ATTRS_o_ai
12190vec_vsubsbs(vector bool char __a, vector signed char __b) {
12191 return __builtin_altivec_vsubsbs((vector signed char)__a, __b);
12192}
12193
12194static __inline__ vector signed char __ATTRS_o_ai
12195vec_vsubsbs(vector signed char __a, vector bool char __b) {
12196 return __builtin_altivec_vsubsbs(__a, (vector signed char)__b);
12197}
12198
12199/* vec_vsububs */
12200
12201static __inline__ vector unsigned char __ATTRS_o_ai
12202vec_vsububs(vector unsigned char __a, vector unsigned char __b) {
12203 return __builtin_altivec_vsububs(__a, __b);
12204}
12205
12206static __inline__ vector unsigned char __ATTRS_o_ai
12207vec_vsububs(vector bool char __a, vector unsigned char __b) {
12208 return __builtin_altivec_vsububs((vector unsigned char)__a, __b);
12209}
12210
12211static __inline__ vector unsigned char __ATTRS_o_ai
12212vec_vsububs(vector unsigned char __a, vector bool char __b) {
12213 return __builtin_altivec_vsububs(__a, (vector unsigned char)__b);
12214}
12215
12216/* vec_vsubshs */
12217
12218static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a,
12219 vector short __b) {
12220 return __builtin_altivec_vsubshs(__a, __b);
12221}
12222
12223static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector bool short __a,
12224 vector short __b) {
12225 return __builtin_altivec_vsubshs((vector short)__a, __b);
12226}
12227
12228static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a,
12229 vector bool short __b) {
12230 return __builtin_altivec_vsubshs(__a, (vector short)__b);
12231}
12232
12233/* vec_vsubuhs */
12234
12235static __inline__ vector unsigned short __ATTRS_o_ai
12236vec_vsubuhs(vector unsigned short __a, vector unsigned short __b) {
12237 return __builtin_altivec_vsubuhs(__a, __b);
12238}
12239
12240static __inline__ vector unsigned short __ATTRS_o_ai
12241vec_vsubuhs(vector bool short __a, vector unsigned short __b) {
12242 return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b);
12243}
12244
12245static __inline__ vector unsigned short __ATTRS_o_ai
12246vec_vsubuhs(vector unsigned short __a, vector bool short __b) {
12247 return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b);
12248}
12249
12250/* vec_vsubsws */
12251
12252static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a,
12253 vector int __b) {
12254 return __builtin_altivec_vsubsws(__a, __b);
12255}
12256
12257static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector bool int __a,
12258 vector int __b) {
12259 return __builtin_altivec_vsubsws((vector int)__a, __b);
12260}
12261
12262static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a,
12263 vector bool int __b) {
12264 return __builtin_altivec_vsubsws(__a, (vector int)__b);
12265}
12266
12267/* vec_vsubuws */
12268
12269static __inline__ vector unsigned int __ATTRS_o_ai
12270vec_vsubuws(vector unsigned int __a, vector unsigned int __b) {
12271 return __builtin_altivec_vsubuws(__a, __b);
12272}
12273
12274static __inline__ vector unsigned int __ATTRS_o_ai
12275vec_vsubuws(vector bool int __a, vector unsigned int __b) {
12276 return __builtin_altivec_vsubuws((vector unsigned int)__a, __b);
12277}
12278
12279static __inline__ vector unsigned int __ATTRS_o_ai
12280vec_vsubuws(vector unsigned int __a, vector bool int __b) {
12281 return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
12282}
12283
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012284#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080012285/* vec_vsubuqm */
12286
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012287#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012288static __inline__ vector signed __int128 __ATTRS_o_ai
12289vec_vsubuqm(vector signed __int128 __a, vector signed __int128 __b) {
12290 return __a - __b;
12291}
12292
12293static __inline__ vector unsigned __int128 __ATTRS_o_ai
12294vec_vsubuqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
12295 return __a - __b;
12296}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012297#endif
12298
12299static __inline__ vector unsigned char __attribute__((__always_inline__))
12300vec_sub_u128(vector unsigned char __a, vector unsigned char __b) {
12301 return __builtin_altivec_vsubuqm(__a, __b);
12302}
Logan Chien2833ffb2018-10-09 10:03:24 +080012303
12304/* vec_vsubeuqm */
12305
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012306#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012307static __inline__ vector signed __int128 __ATTRS_o_ai
12308vec_vsubeuqm(vector signed __int128 __a, vector signed __int128 __b,
12309 vector signed __int128 __c) {
12310 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12311}
12312
12313static __inline__ vector unsigned __int128 __ATTRS_o_ai
12314vec_vsubeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
12315 vector unsigned __int128 __c) {
12316 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12317}
12318
Logan Chien55afb0a2018-10-15 10:42:14 +080012319static __inline__ vector signed __int128 __ATTRS_o_ai
12320vec_sube(vector signed __int128 __a, vector signed __int128 __b,
12321 vector signed __int128 __c) {
12322 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12323}
12324
12325static __inline__ vector unsigned __int128 __ATTRS_o_ai
12326vec_sube(vector unsigned __int128 __a, vector unsigned __int128 __b,
12327 vector unsigned __int128 __c) {
12328 return __builtin_altivec_vsubeuqm(__a, __b, __c);
12329}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012330#endif
12331
12332static __inline__ vector unsigned char __attribute__((__always_inline__))
12333vec_sube_u128(vector unsigned char __a, vector unsigned char __b,
12334 vector unsigned char __c) {
12335 return (vector unsigned char)__builtin_altivec_vsubeuqm(__a, __b, __c);
12336}
Logan Chien55afb0a2018-10-15 10:42:14 +080012337
Logan Chien2833ffb2018-10-09 10:03:24 +080012338/* vec_vsubcuq */
12339
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012340#ifdef __SIZEOF_INT128__
Logan Chien2833ffb2018-10-09 10:03:24 +080012341static __inline__ vector signed __int128 __ATTRS_o_ai
12342vec_vsubcuq(vector signed __int128 __a, vector signed __int128 __b) {
12343 return __builtin_altivec_vsubcuq(__a, __b);
12344}
12345
12346static __inline__ vector unsigned __int128 __ATTRS_o_ai
12347vec_vsubcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
12348 return __builtin_altivec_vsubcuq(__a, __b);
12349}
12350
12351/* vec_vsubecuq */
12352
12353static __inline__ vector signed __int128 __ATTRS_o_ai
12354vec_vsubecuq(vector signed __int128 __a, vector signed __int128 __b,
12355 vector signed __int128 __c) {
12356 return __builtin_altivec_vsubecuq(__a, __b, __c);
12357}
12358
12359static __inline__ vector unsigned __int128 __ATTRS_o_ai
12360vec_vsubecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
12361 vector unsigned __int128 __c) {
12362 return __builtin_altivec_vsubecuq(__a, __b, __c);
12363}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012364#endif
Logan Chien55afb0a2018-10-15 10:42:14 +080012365
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012366#ifdef __powerpc64__
Logan Chien55afb0a2018-10-15 10:42:14 +080012367static __inline__ vector signed int __ATTRS_o_ai
12368vec_subec(vector signed int __a, vector signed int __b,
12369 vector signed int __c) {
12370 return vec_addec(__a, ~__b, __c);
12371}
12372
12373static __inline__ vector unsigned int __ATTRS_o_ai
12374vec_subec(vector unsigned int __a, vector unsigned int __b,
12375 vector unsigned int __c) {
12376 return vec_addec(__a, ~__b, __c);
12377}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012378#endif
Logan Chien55afb0a2018-10-15 10:42:14 +080012379
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012380#ifdef __SIZEOF_INT128__
Logan Chien55afb0a2018-10-15 10:42:14 +080012381static __inline__ vector signed __int128 __ATTRS_o_ai
12382vec_subec(vector signed __int128 __a, vector signed __int128 __b,
12383 vector signed __int128 __c) {
12384 return __builtin_altivec_vsubecuq(__a, __b, __c);
12385}
12386
12387static __inline__ vector unsigned __int128 __ATTRS_o_ai
12388vec_subec(vector unsigned __int128 __a, vector unsigned __int128 __b,
12389 vector unsigned __int128 __c) {
12390 return __builtin_altivec_vsubecuq(__a, __b, __c);
12391}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012392#endif
12393
12394static __inline__ vector unsigned char __attribute__((__always_inline__))
12395vec_subec_u128(vector unsigned char __a, vector unsigned char __b,
12396 vector unsigned char __c) {
12397 return (vector unsigned char)__builtin_altivec_vsubecuq(__a, __b, __c);
12398}
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080012399#endif // __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080012400
Logan Chien55afb0a2018-10-15 10:42:14 +080012401static __inline__ vector signed int __ATTRS_o_ai
12402vec_sube(vector signed int __a, vector signed int __b,
12403 vector signed int __c) {
12404 vector signed int __mask = {1, 1, 1, 1};
12405 vector signed int __carry = __c & __mask;
12406 return vec_adde(__a, ~__b, __carry);
12407}
12408
12409static __inline__ vector unsigned int __ATTRS_o_ai
12410vec_sube(vector unsigned int __a, vector unsigned int __b,
12411 vector unsigned int __c) {
12412 vector unsigned int __mask = {1, 1, 1, 1};
12413 vector unsigned int __carry = __c & __mask;
12414 return vec_adde(__a, ~__b, __carry);
12415}
Logan Chien2833ffb2018-10-09 10:03:24 +080012416/* vec_sum4s */
12417
12418static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed char __a,
12419 vector int __b) {
12420 return __builtin_altivec_vsum4sbs(__a, __b);
12421}
12422
12423static __inline__ vector unsigned int __ATTRS_o_ai
12424vec_sum4s(vector unsigned char __a, vector unsigned int __b) {
12425 return __builtin_altivec_vsum4ubs(__a, __b);
12426}
12427
12428static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed short __a,
12429 vector int __b) {
12430 return __builtin_altivec_vsum4shs(__a, __b);
12431}
12432
12433/* vec_vsum4sbs */
12434
12435static __inline__ vector int __attribute__((__always_inline__))
12436vec_vsum4sbs(vector signed char __a, vector int __b) {
12437 return __builtin_altivec_vsum4sbs(__a, __b);
12438}
12439
12440/* vec_vsum4ubs */
12441
12442static __inline__ vector unsigned int __attribute__((__always_inline__))
12443vec_vsum4ubs(vector unsigned char __a, vector unsigned int __b) {
12444 return __builtin_altivec_vsum4ubs(__a, __b);
12445}
12446
12447/* vec_vsum4shs */
12448
12449static __inline__ vector int __attribute__((__always_inline__))
12450vec_vsum4shs(vector signed short __a, vector int __b) {
12451 return __builtin_altivec_vsum4shs(__a, __b);
12452}
12453
12454/* vec_sum2s */
12455
12456/* The vsum2sws instruction has a big-endian bias, so that the second
12457 input vector and the result always reference big-endian elements
12458 1 and 3 (little-endian element 0 and 2). For ease of porting the
12459 programmer wants elements 1 and 3 in both cases, so for little
12460 endian we must perform some permutes. */
12461
12462static __inline__ vector signed int __attribute__((__always_inline__))
12463vec_sum2s(vector int __a, vector int __b) {
12464#ifdef __LITTLE_ENDIAN__
12465 vector int __c = (vector signed int)vec_perm(
12466 __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12467 8, 9, 10, 11));
12468 __c = __builtin_altivec_vsum2sws(__a, __c);
12469 return (vector signed int)vec_perm(
12470 __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12471 8, 9, 10, 11));
12472#else
12473 return __builtin_altivec_vsum2sws(__a, __b);
12474#endif
12475}
12476
12477/* vec_vsum2sws */
12478
12479static __inline__ vector signed int __attribute__((__always_inline__))
12480vec_vsum2sws(vector int __a, vector int __b) {
12481#ifdef __LITTLE_ENDIAN__
12482 vector int __c = (vector signed int)vec_perm(
12483 __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12484 8, 9, 10, 11));
12485 __c = __builtin_altivec_vsum2sws(__a, __c);
12486 return (vector signed int)vec_perm(
12487 __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
12488 8, 9, 10, 11));
12489#else
12490 return __builtin_altivec_vsum2sws(__a, __b);
12491#endif
12492}
12493
12494/* vec_sums */
12495
12496/* The vsumsws instruction has a big-endian bias, so that the second
12497 input vector and the result always reference big-endian element 3
12498 (little-endian element 0). For ease of porting the programmer
12499 wants element 3 in both cases, so for little endian we must perform
12500 some permutes. */
12501
12502static __inline__ vector signed int __attribute__((__always_inline__))
12503vec_sums(vector signed int __a, vector signed int __b) {
12504#ifdef __LITTLE_ENDIAN__
12505 __b = (vector signed int)vec_splat(__b, 3);
12506 __b = __builtin_altivec_vsumsws(__a, __b);
12507 return (vector signed int)(0, 0, 0, __b[0]);
12508#else
12509 return __builtin_altivec_vsumsws(__a, __b);
12510#endif
12511}
12512
12513/* vec_vsumsws */
12514
12515static __inline__ vector signed int __attribute__((__always_inline__))
12516vec_vsumsws(vector signed int __a, vector signed int __b) {
12517#ifdef __LITTLE_ENDIAN__
12518 __b = (vector signed int)vec_splat(__b, 3);
12519 __b = __builtin_altivec_vsumsws(__a, __b);
12520 return (vector signed int)(0, 0, 0, __b[0]);
12521#else
12522 return __builtin_altivec_vsumsws(__a, __b);
12523#endif
12524}
12525
12526/* vec_trunc */
12527
12528static __inline__ vector float __ATTRS_o_ai vec_trunc(vector float __a) {
12529#ifdef __VSX__
12530 return __builtin_vsx_xvrspiz(__a);
12531#else
12532 return __builtin_altivec_vrfiz(__a);
12533#endif
12534}
12535
12536#ifdef __VSX__
12537static __inline__ vector double __ATTRS_o_ai vec_trunc(vector double __a) {
12538 return __builtin_vsx_xvrdpiz(__a);
12539}
12540#endif
12541
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012542/* vec_roundz */
12543static __inline__ vector float __ATTRS_o_ai vec_roundz(vector float __a) {
12544 return vec_trunc(__a);
12545}
12546
12547#ifdef __VSX__
12548static __inline__ vector double __ATTRS_o_ai vec_roundz(vector double __a) {
12549 return vec_trunc(__a);
12550}
12551#endif
12552
Logan Chien2833ffb2018-10-09 10:03:24 +080012553/* vec_vrfiz */
12554
12555static __inline__ vector float __attribute__((__always_inline__))
12556vec_vrfiz(vector float __a) {
12557 return __builtin_altivec_vrfiz(__a);
12558}
12559
12560/* vec_unpackh */
12561
12562/* The vector unpack instructions all have a big-endian bias, so for
12563 little endian we must reverse the meanings of "high" and "low." */
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070012564#ifdef __LITTLE_ENDIAN__
12565#define vec_vupkhpx(__a) __builtin_altivec_vupklpx((vector short)(__a))
12566#define vec_vupklpx(__a) __builtin_altivec_vupkhpx((vector short)(__a))
12567#else
12568#define vec_vupkhpx(__a) __builtin_altivec_vupkhpx((vector short)(__a))
12569#define vec_vupklpx(__a) __builtin_altivec_vupklpx((vector short)(__a))
12570#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080012571
12572static __inline__ vector short __ATTRS_o_ai
12573vec_unpackh(vector signed char __a) {
12574#ifdef __LITTLE_ENDIAN__
12575 return __builtin_altivec_vupklsb((vector char)__a);
12576#else
12577 return __builtin_altivec_vupkhsb((vector char)__a);
12578#endif
12579}
12580
12581static __inline__ vector bool short __ATTRS_o_ai
12582vec_unpackh(vector bool char __a) {
12583#ifdef __LITTLE_ENDIAN__
12584 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12585#else
12586 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12587#endif
12588}
12589
12590static __inline__ vector int __ATTRS_o_ai vec_unpackh(vector short __a) {
12591#ifdef __LITTLE_ENDIAN__
12592 return __builtin_altivec_vupklsh(__a);
12593#else
12594 return __builtin_altivec_vupkhsh(__a);
12595#endif
12596}
12597
12598static __inline__ vector bool int __ATTRS_o_ai
12599vec_unpackh(vector bool short __a) {
12600#ifdef __LITTLE_ENDIAN__
12601 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12602#else
12603 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12604#endif
12605}
12606
12607static __inline__ vector unsigned int __ATTRS_o_ai
12608vec_unpackh(vector pixel __a) {
12609#ifdef __LITTLE_ENDIAN__
12610 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12611#else
12612 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12613#endif
12614}
12615
12616#ifdef __POWER8_VECTOR__
12617static __inline__ vector long long __ATTRS_o_ai vec_unpackh(vector int __a) {
12618#ifdef __LITTLE_ENDIAN__
12619 return __builtin_altivec_vupklsw(__a);
12620#else
12621 return __builtin_altivec_vupkhsw(__a);
12622#endif
12623}
12624
12625static __inline__ vector bool long long __ATTRS_o_ai
12626vec_unpackh(vector bool int __a) {
12627#ifdef __LITTLE_ENDIAN__
12628 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12629#else
12630 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12631#endif
12632}
Logan Chien55afb0a2018-10-15 10:42:14 +080012633
12634static __inline__ vector double __ATTRS_o_ai
12635vec_unpackh(vector float __a) {
12636 return (vector double)(__a[0], __a[1]);
12637}
Logan Chien2833ffb2018-10-09 10:03:24 +080012638#endif
12639
12640/* vec_vupkhsb */
12641
12642static __inline__ vector short __ATTRS_o_ai
12643vec_vupkhsb(vector signed char __a) {
12644#ifdef __LITTLE_ENDIAN__
12645 return __builtin_altivec_vupklsb((vector char)__a);
12646#else
12647 return __builtin_altivec_vupkhsb((vector char)__a);
12648#endif
12649}
12650
12651static __inline__ vector bool short __ATTRS_o_ai
12652vec_vupkhsb(vector bool char __a) {
12653#ifdef __LITTLE_ENDIAN__
12654 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12655#else
12656 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12657#endif
12658}
12659
12660/* vec_vupkhsh */
12661
12662static __inline__ vector int __ATTRS_o_ai vec_vupkhsh(vector short __a) {
12663#ifdef __LITTLE_ENDIAN__
12664 return __builtin_altivec_vupklsh(__a);
12665#else
12666 return __builtin_altivec_vupkhsh(__a);
12667#endif
12668}
12669
12670static __inline__ vector bool int __ATTRS_o_ai
12671vec_vupkhsh(vector bool short __a) {
12672#ifdef __LITTLE_ENDIAN__
12673 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12674#else
12675 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12676#endif
12677}
12678
12679static __inline__ vector unsigned int __ATTRS_o_ai
12680vec_vupkhsh(vector pixel __a) {
12681#ifdef __LITTLE_ENDIAN__
12682 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12683#else
12684 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12685#endif
12686}
12687
12688/* vec_vupkhsw */
12689
12690#ifdef __POWER8_VECTOR__
12691static __inline__ vector long long __ATTRS_o_ai vec_vupkhsw(vector int __a) {
12692#ifdef __LITTLE_ENDIAN__
12693 return __builtin_altivec_vupklsw(__a);
12694#else
12695 return __builtin_altivec_vupkhsw(__a);
12696#endif
12697}
12698
12699static __inline__ vector bool long long __ATTRS_o_ai
12700vec_vupkhsw(vector bool int __a) {
12701#ifdef __LITTLE_ENDIAN__
12702 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12703#else
12704 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12705#endif
12706}
12707#endif
12708
12709/* vec_unpackl */
12710
12711static __inline__ vector short __ATTRS_o_ai
12712vec_unpackl(vector signed char __a) {
12713#ifdef __LITTLE_ENDIAN__
12714 return __builtin_altivec_vupkhsb((vector char)__a);
12715#else
12716 return __builtin_altivec_vupklsb((vector char)__a);
12717#endif
12718}
12719
12720static __inline__ vector bool short __ATTRS_o_ai
12721vec_unpackl(vector bool char __a) {
12722#ifdef __LITTLE_ENDIAN__
12723 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12724#else
12725 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12726#endif
12727}
12728
12729static __inline__ vector int __ATTRS_o_ai vec_unpackl(vector short __a) {
12730#ifdef __LITTLE_ENDIAN__
12731 return __builtin_altivec_vupkhsh(__a);
12732#else
12733 return __builtin_altivec_vupklsh(__a);
12734#endif
12735}
12736
12737static __inline__ vector bool int __ATTRS_o_ai
12738vec_unpackl(vector bool short __a) {
12739#ifdef __LITTLE_ENDIAN__
12740 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12741#else
12742 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12743#endif
12744}
12745
12746static __inline__ vector unsigned int __ATTRS_o_ai
12747vec_unpackl(vector pixel __a) {
12748#ifdef __LITTLE_ENDIAN__
12749 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12750#else
12751 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12752#endif
12753}
12754
12755#ifdef __POWER8_VECTOR__
12756static __inline__ vector long long __ATTRS_o_ai vec_unpackl(vector int __a) {
12757#ifdef __LITTLE_ENDIAN__
12758 return __builtin_altivec_vupkhsw(__a);
12759#else
12760 return __builtin_altivec_vupklsw(__a);
12761#endif
12762}
12763
12764static __inline__ vector bool long long __ATTRS_o_ai
12765vec_unpackl(vector bool int __a) {
12766#ifdef __LITTLE_ENDIAN__
12767 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12768#else
12769 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12770#endif
12771}
Logan Chien55afb0a2018-10-15 10:42:14 +080012772
12773static __inline__ vector double __ATTRS_o_ai
12774vec_unpackl(vector float __a) {
12775 return (vector double)(__a[2], __a[3]);
12776}
Logan Chien2833ffb2018-10-09 10:03:24 +080012777#endif
12778
12779/* vec_vupklsb */
12780
12781static __inline__ vector short __ATTRS_o_ai
12782vec_vupklsb(vector signed char __a) {
12783#ifdef __LITTLE_ENDIAN__
12784 return __builtin_altivec_vupkhsb((vector char)__a);
12785#else
12786 return __builtin_altivec_vupklsb((vector char)__a);
12787#endif
12788}
12789
12790static __inline__ vector bool short __ATTRS_o_ai
12791vec_vupklsb(vector bool char __a) {
12792#ifdef __LITTLE_ENDIAN__
12793 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
12794#else
12795 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
12796#endif
12797}
12798
12799/* vec_vupklsh */
12800
12801static __inline__ vector int __ATTRS_o_ai vec_vupklsh(vector short __a) {
12802#ifdef __LITTLE_ENDIAN__
12803 return __builtin_altivec_vupkhsh(__a);
12804#else
12805 return __builtin_altivec_vupklsh(__a);
12806#endif
12807}
12808
12809static __inline__ vector bool int __ATTRS_o_ai
12810vec_vupklsh(vector bool short __a) {
12811#ifdef __LITTLE_ENDIAN__
12812 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
12813#else
12814 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
12815#endif
12816}
12817
12818static __inline__ vector unsigned int __ATTRS_o_ai
12819vec_vupklsh(vector pixel __a) {
12820#ifdef __LITTLE_ENDIAN__
12821 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
12822#else
12823 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
12824#endif
12825}
12826
12827/* vec_vupklsw */
12828
12829#ifdef __POWER8_VECTOR__
12830static __inline__ vector long long __ATTRS_o_ai vec_vupklsw(vector int __a) {
12831#ifdef __LITTLE_ENDIAN__
12832 return __builtin_altivec_vupkhsw(__a);
12833#else
12834 return __builtin_altivec_vupklsw(__a);
12835#endif
12836}
12837
12838static __inline__ vector bool long long __ATTRS_o_ai
12839vec_vupklsw(vector bool int __a) {
12840#ifdef __LITTLE_ENDIAN__
12841 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
12842#else
12843 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
12844#endif
12845}
12846#endif
12847
12848/* vec_vsx_ld */
12849
12850#ifdef __VSX__
12851
12852static __inline__ vector bool int __ATTRS_o_ai
12853vec_vsx_ld(int __a, const vector bool int *__b) {
12854 return (vector bool int)__builtin_vsx_lxvw4x(__a, __b);
12855}
12856
12857static __inline__ vector signed int __ATTRS_o_ai
12858vec_vsx_ld(int __a, const vector signed int *__b) {
12859 return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
12860}
12861
12862static __inline__ vector signed int __ATTRS_o_ai
12863vec_vsx_ld(int __a, const signed int *__b) {
12864 return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
12865}
12866
12867static __inline__ vector unsigned int __ATTRS_o_ai
12868vec_vsx_ld(int __a, const vector unsigned int *__b) {
12869 return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
12870}
12871
12872static __inline__ vector unsigned int __ATTRS_o_ai
12873vec_vsx_ld(int __a, const unsigned int *__b) {
12874 return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
12875}
12876
12877static __inline__ vector float __ATTRS_o_ai
12878vec_vsx_ld(int __a, const vector float *__b) {
12879 return (vector float)__builtin_vsx_lxvw4x(__a, __b);
12880}
12881
12882static __inline__ vector float __ATTRS_o_ai vec_vsx_ld(int __a,
12883 const float *__b) {
12884 return (vector float)__builtin_vsx_lxvw4x(__a, __b);
12885}
12886
12887static __inline__ vector signed long long __ATTRS_o_ai
12888vec_vsx_ld(int __a, const vector signed long long *__b) {
12889 return (vector signed long long)__builtin_vsx_lxvd2x(__a, __b);
12890}
12891
12892static __inline__ vector unsigned long long __ATTRS_o_ai
12893vec_vsx_ld(int __a, const vector unsigned long long *__b) {
12894 return (vector unsigned long long)__builtin_vsx_lxvd2x(__a, __b);
12895}
12896
12897static __inline__ vector double __ATTRS_o_ai
12898vec_vsx_ld(int __a, const vector double *__b) {
12899 return (vector double)__builtin_vsx_lxvd2x(__a, __b);
12900}
12901
12902static __inline__ vector double __ATTRS_o_ai
12903vec_vsx_ld(int __a, const double *__b) {
12904 return (vector double)__builtin_vsx_lxvd2x(__a, __b);
12905}
12906
12907static __inline__ vector bool short __ATTRS_o_ai
12908vec_vsx_ld(int __a, const vector bool short *__b) {
12909 return (vector bool short)__builtin_vsx_lxvw4x(__a, __b);
12910}
12911
12912static __inline__ vector signed short __ATTRS_o_ai
12913vec_vsx_ld(int __a, const vector signed short *__b) {
12914 return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
12915}
12916
12917static __inline__ vector signed short __ATTRS_o_ai
12918vec_vsx_ld(int __a, const signed short *__b) {
12919 return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
12920}
12921
12922static __inline__ vector unsigned short __ATTRS_o_ai
12923vec_vsx_ld(int __a, const vector unsigned short *__b) {
12924 return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
12925}
12926
12927static __inline__ vector unsigned short __ATTRS_o_ai
12928vec_vsx_ld(int __a, const unsigned short *__b) {
12929 return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
12930}
12931
12932static __inline__ vector bool char __ATTRS_o_ai
12933vec_vsx_ld(int __a, const vector bool char *__b) {
12934 return (vector bool char)__builtin_vsx_lxvw4x(__a, __b);
12935}
12936
12937static __inline__ vector signed char __ATTRS_o_ai
12938vec_vsx_ld(int __a, const vector signed char *__b) {
12939 return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
12940}
12941
12942static __inline__ vector signed char __ATTRS_o_ai
12943vec_vsx_ld(int __a, const signed char *__b) {
12944 return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
12945}
12946
12947static __inline__ vector unsigned char __ATTRS_o_ai
12948vec_vsx_ld(int __a, const vector unsigned char *__b) {
12949 return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
12950}
12951
12952static __inline__ vector unsigned char __ATTRS_o_ai
12953vec_vsx_ld(int __a, const unsigned char *__b) {
12954 return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
12955}
12956
12957#endif
12958
12959/* vec_vsx_st */
12960
12961#ifdef __VSX__
12962
12963static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
12964 vector bool int *__c) {
12965 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12966}
12967
12968static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
12969 signed int *__c) {
12970 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12971}
12972
12973static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
12974 unsigned int *__c) {
12975 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12976}
12977
12978static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
12979 vector signed int *__c) {
12980 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12981}
12982
12983static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
12984 signed int *__c) {
12985 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12986}
12987
12988static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
12989 vector unsigned int *__c) {
12990 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12991}
12992
12993static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
12994 unsigned int *__c) {
12995 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
12996}
12997
12998static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
12999 vector float *__c) {
13000 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13001}
13002
13003static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
13004 float *__c) {
13005 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13006}
13007
13008static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed long long __a,
13009 int __b,
13010 vector signed long long *__c) {
13011 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
13012}
13013
13014static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned long long __a,
13015 int __b,
13016 vector unsigned long long *__c) {
13017 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
13018}
13019
13020static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
13021 vector double *__c) {
13022 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
13023}
13024
13025static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
13026 double *__c) {
13027 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
13028}
13029
13030static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
13031 vector bool short *__c) {
13032 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13033}
13034
13035static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
13036 signed short *__c) {
13037 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13038}
13039
13040static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
13041 unsigned short *__c) {
13042 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13043}
13044static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
13045 vector signed short *__c) {
13046 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13047}
13048
13049static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
13050 signed short *__c) {
13051 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13052}
13053
13054static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a,
13055 int __b,
13056 vector unsigned short *__c) {
13057 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13058}
13059
13060static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a,
13061 int __b, unsigned short *__c) {
13062 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13063}
13064
13065static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
13066 vector bool char *__c) {
13067 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13068}
13069
13070static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
13071 signed char *__c) {
13072 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13073}
13074
13075static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
13076 unsigned char *__c) {
13077 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13078}
13079
13080static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
13081 vector signed char *__c) {
13082 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13083}
13084
13085static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
13086 signed char *__c) {
13087 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13088}
13089
13090static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a,
13091 int __b,
13092 vector unsigned char *__c) {
13093 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13094}
13095
13096static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a,
13097 int __b, unsigned char *__c) {
13098 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
13099}
13100
13101#endif
13102
Logan Chien55afb0a2018-10-15 10:42:14 +080013103#ifdef __VSX__
13104#define vec_xxpermdi __builtin_vsx_xxpermdi
13105#define vec_xxsldwi __builtin_vsx_xxsldwi
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013106#define vec_permi(__a, __b, __c) \
13107 _Generic((__a), vector signed long long \
13108 : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \
13109 (((__c)&0x1) + 2)), \
13110 vector unsigned long long \
13111 : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \
13112 (((__c)&0x1) + 2)), \
13113 vector double \
13114 : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \
13115 (((__c)&0x1) + 2)))
Logan Chien55afb0a2018-10-15 10:42:14 +080013116#endif
13117
Logan Chien2833ffb2018-10-09 10:03:24 +080013118/* vec_xor */
13119
13120#define __builtin_altivec_vxor vec_xor
13121
13122static __inline__ vector signed char __ATTRS_o_ai
13123vec_xor(vector signed char __a, vector signed char __b) {
13124 return __a ^ __b;
13125}
13126
13127static __inline__ vector signed char __ATTRS_o_ai
13128vec_xor(vector bool char __a, vector signed char __b) {
13129 return (vector signed char)__a ^ __b;
13130}
13131
13132static __inline__ vector signed char __ATTRS_o_ai
13133vec_xor(vector signed char __a, vector bool char __b) {
13134 return __a ^ (vector signed char)__b;
13135}
13136
13137static __inline__ vector unsigned char __ATTRS_o_ai
13138vec_xor(vector unsigned char __a, vector unsigned char __b) {
13139 return __a ^ __b;
13140}
13141
13142static __inline__ vector unsigned char __ATTRS_o_ai
13143vec_xor(vector bool char __a, vector unsigned char __b) {
13144 return (vector unsigned char)__a ^ __b;
13145}
13146
13147static __inline__ vector unsigned char __ATTRS_o_ai
13148vec_xor(vector unsigned char __a, vector bool char __b) {
13149 return __a ^ (vector unsigned char)__b;
13150}
13151
13152static __inline__ vector bool char __ATTRS_o_ai vec_xor(vector bool char __a,
13153 vector bool char __b) {
13154 return __a ^ __b;
13155}
13156
13157static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a,
13158 vector short __b) {
13159 return __a ^ __b;
13160}
13161
13162static __inline__ vector short __ATTRS_o_ai vec_xor(vector bool short __a,
13163 vector short __b) {
13164 return (vector short)__a ^ __b;
13165}
13166
13167static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a,
13168 vector bool short __b) {
13169 return __a ^ (vector short)__b;
13170}
13171
13172static __inline__ vector unsigned short __ATTRS_o_ai
13173vec_xor(vector unsigned short __a, vector unsigned short __b) {
13174 return __a ^ __b;
13175}
13176
13177static __inline__ vector unsigned short __ATTRS_o_ai
13178vec_xor(vector bool short __a, vector unsigned short __b) {
13179 return (vector unsigned short)__a ^ __b;
13180}
13181
13182static __inline__ vector unsigned short __ATTRS_o_ai
13183vec_xor(vector unsigned short __a, vector bool short __b) {
13184 return __a ^ (vector unsigned short)__b;
13185}
13186
13187static __inline__ vector bool short __ATTRS_o_ai
13188vec_xor(vector bool short __a, vector bool short __b) {
13189 return __a ^ __b;
13190}
13191
13192static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a,
13193 vector int __b) {
13194 return __a ^ __b;
13195}
13196
13197static __inline__ vector int __ATTRS_o_ai vec_xor(vector bool int __a,
13198 vector int __b) {
13199 return (vector int)__a ^ __b;
13200}
13201
13202static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a,
13203 vector bool int __b) {
13204 return __a ^ (vector int)__b;
13205}
13206
13207static __inline__ vector unsigned int __ATTRS_o_ai
13208vec_xor(vector unsigned int __a, vector unsigned int __b) {
13209 return __a ^ __b;
13210}
13211
13212static __inline__ vector unsigned int __ATTRS_o_ai
13213vec_xor(vector bool int __a, vector unsigned int __b) {
13214 return (vector unsigned int)__a ^ __b;
13215}
13216
13217static __inline__ vector unsigned int __ATTRS_o_ai
13218vec_xor(vector unsigned int __a, vector bool int __b) {
13219 return __a ^ (vector unsigned int)__b;
13220}
13221
13222static __inline__ vector bool int __ATTRS_o_ai vec_xor(vector bool int __a,
13223 vector bool int __b) {
13224 return __a ^ __b;
13225}
13226
13227static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a,
13228 vector float __b) {
13229 vector unsigned int __res =
13230 (vector unsigned int)__a ^ (vector unsigned int)__b;
13231 return (vector float)__res;
13232}
13233
13234static __inline__ vector float __ATTRS_o_ai vec_xor(vector bool int __a,
13235 vector float __b) {
13236 vector unsigned int __res =
13237 (vector unsigned int)__a ^ (vector unsigned int)__b;
13238 return (vector float)__res;
13239}
13240
13241static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a,
13242 vector bool int __b) {
13243 vector unsigned int __res =
13244 (vector unsigned int)__a ^ (vector unsigned int)__b;
13245 return (vector float)__res;
13246}
13247
13248#ifdef __VSX__
13249static __inline__ vector signed long long __ATTRS_o_ai
13250vec_xor(vector signed long long __a, vector signed long long __b) {
13251 return __a ^ __b;
13252}
13253
13254static __inline__ vector signed long long __ATTRS_o_ai
13255vec_xor(vector bool long long __a, vector signed long long __b) {
13256 return (vector signed long long)__a ^ __b;
13257}
13258
13259static __inline__ vector signed long long __ATTRS_o_ai
13260vec_xor(vector signed long long __a, vector bool long long __b) {
13261 return __a ^ (vector signed long long)__b;
13262}
13263
13264static __inline__ vector unsigned long long __ATTRS_o_ai
13265vec_xor(vector unsigned long long __a, vector unsigned long long __b) {
13266 return __a ^ __b;
13267}
13268
13269static __inline__ vector unsigned long long __ATTRS_o_ai
13270vec_xor(vector bool long long __a, vector unsigned long long __b) {
13271 return (vector unsigned long long)__a ^ __b;
13272}
13273
13274static __inline__ vector unsigned long long __ATTRS_o_ai
13275vec_xor(vector unsigned long long __a, vector bool long long __b) {
13276 return __a ^ (vector unsigned long long)__b;
13277}
13278
13279static __inline__ vector bool long long __ATTRS_o_ai
13280vec_xor(vector bool long long __a, vector bool long long __b) {
13281 return __a ^ __b;
13282}
13283
13284static __inline__ vector double __ATTRS_o_ai vec_xor(vector double __a,
13285 vector double __b) {
13286 return (vector double)((vector unsigned long long)__a ^
13287 (vector unsigned long long)__b);
13288}
13289
13290static __inline__ vector double __ATTRS_o_ai
13291vec_xor(vector double __a, vector bool long long __b) {
13292 return (vector double)((vector unsigned long long)__a ^
13293 (vector unsigned long long)__b);
13294}
13295
13296static __inline__ vector double __ATTRS_o_ai vec_xor(vector bool long long __a,
13297 vector double __b) {
13298 return (vector double)((vector unsigned long long)__a ^
13299 (vector unsigned long long)__b);
13300}
13301#endif
13302
13303/* vec_vxor */
13304
13305static __inline__ vector signed char __ATTRS_o_ai
13306vec_vxor(vector signed char __a, vector signed char __b) {
13307 return __a ^ __b;
13308}
13309
13310static __inline__ vector signed char __ATTRS_o_ai
13311vec_vxor(vector bool char __a, vector signed char __b) {
13312 return (vector signed char)__a ^ __b;
13313}
13314
13315static __inline__ vector signed char __ATTRS_o_ai
13316vec_vxor(vector signed char __a, vector bool char __b) {
13317 return __a ^ (vector signed char)__b;
13318}
13319
13320static __inline__ vector unsigned char __ATTRS_o_ai
13321vec_vxor(vector unsigned char __a, vector unsigned char __b) {
13322 return __a ^ __b;
13323}
13324
13325static __inline__ vector unsigned char __ATTRS_o_ai
13326vec_vxor(vector bool char __a, vector unsigned char __b) {
13327 return (vector unsigned char)__a ^ __b;
13328}
13329
13330static __inline__ vector unsigned char __ATTRS_o_ai
13331vec_vxor(vector unsigned char __a, vector bool char __b) {
13332 return __a ^ (vector unsigned char)__b;
13333}
13334
13335static __inline__ vector bool char __ATTRS_o_ai vec_vxor(vector bool char __a,
13336 vector bool char __b) {
13337 return __a ^ __b;
13338}
13339
13340static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a,
13341 vector short __b) {
13342 return __a ^ __b;
13343}
13344
13345static __inline__ vector short __ATTRS_o_ai vec_vxor(vector bool short __a,
13346 vector short __b) {
13347 return (vector short)__a ^ __b;
13348}
13349
13350static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a,
13351 vector bool short __b) {
13352 return __a ^ (vector short)__b;
13353}
13354
13355static __inline__ vector unsigned short __ATTRS_o_ai
13356vec_vxor(vector unsigned short __a, vector unsigned short __b) {
13357 return __a ^ __b;
13358}
13359
13360static __inline__ vector unsigned short __ATTRS_o_ai
13361vec_vxor(vector bool short __a, vector unsigned short __b) {
13362 return (vector unsigned short)__a ^ __b;
13363}
13364
13365static __inline__ vector unsigned short __ATTRS_o_ai
13366vec_vxor(vector unsigned short __a, vector bool short __b) {
13367 return __a ^ (vector unsigned short)__b;
13368}
13369
13370static __inline__ vector bool short __ATTRS_o_ai
13371vec_vxor(vector bool short __a, vector bool short __b) {
13372 return __a ^ __b;
13373}
13374
13375static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a,
13376 vector int __b) {
13377 return __a ^ __b;
13378}
13379
13380static __inline__ vector int __ATTRS_o_ai vec_vxor(vector bool int __a,
13381 vector int __b) {
13382 return (vector int)__a ^ __b;
13383}
13384
13385static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a,
13386 vector bool int __b) {
13387 return __a ^ (vector int)__b;
13388}
13389
13390static __inline__ vector unsigned int __ATTRS_o_ai
13391vec_vxor(vector unsigned int __a, vector unsigned int __b) {
13392 return __a ^ __b;
13393}
13394
13395static __inline__ vector unsigned int __ATTRS_o_ai
13396vec_vxor(vector bool int __a, vector unsigned int __b) {
13397 return (vector unsigned int)__a ^ __b;
13398}
13399
13400static __inline__ vector unsigned int __ATTRS_o_ai
13401vec_vxor(vector unsigned int __a, vector bool int __b) {
13402 return __a ^ (vector unsigned int)__b;
13403}
13404
13405static __inline__ vector bool int __ATTRS_o_ai vec_vxor(vector bool int __a,
13406 vector bool int __b) {
13407 return __a ^ __b;
13408}
13409
13410static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a,
13411 vector float __b) {
13412 vector unsigned int __res =
13413 (vector unsigned int)__a ^ (vector unsigned int)__b;
13414 return (vector float)__res;
13415}
13416
13417static __inline__ vector float __ATTRS_o_ai vec_vxor(vector bool int __a,
13418 vector float __b) {
13419 vector unsigned int __res =
13420 (vector unsigned int)__a ^ (vector unsigned int)__b;
13421 return (vector float)__res;
13422}
13423
13424static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a,
13425 vector bool int __b) {
13426 vector unsigned int __res =
13427 (vector unsigned int)__a ^ (vector unsigned int)__b;
13428 return (vector float)__res;
13429}
13430
13431#ifdef __VSX__
13432static __inline__ vector signed long long __ATTRS_o_ai
13433vec_vxor(vector signed long long __a, vector signed long long __b) {
13434 return __a ^ __b;
13435}
13436
13437static __inline__ vector signed long long __ATTRS_o_ai
13438vec_vxor(vector bool long long __a, vector signed long long __b) {
13439 return (vector signed long long)__a ^ __b;
13440}
13441
13442static __inline__ vector signed long long __ATTRS_o_ai
13443vec_vxor(vector signed long long __a, vector bool long long __b) {
13444 return __a ^ (vector signed long long)__b;
13445}
13446
13447static __inline__ vector unsigned long long __ATTRS_o_ai
13448vec_vxor(vector unsigned long long __a, vector unsigned long long __b) {
13449 return __a ^ __b;
13450}
13451
13452static __inline__ vector unsigned long long __ATTRS_o_ai
13453vec_vxor(vector bool long long __a, vector unsigned long long __b) {
13454 return (vector unsigned long long)__a ^ __b;
13455}
13456
13457static __inline__ vector unsigned long long __ATTRS_o_ai
13458vec_vxor(vector unsigned long long __a, vector bool long long __b) {
13459 return __a ^ (vector unsigned long long)__b;
13460}
13461
13462static __inline__ vector bool long long __ATTRS_o_ai
13463vec_vxor(vector bool long long __a, vector bool long long __b) {
13464 return __a ^ __b;
13465}
13466#endif
13467
13468/* ------------------------ extensions for CBEA ----------------------------- */
13469
13470/* vec_extract */
13471
13472static __inline__ signed char __ATTRS_o_ai vec_extract(vector signed char __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013473 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013474 return __a[__b & 0xf];
Logan Chien2833ffb2018-10-09 10:03:24 +080013475}
13476
13477static __inline__ unsigned char __ATTRS_o_ai
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013478vec_extract(vector unsigned char __a, signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013479 return __a[__b & 0xf];
Logan Chien2833ffb2018-10-09 10:03:24 +080013480}
13481
13482static __inline__ unsigned char __ATTRS_o_ai vec_extract(vector bool char __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013483 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013484 return __a[__b & 0xf];
Logan Chien2833ffb2018-10-09 10:03:24 +080013485}
13486
13487static __inline__ signed short __ATTRS_o_ai vec_extract(vector signed short __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013488 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013489 return __a[__b & 0x7];
Logan Chien2833ffb2018-10-09 10:03:24 +080013490}
13491
13492static __inline__ unsigned short __ATTRS_o_ai
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013493vec_extract(vector unsigned short __a, signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013494 return __a[__b & 0x7];
Logan Chien2833ffb2018-10-09 10:03:24 +080013495}
13496
13497static __inline__ unsigned short __ATTRS_o_ai vec_extract(vector bool short __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013498 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013499 return __a[__b & 0x7];
Logan Chien2833ffb2018-10-09 10:03:24 +080013500}
13501
13502static __inline__ signed int __ATTRS_o_ai vec_extract(vector signed int __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013503 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013504 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013505}
13506
13507static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector unsigned int __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013508 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013509 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013510}
13511
13512static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector bool int __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013513 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013514 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013515}
13516
13517#ifdef __VSX__
13518static __inline__ signed long long __ATTRS_o_ai
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013519vec_extract(vector signed long long __a, signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013520 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013521}
13522
13523static __inline__ unsigned long long __ATTRS_o_ai
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013524vec_extract(vector unsigned long long __a, signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013525 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013526}
13527
13528static __inline__ unsigned long long __ATTRS_o_ai
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013529vec_extract(vector bool long long __a, signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013530 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013531}
13532
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013533static __inline__ double __ATTRS_o_ai vec_extract(vector double __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013534 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013535 return __a[__b & 0x1];
Logan Chien2833ffb2018-10-09 10:03:24 +080013536}
13537#endif
13538
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013539static __inline__ float __ATTRS_o_ai vec_extract(vector float __a,
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013540 signed int __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070013541 return __a[__b & 0x3];
Logan Chien2833ffb2018-10-09 10:03:24 +080013542}
13543
Logan Chien55afb0a2018-10-15 10:42:14 +080013544#ifdef __POWER9_VECTOR__
13545
13546#define vec_insert4b __builtin_vsx_insertword
13547#define vec_extract4b __builtin_vsx_extractuword
13548
13549/* vec_extract_exp */
13550
13551static __inline__ vector unsigned int __ATTRS_o_ai
13552vec_extract_exp(vector float __a) {
13553 return __builtin_vsx_xvxexpsp(__a);
13554}
13555
13556static __inline__ vector unsigned long long __ATTRS_o_ai
13557vec_extract_exp(vector double __a) {
13558 return __builtin_vsx_xvxexpdp(__a);
13559}
13560
13561/* vec_extract_sig */
13562
13563static __inline__ vector unsigned int __ATTRS_o_ai
13564vec_extract_sig(vector float __a) {
13565 return __builtin_vsx_xvxsigsp(__a);
13566}
13567
13568static __inline__ vector unsigned long long __ATTRS_o_ai
13569vec_extract_sig (vector double __a) {
13570 return __builtin_vsx_xvxsigdp(__a);
13571}
13572
13573static __inline__ vector float __ATTRS_o_ai
13574vec_extract_fp32_from_shorth(vector unsigned short __a) {
13575 vector unsigned short __b =
13576#ifdef __LITTLE_ENDIAN__
13577 __builtin_shufflevector(__a, __a, 0, -1, 1, -1, 2, -1, 3, -1);
13578#else
13579 __builtin_shufflevector(__a, __a, -1, 0, -1, 1, -1, 2, -1, 3);
13580#endif
13581 return __builtin_vsx_xvcvhpsp(__b);
13582}
13583
13584static __inline__ vector float __ATTRS_o_ai
13585vec_extract_fp32_from_shortl(vector unsigned short __a) {
13586 vector unsigned short __b =
13587#ifdef __LITTLE_ENDIAN__
13588 __builtin_shufflevector(__a, __a, 4, -1, 5, -1, 6, -1, 7, -1);
13589#else
13590 __builtin_shufflevector(__a, __a, -1, 4, -1, 5, -1, 6, -1, 7);
13591#endif
13592 return __builtin_vsx_xvcvhpsp(__b);
13593}
13594#endif /* __POWER9_VECTOR__ */
13595
Logan Chien2833ffb2018-10-09 10:03:24 +080013596/* vec_insert */
13597
13598static __inline__ vector signed char __ATTRS_o_ai
13599vec_insert(signed char __a, vector signed char __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013600 __b[__c & 0xF] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013601 return __b;
13602}
13603
13604static __inline__ vector unsigned char __ATTRS_o_ai
13605vec_insert(unsigned char __a, vector unsigned char __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013606 __b[__c & 0xF] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013607 return __b;
13608}
13609
13610static __inline__ vector bool char __ATTRS_o_ai vec_insert(unsigned char __a,
13611 vector bool char __b,
13612 int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013613 __b[__c & 0xF] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013614 return __b;
13615}
13616
13617static __inline__ vector signed short __ATTRS_o_ai
13618vec_insert(signed short __a, vector signed short __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013619 __b[__c & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013620 return __b;
13621}
13622
13623static __inline__ vector unsigned short __ATTRS_o_ai
13624vec_insert(unsigned short __a, vector unsigned short __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013625 __b[__c & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013626 return __b;
13627}
13628
13629static __inline__ vector bool short __ATTRS_o_ai
13630vec_insert(unsigned short __a, vector bool short __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013631 __b[__c & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013632 return __b;
13633}
13634
13635static __inline__ vector signed int __ATTRS_o_ai
13636vec_insert(signed int __a, vector signed int __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013637 __b[__c & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013638 return __b;
13639}
13640
13641static __inline__ vector unsigned int __ATTRS_o_ai
13642vec_insert(unsigned int __a, vector unsigned int __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013643 __b[__c & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013644 return __b;
13645}
13646
13647static __inline__ vector bool int __ATTRS_o_ai vec_insert(unsigned int __a,
13648 vector bool int __b,
13649 int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013650 __b[__c & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013651 return __b;
13652}
13653
13654#ifdef __VSX__
13655static __inline__ vector signed long long __ATTRS_o_ai
13656vec_insert(signed long long __a, vector signed long long __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013657 __b[__c & 0x1] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013658 return __b;
13659}
13660
13661static __inline__ vector unsigned long long __ATTRS_o_ai
13662vec_insert(unsigned long long __a, vector unsigned long long __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013663 __b[__c & 0x1] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013664 return __b;
13665}
13666
13667static __inline__ vector bool long long __ATTRS_o_ai
13668vec_insert(unsigned long long __a, vector bool long long __b, int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013669 __b[__c & 0x1] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013670 return __b;
13671}
13672static __inline__ vector double __ATTRS_o_ai vec_insert(double __a,
13673 vector double __b,
13674 int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013675 __b[__c & 0x1] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013676 return __b;
13677}
13678#endif
13679
13680static __inline__ vector float __ATTRS_o_ai vec_insert(float __a,
13681 vector float __b,
13682 int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080013683 __b[__c & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080013684 return __b;
13685}
13686
13687/* vec_lvlx */
13688
13689static __inline__ vector signed char __ATTRS_o_ai
13690vec_lvlx(int __a, const signed char *__b) {
13691 return vec_perm(vec_ld(__a, __b), (vector signed char)(0),
13692 vec_lvsl(__a, __b));
13693}
13694
13695static __inline__ vector signed char __ATTRS_o_ai
13696vec_lvlx(int __a, const vector signed char *__b) {
13697 return vec_perm(vec_ld(__a, __b), (vector signed char)(0),
13698 vec_lvsl(__a, (unsigned char *)__b));
13699}
13700
13701static __inline__ vector unsigned char __ATTRS_o_ai
13702vec_lvlx(int __a, const unsigned char *__b) {
13703 return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0),
13704 vec_lvsl(__a, __b));
13705}
13706
13707static __inline__ vector unsigned char __ATTRS_o_ai
13708vec_lvlx(int __a, const vector unsigned char *__b) {
13709 return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0),
13710 vec_lvsl(__a, (unsigned char *)__b));
13711}
13712
13713static __inline__ vector bool char __ATTRS_o_ai
13714vec_lvlx(int __a, const vector bool char *__b) {
13715 return vec_perm(vec_ld(__a, __b), (vector bool char)(0),
13716 vec_lvsl(__a, (unsigned char *)__b));
13717}
13718
13719static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a,
13720 const short *__b) {
13721 return vec_perm(vec_ld(__a, __b), (vector short)(0), vec_lvsl(__a, __b));
13722}
13723
13724static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a,
13725 const vector short *__b) {
13726 return vec_perm(vec_ld(__a, __b), (vector short)(0),
13727 vec_lvsl(__a, (unsigned char *)__b));
13728}
13729
13730static __inline__ vector unsigned short __ATTRS_o_ai
13731vec_lvlx(int __a, const unsigned short *__b) {
13732 return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0),
13733 vec_lvsl(__a, __b));
13734}
13735
13736static __inline__ vector unsigned short __ATTRS_o_ai
13737vec_lvlx(int __a, const vector unsigned short *__b) {
13738 return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0),
13739 vec_lvsl(__a, (unsigned char *)__b));
13740}
13741
13742static __inline__ vector bool short __ATTRS_o_ai
13743vec_lvlx(int __a, const vector bool short *__b) {
13744 return vec_perm(vec_ld(__a, __b), (vector bool short)(0),
13745 vec_lvsl(__a, (unsigned char *)__b));
13746}
13747
13748static __inline__ vector pixel __ATTRS_o_ai vec_lvlx(int __a,
13749 const vector pixel *__b) {
13750 return vec_perm(vec_ld(__a, __b), (vector pixel)(0),
13751 vec_lvsl(__a, (unsigned char *)__b));
13752}
13753
13754static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a, const int *__b) {
13755 return vec_perm(vec_ld(__a, __b), (vector int)(0), vec_lvsl(__a, __b));
13756}
13757
13758static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a,
13759 const vector int *__b) {
13760 return vec_perm(vec_ld(__a, __b), (vector int)(0),
13761 vec_lvsl(__a, (unsigned char *)__b));
13762}
13763
13764static __inline__ vector unsigned int __ATTRS_o_ai
13765vec_lvlx(int __a, const unsigned int *__b) {
13766 return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0),
13767 vec_lvsl(__a, __b));
13768}
13769
13770static __inline__ vector unsigned int __ATTRS_o_ai
13771vec_lvlx(int __a, const vector unsigned int *__b) {
13772 return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0),
13773 vec_lvsl(__a, (unsigned char *)__b));
13774}
13775
13776static __inline__ vector bool int __ATTRS_o_ai
13777vec_lvlx(int __a, const vector bool int *__b) {
13778 return vec_perm(vec_ld(__a, __b), (vector bool int)(0),
13779 vec_lvsl(__a, (unsigned char *)__b));
13780}
13781
13782static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a,
13783 const float *__b) {
13784 return vec_perm(vec_ld(__a, __b), (vector float)(0), vec_lvsl(__a, __b));
13785}
13786
13787static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a,
13788 const vector float *__b) {
13789 return vec_perm(vec_ld(__a, __b), (vector float)(0),
13790 vec_lvsl(__a, (unsigned char *)__b));
13791}
13792
13793/* vec_lvlxl */
13794
13795static __inline__ vector signed char __ATTRS_o_ai
13796vec_lvlxl(int __a, const signed char *__b) {
13797 return vec_perm(vec_ldl(__a, __b), (vector signed char)(0),
13798 vec_lvsl(__a, __b));
13799}
13800
13801static __inline__ vector signed char __ATTRS_o_ai
13802vec_lvlxl(int __a, const vector signed char *__b) {
13803 return vec_perm(vec_ldl(__a, __b), (vector signed char)(0),
13804 vec_lvsl(__a, (unsigned char *)__b));
13805}
13806
13807static __inline__ vector unsigned char __ATTRS_o_ai
13808vec_lvlxl(int __a, const unsigned char *__b) {
13809 return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0),
13810 vec_lvsl(__a, __b));
13811}
13812
13813static __inline__ vector unsigned char __ATTRS_o_ai
13814vec_lvlxl(int __a, const vector unsigned char *__b) {
13815 return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0),
13816 vec_lvsl(__a, (unsigned char *)__b));
13817}
13818
13819static __inline__ vector bool char __ATTRS_o_ai
13820vec_lvlxl(int __a, const vector bool char *__b) {
13821 return vec_perm(vec_ldl(__a, __b), (vector bool char)(0),
13822 vec_lvsl(__a, (unsigned char *)__b));
13823}
13824
13825static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a,
13826 const short *__b) {
13827 return vec_perm(vec_ldl(__a, __b), (vector short)(0), vec_lvsl(__a, __b));
13828}
13829
13830static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a,
13831 const vector short *__b) {
13832 return vec_perm(vec_ldl(__a, __b), (vector short)(0),
13833 vec_lvsl(__a, (unsigned char *)__b));
13834}
13835
13836static __inline__ vector unsigned short __ATTRS_o_ai
13837vec_lvlxl(int __a, const unsigned short *__b) {
13838 return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0),
13839 vec_lvsl(__a, __b));
13840}
13841
13842static __inline__ vector unsigned short __ATTRS_o_ai
13843vec_lvlxl(int __a, const vector unsigned short *__b) {
13844 return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0),
13845 vec_lvsl(__a, (unsigned char *)__b));
13846}
13847
13848static __inline__ vector bool short __ATTRS_o_ai
13849vec_lvlxl(int __a, const vector bool short *__b) {
13850 return vec_perm(vec_ldl(__a, __b), (vector bool short)(0),
13851 vec_lvsl(__a, (unsigned char *)__b));
13852}
13853
13854static __inline__ vector pixel __ATTRS_o_ai vec_lvlxl(int __a,
13855 const vector pixel *__b) {
13856 return vec_perm(vec_ldl(__a, __b), (vector pixel)(0),
13857 vec_lvsl(__a, (unsigned char *)__b));
13858}
13859
13860static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a, const int *__b) {
13861 return vec_perm(vec_ldl(__a, __b), (vector int)(0), vec_lvsl(__a, __b));
13862}
13863
13864static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a,
13865 const vector int *__b) {
13866 return vec_perm(vec_ldl(__a, __b), (vector int)(0),
13867 vec_lvsl(__a, (unsigned char *)__b));
13868}
13869
13870static __inline__ vector unsigned int __ATTRS_o_ai
13871vec_lvlxl(int __a, const unsigned int *__b) {
13872 return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0),
13873 vec_lvsl(__a, __b));
13874}
13875
13876static __inline__ vector unsigned int __ATTRS_o_ai
13877vec_lvlxl(int __a, const vector unsigned int *__b) {
13878 return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0),
13879 vec_lvsl(__a, (unsigned char *)__b));
13880}
13881
13882static __inline__ vector bool int __ATTRS_o_ai
13883vec_lvlxl(int __a, const vector bool int *__b) {
13884 return vec_perm(vec_ldl(__a, __b), (vector bool int)(0),
13885 vec_lvsl(__a, (unsigned char *)__b));
13886}
13887
13888static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a,
13889 const float *__b) {
13890 return vec_perm(vec_ldl(__a, __b), (vector float)(0), vec_lvsl(__a, __b));
13891}
13892
13893static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a,
13894 vector float *__b) {
13895 return vec_perm(vec_ldl(__a, __b), (vector float)(0),
13896 vec_lvsl(__a, (unsigned char *)__b));
13897}
13898
13899/* vec_lvrx */
13900
13901static __inline__ vector signed char __ATTRS_o_ai
13902vec_lvrx(int __a, const signed char *__b) {
13903 return vec_perm((vector signed char)(0), vec_ld(__a, __b),
13904 vec_lvsl(__a, __b));
13905}
13906
13907static __inline__ vector signed char __ATTRS_o_ai
13908vec_lvrx(int __a, const vector signed char *__b) {
13909 return vec_perm((vector signed char)(0), vec_ld(__a, __b),
13910 vec_lvsl(__a, (unsigned char *)__b));
13911}
13912
13913static __inline__ vector unsigned char __ATTRS_o_ai
13914vec_lvrx(int __a, const unsigned char *__b) {
13915 return vec_perm((vector unsigned char)(0), vec_ld(__a, __b),
13916 vec_lvsl(__a, __b));
13917}
13918
13919static __inline__ vector unsigned char __ATTRS_o_ai
13920vec_lvrx(int __a, const vector unsigned char *__b) {
13921 return vec_perm((vector unsigned char)(0), vec_ld(__a, __b),
13922 vec_lvsl(__a, (unsigned char *)__b));
13923}
13924
13925static __inline__ vector bool char __ATTRS_o_ai
13926vec_lvrx(int __a, const vector bool char *__b) {
13927 return vec_perm((vector bool char)(0), vec_ld(__a, __b),
13928 vec_lvsl(__a, (unsigned char *)__b));
13929}
13930
13931static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a,
13932 const short *__b) {
13933 return vec_perm((vector short)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
13934}
13935
13936static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a,
13937 const vector short *__b) {
13938 return vec_perm((vector short)(0), vec_ld(__a, __b),
13939 vec_lvsl(__a, (unsigned char *)__b));
13940}
13941
13942static __inline__ vector unsigned short __ATTRS_o_ai
13943vec_lvrx(int __a, const unsigned short *__b) {
13944 return vec_perm((vector unsigned short)(0), vec_ld(__a, __b),
13945 vec_lvsl(__a, __b));
13946}
13947
13948static __inline__ vector unsigned short __ATTRS_o_ai
13949vec_lvrx(int __a, const vector unsigned short *__b) {
13950 return vec_perm((vector unsigned short)(0), vec_ld(__a, __b),
13951 vec_lvsl(__a, (unsigned char *)__b));
13952}
13953
13954static __inline__ vector bool short __ATTRS_o_ai
13955vec_lvrx(int __a, const vector bool short *__b) {
13956 return vec_perm((vector bool short)(0), vec_ld(__a, __b),
13957 vec_lvsl(__a, (unsigned char *)__b));
13958}
13959
13960static __inline__ vector pixel __ATTRS_o_ai vec_lvrx(int __a,
13961 const vector pixel *__b) {
13962 return vec_perm((vector pixel)(0), vec_ld(__a, __b),
13963 vec_lvsl(__a, (unsigned char *)__b));
13964}
13965
13966static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a, const int *__b) {
13967 return vec_perm((vector int)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
13968}
13969
13970static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a,
13971 const vector int *__b) {
13972 return vec_perm((vector int)(0), vec_ld(__a, __b),
13973 vec_lvsl(__a, (unsigned char *)__b));
13974}
13975
13976static __inline__ vector unsigned int __ATTRS_o_ai
13977vec_lvrx(int __a, const unsigned int *__b) {
13978 return vec_perm((vector unsigned int)(0), vec_ld(__a, __b),
13979 vec_lvsl(__a, __b));
13980}
13981
13982static __inline__ vector unsigned int __ATTRS_o_ai
13983vec_lvrx(int __a, const vector unsigned int *__b) {
13984 return vec_perm((vector unsigned int)(0), vec_ld(__a, __b),
13985 vec_lvsl(__a, (unsigned char *)__b));
13986}
13987
13988static __inline__ vector bool int __ATTRS_o_ai
13989vec_lvrx(int __a, const vector bool int *__b) {
13990 return vec_perm((vector bool int)(0), vec_ld(__a, __b),
13991 vec_lvsl(__a, (unsigned char *)__b));
13992}
13993
13994static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a,
13995 const float *__b) {
13996 return vec_perm((vector float)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
13997}
13998
13999static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a,
14000 const vector float *__b) {
14001 return vec_perm((vector float)(0), vec_ld(__a, __b),
14002 vec_lvsl(__a, (unsigned char *)__b));
14003}
14004
14005/* vec_lvrxl */
14006
14007static __inline__ vector signed char __ATTRS_o_ai
14008vec_lvrxl(int __a, const signed char *__b) {
14009 return vec_perm((vector signed char)(0), vec_ldl(__a, __b),
14010 vec_lvsl(__a, __b));
14011}
14012
14013static __inline__ vector signed char __ATTRS_o_ai
14014vec_lvrxl(int __a, const vector signed char *__b) {
14015 return vec_perm((vector signed char)(0), vec_ldl(__a, __b),
14016 vec_lvsl(__a, (unsigned char *)__b));
14017}
14018
14019static __inline__ vector unsigned char __ATTRS_o_ai
14020vec_lvrxl(int __a, const unsigned char *__b) {
14021 return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b),
14022 vec_lvsl(__a, __b));
14023}
14024
14025static __inline__ vector unsigned char __ATTRS_o_ai
14026vec_lvrxl(int __a, const vector unsigned char *__b) {
14027 return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b),
14028 vec_lvsl(__a, (unsigned char *)__b));
14029}
14030
14031static __inline__ vector bool char __ATTRS_o_ai
14032vec_lvrxl(int __a, const vector bool char *__b) {
14033 return vec_perm((vector bool char)(0), vec_ldl(__a, __b),
14034 vec_lvsl(__a, (unsigned char *)__b));
14035}
14036
14037static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a,
14038 const short *__b) {
14039 return vec_perm((vector short)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
14040}
14041
14042static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a,
14043 const vector short *__b) {
14044 return vec_perm((vector short)(0), vec_ldl(__a, __b),
14045 vec_lvsl(__a, (unsigned char *)__b));
14046}
14047
14048static __inline__ vector unsigned short __ATTRS_o_ai
14049vec_lvrxl(int __a, const unsigned short *__b) {
14050 return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b),
14051 vec_lvsl(__a, __b));
14052}
14053
14054static __inline__ vector unsigned short __ATTRS_o_ai
14055vec_lvrxl(int __a, const vector unsigned short *__b) {
14056 return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b),
14057 vec_lvsl(__a, (unsigned char *)__b));
14058}
14059
14060static __inline__ vector bool short __ATTRS_o_ai
14061vec_lvrxl(int __a, const vector bool short *__b) {
14062 return vec_perm((vector bool short)(0), vec_ldl(__a, __b),
14063 vec_lvsl(__a, (unsigned char *)__b));
14064}
14065
14066static __inline__ vector pixel __ATTRS_o_ai vec_lvrxl(int __a,
14067 const vector pixel *__b) {
14068 return vec_perm((vector pixel)(0), vec_ldl(__a, __b),
14069 vec_lvsl(__a, (unsigned char *)__b));
14070}
14071
14072static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a, const int *__b) {
14073 return vec_perm((vector int)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
14074}
14075
14076static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a,
14077 const vector int *__b) {
14078 return vec_perm((vector int)(0), vec_ldl(__a, __b),
14079 vec_lvsl(__a, (unsigned char *)__b));
14080}
14081
14082static __inline__ vector unsigned int __ATTRS_o_ai
14083vec_lvrxl(int __a, const unsigned int *__b) {
14084 return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b),
14085 vec_lvsl(__a, __b));
14086}
14087
14088static __inline__ vector unsigned int __ATTRS_o_ai
14089vec_lvrxl(int __a, const vector unsigned int *__b) {
14090 return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b),
14091 vec_lvsl(__a, (unsigned char *)__b));
14092}
14093
14094static __inline__ vector bool int __ATTRS_o_ai
14095vec_lvrxl(int __a, const vector bool int *__b) {
14096 return vec_perm((vector bool int)(0), vec_ldl(__a, __b),
14097 vec_lvsl(__a, (unsigned char *)__b));
14098}
14099
14100static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a,
14101 const float *__b) {
14102 return vec_perm((vector float)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
14103}
14104
14105static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a,
14106 const vector float *__b) {
14107 return vec_perm((vector float)(0), vec_ldl(__a, __b),
14108 vec_lvsl(__a, (unsigned char *)__b));
14109}
14110
14111/* vec_stvlx */
14112
14113static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b,
14114 signed char *__c) {
14115 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14116 __c);
14117}
14118
14119static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b,
14120 vector signed char *__c) {
14121 return vec_st(
14122 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14123 __b, __c);
14124}
14125
14126static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b,
14127 unsigned char *__c) {
14128 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14129 __c);
14130}
14131
14132static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b,
14133 vector unsigned char *__c) {
14134 return vec_st(
14135 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14136 __b, __c);
14137}
14138
14139static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool char __a, int __b,
14140 vector bool char *__c) {
14141 return vec_st(
14142 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14143 __b, __c);
14144}
14145
14146static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b,
14147 short *__c) {
14148 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14149 __c);
14150}
14151
14152static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b,
14153 vector short *__c) {
14154 return vec_st(
14155 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14156 __b, __c);
14157}
14158
14159static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a,
14160 int __b, unsigned short *__c) {
14161 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14162 __c);
14163}
14164
14165static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a,
14166 int __b,
14167 vector unsigned short *__c) {
14168 return vec_st(
14169 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14170 __b, __c);
14171}
14172
14173static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool short __a, int __b,
14174 vector bool short *__c) {
14175 return vec_st(
14176 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14177 __b, __c);
14178}
14179
14180static __inline__ void __ATTRS_o_ai vec_stvlx(vector pixel __a, int __b,
14181 vector pixel *__c) {
14182 return vec_st(
14183 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14184 __b, __c);
14185}
14186
14187static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b,
14188 int *__c) {
14189 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14190 __c);
14191}
14192
14193static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b,
14194 vector int *__c) {
14195 return vec_st(
14196 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14197 __b, __c);
14198}
14199
14200static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b,
14201 unsigned int *__c) {
14202 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14203 __c);
14204}
14205
14206static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b,
14207 vector unsigned int *__c) {
14208 return vec_st(
14209 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14210 __b, __c);
14211}
14212
14213static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool int __a, int __b,
14214 vector bool int *__c) {
14215 return vec_st(
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_stvlx(vector float __a, int __b,
14221 vector float *__c) {
14222 return vec_st(
14223 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14224 __b, __c);
14225}
14226
14227/* vec_stvlxl */
14228
14229static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b,
14230 signed char *__c) {
14231 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14232 __c);
14233}
14234
14235static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b,
14236 vector signed char *__c) {
14237 return vec_stl(
14238 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14239 __b, __c);
14240}
14241
14242static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a,
14243 int __b, unsigned char *__c) {
14244 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14245 __c);
14246}
14247
14248static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a,
14249 int __b,
14250 vector unsigned char *__c) {
14251 return vec_stl(
14252 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14253 __b, __c);
14254}
14255
14256static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool char __a, int __b,
14257 vector bool char *__c) {
14258 return vec_stl(
14259 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14260 __b, __c);
14261}
14262
14263static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b,
14264 short *__c) {
14265 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14266 __c);
14267}
14268
14269static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b,
14270 vector short *__c) {
14271 return vec_stl(
14272 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14273 __b, __c);
14274}
14275
14276static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a,
14277 int __b, unsigned short *__c) {
14278 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14279 __c);
14280}
14281
14282static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a,
14283 int __b,
14284 vector unsigned short *__c) {
14285 return vec_stl(
14286 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14287 __b, __c);
14288}
14289
14290static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool short __a, int __b,
14291 vector bool short *__c) {
14292 return vec_stl(
14293 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14294 __b, __c);
14295}
14296
14297static __inline__ void __ATTRS_o_ai vec_stvlxl(vector pixel __a, int __b,
14298 vector pixel *__c) {
14299 return vec_stl(
14300 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14301 __b, __c);
14302}
14303
14304static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b,
14305 int *__c) {
14306 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14307 __c);
14308}
14309
14310static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b,
14311 vector int *__c) {
14312 return vec_stl(
14313 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14314 __b, __c);
14315}
14316
14317static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b,
14318 unsigned int *__c) {
14319 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
14320 __c);
14321}
14322
14323static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b,
14324 vector unsigned int *__c) {
14325 return vec_stl(
14326 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14327 __b, __c);
14328}
14329
14330static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool int __a, int __b,
14331 vector bool int *__c) {
14332 return vec_stl(
14333 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14334 __b, __c);
14335}
14336
14337static __inline__ void __ATTRS_o_ai vec_stvlxl(vector float __a, int __b,
14338 vector float *__c) {
14339 return vec_stl(
14340 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
14341 __b, __c);
14342}
14343
14344/* vec_stvrx */
14345
14346static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b,
14347 signed char *__c) {
14348 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14349 __c);
14350}
14351
14352static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b,
14353 vector signed char *__c) {
14354 return vec_st(
14355 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14356 __b, __c);
14357}
14358
14359static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b,
14360 unsigned char *__c) {
14361 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14362 __c);
14363}
14364
14365static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b,
14366 vector unsigned char *__c) {
14367 return vec_st(
14368 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14369 __b, __c);
14370}
14371
14372static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool char __a, int __b,
14373 vector bool char *__c) {
14374 return vec_st(
14375 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14376 __b, __c);
14377}
14378
14379static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b,
14380 short *__c) {
14381 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14382 __c);
14383}
14384
14385static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b,
14386 vector short *__c) {
14387 return vec_st(
14388 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14389 __b, __c);
14390}
14391
14392static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a,
14393 int __b, unsigned short *__c) {
14394 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14395 __c);
14396}
14397
14398static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a,
14399 int __b,
14400 vector unsigned short *__c) {
14401 return vec_st(
14402 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14403 __b, __c);
14404}
14405
14406static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool short __a, int __b,
14407 vector bool short *__c) {
14408 return vec_st(
14409 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14410 __b, __c);
14411}
14412
14413static __inline__ void __ATTRS_o_ai vec_stvrx(vector pixel __a, int __b,
14414 vector pixel *__c) {
14415 return vec_st(
14416 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14417 __b, __c);
14418}
14419
14420static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b,
14421 int *__c) {
14422 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14423 __c);
14424}
14425
14426static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b,
14427 vector int *__c) {
14428 return vec_st(
14429 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14430 __b, __c);
14431}
14432
14433static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b,
14434 unsigned int *__c) {
14435 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14436 __c);
14437}
14438
14439static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b,
14440 vector unsigned int *__c) {
14441 return vec_st(
14442 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14443 __b, __c);
14444}
14445
14446static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool int __a, int __b,
14447 vector bool int *__c) {
14448 return vec_st(
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_stvrx(vector float __a, int __b,
14454 vector float *__c) {
14455 return vec_st(
14456 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14457 __b, __c);
14458}
14459
14460/* vec_stvrxl */
14461
14462static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b,
14463 signed char *__c) {
14464 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14465 __c);
14466}
14467
14468static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b,
14469 vector signed char *__c) {
14470 return vec_stl(
14471 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14472 __b, __c);
14473}
14474
14475static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a,
14476 int __b, unsigned char *__c) {
14477 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14478 __c);
14479}
14480
14481static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a,
14482 int __b,
14483 vector unsigned char *__c) {
14484 return vec_stl(
14485 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14486 __b, __c);
14487}
14488
14489static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool char __a, int __b,
14490 vector bool char *__c) {
14491 return vec_stl(
14492 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14493 __b, __c);
14494}
14495
14496static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b,
14497 short *__c) {
14498 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14499 __c);
14500}
14501
14502static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b,
14503 vector short *__c) {
14504 return vec_stl(
14505 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14506 __b, __c);
14507}
14508
14509static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a,
14510 int __b, unsigned short *__c) {
14511 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14512 __c);
14513}
14514
14515static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a,
14516 int __b,
14517 vector unsigned short *__c) {
14518 return vec_stl(
14519 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14520 __b, __c);
14521}
14522
14523static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool short __a, int __b,
14524 vector bool short *__c) {
14525 return vec_stl(
14526 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14527 __b, __c);
14528}
14529
14530static __inline__ void __ATTRS_o_ai vec_stvrxl(vector pixel __a, int __b,
14531 vector pixel *__c) {
14532 return vec_stl(
14533 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14534 __b, __c);
14535}
14536
14537static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b,
14538 int *__c) {
14539 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14540 __c);
14541}
14542
14543static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b,
14544 vector int *__c) {
14545 return vec_stl(
14546 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14547 __b, __c);
14548}
14549
14550static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b,
14551 unsigned int *__c) {
14552 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
14553 __c);
14554}
14555
14556static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b,
14557 vector unsigned int *__c) {
14558 return vec_stl(
14559 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14560 __b, __c);
14561}
14562
14563static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool int __a, int __b,
14564 vector bool int *__c) {
14565 return vec_stl(
14566 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14567 __b, __c);
14568}
14569
14570static __inline__ void __ATTRS_o_ai vec_stvrxl(vector float __a, int __b,
14571 vector float *__c) {
14572 return vec_stl(
14573 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
14574 __b, __c);
14575}
14576
14577/* vec_promote */
14578
14579static __inline__ vector signed char __ATTRS_o_ai vec_promote(signed char __a,
14580 int __b) {
14581 vector signed char __res = (vector signed char)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014582 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014583 return __res;
14584}
14585
14586static __inline__ vector unsigned char __ATTRS_o_ai
14587vec_promote(unsigned char __a, int __b) {
14588 vector unsigned char __res = (vector unsigned char)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014589 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014590 return __res;
14591}
14592
14593static __inline__ vector short __ATTRS_o_ai vec_promote(short __a, int __b) {
14594 vector short __res = (vector short)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014595 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014596 return __res;
14597}
14598
14599static __inline__ vector unsigned short __ATTRS_o_ai
14600vec_promote(unsigned short __a, int __b) {
14601 vector unsigned short __res = (vector unsigned short)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014602 __res[__b & 0x7] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014603 return __res;
14604}
14605
14606static __inline__ vector int __ATTRS_o_ai vec_promote(int __a, int __b) {
14607 vector int __res = (vector int)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014608 __res[__b & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014609 return __res;
14610}
14611
14612static __inline__ vector unsigned int __ATTRS_o_ai vec_promote(unsigned int __a,
14613 int __b) {
14614 vector unsigned int __res = (vector unsigned int)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014615 __res[__b & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014616 return __res;
14617}
14618
14619static __inline__ vector float __ATTRS_o_ai vec_promote(float __a, int __b) {
14620 vector float __res = (vector float)(0);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014621 __res[__b & 0x3] = __a;
Logan Chien2833ffb2018-10-09 10:03:24 +080014622 return __res;
14623}
14624
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014625#ifdef __VSX__
14626static __inline__ vector double __ATTRS_o_ai vec_promote(double __a, int __b) {
14627 vector double __res = (vector double)(0);
14628 __res[__b & 0x1] = __a;
14629 return __res;
14630}
14631
14632static __inline__ vector signed long long __ATTRS_o_ai
14633vec_promote(signed long long __a, int __b) {
14634 vector signed long long __res = (vector signed long long)(0);
14635 __res[__b & 0x1] = __a;
14636 return __res;
14637}
14638
14639static __inline__ vector unsigned long long __ATTRS_o_ai
14640vec_promote(unsigned long long __a, int __b) {
14641 vector unsigned long long __res = (vector unsigned long long)(0);
14642 __res[__b & 0x1] = __a;
14643 return __res;
14644}
14645#endif
14646
Logan Chien2833ffb2018-10-09 10:03:24 +080014647/* vec_splats */
14648
14649static __inline__ vector signed char __ATTRS_o_ai vec_splats(signed char __a) {
14650 return (vector signed char)(__a);
14651}
14652
14653static __inline__ vector unsigned char __ATTRS_o_ai
14654vec_splats(unsigned char __a) {
14655 return (vector unsigned char)(__a);
14656}
14657
14658static __inline__ vector short __ATTRS_o_ai vec_splats(short __a) {
14659 return (vector short)(__a);
14660}
14661
14662static __inline__ vector unsigned short __ATTRS_o_ai
14663vec_splats(unsigned short __a) {
14664 return (vector unsigned short)(__a);
14665}
14666
14667static __inline__ vector int __ATTRS_o_ai vec_splats(int __a) {
14668 return (vector int)(__a);
14669}
14670
14671static __inline__ vector unsigned int __ATTRS_o_ai
14672vec_splats(unsigned int __a) {
14673 return (vector unsigned int)(__a);
14674}
14675
14676#ifdef __VSX__
14677static __inline__ vector signed long long __ATTRS_o_ai
14678vec_splats(signed long long __a) {
14679 return (vector signed long long)(__a);
14680}
14681
14682static __inline__ vector unsigned long long __ATTRS_o_ai
14683vec_splats(unsigned long long __a) {
14684 return (vector unsigned long long)(__a);
14685}
14686
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014687#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
14688 defined(__SIZEOF_INT128__)
Logan Chien2833ffb2018-10-09 10:03:24 +080014689static __inline__ vector signed __int128 __ATTRS_o_ai
14690vec_splats(signed __int128 __a) {
14691 return (vector signed __int128)(__a);
14692}
14693
14694static __inline__ vector unsigned __int128 __ATTRS_o_ai
14695vec_splats(unsigned __int128 __a) {
14696 return (vector unsigned __int128)(__a);
14697}
14698
14699#endif
14700
14701static __inline__ vector double __ATTRS_o_ai vec_splats(double __a) {
14702 return (vector double)(__a);
14703}
14704#endif
14705
14706static __inline__ vector float __ATTRS_o_ai vec_splats(float __a) {
14707 return (vector float)(__a);
14708}
14709
14710/* ----------------------------- predicates --------------------------------- */
14711
14712/* vec_all_eq */
14713
14714static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a,
14715 vector signed 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 signed char __a,
14721 vector bool char __b) {
14722 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14723 (vector char)__b);
14724}
14725
14726static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a,
14727 vector unsigned char __b) {
14728 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14729 (vector char)__b);
14730}
14731
14732static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a,
14733 vector bool char __b) {
14734 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14735 (vector char)__b);
14736}
14737
14738static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
14739 vector signed char __b) {
14740 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14741 (vector char)__b);
14742}
14743
14744static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
14745 vector unsigned char __b) {
14746 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14747 (vector char)__b);
14748}
14749
14750static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
14751 vector bool char __b) {
14752 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
14753 (vector char)__b);
14754}
14755
14756static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a,
14757 vector short __b) {
14758 return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, __b);
14759}
14760
14761static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a,
14762 vector bool short __b) {
14763 return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, (vector short)__b);
14764}
14765
14766static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a,
14767 vector unsigned short __b) {
14768 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14769 (vector short)__b);
14770}
14771
14772static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a,
14773 vector bool short __b) {
14774 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14775 (vector short)__b);
14776}
14777
14778static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
14779 vector short __b) {
14780 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14781 (vector short)__b);
14782}
14783
14784static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
14785 vector unsigned short __b) {
14786 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14787 (vector short)__b);
14788}
14789
14790static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
14791 vector bool short __b) {
14792 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14793 (vector short)__b);
14794}
14795
14796static __inline__ int __ATTRS_o_ai vec_all_eq(vector pixel __a,
14797 vector pixel __b) {
14798 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
14799 (vector short)__b);
14800}
14801
14802static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a, vector int __b) {
14803 return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, __b);
14804}
14805
14806static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a,
14807 vector bool int __b) {
14808 return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, (vector int)__b);
14809}
14810
14811static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a,
14812 vector unsigned int __b) {
14813 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14814 (vector int)__b);
14815}
14816
14817static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a,
14818 vector bool int __b) {
14819 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14820 (vector int)__b);
14821}
14822
14823static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
14824 vector int __b) {
14825 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14826 (vector int)__b);
14827}
14828
14829static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
14830 vector unsigned int __b) {
14831 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14832 (vector int)__b);
14833}
14834
14835static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
14836 vector bool int __b) {
14837 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
14838 (vector int)__b);
14839}
14840
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014841#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080014842static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed long long __a,
14843 vector signed long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014844#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080014845 return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, __b);
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014846#else
14847 // No vcmpequd on Power7 so we xor the two vectors and compare against zero as
14848 // 32-bit elements.
14849 return vec_all_eq((vector signed int)vec_xor(__a, __b), (vector signed int)0);
14850#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080014851}
14852
14853static __inline__ int __ATTRS_o_ai vec_all_eq(vector long long __a,
14854 vector bool long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014855 return vec_all_eq((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080014856}
14857
14858static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a,
14859 vector unsigned long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014860 return vec_all_eq((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080014861}
14862
14863static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a,
14864 vector bool long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014865 return vec_all_eq((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080014866}
14867
14868static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
14869 vector long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014870 return vec_all_eq((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080014871}
14872
14873static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
14874 vector unsigned long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014875 return vec_all_eq((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080014876}
14877
14878static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
14879 vector bool long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014880 return vec_all_eq((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080014881}
14882#endif
14883
14884static __inline__ int __ATTRS_o_ai vec_all_eq(vector float __a,
14885 vector float __b) {
14886#ifdef __VSX__
14887 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __b);
14888#else
14889 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __b);
14890#endif
14891}
14892
14893#ifdef __VSX__
14894static __inline__ int __ATTRS_o_ai vec_all_eq(vector double __a,
14895 vector double __b) {
14896 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __b);
14897}
14898#endif
14899
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070014900#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080014901static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed __int128 __a,
14902 vector signed __int128 __b) {
14903 return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
14904}
14905
14906static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned __int128 __a,
14907 vector unsigned __int128 __b) {
14908 return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
14909}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080014910
14911static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool __int128 __a,
14912 vector bool __int128 __b) {
14913 return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
14914}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080014915#endif
14916
Logan Chien2833ffb2018-10-09 10:03:24 +080014917/* vec_all_ge */
14918
14919static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a,
14920 vector signed char __b) {
14921 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, __a);
14922}
14923
14924static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a,
14925 vector bool char __b) {
14926 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b, __a);
14927}
14928
14929static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a,
14930 vector unsigned char __b) {
14931 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, __a);
14932}
14933
14934static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a,
14935 vector bool char __b) {
14936 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b, __a);
14937}
14938
14939static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
14940 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080014941 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080014942}
14943
14944static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
14945 vector unsigned char __b) {
14946 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, (vector unsigned char)__a);
14947}
14948
14949static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
14950 vector bool char __b) {
14951 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
14952 (vector unsigned char)__a);
14953}
14954
14955static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a,
14956 vector short __b) {
14957 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, __a);
14958}
14959
14960static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a,
14961 vector bool short __b) {
14962 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector short)__b, __a);
14963}
14964
14965static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a,
14966 vector unsigned short __b) {
14967 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b, __a);
14968}
14969
14970static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a,
14971 vector bool short __b) {
14972 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
14973 __a);
14974}
14975
14976static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
14977 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080014978 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080014979}
14980
14981static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
14982 vector unsigned short __b) {
14983 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b,
14984 (vector unsigned short)__a);
14985}
14986
14987static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
14988 vector bool short __b) {
14989 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
14990 (vector unsigned short)__a);
14991}
14992
14993static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a, vector int __b) {
14994 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, __a);
14995}
14996
14997static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a,
14998 vector bool int __b) {
14999 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector int)__b, __a);
15000}
15001
15002static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a,
15003 vector unsigned int __b) {
15004 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, __a);
15005}
15006
15007static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a,
15008 vector bool int __b) {
15009 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b, __a);
15010}
15011
15012static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
15013 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015014 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015015}
15016
15017static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
15018 vector unsigned int __b) {
15019 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, (vector unsigned int)__a);
15020}
15021
15022static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
15023 vector bool int __b) {
15024 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b,
15025 (vector unsigned int)__a);
15026}
15027
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015028#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015029static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
15030 vector signed long long __b) {
15031 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, __a);
15032}
15033static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
15034 vector bool long long __b) {
15035 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b,
15036 __a);
15037}
15038
15039static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a,
15040 vector unsigned long long __b) {
15041 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b, __a);
15042}
15043
15044static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a,
15045 vector bool long long __b) {
15046 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
15047 __a);
15048}
15049
15050static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
15051 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015052 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b,
15053 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015054}
15055
15056static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
15057 vector unsigned long long __b) {
15058 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b,
15059 (vector unsigned long long)__a);
15060}
15061
15062static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
15063 vector bool long long __b) {
15064 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
15065 (vector unsigned long long)__a);
15066}
15067#endif
15068
15069static __inline__ int __ATTRS_o_ai vec_all_ge(vector float __a,
15070 vector float __b) {
15071#ifdef __VSX__
15072 return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __a, __b);
15073#else
15074 return __builtin_altivec_vcmpgefp_p(__CR6_LT, __a, __b);
15075#endif
15076}
15077
15078#ifdef __VSX__
15079static __inline__ int __ATTRS_o_ai vec_all_ge(vector double __a,
15080 vector double __b) {
15081 return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __a, __b);
15082}
15083#endif
15084
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015085#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015086static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed __int128 __a,
15087 vector signed __int128 __b) {
15088 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ, __b, __a);
15089}
15090
15091static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned __int128 __a,
15092 vector unsigned __int128 __b) {
15093 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ, __b, __a);
15094}
15095#endif
15096
Logan Chien2833ffb2018-10-09 10:03:24 +080015097/* vec_all_gt */
15098
15099static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a,
15100 vector signed char __b) {
15101 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, __b);
15102}
15103
15104static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a,
15105 vector bool char __b) {
15106 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, (vector signed char)__b);
15107}
15108
15109static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a,
15110 vector unsigned char __b) {
15111 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, __b);
15112}
15113
15114static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a,
15115 vector bool char __b) {
15116 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, (vector unsigned char)__b);
15117}
15118
15119static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
15120 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015121 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015122}
15123
15124static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
15125 vector unsigned char __b) {
15126 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a, __b);
15127}
15128
15129static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
15130 vector bool char __b) {
15131 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
15132 (vector unsigned char)__b);
15133}
15134
15135static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a,
15136 vector short __b) {
15137 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, __b);
15138}
15139
15140static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a,
15141 vector bool short __b) {
15142 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, (vector short)__b);
15143}
15144
15145static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a,
15146 vector unsigned short __b) {
15147 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a, __b);
15148}
15149
15150static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a,
15151 vector bool short __b) {
15152 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a,
15153 (vector unsigned short)__b);
15154}
15155
15156static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
15157 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015158 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015159}
15160
15161static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
15162 vector unsigned short __b) {
15163 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
15164 __b);
15165}
15166
15167static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
15168 vector bool short __b) {
15169 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
15170 (vector unsigned short)__b);
15171}
15172
15173static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a, vector int __b) {
15174 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, __b);
15175}
15176
15177static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a,
15178 vector bool int __b) {
15179 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, (vector int)__b);
15180}
15181
15182static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a,
15183 vector unsigned int __b) {
15184 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, __b);
15185}
15186
15187static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a,
15188 vector bool int __b) {
15189 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, (vector unsigned int)__b);
15190}
15191
15192static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
15193 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015194 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector signed int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015195}
15196
15197static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
15198 vector unsigned int __b) {
15199 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a, __b);
15200}
15201
15202static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
15203 vector bool int __b) {
15204 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a,
15205 (vector unsigned int)__b);
15206}
15207
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015208#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015209static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
15210 vector signed long long __b) {
15211 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a, __b);
15212}
15213static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
15214 vector bool long long __b) {
15215 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a,
15216 (vector signed long long)__b);
15217}
15218
15219static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a,
15220 vector unsigned long long __b) {
15221 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a, __b);
15222}
15223
15224static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a,
15225 vector bool long long __b) {
15226 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a,
15227 (vector unsigned long long)__b);
15228}
15229
15230static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
15231 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015232 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__a,
15233 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015234}
15235
15236static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
15237 vector unsigned long long __b) {
15238 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
15239 __b);
15240}
15241
15242static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
15243 vector bool long long __b) {
15244 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
15245 (vector unsigned long long)__b);
15246}
15247#endif
15248
15249static __inline__ int __ATTRS_o_ai vec_all_gt(vector float __a,
15250 vector float __b) {
15251#ifdef __VSX__
15252 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __a, __b);
15253#else
15254 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __a, __b);
15255#endif
15256}
15257
15258#ifdef __VSX__
15259static __inline__ int __ATTRS_o_ai vec_all_gt(vector double __a,
15260 vector double __b) {
15261 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __a, __b);
15262}
15263#endif
15264
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015265#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015266static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed __int128 __a,
15267 vector signed __int128 __b) {
15268 return __builtin_altivec_vcmpgtsq_p(__CR6_LT, __a, __b);
15269}
15270
15271static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned __int128 __a,
15272 vector unsigned __int128 __b) {
15273 return __builtin_altivec_vcmpgtuq_p(__CR6_LT, __a, __b);
15274}
15275#endif
15276
Logan Chien2833ffb2018-10-09 10:03:24 +080015277/* vec_all_in */
15278
15279static __inline__ int __attribute__((__always_inline__))
15280vec_all_in(vector float __a, vector float __b) {
15281 return __builtin_altivec_vcmpbfp_p(__CR6_EQ, __a, __b);
15282}
15283
15284/* vec_all_le */
15285
15286static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a,
15287 vector signed char __b) {
15288 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, __b);
15289}
15290
15291static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a,
15292 vector bool char __b) {
15293 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, (vector signed char)__b);
15294}
15295
15296static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a,
15297 vector unsigned char __b) {
15298 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, __b);
15299}
15300
15301static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a,
15302 vector bool char __b) {
15303 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, (vector unsigned char)__b);
15304}
15305
15306static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
15307 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015308 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015309}
15310
15311static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
15312 vector unsigned char __b) {
15313 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a, __b);
15314}
15315
15316static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
15317 vector bool char __b) {
15318 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a,
15319 (vector unsigned char)__b);
15320}
15321
15322static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a,
15323 vector short __b) {
15324 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, __b);
15325}
15326
15327static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a,
15328 vector bool short __b) {
15329 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, (vector short)__b);
15330}
15331
15332static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a,
15333 vector unsigned short __b) {
15334 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a, __b);
15335}
15336
15337static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a,
15338 vector bool short __b) {
15339 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a,
15340 (vector unsigned short)__b);
15341}
15342
15343static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
15344 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015345 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector signed short)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015346}
15347
15348static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
15349 vector unsigned short __b) {
15350 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
15351 __b);
15352}
15353
15354static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
15355 vector bool short __b) {
15356 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
15357 (vector unsigned short)__b);
15358}
15359
15360static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a, vector int __b) {
15361 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, __b);
15362}
15363
15364static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a,
15365 vector bool int __b) {
15366 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, (vector int)__b);
15367}
15368
15369static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a,
15370 vector unsigned int __b) {
15371 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, __b);
15372}
15373
15374static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a,
15375 vector bool int __b) {
15376 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, (vector unsigned int)__b);
15377}
15378
15379static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
15380 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015381 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector signed int)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015382}
15383
15384static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
15385 vector unsigned int __b) {
15386 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a, __b);
15387}
15388
15389static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
15390 vector bool int __b) {
15391 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a,
15392 (vector unsigned int)__b);
15393}
15394
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015395#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015396static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
15397 vector signed long long __b) {
15398 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a, __b);
15399}
15400
15401static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a,
15402 vector unsigned long long __b) {
15403 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a, __b);
15404}
15405
15406static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
15407 vector bool long long __b) {
15408 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a,
15409 (vector signed long long)__b);
15410}
15411
15412static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a,
15413 vector bool long long __b) {
15414 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a,
15415 (vector unsigned long long)__b);
15416}
15417
15418static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
15419 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015420 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__a,
15421 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015422}
15423
15424static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
15425 vector unsigned long long __b) {
15426 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
15427 __b);
15428}
15429
15430static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
15431 vector bool long long __b) {
15432 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
15433 (vector unsigned long long)__b);
15434}
15435#endif
15436
15437static __inline__ int __ATTRS_o_ai vec_all_le(vector float __a,
15438 vector float __b) {
15439#ifdef __VSX__
15440 return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __b, __a);
15441#else
15442 return __builtin_altivec_vcmpgefp_p(__CR6_LT, __b, __a);
15443#endif
15444}
15445
15446#ifdef __VSX__
15447static __inline__ int __ATTRS_o_ai vec_all_le(vector double __a,
15448 vector double __b) {
15449 return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __b, __a);
15450}
15451#endif
15452
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015453#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015454static __inline__ int __ATTRS_o_ai vec_all_le(vector signed __int128 __a,
15455 vector signed __int128 __b) {
15456 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ, __a, __b);
15457}
15458
15459static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned __int128 __a,
15460 vector unsigned __int128 __b) {
15461 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ, __a, __b);
15462}
15463#endif
15464
Logan Chien2833ffb2018-10-09 10:03:24 +080015465/* vec_all_lt */
15466
15467static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a,
15468 vector signed char __b) {
15469 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, __a);
15470}
15471
15472static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a,
15473 vector bool char __b) {
15474 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__b, __a);
15475}
15476
15477static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a,
15478 vector unsigned char __b) {
15479 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, __a);
15480}
15481
15482static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a,
15483 vector bool char __b) {
15484 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b, __a);
15485}
15486
15487static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
15488 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015489 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015490}
15491
15492static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
15493 vector unsigned char __b) {
15494 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, (vector unsigned char)__a);
15495}
15496
15497static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
15498 vector bool char __b) {
15499 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b,
15500 (vector unsigned char)__a);
15501}
15502
15503static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a,
15504 vector short __b) {
15505 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, __a);
15506}
15507
15508static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a,
15509 vector bool short __b) {
15510 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector short)__b, __a);
15511}
15512
15513static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a,
15514 vector unsigned short __b) {
15515 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b, __a);
15516}
15517
15518static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a,
15519 vector bool short __b) {
15520 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
15521 __a);
15522}
15523
15524static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
15525 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015526 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015527}
15528
15529static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
15530 vector unsigned short __b) {
15531 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b,
15532 (vector unsigned short)__a);
15533}
15534
15535static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
15536 vector bool short __b) {
15537 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
15538 (vector unsigned short)__a);
15539}
15540
15541static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a, vector int __b) {
15542 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, __a);
15543}
15544
15545static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a,
15546 vector bool int __b) {
15547 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector int)__b, __a);
15548}
15549
15550static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a,
15551 vector unsigned int __b) {
15552 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, __a);
15553}
15554
15555static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a,
15556 vector bool int __b) {
15557 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b, __a);
15558}
15559
15560static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
15561 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015562 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015563}
15564
15565static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
15566 vector unsigned int __b) {
15567 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, (vector unsigned int)__a);
15568}
15569
15570static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
15571 vector bool int __b) {
15572 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b,
15573 (vector unsigned int)__a);
15574}
15575
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015576#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015577static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
15578 vector signed long long __b) {
15579 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, __a);
15580}
15581
15582static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a,
15583 vector unsigned long long __b) {
15584 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b, __a);
15585}
15586
15587static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
15588 vector bool long long __b) {
15589 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__b,
15590 __a);
15591}
15592
15593static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a,
15594 vector bool long long __b) {
15595 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
15596 __a);
15597}
15598
15599static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
15600 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080015601 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b,
15602 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080015603}
15604
15605static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
15606 vector unsigned long long __b) {
15607 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b,
15608 (vector unsigned long long)__a);
15609}
15610
15611static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
15612 vector bool long long __b) {
15613 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
15614 (vector unsigned long long)__a);
15615}
15616#endif
15617
15618static __inline__ int __ATTRS_o_ai vec_all_lt(vector float __a,
15619 vector float __b) {
15620#ifdef __VSX__
15621 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __b, __a);
15622#else
15623 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __b, __a);
15624#endif
15625}
15626
15627#ifdef __VSX__
15628static __inline__ int __ATTRS_o_ai vec_all_lt(vector double __a,
15629 vector double __b) {
15630 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __b, __a);
15631}
15632#endif
15633
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015634#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015635static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed __int128 __a,
15636 vector signed __int128 __b) {
15637 return __builtin_altivec_vcmpgtsq_p(__CR6_LT, __b, __a);
15638}
15639
15640static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned __int128 __a,
15641 vector unsigned __int128 __b) {
15642 return __builtin_altivec_vcmpgtuq_p(__CR6_LT, __b, __a);
15643}
15644#endif
15645
Logan Chien2833ffb2018-10-09 10:03:24 +080015646/* vec_all_nan */
15647
15648static __inline__ int __ATTRS_o_ai vec_all_nan(vector float __a) {
15649#ifdef __VSX__
15650 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __a);
15651#else
15652 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __a);
15653#endif
15654}
15655
15656#ifdef __VSX__
15657static __inline__ int __ATTRS_o_ai vec_all_nan(vector double __a) {
15658 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __a);
15659}
15660#endif
15661
15662/* vec_all_ne */
15663
15664static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a,
15665 vector signed char __b) {
15666 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15667 (vector char)__b);
15668}
15669
15670static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a,
15671 vector bool char __b) {
15672 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15673 (vector char)__b);
15674}
15675
15676static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a,
15677 vector unsigned char __b) {
15678 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15679 (vector char)__b);
15680}
15681
15682static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a,
15683 vector bool char __b) {
15684 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15685 (vector char)__b);
15686}
15687
15688static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
15689 vector signed char __b) {
15690 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15691 (vector char)__b);
15692}
15693
15694static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
15695 vector unsigned char __b) {
15696 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15697 (vector char)__b);
15698}
15699
15700static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
15701 vector bool char __b) {
15702 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
15703 (vector char)__b);
15704}
15705
15706static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a,
15707 vector short __b) {
15708 return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, __b);
15709}
15710
15711static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a,
15712 vector bool short __b) {
15713 return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, (vector short)__b);
15714}
15715
15716static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a,
15717 vector unsigned short __b) {
15718 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15719 (vector short)__b);
15720}
15721
15722static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a,
15723 vector bool short __b) {
15724 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15725 (vector short)__b);
15726}
15727
15728static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
15729 vector short __b) {
15730 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15731 (vector short)__b);
15732}
15733
15734static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
15735 vector unsigned short __b) {
15736 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15737 (vector short)__b);
15738}
15739
15740static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
15741 vector bool short __b) {
15742 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15743 (vector short)__b);
15744}
15745
15746static __inline__ int __ATTRS_o_ai vec_all_ne(vector pixel __a,
15747 vector pixel __b) {
15748 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
15749 (vector short)__b);
15750}
15751
15752static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a, vector int __b) {
15753 return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, __b);
15754}
15755
15756static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a,
15757 vector bool int __b) {
15758 return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, (vector int)__b);
15759}
15760
15761static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a,
15762 vector unsigned int __b) {
15763 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15764 (vector int)__b);
15765}
15766
15767static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a,
15768 vector bool int __b) {
15769 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15770 (vector int)__b);
15771}
15772
15773static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
15774 vector int __b) {
15775 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15776 (vector int)__b);
15777}
15778
15779static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
15780 vector unsigned int __b) {
15781 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15782 (vector int)__b);
15783}
15784
15785static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
15786 vector bool int __b) {
15787 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
15788 (vector int)__b);
15789}
15790
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015791#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080015792static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
15793 vector signed long long __b) {
15794 return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a, __b);
15795}
15796
15797static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a,
15798 vector unsigned long long __b) {
15799 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector long long)__a,
15800 (vector long long)__b);
15801}
15802
15803static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
15804 vector bool long long __b) {
15805 return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a,
15806 (vector signed long long)__b);
15807}
15808
15809static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a,
15810 vector bool long long __b) {
15811 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15812 (vector signed long long)__b);
15813}
15814
15815static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
15816 vector signed long long __b) {
15817 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15818 (vector signed long long)__b);
15819}
15820
15821static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
15822 vector unsigned long long __b) {
15823 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15824 (vector signed long long)__b);
15825}
15826
15827static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
15828 vector bool long long __b) {
15829 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
15830 (vector signed long long)__b);
15831}
15832#endif
15833
15834static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a,
15835 vector float __b) {
15836#ifdef __VSX__
Sasha Smundak746b0222020-02-25 09:19:04 -080015837 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080015838#else
15839 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __b);
15840#endif
15841}
15842
15843#ifdef __VSX__
15844static __inline__ int __ATTRS_o_ai vec_all_ne(vector double __a,
15845 vector double __b) {
15846 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __b);
15847}
15848#endif
15849
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015850#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015851static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed __int128 __a,
15852 vector signed __int128 __b) {
15853 return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
15854}
15855
15856static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned __int128 __a,
15857 vector unsigned __int128 __b) {
15858 return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
15859}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080015860
15861static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool __int128 __a,
15862 vector bool __int128 __b) {
15863 return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
15864}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015865#endif
15866
Logan Chien2833ffb2018-10-09 10:03:24 +080015867/* vec_all_nge */
15868
15869static __inline__ int __ATTRS_o_ai vec_all_nge(vector float __a,
15870 vector float __b) {
15871#ifdef __VSX__
15872 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __a, __b);
15873#else
15874 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __a, __b);
15875#endif
15876}
15877
15878#ifdef __VSX__
15879static __inline__ int __ATTRS_o_ai vec_all_nge(vector double __a,
15880 vector double __b) {
15881 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __a, __b);
15882}
15883#endif
15884
15885/* vec_all_ngt */
15886
15887static __inline__ int __ATTRS_o_ai vec_all_ngt(vector float __a,
15888 vector float __b) {
15889#ifdef __VSX__
15890 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __a, __b);
15891#else
15892 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __a, __b);
15893#endif
15894}
15895
15896#ifdef __VSX__
15897static __inline__ int __ATTRS_o_ai vec_all_ngt(vector double __a,
15898 vector double __b) {
15899 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __a, __b);
15900}
15901#endif
15902
15903/* vec_all_nle */
15904
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015905static __inline__ int __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080015906vec_all_nle(vector float __a, vector float __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015907#ifdef __VSX__
15908 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __b, __a);
15909#else
Logan Chien2833ffb2018-10-09 10:03:24 +080015910 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015911#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080015912}
15913
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015914#ifdef __VSX__
15915static __inline__ int __ATTRS_o_ai vec_all_nle(vector double __a,
15916 vector double __b) {
15917 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __b, __a);
15918}
15919#endif
15920
Logan Chien2833ffb2018-10-09 10:03:24 +080015921/* vec_all_nlt */
15922
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015923static __inline__ int __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080015924vec_all_nlt(vector float __a, vector float __b) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015925#ifdef __VSX__
15926 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __b, __a);
15927#else
Logan Chien2833ffb2018-10-09 10:03:24 +080015928 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015929#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080015930}
15931
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015932#ifdef __VSX__
15933static __inline__ int __ATTRS_o_ai vec_all_nlt(vector double __a,
15934 vector double __b) {
15935 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __b, __a);
15936}
15937#endif
15938
Logan Chien2833ffb2018-10-09 10:03:24 +080015939/* vec_all_numeric */
15940
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015941static __inline__ int __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080015942vec_all_numeric(vector float __a) {
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015943#ifdef __VSX__
15944 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __a);
15945#else
Logan Chien2833ffb2018-10-09 10:03:24 +080015946 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015947#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080015948}
15949
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070015950#ifdef __VSX__
15951static __inline__ int __ATTRS_o_ai vec_all_numeric(vector double __a) {
15952 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __a);
15953}
15954#endif
15955
Logan Chien2833ffb2018-10-09 10:03:24 +080015956/* vec_any_eq */
15957
15958static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a,
15959 vector signed char __b) {
15960 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15961 (vector char)__b);
15962}
15963
15964static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a,
15965 vector bool char __b) {
15966 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15967 (vector char)__b);
15968}
15969
15970static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a,
15971 vector unsigned char __b) {
15972 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15973 (vector char)__b);
15974}
15975
15976static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a,
15977 vector bool char __b) {
15978 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15979 (vector char)__b);
15980}
15981
15982static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
15983 vector signed char __b) {
15984 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15985 (vector char)__b);
15986}
15987
15988static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
15989 vector unsigned char __b) {
15990 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15991 (vector char)__b);
15992}
15993
15994static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
15995 vector bool char __b) {
15996 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
15997 (vector char)__b);
15998}
15999
16000static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a,
16001 vector short __b) {
16002 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, __b);
16003}
16004
16005static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a,
16006 vector bool short __b) {
16007 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, (vector short)__b);
16008}
16009
16010static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a,
16011 vector unsigned short __b) {
16012 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
16013 (vector short)__b);
16014}
16015
16016static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a,
16017 vector bool short __b) {
16018 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
16019 (vector short)__b);
16020}
16021
16022static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
16023 vector short __b) {
16024 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
16025 (vector short)__b);
16026}
16027
16028static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
16029 vector unsigned short __b) {
16030 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
16031 (vector short)__b);
16032}
16033
16034static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
16035 vector bool short __b) {
16036 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
16037 (vector short)__b);
16038}
16039
16040static __inline__ int __ATTRS_o_ai vec_any_eq(vector pixel __a,
16041 vector pixel __b) {
16042 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
16043 (vector short)__b);
16044}
16045
16046static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a, vector int __b) {
16047 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, __b);
16048}
16049
16050static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a,
16051 vector bool int __b) {
16052 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, (vector int)__b);
16053}
16054
16055static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a,
16056 vector unsigned int __b) {
16057 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16058 (vector int)__b);
16059}
16060
16061static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a,
16062 vector bool int __b) {
16063 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16064 (vector int)__b);
16065}
16066
16067static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
16068 vector int __b) {
16069 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16070 (vector int)__b);
16071}
16072
16073static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
16074 vector unsigned int __b) {
16075 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16076 (vector int)__b);
16077}
16078
16079static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
16080 vector bool int __b) {
16081 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
16082 (vector int)__b);
16083}
16084
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016085#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016086static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
16087 vector signed long long __b) {
16088 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a, __b);
16089}
16090
16091static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a,
16092 vector unsigned long long __b) {
16093 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, (vector long long)__a,
16094 (vector long long)__b);
16095}
16096
16097static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
16098 vector bool long long __b) {
16099 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a,
16100 (vector signed long long)__b);
16101}
16102
16103static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a,
16104 vector bool long long __b) {
16105 return __builtin_altivec_vcmpequd_p(
16106 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16107}
16108
16109static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
16110 vector signed long long __b) {
16111 return __builtin_altivec_vcmpequd_p(
16112 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16113}
16114
16115static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
16116 vector unsigned long long __b) {
16117 return __builtin_altivec_vcmpequd_p(
16118 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16119}
16120
16121static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
16122 vector bool long long __b) {
16123 return __builtin_altivec_vcmpequd_p(
16124 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
16125}
16126#endif
16127
16128static __inline__ int __ATTRS_o_ai vec_any_eq(vector float __a,
16129 vector float __b) {
16130#ifdef __VSX__
16131 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __b);
16132#else
16133 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __b);
16134#endif
16135}
16136
16137#ifdef __VSX__
16138static __inline__ int __ATTRS_o_ai vec_any_eq(vector double __a,
16139 vector double __b) {
16140 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __b);
16141}
16142#endif
16143
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016144#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016145static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed __int128 __a,
16146 vector signed __int128 __b) {
16147 return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
16148}
16149
16150static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned __int128 __a,
16151 vector unsigned __int128 __b) {
16152 return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
16153}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080016154
16155static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool __int128 __a,
16156 vector bool __int128 __b) {
16157 return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
16158}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016159#endif
16160
Logan Chien2833ffb2018-10-09 10:03:24 +080016161/* vec_any_ge */
16162
16163static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a,
16164 vector signed char __b) {
16165 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b, __a);
16166}
16167
16168static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a,
16169 vector bool char __b) {
16170 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__b,
16171 __a);
16172}
16173
16174static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a,
16175 vector unsigned char __b) {
16176 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b, __a);
16177}
16178
16179static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a,
16180 vector bool char __b) {
16181 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
16182 __a);
16183}
16184
16185static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
16186 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016187 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b,
16188 (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016189}
16190
16191static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
16192 vector unsigned char __b) {
16193 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b,
16194 (vector unsigned char)__a);
16195}
16196
16197static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
16198 vector bool char __b) {
16199 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
16200 (vector unsigned char)__a);
16201}
16202
16203static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a,
16204 vector short __b) {
16205 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b, __a);
16206}
16207
16208static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a,
16209 vector bool short __b) {
16210 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector short)__b, __a);
16211}
16212
16213static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a,
16214 vector unsigned short __b) {
16215 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b, __a);
16216}
16217
16218static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a,
16219 vector bool short __b) {
16220 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
16221 __a);
16222}
16223
16224static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
16225 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016226 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b,
16227 (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016228}
16229
16230static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
16231 vector unsigned short __b) {
16232 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b,
16233 (vector unsigned short)__a);
16234}
16235
16236static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
16237 vector bool short __b) {
16238 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
16239 (vector unsigned short)__a);
16240}
16241
16242static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a, vector int __b) {
16243 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b, __a);
16244}
16245
16246static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a,
16247 vector bool int __b) {
16248 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector int)__b, __a);
16249}
16250
16251static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a,
16252 vector unsigned int __b) {
16253 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b, __a);
16254}
16255
16256static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a,
16257 vector bool int __b) {
16258 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
16259 __a);
16260}
16261
16262static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
16263 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016264 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b,
16265 (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016266}
16267
16268static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
16269 vector unsigned int __b) {
16270 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b,
16271 (vector unsigned int)__a);
16272}
16273
16274static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
16275 vector bool int __b) {
16276 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
16277 (vector unsigned int)__a);
16278}
16279
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016280#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016281static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
16282 vector signed long long __b) {
16283 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b, __a);
16284}
16285
16286static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a,
16287 vector unsigned long long __b) {
16288 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b, __a);
16289}
16290
16291static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
16292 vector bool long long __b) {
16293 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV,
16294 (vector signed long long)__b, __a);
16295}
16296
16297static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a,
16298 vector bool long long __b) {
16299 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16300 (vector unsigned long long)__b, __a);
16301}
16302
16303static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
16304 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016305 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b,
16306 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016307}
16308
16309static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
16310 vector unsigned long long __b) {
16311 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b,
16312 (vector unsigned long long)__a);
16313}
16314
16315static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
16316 vector bool long long __b) {
16317 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16318 (vector unsigned long long)__b,
16319 (vector unsigned long long)__a);
16320}
16321#endif
16322
16323static __inline__ int __ATTRS_o_ai vec_any_ge(vector float __a,
16324 vector float __b) {
16325#ifdef __VSX__
16326 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __a, __b);
16327#else
16328 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __a, __b);
16329#endif
16330}
16331
16332#ifdef __VSX__
16333static __inline__ int __ATTRS_o_ai vec_any_ge(vector double __a,
16334 vector double __b) {
16335 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __a, __b);
16336}
16337#endif
16338
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016339#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016340static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed __int128 __a,
16341 vector signed __int128 __b) {
16342 return __builtin_altivec_vcmpgtsq_p(__CR6_LT_REV, __b, __a);
16343}
16344
16345static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned __int128 __a,
16346 vector unsigned __int128 __b) {
16347 return __builtin_altivec_vcmpgtuq_p(__CR6_LT_REV, __b, __a);
16348}
16349#endif
16350
Logan Chien2833ffb2018-10-09 10:03:24 +080016351/* vec_any_gt */
16352
16353static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a,
16354 vector signed char __b) {
16355 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a, __b);
16356}
16357
16358static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a,
16359 vector bool char __b) {
16360 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a,
16361 (vector signed char)__b);
16362}
16363
16364static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a,
16365 vector unsigned char __b) {
16366 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a, __b);
16367}
16368
16369static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a,
16370 vector bool char __b) {
16371 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a,
16372 (vector unsigned char)__b);
16373}
16374
16375static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
16376 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016377 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__a,
16378 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016379}
16380
16381static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
16382 vector unsigned char __b) {
16383 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
16384 __b);
16385}
16386
16387static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
16388 vector bool char __b) {
16389 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
16390 (vector unsigned char)__b);
16391}
16392
16393static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a,
16394 vector short __b) {
16395 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, __b);
16396}
16397
16398static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a,
16399 vector bool short __b) {
16400 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, (vector short)__b);
16401}
16402
16403static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a,
16404 vector unsigned short __b) {
16405 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a, __b);
16406}
16407
16408static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a,
16409 vector bool short __b) {
16410 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a,
16411 (vector unsigned short)__b);
16412}
16413
16414static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
16415 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016416 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector signed short)__a,
16417 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016418}
16419
16420static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
16421 vector unsigned short __b) {
16422 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
16423 __b);
16424}
16425
16426static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
16427 vector bool short __b) {
16428 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
16429 (vector unsigned short)__b);
16430}
16431
16432static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a, vector int __b) {
16433 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, __b);
16434}
16435
16436static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a,
16437 vector bool int __b) {
16438 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, (vector int)__b);
16439}
16440
16441static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a,
16442 vector unsigned int __b) {
16443 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a, __b);
16444}
16445
16446static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a,
16447 vector bool int __b) {
16448 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a,
16449 (vector unsigned int)__b);
16450}
16451
16452static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
16453 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016454 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector signed int)__a,
16455 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016456}
16457
16458static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
16459 vector unsigned int __b) {
16460 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
16461 __b);
16462}
16463
16464static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
16465 vector bool int __b) {
16466 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
16467 (vector unsigned int)__b);
16468}
16469
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016470#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016471static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a,
16472 vector signed long long __b) {
16473 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a, __b);
16474}
16475
16476static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a,
16477 vector unsigned long long __b) {
16478 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a, __b);
16479}
16480
16481static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a,
16482 vector bool long long __b) {
16483 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a,
16484 (vector signed long long)__b);
16485}
16486
16487static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a,
16488 vector bool long long __b) {
16489 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a,
16490 (vector unsigned long long)__b);
16491}
16492
16493static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
16494 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016495 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV,
16496 (vector signed long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016497}
16498
16499static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
16500 vector unsigned long long __b) {
16501 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16502 (vector unsigned long long)__a, __b);
16503}
16504
16505static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
16506 vector bool long long __b) {
16507 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16508 (vector unsigned long long)__a,
16509 (vector unsigned long long)__b);
16510}
16511#endif
16512
16513static __inline__ int __ATTRS_o_ai vec_any_gt(vector float __a,
16514 vector float __b) {
16515#ifdef __VSX__
16516 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __a, __b);
16517#else
16518 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __a, __b);
16519#endif
16520}
16521
16522#ifdef __VSX__
16523static __inline__ int __ATTRS_o_ai vec_any_gt(vector double __a,
16524 vector double __b) {
16525 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __a, __b);
16526}
16527#endif
16528
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016529#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016530static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed __int128 __a,
16531 vector signed __int128 __b) {
16532 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ_REV, __a, __b);
16533}
16534
16535static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned __int128 __a,
16536 vector unsigned __int128 __b) {
16537 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ_REV, __a, __b);
16538}
16539#endif
16540
Logan Chien2833ffb2018-10-09 10:03:24 +080016541/* vec_any_le */
16542
16543static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a,
16544 vector signed char __b) {
16545 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a, __b);
16546}
16547
16548static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a,
16549 vector bool char __b) {
16550 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a,
16551 (vector signed char)__b);
16552}
16553
16554static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a,
16555 vector unsigned char __b) {
16556 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a, __b);
16557}
16558
16559static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a,
16560 vector bool char __b) {
16561 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a,
16562 (vector unsigned char)__b);
16563}
16564
16565static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
16566 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016567 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__a,
16568 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016569}
16570
16571static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
16572 vector unsigned char __b) {
16573 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
16574 __b);
16575}
16576
16577static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
16578 vector bool char __b) {
16579 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
16580 (vector unsigned char)__b);
16581}
16582
16583static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a,
16584 vector short __b) {
16585 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, __b);
16586}
16587
16588static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a,
16589 vector bool short __b) {
16590 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, (vector short)__b);
16591}
16592
16593static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a,
16594 vector unsigned short __b) {
16595 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a, __b);
16596}
16597
16598static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a,
16599 vector bool short __b) {
16600 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a,
16601 (vector unsigned short)__b);
16602}
16603
16604static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
16605 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016606 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector signed short)__a,
16607 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016608}
16609
16610static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
16611 vector unsigned short __b) {
16612 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
16613 __b);
16614}
16615
16616static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
16617 vector bool short __b) {
16618 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
16619 (vector unsigned short)__b);
16620}
16621
16622static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a, vector int __b) {
16623 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, __b);
16624}
16625
16626static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a,
16627 vector bool int __b) {
16628 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, (vector int)__b);
16629}
16630
16631static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a,
16632 vector unsigned int __b) {
16633 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a, __b);
16634}
16635
16636static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a,
16637 vector bool int __b) {
16638 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a,
16639 (vector unsigned int)__b);
16640}
16641
16642static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
16643 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016644 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector signed int)__a,
16645 __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016646}
16647
16648static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
16649 vector unsigned int __b) {
16650 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
16651 __b);
16652}
16653
16654static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
16655 vector bool int __b) {
16656 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
16657 (vector unsigned int)__b);
16658}
16659
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016660#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016661static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a,
16662 vector signed long long __b) {
16663 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a, __b);
16664}
16665
16666static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a,
16667 vector unsigned long long __b) {
16668 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a, __b);
16669}
16670
16671static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a,
16672 vector bool long long __b) {
16673 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a,
16674 (vector signed long long)__b);
16675}
16676
16677static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a,
16678 vector bool long long __b) {
16679 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a,
16680 (vector unsigned long long)__b);
16681}
16682
16683static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
16684 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016685 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV,
16686 (vector signed long long)__a, __b);
Logan Chien2833ffb2018-10-09 10:03:24 +080016687}
16688
16689static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
16690 vector unsigned long long __b) {
16691 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16692 (vector unsigned long long)__a, __b);
16693}
16694
16695static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
16696 vector bool long long __b) {
16697 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
16698 (vector unsigned long long)__a,
16699 (vector unsigned long long)__b);
16700}
16701#endif
16702
16703static __inline__ int __ATTRS_o_ai vec_any_le(vector float __a,
16704 vector float __b) {
16705#ifdef __VSX__
16706 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __b, __a);
16707#else
16708 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __b, __a);
16709#endif
16710}
16711
16712#ifdef __VSX__
16713static __inline__ int __ATTRS_o_ai vec_any_le(vector double __a,
16714 vector double __b) {
16715 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __b, __a);
16716}
16717#endif
16718
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016719#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016720static __inline__ int __ATTRS_o_ai vec_any_le(vector signed __int128 __a,
16721 vector signed __int128 __b) {
16722 return __builtin_altivec_vcmpgtsq_p(__CR6_LT_REV, __a, __b);
16723}
16724
16725static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned __int128 __a,
16726 vector unsigned __int128 __b) {
16727 return __builtin_altivec_vcmpgtuq_p(__CR6_LT_REV, __a, __b);
16728}
16729#endif
16730
Logan Chien2833ffb2018-10-09 10:03:24 +080016731/* vec_any_lt */
16732
16733static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a,
16734 vector signed char __b) {
16735 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b, __a);
16736}
16737
16738static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a,
16739 vector bool char __b) {
16740 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__b,
16741 __a);
16742}
16743
16744static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a,
16745 vector unsigned char __b) {
16746 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b, __a);
16747}
16748
16749static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a,
16750 vector bool char __b) {
16751 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
16752 __a);
16753}
16754
16755static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
16756 vector signed char __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016757 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b,
16758 (vector signed char)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016759}
16760
16761static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
16762 vector unsigned char __b) {
16763 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b,
16764 (vector unsigned char)__a);
16765}
16766
16767static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
16768 vector bool char __b) {
16769 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
16770 (vector unsigned char)__a);
16771}
16772
16773static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a,
16774 vector short __b) {
16775 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b, __a);
16776}
16777
16778static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a,
16779 vector bool short __b) {
16780 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector short)__b, __a);
16781}
16782
16783static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a,
16784 vector unsigned short __b) {
16785 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b, __a);
16786}
16787
16788static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a,
16789 vector bool short __b) {
16790 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
16791 __a);
16792}
16793
16794static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
16795 vector short __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016796 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b,
16797 (vector signed short)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016798}
16799
16800static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
16801 vector unsigned short __b) {
16802 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b,
16803 (vector unsigned short)__a);
16804}
16805
16806static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
16807 vector bool short __b) {
16808 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
16809 (vector unsigned short)__a);
16810}
16811
16812static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a, vector int __b) {
16813 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b, __a);
16814}
16815
16816static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a,
16817 vector bool int __b) {
16818 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector int)__b, __a);
16819}
16820
16821static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a,
16822 vector unsigned int __b) {
16823 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b, __a);
16824}
16825
16826static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a,
16827 vector bool int __b) {
16828 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
16829 __a);
16830}
16831
16832static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
16833 vector int __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016834 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b,
16835 (vector signed int)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016836}
16837
16838static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
16839 vector unsigned int __b) {
16840 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b,
16841 (vector unsigned int)__a);
16842}
16843
16844static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
16845 vector bool int __b) {
16846 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
16847 (vector unsigned int)__a);
16848}
16849
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016850#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080016851static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a,
16852 vector signed long long __b) {
16853 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b, __a);
16854}
16855
16856static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a,
16857 vector unsigned long long __b) {
16858 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b, __a);
16859}
16860
16861static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a,
16862 vector bool long long __b) {
16863 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV,
16864 (vector signed long long)__b, __a);
16865}
16866
16867static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a,
16868 vector bool long long __b) {
16869 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16870 (vector unsigned long long)__b, __a);
16871}
16872
16873static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
16874 vector signed long long __b) {
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080016875 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b,
16876 (vector signed long long)__a);
Logan Chien2833ffb2018-10-09 10:03:24 +080016877}
16878
16879static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
16880 vector unsigned long long __b) {
16881 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b,
16882 (vector unsigned long long)__a);
16883}
16884
16885static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
16886 vector bool long long __b) {
16887 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
16888 (vector unsigned long long)__b,
16889 (vector unsigned long long)__a);
16890}
16891#endif
16892
16893static __inline__ int __ATTRS_o_ai vec_any_lt(vector float __a,
16894 vector float __b) {
16895#ifdef __VSX__
16896 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __b, __a);
16897#else
16898 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __b, __a);
16899#endif
16900}
16901
16902#ifdef __VSX__
16903static __inline__ int __ATTRS_o_ai vec_any_lt(vector double __a,
16904 vector double __b) {
16905 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __b, __a);
16906}
16907#endif
16908
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016909#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080016910static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed __int128 __a,
16911 vector signed __int128 __b) {
16912 return __builtin_altivec_vcmpgtsq_p(__CR6_EQ_REV, __b, __a);
16913}
16914
16915static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned __int128 __a,
16916 vector unsigned __int128 __b) {
16917 return __builtin_altivec_vcmpgtuq_p(__CR6_EQ_REV, __b, __a);
16918}
16919#endif
16920
Logan Chien2833ffb2018-10-09 10:03:24 +080016921/* vec_any_nan */
16922
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016923static __inline__ int __ATTRS_o_ai vec_any_nan(vector float __a) {
16924#ifdef __VSX__
16925 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __a);
16926#else
Logan Chien2833ffb2018-10-09 10:03:24 +080016927 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016928#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080016929}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070016930#ifdef __VSX__
16931static __inline__ int __ATTRS_o_ai vec_any_nan(vector double __a) {
16932 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __a);
16933}
16934#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080016935
16936/* vec_any_ne */
16937
16938static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a,
16939 vector signed char __b) {
16940 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16941 (vector char)__b);
16942}
16943
16944static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a,
16945 vector bool char __b) {
16946 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16947 (vector char)__b);
16948}
16949
16950static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a,
16951 vector unsigned char __b) {
16952 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16953 (vector char)__b);
16954}
16955
16956static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a,
16957 vector bool char __b) {
16958 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16959 (vector char)__b);
16960}
16961
16962static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
16963 vector signed char __b) {
16964 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16965 (vector char)__b);
16966}
16967
16968static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
16969 vector unsigned char __b) {
16970 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16971 (vector char)__b);
16972}
16973
16974static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
16975 vector bool char __b) {
16976 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
16977 (vector char)__b);
16978}
16979
16980static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a,
16981 vector short __b) {
16982 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, __b);
16983}
16984
16985static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a,
16986 vector bool short __b) {
16987 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, (vector short)__b);
16988}
16989
16990static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a,
16991 vector unsigned short __b) {
16992 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16993 (vector short)__b);
16994}
16995
16996static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a,
16997 vector bool short __b) {
16998 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
16999 (vector short)__b);
17000}
17001
17002static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
17003 vector short __b) {
17004 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
17005 (vector short)__b);
17006}
17007
17008static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
17009 vector unsigned short __b) {
17010 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
17011 (vector short)__b);
17012}
17013
17014static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
17015 vector bool short __b) {
17016 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
17017 (vector short)__b);
17018}
17019
17020static __inline__ int __ATTRS_o_ai vec_any_ne(vector pixel __a,
17021 vector pixel __b) {
17022 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
17023 (vector short)__b);
17024}
17025
17026static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a, vector int __b) {
17027 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, __b);
17028}
17029
17030static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a,
17031 vector bool int __b) {
17032 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, (vector int)__b);
17033}
17034
17035static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a,
17036 vector unsigned int __b) {
17037 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17038 (vector int)__b);
17039}
17040
17041static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a,
17042 vector bool int __b) {
17043 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17044 (vector int)__b);
17045}
17046
17047static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
17048 vector int __b) {
17049 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17050 (vector int)__b);
17051}
17052
17053static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
17054 vector unsigned int __b) {
17055 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17056 (vector int)__b);
17057}
17058
17059static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
17060 vector bool int __b) {
17061 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
17062 (vector int)__b);
17063}
17064
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017065#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080017066static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a,
17067 vector signed long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017068#ifdef __POWER8_VECTOR__
Logan Chien2833ffb2018-10-09 10:03:24 +080017069 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, __a, __b);
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017070#else
17071 // Take advantage of the optimized sequence for vec_all_eq when vcmpequd is
17072 // not available.
17073 return !vec_all_eq(__a, __b);
17074#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017075}
17076
17077static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a,
17078 vector unsigned long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017079 return vec_any_ne((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080017080}
17081
17082static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a,
17083 vector bool long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017084 return vec_any_ne((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080017085}
17086
17087static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a,
17088 vector bool long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017089 return vec_any_ne((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080017090}
17091
17092static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
17093 vector signed long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017094 return vec_any_ne((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080017095}
17096
17097static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
17098 vector unsigned long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017099 return vec_any_ne((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080017100}
17101
17102static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
17103 vector bool long long __b) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017104 return vec_any_ne((vector signed long long)__a, (vector signed long long)__b);
Logan Chien2833ffb2018-10-09 10:03:24 +080017105}
17106#endif
17107
17108static __inline__ int __ATTRS_o_ai vec_any_ne(vector float __a,
17109 vector float __b) {
17110#ifdef __VSX__
17111 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __b);
17112#else
17113 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __b);
17114#endif
17115}
17116
17117#ifdef __VSX__
17118static __inline__ int __ATTRS_o_ai vec_any_ne(vector double __a,
17119 vector double __b) {
17120 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __b);
17121}
17122#endif
17123
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017124#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017125static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed __int128 __a,
17126 vector signed __int128 __b) {
17127 return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
17128}
17129
17130static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned __int128 __a,
17131 vector unsigned __int128 __b) {
17132 return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
17133}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017134
17135static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool __int128 __a,
17136 vector bool __int128 __b) {
17137 return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
17138}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017139#endif
17140
Logan Chien2833ffb2018-10-09 10:03:24 +080017141/* vec_any_nge */
17142
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017143static __inline__ int __ATTRS_o_ai vec_any_nge(vector float __a,
17144 vector float __b) {
17145#ifdef __VSX__
17146 return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __a, __b);
17147#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017148 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __a, __b);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017149#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017150}
17151
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017152#ifdef __VSX__
17153static __inline__ int __ATTRS_o_ai vec_any_nge(vector double __a,
17154 vector double __b) {
17155 return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __a, __b);
17156}
17157#endif
17158
Logan Chien2833ffb2018-10-09 10:03:24 +080017159/* vec_any_ngt */
17160
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017161static __inline__ int __ATTRS_o_ai vec_any_ngt(vector float __a,
17162 vector float __b) {
17163#ifdef __VSX__
17164 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __a, __b);
17165#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017166 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __a, __b);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017167#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017168}
17169
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017170#ifdef __VSX__
17171static __inline__ int __ATTRS_o_ai vec_any_ngt(vector double __a,
17172 vector double __b) {
17173 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __a, __b);
17174}
17175#endif
17176
Logan Chien2833ffb2018-10-09 10:03:24 +080017177/* vec_any_nle */
17178
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017179static __inline__ int __ATTRS_o_ai vec_any_nle(vector float __a,
17180 vector float __b) {
17181#ifdef __VSX__
17182 return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __b, __a);
17183#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017184 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017185#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017186}
17187
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017188#ifdef __VSX__
17189static __inline__ int __ATTRS_o_ai vec_any_nle(vector double __a,
17190 vector double __b) {
17191 return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __b, __a);
17192}
17193#endif
17194
Logan Chien2833ffb2018-10-09 10:03:24 +080017195/* vec_any_nlt */
17196
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017197static __inline__ int __ATTRS_o_ai vec_any_nlt(vector float __a,
17198 vector float __b) {
17199#ifdef __VSX__
17200 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __b, __a);
17201#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017202 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __b, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017203#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017204}
17205
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017206#ifdef __VSX__
17207static __inline__ int __ATTRS_o_ai vec_any_nlt(vector double __a,
17208 vector double __b) {
17209 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __b, __a);
17210}
17211#endif
17212
Logan Chien2833ffb2018-10-09 10:03:24 +080017213/* vec_any_numeric */
17214
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017215static __inline__ int __ATTRS_o_ai vec_any_numeric(vector float __a) {
17216#ifdef __VSX__
17217 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __a);
17218#else
Logan Chien2833ffb2018-10-09 10:03:24 +080017219 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __a);
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017220#endif
Logan Chien2833ffb2018-10-09 10:03:24 +080017221}
17222
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017223#ifdef __VSX__
17224static __inline__ int __ATTRS_o_ai vec_any_numeric(vector double __a) {
17225 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __a);
17226}
17227#endif
17228
Logan Chien2833ffb2018-10-09 10:03:24 +080017229/* vec_any_out */
17230
17231static __inline__ int __attribute__((__always_inline__))
17232vec_any_out(vector float __a, vector float __b) {
17233 return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, __a, __b);
17234}
17235
17236/* Power 8 Crypto functions
17237Note: We diverge from the current GCC implementation with regard
17238to cryptography and related functions as follows:
17239- Only the SHA and AES instructions and builtins are disabled by -mno-crypto
17240- The remaining ones are only available on Power8 and up so
17241 require -mpower8-vector
17242The justification for this is that export requirements require that
17243Category:Vector.Crypto is optional (i.e. compliant hardware may not provide
17244support). As a result, we need to be able to turn off support for those.
17245The remaining ones (currently controlled by -mcrypto for GCC) still
17246need to be provided on compliant hardware even if Vector.Crypto is not
17247provided.
17248*/
17249#ifdef __CRYPTO__
17250#define vec_sbox_be __builtin_altivec_crypto_vsbox
17251#define vec_cipher_be __builtin_altivec_crypto_vcipher
17252#define vec_cipherlast_be __builtin_altivec_crypto_vcipherlast
17253#define vec_ncipher_be __builtin_altivec_crypto_vncipher
17254#define vec_ncipherlast_be __builtin_altivec_crypto_vncipherlast
17255
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017256#ifdef __VSX__
Logan Chien2833ffb2018-10-09 10:03:24 +080017257static __inline__ vector unsigned long long __attribute__((__always_inline__))
17258__builtin_crypto_vsbox(vector unsigned long long __a) {
17259 return __builtin_altivec_crypto_vsbox(__a);
17260}
17261
17262static __inline__ vector unsigned long long __attribute__((__always_inline__))
17263__builtin_crypto_vcipher(vector unsigned long long __a,
17264 vector unsigned long long __b) {
17265 return __builtin_altivec_crypto_vcipher(__a, __b);
17266}
17267
17268static __inline__ vector unsigned long long __attribute__((__always_inline__))
17269__builtin_crypto_vcipherlast(vector unsigned long long __a,
17270 vector unsigned long long __b) {
17271 return __builtin_altivec_crypto_vcipherlast(__a, __b);
17272}
17273
17274static __inline__ vector unsigned long long __attribute__((__always_inline__))
17275__builtin_crypto_vncipher(vector unsigned long long __a,
17276 vector unsigned long long __b) {
17277 return __builtin_altivec_crypto_vncipher(__a, __b);
17278}
17279
17280static __inline__ vector unsigned long long __attribute__((__always_inline__))
17281__builtin_crypto_vncipherlast(vector unsigned long long __a,
17282 vector unsigned long long __b) {
17283 return __builtin_altivec_crypto_vncipherlast(__a, __b);
17284}
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017285#endif /* __VSX__ */
Logan Chien2833ffb2018-10-09 10:03:24 +080017286
17287#define __builtin_crypto_vshasigmad __builtin_altivec_crypto_vshasigmad
17288#define __builtin_crypto_vshasigmaw __builtin_altivec_crypto_vshasigmaw
17289
17290#define vec_shasigma_be(X, Y, Z) \
17291 _Generic((X), vector unsigned int \
17292 : __builtin_crypto_vshasigmaw, vector unsigned long long \
17293 : __builtin_crypto_vshasigmad)((X), (Y), (Z))
17294#endif
17295
17296#ifdef __POWER8_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +080017297static __inline__ vector bool char __ATTRS_o_ai
17298vec_permxor(vector bool char __a, vector bool char __b,
17299 vector bool char __c) {
17300 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17301}
17302
17303static __inline__ vector signed char __ATTRS_o_ai
17304vec_permxor(vector signed char __a, vector signed char __b,
17305 vector signed char __c) {
17306 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17307}
17308
17309static __inline__ vector unsigned char __ATTRS_o_ai
17310vec_permxor(vector unsigned char __a, vector unsigned char __b,
17311 vector unsigned char __c) {
17312 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17313}
17314
Logan Chien2833ffb2018-10-09 10:03:24 +080017315static __inline__ vector unsigned char __ATTRS_o_ai
17316__builtin_crypto_vpermxor(vector unsigned char __a, vector unsigned char __b,
17317 vector unsigned char __c) {
17318 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
17319}
17320
17321static __inline__ vector unsigned short __ATTRS_o_ai
17322__builtin_crypto_vpermxor(vector unsigned short __a, vector unsigned short __b,
17323 vector unsigned short __c) {
17324 return (vector unsigned short)__builtin_altivec_crypto_vpermxor(
17325 (vector unsigned char)__a, (vector unsigned char)__b,
17326 (vector unsigned char)__c);
17327}
17328
17329static __inline__ vector unsigned int __ATTRS_o_ai __builtin_crypto_vpermxor(
17330 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
17331 return (vector unsigned int)__builtin_altivec_crypto_vpermxor(
17332 (vector unsigned char)__a, (vector unsigned char)__b,
17333 (vector unsigned char)__c);
17334}
17335
17336static __inline__ vector unsigned long long __ATTRS_o_ai
17337__builtin_crypto_vpermxor(vector unsigned long long __a,
17338 vector unsigned long long __b,
17339 vector unsigned long long __c) {
17340 return (vector unsigned long long)__builtin_altivec_crypto_vpermxor(
17341 (vector unsigned char)__a, (vector unsigned char)__b,
17342 (vector unsigned char)__c);
17343}
17344
17345static __inline__ vector unsigned char __ATTRS_o_ai
17346__builtin_crypto_vpmsumb(vector unsigned char __a, vector unsigned char __b) {
17347 return __builtin_altivec_crypto_vpmsumb(__a, __b);
17348}
17349
17350static __inline__ vector unsigned short __ATTRS_o_ai
17351__builtin_crypto_vpmsumb(vector unsigned short __a, vector unsigned short __b) {
17352 return __builtin_altivec_crypto_vpmsumh(__a, __b);
17353}
17354
17355static __inline__ vector unsigned int __ATTRS_o_ai
17356__builtin_crypto_vpmsumb(vector unsigned int __a, vector unsigned int __b) {
17357 return __builtin_altivec_crypto_vpmsumw(__a, __b);
17358}
17359
17360static __inline__ vector unsigned long long __ATTRS_o_ai
17361__builtin_crypto_vpmsumb(vector unsigned long long __a,
17362 vector unsigned long long __b) {
17363 return __builtin_altivec_crypto_vpmsumd(__a, __b);
17364}
17365
17366static __inline__ vector signed char __ATTRS_o_ai
17367vec_vgbbd(vector signed char __a) {
17368 return __builtin_altivec_vgbbd((vector unsigned char)__a);
17369}
17370
17371#define vec_pmsum_be __builtin_crypto_vpmsumb
17372#define vec_gb __builtin_altivec_vgbbd
17373
17374static __inline__ vector unsigned char __ATTRS_o_ai
17375vec_vgbbd(vector unsigned char __a) {
17376 return __builtin_altivec_vgbbd(__a);
17377}
17378
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017379static __inline__ vector signed long long __ATTRS_o_ai
17380vec_gbb(vector signed long long __a) {
17381 return __builtin_altivec_vgbbd((vector unsigned char)__a);
17382}
17383
17384static __inline__ vector unsigned long long __ATTRS_o_ai
17385vec_gbb(vector unsigned long long __a) {
17386 return __builtin_altivec_vgbbd((vector unsigned char)__a);
17387}
17388
Logan Chien2833ffb2018-10-09 10:03:24 +080017389static __inline__ vector long long __ATTRS_o_ai
17390vec_vbpermq(vector signed char __a, vector signed char __b) {
17391 return __builtin_altivec_vbpermq((vector unsigned char)__a,
17392 (vector unsigned char)__b);
17393}
17394
17395static __inline__ vector long long __ATTRS_o_ai
17396vec_vbpermq(vector unsigned char __a, vector unsigned char __b) {
17397 return __builtin_altivec_vbpermq(__a, __b);
17398}
17399
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017400#if defined(__powerpc64__) && defined(__SIZEOF_INT128__)
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017401static __inline__ vector unsigned long long __ATTRS_o_ai
Logan Chien2833ffb2018-10-09 10:03:24 +080017402vec_bperm(vector unsigned __int128 __a, vector unsigned char __b) {
17403 return __builtin_altivec_vbpermq((vector unsigned char)__a,
17404 (vector unsigned char)__b);
17405}
17406#endif
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080017407static __inline__ vector unsigned char __ATTRS_o_ai
17408vec_bperm(vector unsigned char __a, vector unsigned char __b) {
17409 return __builtin_altivec_vbpermq(__a, __b);
17410}
17411#endif // __POWER8_VECTOR__
17412#ifdef __POWER9_VECTOR__
17413static __inline__ vector unsigned long long __ATTRS_o_ai
17414vec_bperm(vector unsigned long long __a, vector unsigned char __b) {
17415 return __builtin_altivec_vbpermd(__a, __b);
17416}
Logan Chien2833ffb2018-10-09 10:03:24 +080017417#endif
17418
Logan Chien55afb0a2018-10-15 10:42:14 +080017419
17420/* vec_reve */
17421
17422static inline __ATTRS_o_ai vector bool char vec_reve(vector bool char __a) {
17423 return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
17424 5, 4, 3, 2, 1, 0);
17425}
17426
17427static inline __ATTRS_o_ai vector signed char vec_reve(vector signed char __a) {
17428 return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
17429 5, 4, 3, 2, 1, 0);
17430}
17431
17432static inline __ATTRS_o_ai vector unsigned char
17433vec_reve(vector unsigned char __a) {
17434 return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
17435 5, 4, 3, 2, 1, 0);
17436}
17437
17438static inline __ATTRS_o_ai vector bool int vec_reve(vector bool int __a) {
17439 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17440}
17441
17442static inline __ATTRS_o_ai vector signed int vec_reve(vector signed int __a) {
17443 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17444}
17445
17446static inline __ATTRS_o_ai vector unsigned int
17447vec_reve(vector unsigned int __a) {
17448 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17449}
17450
17451static inline __ATTRS_o_ai vector bool short vec_reve(vector bool short __a) {
17452 return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
17453}
17454
17455static inline __ATTRS_o_ai vector signed short
17456vec_reve(vector signed short __a) {
17457 return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
17458}
17459
17460static inline __ATTRS_o_ai vector unsigned short
17461vec_reve(vector unsigned short __a) {
17462 return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
17463}
17464
17465static inline __ATTRS_o_ai vector float vec_reve(vector float __a) {
17466 return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
17467}
17468
17469#ifdef __VSX__
17470static inline __ATTRS_o_ai vector bool long long
17471vec_reve(vector bool long long __a) {
17472 return __builtin_shufflevector(__a, __a, 1, 0);
17473}
17474
17475static inline __ATTRS_o_ai vector signed long long
17476vec_reve(vector signed long long __a) {
17477 return __builtin_shufflevector(__a, __a, 1, 0);
17478}
17479
17480static inline __ATTRS_o_ai vector unsigned long long
17481vec_reve(vector unsigned long long __a) {
17482 return __builtin_shufflevector(__a, __a, 1, 0);
17483}
17484
17485static inline __ATTRS_o_ai vector double vec_reve(vector double __a) {
17486 return __builtin_shufflevector(__a, __a, 1, 0);
17487}
17488#endif
17489
17490/* vec_revb */
17491static __inline__ vector bool char __ATTRS_o_ai
17492vec_revb(vector bool char __a) {
17493 return __a;
17494}
17495
17496static __inline__ vector signed char __ATTRS_o_ai
17497vec_revb(vector signed char __a) {
17498 return __a;
17499}
17500
17501static __inline__ vector unsigned char __ATTRS_o_ai
17502vec_revb(vector unsigned char __a) {
17503 return __a;
17504}
17505
17506static __inline__ vector bool short __ATTRS_o_ai
17507vec_revb(vector bool short __a) {
17508 vector unsigned char __indices =
17509 { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 };
17510 return vec_perm(__a, __a, __indices);
17511}
17512
17513static __inline__ vector signed short __ATTRS_o_ai
17514vec_revb(vector signed short __a) {
17515 vector unsigned char __indices =
17516 { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 };
17517 return vec_perm(__a, __a, __indices);
17518}
17519
17520static __inline__ vector unsigned short __ATTRS_o_ai
17521vec_revb(vector unsigned short __a) {
17522 vector unsigned char __indices =
17523 { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 };
17524 return vec_perm(__a, __a, __indices);
17525}
17526
17527static __inline__ vector bool int __ATTRS_o_ai
17528vec_revb(vector bool int __a) {
17529 vector unsigned char __indices =
17530 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17531 return vec_perm(__a, __a, __indices);
17532}
17533
17534static __inline__ vector signed int __ATTRS_o_ai
17535vec_revb(vector signed int __a) {
17536 vector unsigned char __indices =
17537 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17538 return vec_perm(__a, __a, __indices);
17539}
17540
17541static __inline__ vector unsigned int __ATTRS_o_ai
17542vec_revb(vector unsigned int __a) {
17543 vector unsigned char __indices =
17544 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17545 return vec_perm(__a, __a, __indices);
17546}
17547
17548static __inline__ vector float __ATTRS_o_ai
17549vec_revb(vector float __a) {
17550 vector unsigned char __indices =
17551 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 };
17552 return vec_perm(__a, __a, __indices);
17553}
17554
17555#ifdef __VSX__
17556static __inline__ vector bool long long __ATTRS_o_ai
17557vec_revb(vector bool long long __a) {
17558 vector unsigned char __indices =
17559 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17560 return vec_perm(__a, __a, __indices);
17561}
17562
17563static __inline__ vector signed long long __ATTRS_o_ai
17564vec_revb(vector signed long long __a) {
17565 vector unsigned char __indices =
17566 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17567 return vec_perm(__a, __a, __indices);
17568}
17569
17570static __inline__ vector unsigned long long __ATTRS_o_ai
17571vec_revb(vector unsigned long long __a) {
17572 vector unsigned char __indices =
17573 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17574 return vec_perm(__a, __a, __indices);
17575}
17576
17577static __inline__ vector double __ATTRS_o_ai
17578vec_revb(vector double __a) {
17579 vector unsigned char __indices =
17580 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };
17581 return vec_perm(__a, __a, __indices);
17582}
17583#endif /* End __VSX__ */
17584
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017585#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17586 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080017587static __inline__ vector signed __int128 __ATTRS_o_ai
17588vec_revb(vector signed __int128 __a) {
17589 vector unsigned char __indices =
17590 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
17591 return (vector signed __int128)vec_perm((vector signed int)__a,
17592 (vector signed int)__a,
17593 __indices);
17594}
17595
17596static __inline__ vector unsigned __int128 __ATTRS_o_ai
17597vec_revb(vector unsigned __int128 __a) {
17598 vector unsigned char __indices =
17599 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
17600 return (vector unsigned __int128)vec_perm((vector signed int)__a,
17601 (vector signed int)__a,
17602 __indices);
17603}
17604#endif /* END __POWER8_VECTOR__ && __powerpc64__ */
17605
17606/* vec_xl */
17607
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017608#define vec_xld2 vec_xl
17609#define vec_xlw4 vec_xl
Logan Chiendbcf4122019-03-21 10:50:25 +080017610typedef vector signed char unaligned_vec_schar __attribute__((aligned(1)));
17611typedef vector unsigned char unaligned_vec_uchar __attribute__((aligned(1)));
17612typedef vector signed short unaligned_vec_sshort __attribute__((aligned(1)));
17613typedef vector unsigned short unaligned_vec_ushort __attribute__((aligned(1)));
17614typedef vector signed int unaligned_vec_sint __attribute__((aligned(1)));
17615typedef vector unsigned int unaligned_vec_uint __attribute__((aligned(1)));
17616typedef vector float unaligned_vec_float __attribute__((aligned(1)));
17617
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017618static inline __ATTRS_o_ai vector signed char vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017619 const signed char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017620 return *(unaligned_vec_schar *)(__ptr + __offset);
Logan Chien55afb0a2018-10-15 10:42:14 +080017621}
17622
17623static inline __ATTRS_o_ai vector unsigned char
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017624vec_xl(ptrdiff_t __offset, const unsigned char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017625 return *(unaligned_vec_uchar*)(__ptr + __offset);
Logan Chien55afb0a2018-10-15 10:42:14 +080017626}
17627
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017628static inline __ATTRS_o_ai vector signed short
17629vec_xl(ptrdiff_t __offset, const signed short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017630 signed char *__addr = (signed char *)__ptr + __offset;
17631 return *(unaligned_vec_sshort *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017632}
17633
17634static inline __ATTRS_o_ai vector unsigned short
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017635vec_xl(ptrdiff_t __offset, const unsigned short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017636 signed char *__addr = (signed char *)__ptr + __offset;
17637 return *(unaligned_vec_ushort *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017638}
17639
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017640static inline __ATTRS_o_ai vector signed int vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017641 const signed int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017642 signed char *__addr = (signed char *)__ptr + __offset;
17643 return *(unaligned_vec_sint *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017644}
17645
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017646static inline __ATTRS_o_ai vector unsigned int
17647vec_xl(ptrdiff_t __offset, const unsigned int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017648 signed char *__addr = (signed char *)__ptr + __offset;
17649 return *(unaligned_vec_uint *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017650}
17651
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017652static inline __ATTRS_o_ai vector float vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017653 const float *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017654 signed char *__addr = (signed char *)__ptr + __offset;
17655 return *(unaligned_vec_float *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017656}
17657
17658#ifdef __VSX__
Logan Chiendbcf4122019-03-21 10:50:25 +080017659typedef vector signed long long unaligned_vec_sll __attribute__((aligned(1)));
17660typedef vector unsigned long long unaligned_vec_ull __attribute__((aligned(1)));
17661typedef vector double unaligned_vec_double __attribute__((aligned(1)));
17662
Logan Chien55afb0a2018-10-15 10:42:14 +080017663static inline __ATTRS_o_ai vector signed long long
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017664vec_xl(ptrdiff_t __offset, const signed long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017665 signed char *__addr = (signed char *)__ptr + __offset;
17666 return *(unaligned_vec_sll *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017667}
17668
17669static inline __ATTRS_o_ai vector unsigned long long
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017670vec_xl(ptrdiff_t __offset, const unsigned long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017671 signed char *__addr = (signed char *)__ptr + __offset;
17672 return *(unaligned_vec_ull *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017673}
17674
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017675static inline __ATTRS_o_ai vector double vec_xl(ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017676 const double *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017677 signed char *__addr = (signed char *)__ptr + __offset;
17678 return *(unaligned_vec_double *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017679}
17680#endif
17681
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017682#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17683 defined(__SIZEOF_INT128__)
Logan Chiendbcf4122019-03-21 10:50:25 +080017684typedef vector signed __int128 unaligned_vec_si128 __attribute__((aligned(1)));
17685typedef vector unsigned __int128 unaligned_vec_ui128
17686 __attribute__((aligned(1)));
Logan Chien55afb0a2018-10-15 10:42:14 +080017687static inline __ATTRS_o_ai vector signed __int128
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017688vec_xl(ptrdiff_t __offset, const signed __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017689 signed char *__addr = (signed char *)__ptr + __offset;
17690 return *(unaligned_vec_si128 *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017691}
17692
17693static inline __ATTRS_o_ai vector unsigned __int128
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017694vec_xl(ptrdiff_t __offset, const unsigned __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017695 signed char *__addr = (signed char *)__ptr + __offset;
17696 return *(unaligned_vec_ui128 *)__addr;
Logan Chien55afb0a2018-10-15 10:42:14 +080017697}
17698#endif
17699
17700/* vec_xl_be */
17701
17702#ifdef __LITTLE_ENDIAN__
17703static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017704vec_xl_be(ptrdiff_t __offset, const signed char *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017705 vector signed char __vec = (vector signed char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017706 return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
17707 13, 12, 11, 10, 9, 8);
17708}
17709
17710static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017711vec_xl_be(ptrdiff_t __offset, const unsigned char *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017712 vector unsigned char __vec = (vector unsigned char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017713 return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
17714 13, 12, 11, 10, 9, 8);
17715}
17716
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017717static __inline__ vector signed short __ATTRS_o_ai
17718vec_xl_be(ptrdiff_t __offset, const signed short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017719 vector signed short __vec = (vector signed short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017720 return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
17721}
17722
17723static __inline__ vector unsigned short __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017724vec_xl_be(ptrdiff_t __offset, const unsigned short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017725 vector unsigned short __vec = (vector unsigned short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080017726 return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
17727}
17728
17729static __inline__ vector signed int __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017730vec_xl_be(signed long long __offset, const signed int *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017731 return (vector signed int)__builtin_vsx_lxvw4x_be(__offset, __ptr);
17732}
17733
17734static __inline__ vector unsigned int __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017735vec_xl_be(signed long long __offset, const unsigned int *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017736 return (vector unsigned int)__builtin_vsx_lxvw4x_be(__offset, __ptr);
17737}
17738
17739static __inline__ vector float __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017740vec_xl_be(signed long long __offset, const float *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017741 return (vector float)__builtin_vsx_lxvw4x_be(__offset, __ptr);
17742}
17743
17744#ifdef __VSX__
17745static __inline__ vector signed long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017746vec_xl_be(signed long long __offset, const signed long long *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017747 return (vector signed long long)__builtin_vsx_lxvd2x_be(__offset, __ptr);
17748}
17749
17750static __inline__ vector unsigned long long __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017751vec_xl_be(signed long long __offset, const unsigned long long *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017752 return (vector unsigned long long)__builtin_vsx_lxvd2x_be(__offset, __ptr);
17753}
17754
17755static __inline__ vector double __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017756vec_xl_be(signed long long __offset, const double *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017757 return (vector double)__builtin_vsx_lxvd2x_be(__offset, __ptr);
17758}
17759#endif
17760
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017761#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17762 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080017763static __inline__ vector signed __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017764vec_xl_be(signed long long __offset, const signed __int128 *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017765 return vec_xl(__offset, __ptr);
17766}
17767
17768static __inline__ vector unsigned __int128 __ATTRS_o_ai
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017769vec_xl_be(signed long long __offset, const unsigned __int128 *__ptr) {
Logan Chien55afb0a2018-10-15 10:42:14 +080017770 return vec_xl(__offset, __ptr);
17771}
17772#endif
17773#else
17774 #define vec_xl_be vec_xl
17775#endif
17776
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017777#if defined(__POWER10_VECTOR__) && defined(__VSX__) && \
17778 defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017779
17780/* vect_xl_sext */
17781
17782static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017783vec_xl_sext(ptrdiff_t __offset, const signed char *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017784 return (vector unsigned __int128)*(__pointer + __offset);
17785}
17786
17787static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017788vec_xl_sext(ptrdiff_t __offset, const signed short *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017789 return (vector unsigned __int128)*(__pointer + __offset);
17790}
17791
17792static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017793vec_xl_sext(ptrdiff_t __offset, const signed int *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017794 return (vector unsigned __int128)*(__pointer + __offset);
17795}
17796
17797static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017798vec_xl_sext(ptrdiff_t __offset, const signed long long *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017799 return (vector unsigned __int128)*(__pointer + __offset);
17800}
17801
17802/* vec_xl_zext */
17803
17804static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017805vec_xl_zext(ptrdiff_t __offset, const unsigned char *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017806 return (vector unsigned __int128)*(__pointer + __offset);
17807}
17808
17809static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017810vec_xl_zext(ptrdiff_t __offset, const unsigned short *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017811 return (vector unsigned __int128)*(__pointer + __offset);
17812}
17813
17814static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017815vec_xl_zext(ptrdiff_t __offset, const unsigned int *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017816 return (vector unsigned __int128)*(__pointer + __offset);
17817}
17818
17819static __inline__ vector unsigned __int128 __ATTRS_o_ai
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017820vec_xl_zext(ptrdiff_t __offset, const unsigned long long *__pointer) {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017821 return (vector unsigned __int128)*(__pointer + __offset);
17822}
17823
17824#endif
17825
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017826/* vec_xlds */
17827#ifdef __VSX__
17828static __inline__ vector signed long long __ATTRS_o_ai
17829vec_xlds(ptrdiff_t __offset, const signed long long *__ptr) {
17830 signed long long *__addr = (signed long long*)((signed char *)__ptr + __offset);
17831 return (vector signed long long) *__addr;
17832}
17833
17834static __inline__ vector unsigned long long __ATTRS_o_ai
17835vec_xlds(ptrdiff_t __offset, const unsigned long long *__ptr) {
17836 unsigned long long *__addr = (unsigned long long *)((signed char *)__ptr + __offset);
17837 return (unaligned_vec_ull) *__addr;
17838}
17839
17840static __inline__ vector double __ATTRS_o_ai vec_xlds(ptrdiff_t __offset,
17841 const double *__ptr) {
17842 double *__addr = (double*)((signed char *)__ptr + __offset);
17843 return (unaligned_vec_double) *__addr;
17844}
17845
17846/* vec_load_splats */
17847static __inline__ vector signed int __ATTRS_o_ai
17848vec_load_splats(signed long long __offset, const signed int *__ptr) {
17849 signed int *__addr = (signed int*)((signed char *)__ptr + __offset);
17850 return (vector signed int)*__addr;
17851}
17852
17853static __inline__ vector signed int __ATTRS_o_ai
17854vec_load_splats(unsigned long long __offset, const signed int *__ptr) {
17855 signed int *__addr = (signed int*)((signed char *)__ptr + __offset);
17856 return (vector signed int)*__addr;
17857}
17858
17859static __inline__ vector unsigned int __ATTRS_o_ai
17860vec_load_splats(signed long long __offset, const unsigned int *__ptr) {
17861 unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset);
17862 return (vector unsigned int)*__addr;
17863}
17864
17865static __inline__ vector unsigned int __ATTRS_o_ai
17866vec_load_splats(unsigned long long __offset, const unsigned int *__ptr) {
17867 unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset);
17868 return (vector unsigned int)*__addr;
17869}
17870
17871static __inline__ vector float __ATTRS_o_ai
17872vec_load_splats(signed long long __offset, const float *__ptr) {
17873 float *__addr = (float*)((signed char *)__ptr + __offset);
17874 return (vector float)*__addr;
17875}
17876
17877static __inline__ vector float __ATTRS_o_ai
17878vec_load_splats(unsigned long long __offset, const float *__ptr) {
17879 float *__addr = (float*)((signed char *)__ptr + __offset);
17880 return (vector float)*__addr;
17881}
17882#endif
17883
Logan Chien55afb0a2018-10-15 10:42:14 +080017884/* vec_xst */
17885
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017886#define vec_xstd2 vec_xst
17887#define vec_xstw4 vec_xst
17888static inline __ATTRS_o_ai void
17889vec_xst(vector signed char __vec, ptrdiff_t __offset, signed char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017890 *(unaligned_vec_schar *)(__ptr + __offset) = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017891}
17892
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017893static inline __ATTRS_o_ai void
17894vec_xst(vector unsigned char __vec, ptrdiff_t __offset, unsigned char *__ptr) {
Logan Chiendbcf4122019-03-21 10:50:25 +080017895 *(unaligned_vec_uchar *)(__ptr + __offset) = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017896}
17897
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017898static inline __ATTRS_o_ai void
17899vec_xst(vector signed short __vec, ptrdiff_t __offset, signed short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017900 signed char *__addr = (signed char *)__ptr + __offset;
17901 *(unaligned_vec_sshort *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017902}
17903
17904static inline __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017905 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017906 unsigned short *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017907 signed char *__addr = (signed char *)__ptr + __offset;
17908 *(unaligned_vec_ushort *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017909}
17910
17911static inline __ATTRS_o_ai void vec_xst(vector signed int __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017912 ptrdiff_t __offset, signed int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017913 signed char *__addr = (signed char *)__ptr + __offset;
17914 *(unaligned_vec_sint *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017915}
17916
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017917static inline __ATTRS_o_ai void
17918vec_xst(vector unsigned int __vec, ptrdiff_t __offset, unsigned int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017919 signed char *__addr = (signed char *)__ptr + __offset;
17920 *(unaligned_vec_uint *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017921}
17922
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017923static inline __ATTRS_o_ai void vec_xst(vector float __vec, ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017924 float *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017925 signed char *__addr = (signed char *)__ptr + __offset;
17926 *(unaligned_vec_float *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017927}
17928
17929#ifdef __VSX__
17930static inline __ATTRS_o_ai void vec_xst(vector signed long long __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017931 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017932 signed long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017933 signed char *__addr = (signed char *)__ptr + __offset;
17934 *(unaligned_vec_sll *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017935}
17936
17937static inline __ATTRS_o_ai void vec_xst(vector unsigned long long __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017938 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017939 unsigned long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017940 signed char *__addr = (signed char *)__ptr + __offset;
17941 *(unaligned_vec_ull *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017942}
17943
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017944static inline __ATTRS_o_ai void vec_xst(vector double __vec, ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017945 double *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017946 signed char *__addr = (signed char *)__ptr + __offset;
17947 *(unaligned_vec_double *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017948}
17949#endif
17950
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017951#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
17952 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080017953static inline __ATTRS_o_ai void vec_xst(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017954 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017955 signed __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017956 signed char *__addr = (signed char *)__ptr + __offset;
17957 *(unaligned_vec_si128 *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017958}
17959
17960static inline __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017961 ptrdiff_t __offset,
Logan Chien55afb0a2018-10-15 10:42:14 +080017962 unsigned __int128 *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080017963 signed char *__addr = (signed char *)__ptr + __offset;
17964 *(unaligned_vec_ui128 *)__addr = __vec;
Logan Chien55afb0a2018-10-15 10:42:14 +080017965}
17966#endif
17967
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017968/* vec_xst_trunc */
17969
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017970#if defined(__POWER10_VECTOR__) && defined(__VSX__) && \
17971 defined(__SIZEOF_INT128__)
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017972static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017973 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017974 signed char *__ptr) {
17975 *(__ptr + __offset) = (signed char)__vec[0];
17976}
17977
17978static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017979 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017980 unsigned char *__ptr) {
17981 *(__ptr + __offset) = (unsigned char)__vec[0];
17982}
17983
17984static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017985 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017986 signed short *__ptr) {
17987 *(__ptr + __offset) = (signed short)__vec[0];
17988}
17989
17990static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017991 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017992 unsigned short *__ptr) {
17993 *(__ptr + __offset) = (unsigned short)__vec[0];
17994}
17995
17996static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070017997 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080017998 signed int *__ptr) {
17999 *(__ptr + __offset) = (signed int)__vec[0];
18000}
18001
18002static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018003 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018004 unsigned int *__ptr) {
18005 *(__ptr + __offset) = (unsigned int)__vec[0];
18006}
18007
18008static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018009 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018010 signed long long *__ptr) {
18011 *(__ptr + __offset) = (signed long long)__vec[0];
18012}
18013
18014static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018015 ptrdiff_t __offset,
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018016 unsigned long long *__ptr) {
18017 *(__ptr + __offset) = (unsigned long long)__vec[0];
18018}
18019#endif
18020
Logan Chien55afb0a2018-10-15 10:42:14 +080018021/* vec_xst_be */
18022
18023#ifdef __LITTLE_ENDIAN__
18024static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed char __vec,
18025 signed long long __offset,
18026 signed char *__ptr) {
18027 vector signed char __tmp =
18028 __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
18029 13, 12, 11, 10, 9, 8);
Sasha Smundak746b0222020-02-25 09:19:04 -080018030 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
18031 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018032}
18033
18034static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned char __vec,
18035 signed long long __offset,
18036 unsigned char *__ptr) {
18037 vector unsigned char __tmp =
18038 __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
18039 13, 12, 11, 10, 9, 8);
Sasha Smundak746b0222020-02-25 09:19:04 -080018040 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
18041 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018042}
18043
18044static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed short __vec,
18045 signed long long __offset,
18046 signed short *__ptr) {
18047 vector signed short __tmp =
18048 __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
Sasha Smundak746b0222020-02-25 09:19:04 -080018049 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
18050 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018051}
18052
18053static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned short __vec,
18054 signed long long __offset,
18055 unsigned short *__ptr) {
18056 vector unsigned short __tmp =
18057 __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
Sasha Smundak746b0222020-02-25 09:19:04 -080018058 typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double;
18059 __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018060}
18061
18062static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed int __vec,
18063 signed long long __offset,
18064 signed int *__ptr) {
18065 __builtin_vsx_stxvw4x_be(__vec, __offset, __ptr);
18066}
18067
18068static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned int __vec,
18069 signed long long __offset,
18070 unsigned int *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018071 __builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018072}
18073
18074static __inline__ void __ATTRS_o_ai vec_xst_be(vector float __vec,
18075 signed long long __offset,
18076 float *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018077 __builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018078}
18079
18080#ifdef __VSX__
18081static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed long long __vec,
18082 signed long long __offset,
18083 signed long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018084 __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018085}
18086
18087static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned long long __vec,
18088 signed long long __offset,
18089 unsigned long long *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018090 __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018091}
18092
18093static __inline__ void __ATTRS_o_ai vec_xst_be(vector double __vec,
18094 signed long long __offset,
18095 double *__ptr) {
Sasha Smundak746b0222020-02-25 09:19:04 -080018096 __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr);
Logan Chien55afb0a2018-10-15 10:42:14 +080018097}
18098#endif
18099
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018100#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
18101 defined(__SIZEOF_INT128__)
Logan Chien55afb0a2018-10-15 10:42:14 +080018102static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed __int128 __vec,
18103 signed long long __offset,
18104 signed __int128 *__ptr) {
18105 vec_xst(__vec, __offset, __ptr);
18106}
18107
18108static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned __int128 __vec,
18109 signed long long __offset,
18110 unsigned __int128 *__ptr) {
18111 vec_xst(__vec, __offset, __ptr);
18112}
18113#endif
18114#else
18115 #define vec_xst_be vec_xst
18116#endif
18117
18118#ifdef __POWER9_VECTOR__
Sasha Smundak746b0222020-02-25 09:19:04 -080018119#define vec_test_data_class(__a, __b) \
18120 _Generic( \
18121 (__a), vector float \
18122 : (vector bool int)__builtin_vsx_xvtstdcsp((vector float)(__a), (__b)), \
18123 vector double \
18124 : (vector bool long long)__builtin_vsx_xvtstdcdp((vector double)(__a), \
18125 (__b)))
Logan Chien55afb0a2018-10-15 10:42:14 +080018126
18127#endif /* #ifdef __POWER9_VECTOR__ */
18128
18129static vector float __ATTRS_o_ai vec_neg(vector float __a) {
18130 return -__a;
18131}
18132
18133#ifdef __VSX__
18134static vector double __ATTRS_o_ai vec_neg(vector double __a) {
18135 return -__a;
18136}
18137
18138#endif
18139
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018140#ifdef __VSX__
Logan Chien55afb0a2018-10-15 10:42:14 +080018141static vector long long __ATTRS_o_ai vec_neg(vector long long __a) {
18142 return -__a;
18143}
18144#endif
18145
18146static vector signed int __ATTRS_o_ai vec_neg(vector signed int __a) {
18147 return -__a;
18148}
18149
18150static vector signed short __ATTRS_o_ai vec_neg(vector signed short __a) {
18151 return -__a;
18152}
18153
18154static vector signed char __ATTRS_o_ai vec_neg(vector signed char __a) {
18155 return -__a;
18156}
18157
18158static vector float __ATTRS_o_ai vec_nabs(vector float __a) {
18159 return - vec_abs(__a);
18160}
18161
18162#ifdef __VSX__
18163static vector double __ATTRS_o_ai vec_nabs(vector double __a) {
18164 return - vec_abs(__a);
18165}
18166
18167#endif
18168
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018169#ifdef __POWER8_VECTOR__
Logan Chien55afb0a2018-10-15 10:42:14 +080018170static vector long long __ATTRS_o_ai vec_nabs(vector long long __a) {
18171 return __builtin_altivec_vminsd(__a, -__a);
18172}
18173#endif
18174
18175static vector signed int __ATTRS_o_ai vec_nabs(vector signed int __a) {
18176 return __builtin_altivec_vminsw(__a, -__a);
18177}
18178
18179static vector signed short __ATTRS_o_ai vec_nabs(vector signed short __a) {
18180 return __builtin_altivec_vminsh(__a, -__a);
18181}
18182
18183static vector signed char __ATTRS_o_ai vec_nabs(vector signed char __a) {
18184 return __builtin_altivec_vminsb(__a, -__a);
18185}
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018186
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018187static vector float __ATTRS_o_ai vec_recipdiv(vector float __a,
18188 vector float __b) {
18189 return __builtin_ppc_recipdivf(__a, __b);
18190}
18191
18192#ifdef __VSX__
18193static vector double __ATTRS_o_ai vec_recipdiv(vector double __a,
18194 vector double __b) {
18195 return __builtin_ppc_recipdivd(__a, __b);
18196}
18197#endif
18198
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018199#ifdef __POWER10_VECTOR__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018200
18201/* vec_extractm */
18202
18203static __inline__ unsigned int __ATTRS_o_ai
18204vec_extractm(vector unsigned char __a) {
18205 return __builtin_altivec_vextractbm(__a);
18206}
18207
18208static __inline__ unsigned int __ATTRS_o_ai
18209vec_extractm(vector unsigned short __a) {
18210 return __builtin_altivec_vextracthm(__a);
18211}
18212
18213static __inline__ unsigned int __ATTRS_o_ai
18214vec_extractm(vector unsigned int __a) {
18215 return __builtin_altivec_vextractwm(__a);
18216}
18217
18218static __inline__ unsigned int __ATTRS_o_ai
18219vec_extractm(vector unsigned long long __a) {
18220 return __builtin_altivec_vextractdm(__a);
18221}
18222
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018223#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018224static __inline__ unsigned int __ATTRS_o_ai
18225vec_extractm(vector unsigned __int128 __a) {
18226 return __builtin_altivec_vextractqm(__a);
18227}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018228#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018229
18230/* vec_expandm */
18231
18232static __inline__ vector unsigned char __ATTRS_o_ai
18233vec_expandm(vector unsigned char __a) {
18234 return __builtin_altivec_vexpandbm(__a);
18235}
18236
18237static __inline__ vector unsigned short __ATTRS_o_ai
18238vec_expandm(vector unsigned short __a) {
18239 return __builtin_altivec_vexpandhm(__a);
18240}
18241
18242static __inline__ vector unsigned int __ATTRS_o_ai
18243vec_expandm(vector unsigned int __a) {
18244 return __builtin_altivec_vexpandwm(__a);
18245}
18246
18247static __inline__ vector unsigned long long __ATTRS_o_ai
18248vec_expandm(vector unsigned long long __a) {
18249 return __builtin_altivec_vexpanddm(__a);
18250}
18251
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018252#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018253static __inline__ vector unsigned __int128 __ATTRS_o_ai
18254vec_expandm(vector unsigned __int128 __a) {
18255 return __builtin_altivec_vexpandqm(__a);
18256}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018257#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018258
18259/* vec_cntm */
18260
18261#define vec_cntm(__a, __mp) \
18262 _Generic((__a), vector unsigned char \
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018263 : __builtin_altivec_vcntmbb((__a), (unsigned char)(__mp)), \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018264 vector unsigned short \
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018265 : __builtin_altivec_vcntmbh((__a), (unsigned char)(__mp)), \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018266 vector unsigned int \
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018267 : __builtin_altivec_vcntmbw((__a), (unsigned char)(__mp)), \
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018268 vector unsigned long long \
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018269 : __builtin_altivec_vcntmbd((__a), (unsigned char)(__mp)))
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018270
18271/* vec_gen[b|h|w|d|q]m */
18272
18273static __inline__ vector unsigned char __ATTRS_o_ai
18274vec_genbm(unsigned long long __bm) {
18275 return __builtin_altivec_mtvsrbm(__bm);
18276}
18277
18278static __inline__ vector unsigned short __ATTRS_o_ai
18279vec_genhm(unsigned long long __bm) {
18280 return __builtin_altivec_mtvsrhm(__bm);
18281}
18282
18283static __inline__ vector unsigned int __ATTRS_o_ai
18284vec_genwm(unsigned long long __bm) {
18285 return __builtin_altivec_mtvsrwm(__bm);
18286}
18287
18288static __inline__ vector unsigned long long __ATTRS_o_ai
18289vec_gendm(unsigned long long __bm) {
18290 return __builtin_altivec_mtvsrdm(__bm);
18291}
18292
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018293#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018294static __inline__ vector unsigned __int128 __ATTRS_o_ai
18295vec_genqm(unsigned long long __bm) {
18296 return __builtin_altivec_mtvsrqm(__bm);
18297}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018298#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018299
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018300/* vec_pdep */
18301
18302static __inline__ vector unsigned long long __ATTRS_o_ai
18303vec_pdep(vector unsigned long long __a, vector unsigned long long __b) {
18304 return __builtin_altivec_vpdepd(__a, __b);
18305}
18306
18307/* vec_pext */
18308
18309static __inline__ vector unsigned long long __ATTRS_o_ai
18310vec_pext(vector unsigned long long __a, vector unsigned long long __b) {
18311 return __builtin_altivec_vpextd(__a, __b);
18312}
18313
18314/* vec_cfuge */
18315
18316static __inline__ vector unsigned long long __ATTRS_o_ai
18317vec_cfuge(vector unsigned long long __a, vector unsigned long long __b) {
18318 return __builtin_altivec_vcfuged(__a, __b);
18319}
18320
18321/* vec_gnb */
18322
18323#define vec_gnb(__a, __b) __builtin_altivec_vgnb(__a, __b)
18324
18325/* vec_ternarylogic */
18326#ifdef __VSX__
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018327#ifdef __SIZEOF_INT128__
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018328#define vec_ternarylogic(__a, __b, __c, __imm) \
18329 _Generic((__a), vector unsigned char \
18330 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18331 (vector unsigned long long)(__b), \
18332 (vector unsigned long long)(__c), (__imm)), \
18333 vector unsigned short \
18334 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18335 (vector unsigned long long)(__b), \
18336 (vector unsigned long long)(__c), (__imm)), \
18337 vector unsigned int \
18338 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18339 (vector unsigned long long)(__b), \
18340 (vector unsigned long long)(__c), (__imm)), \
18341 vector unsigned long long \
18342 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18343 (vector unsigned long long)(__b), \
18344 (vector unsigned long long)(__c), (__imm)), \
18345 vector unsigned __int128 \
18346 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18347 (vector unsigned long long)(__b), \
18348 (vector unsigned long long)(__c), (__imm)))
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018349#else
18350#define vec_ternarylogic(__a, __b, __c, __imm) \
18351 _Generic((__a), vector unsigned char \
18352 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18353 (vector unsigned long long)(__b), \
18354 (vector unsigned long long)(__c), (__imm)), \
18355 vector unsigned short \
18356 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18357 (vector unsigned long long)(__b), \
18358 (vector unsigned long long)(__c), (__imm)), \
18359 vector unsigned int \
18360 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18361 (vector unsigned long long)(__b), \
18362 (vector unsigned long long)(__c), (__imm)), \
18363 vector unsigned long long \
18364 : __builtin_vsx_xxeval((vector unsigned long long)(__a), \
18365 (vector unsigned long long)(__b), \
18366 (vector unsigned long long)(__c), (__imm)))
18367#endif /* __SIZEOF_INT128__ */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018368#endif /* __VSX__ */
18369
18370/* vec_genpcvm */
18371
18372#ifdef __VSX__
18373#define vec_genpcvm(__a, __imm) \
18374 _Generic((__a), vector unsigned char \
18375 : __builtin_vsx_xxgenpcvbm((__a), (int)(__imm)), \
18376 vector unsigned short \
18377 : __builtin_vsx_xxgenpcvhm((__a), (int)(__imm)), \
18378 vector unsigned int \
18379 : __builtin_vsx_xxgenpcvwm((__a), (int)(__imm)), \
18380 vector unsigned long long \
18381 : __builtin_vsx_xxgenpcvdm((__a), (int)(__imm)))
18382#endif /* __VSX__ */
18383
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018384/* vec_clr_first */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018385
18386static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018387vec_clr_first(vector signed char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018388#ifdef __LITTLE_ENDIAN__
18389 return __builtin_altivec_vclrrb(__a, __n);
18390#else
18391 return __builtin_altivec_vclrlb( __a, __n);
18392#endif
18393}
18394
18395static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018396vec_clr_first(vector unsigned char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018397#ifdef __LITTLE_ENDIAN__
18398 return __builtin_altivec_vclrrb((vector signed char)__a, __n);
18399#else
18400 return __builtin_altivec_vclrlb((vector signed char)__a, __n);
18401#endif
18402}
18403
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018404/* vec_clr_last */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018405
18406static __inline__ vector signed char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018407vec_clr_last(vector signed char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018408#ifdef __LITTLE_ENDIAN__
18409 return __builtin_altivec_vclrlb(__a, __n);
18410#else
18411 return __builtin_altivec_vclrrb( __a, __n);
18412#endif
18413}
18414
18415static __inline__ vector unsigned char __ATTRS_o_ai
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -080018416vec_clr_last(vector unsigned char __a, unsigned int __n) {
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018417#ifdef __LITTLE_ENDIAN__
18418 return __builtin_altivec_vclrlb((vector signed char)__a, __n);
18419#else
18420 return __builtin_altivec_vclrrb((vector signed char)__a, __n);
18421#endif
18422}
18423
18424/* vec_cntlzm */
18425
18426static __inline__ vector unsigned long long __ATTRS_o_ai
18427vec_cntlzm(vector unsigned long long __a, vector unsigned long long __b) {
18428 return __builtin_altivec_vclzdm(__a, __b);
18429}
18430
18431/* vec_cnttzm */
18432
18433static __inline__ vector unsigned long long __ATTRS_o_ai
18434vec_cnttzm(vector unsigned long long __a, vector unsigned long long __b) {
18435 return __builtin_altivec_vctzdm(__a, __b);
18436}
18437
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018438/* vec_mod */
18439
18440static __inline__ vector signed int __ATTRS_o_ai
18441vec_mod(vector signed int __a, vector signed int __b) {
18442 return __a % __b;
18443}
18444
18445static __inline__ vector unsigned int __ATTRS_o_ai
18446vec_mod(vector unsigned int __a, vector unsigned int __b) {
18447 return __a % __b;
18448}
18449
18450static __inline__ vector signed long long __ATTRS_o_ai
18451vec_mod(vector signed long long __a, vector signed long long __b) {
18452 return __a % __b;
18453}
18454
18455static __inline__ vector unsigned long long __ATTRS_o_ai
18456vec_mod(vector unsigned long long __a, vector unsigned long long __b) {
18457 return __a % __b;
18458}
18459
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018460#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018461static __inline__ vector signed __int128 __ATTRS_o_ai
18462vec_mod(vector signed __int128 __a, vector signed __int128 __b) {
18463 return __a % __b;
18464}
18465
18466static __inline__ vector unsigned __int128 __ATTRS_o_ai
18467vec_mod(vector unsigned __int128 __a, vector unsigned __int128 __b) {
18468 return __a % __b;
18469}
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018470#endif
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018471
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018472/* vec_sldbi */
18473
18474#define vec_sldb(__a, __b, __c) __builtin_altivec_vsldbi(__a, __b, (__c & 0x7))
18475
18476/* vec_srdbi */
18477
18478#define vec_srdb(__a, __b, __c) __builtin_altivec_vsrdbi(__a, __b, (__c & 0x7))
18479
18480/* vec_insertl */
18481
18482static __inline__ vector unsigned char __ATTRS_o_ai
18483vec_insertl(unsigned char __a, vector unsigned char __b, unsigned int __c) {
18484#ifdef __LITTLE_ENDIAN__
18485 return __builtin_altivec_vinsbrx(__b, __c, __a);
18486#else
18487 return __builtin_altivec_vinsblx(__b, __c, __a);
18488#endif
18489}
18490
18491static __inline__ vector unsigned short __ATTRS_o_ai
18492vec_insertl(unsigned short __a, vector unsigned short __b, unsigned int __c) {
18493#ifdef __LITTLE_ENDIAN__
18494 return __builtin_altivec_vinshrx(__b, __c, __a);
18495#else
18496 return __builtin_altivec_vinshlx(__b, __c, __a);
18497#endif
18498}
18499
18500static __inline__ vector unsigned int __ATTRS_o_ai
18501vec_insertl(unsigned int __a, vector unsigned int __b, unsigned int __c) {
18502#ifdef __LITTLE_ENDIAN__
18503 return __builtin_altivec_vinswrx(__b, __c, __a);
18504#else
18505 return __builtin_altivec_vinswlx(__b, __c, __a);
18506#endif
18507}
18508
18509static __inline__ vector unsigned long long __ATTRS_o_ai
18510vec_insertl(unsigned long long __a, vector unsigned long long __b,
18511 unsigned int __c) {
18512#ifdef __LITTLE_ENDIAN__
18513 return __builtin_altivec_vinsdrx(__b, __c, __a);
18514#else
18515 return __builtin_altivec_vinsdlx(__b, __c, __a);
18516#endif
18517}
18518
18519static __inline__ vector unsigned char __ATTRS_o_ai
18520vec_insertl(vector unsigned char __a, vector unsigned char __b,
18521 unsigned int __c) {
18522#ifdef __LITTLE_ENDIAN__
18523 return __builtin_altivec_vinsbvrx(__b, __c, __a);
18524#else
18525 return __builtin_altivec_vinsbvlx(__b, __c, __a);
18526#endif
18527}
18528
18529static __inline__ vector unsigned short __ATTRS_o_ai
18530vec_insertl(vector unsigned short __a, vector unsigned short __b,
18531 unsigned int __c) {
18532#ifdef __LITTLE_ENDIAN__
18533 return __builtin_altivec_vinshvrx(__b, __c, __a);
18534#else
18535 return __builtin_altivec_vinshvlx(__b, __c, __a);
18536#endif
18537}
18538
18539static __inline__ vector unsigned int __ATTRS_o_ai
18540vec_insertl(vector unsigned int __a, vector unsigned int __b,
18541 unsigned int __c) {
18542#ifdef __LITTLE_ENDIAN__
18543 return __builtin_altivec_vinswvrx(__b, __c, __a);
18544#else
18545 return __builtin_altivec_vinswvlx(__b, __c, __a);
18546#endif
18547}
18548
18549/* vec_inserth */
18550
18551static __inline__ vector unsigned char __ATTRS_o_ai
18552vec_inserth(unsigned char __a, vector unsigned char __b, unsigned int __c) {
18553#ifdef __LITTLE_ENDIAN__
18554 return __builtin_altivec_vinsblx(__b, __c, __a);
18555#else
18556 return __builtin_altivec_vinsbrx(__b, __c, __a);
18557#endif
18558}
18559
18560static __inline__ vector unsigned short __ATTRS_o_ai
18561vec_inserth(unsigned short __a, vector unsigned short __b, unsigned int __c) {
18562#ifdef __LITTLE_ENDIAN__
18563 return __builtin_altivec_vinshlx(__b, __c, __a);
18564#else
18565 return __builtin_altivec_vinshrx(__b, __c, __a);
18566#endif
18567}
18568
18569static __inline__ vector unsigned int __ATTRS_o_ai
18570vec_inserth(unsigned int __a, vector unsigned int __b, unsigned int __c) {
18571#ifdef __LITTLE_ENDIAN__
18572 return __builtin_altivec_vinswlx(__b, __c, __a);
18573#else
18574 return __builtin_altivec_vinswrx(__b, __c, __a);
18575#endif
18576}
18577
18578static __inline__ vector unsigned long long __ATTRS_o_ai
18579vec_inserth(unsigned long long __a, vector unsigned long long __b,
18580 unsigned int __c) {
18581#ifdef __LITTLE_ENDIAN__
18582 return __builtin_altivec_vinsdlx(__b, __c, __a);
18583#else
18584 return __builtin_altivec_vinsdrx(__b, __c, __a);
18585#endif
18586}
18587
18588static __inline__ vector unsigned char __ATTRS_o_ai
18589vec_inserth(vector unsigned char __a, vector unsigned char __b,
18590 unsigned int __c) {
18591#ifdef __LITTLE_ENDIAN__
18592 return __builtin_altivec_vinsbvlx(__b, __c, __a);
18593#else
18594 return __builtin_altivec_vinsbvrx(__b, __c, __a);
18595#endif
18596}
18597
18598static __inline__ vector unsigned short __ATTRS_o_ai
18599vec_inserth(vector unsigned short __a, vector unsigned short __b,
18600 unsigned int __c) {
18601#ifdef __LITTLE_ENDIAN__
18602 return __builtin_altivec_vinshvlx(__b, __c, __a);
18603#else
18604 return __builtin_altivec_vinshvrx(__b, __c, __a);
18605#endif
18606}
18607
18608static __inline__ vector unsigned int __ATTRS_o_ai
18609vec_inserth(vector unsigned int __a, vector unsigned int __b,
18610 unsigned int __c) {
18611#ifdef __LITTLE_ENDIAN__
18612 return __builtin_altivec_vinswvlx(__b, __c, __a);
18613#else
18614 return __builtin_altivec_vinswvrx(__b, __c, __a);
18615#endif
18616}
18617
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018618/* vec_extractl */
18619
18620static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl(
18621 vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
18622#ifdef __LITTLE_ENDIAN__
18623 return __builtin_altivec_vextdubvrx(__a, __b, __c);
18624#else
18625 vector unsigned long long __ret = __builtin_altivec_vextdubvlx(__a, __b, __c);
18626 return vec_sld(__ret, __ret, 8);
18627#endif
18628}
18629
18630static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl(
18631 vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
18632#ifdef __LITTLE_ENDIAN__
18633 return __builtin_altivec_vextduhvrx(__a, __b, __c);
18634#else
18635 vector unsigned long long __ret = __builtin_altivec_vextduhvlx(__a, __b, __c);
18636 return vec_sld(__ret, __ret, 8);
18637#endif
18638}
18639
18640static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl(
18641 vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
18642#ifdef __LITTLE_ENDIAN__
18643 return __builtin_altivec_vextduwvrx(__a, __b, __c);
18644#else
18645 vector unsigned long long __ret = __builtin_altivec_vextduwvlx(__a, __b, __c);
18646 return vec_sld(__ret, __ret, 8);
18647#endif
18648}
18649
18650static __inline__ vector unsigned long long __ATTRS_o_ai
18651vec_extractl(vector unsigned long long __a, vector unsigned long long __b,
18652 unsigned int __c) {
18653#ifdef __LITTLE_ENDIAN__
18654 return __builtin_altivec_vextddvrx(__a, __b, __c);
18655#else
18656 vector unsigned long long __ret = __builtin_altivec_vextddvlx(__a, __b, __c);
18657 return vec_sld(__ret, __ret, 8);
18658#endif
18659}
18660
18661/* vec_extracth */
18662
18663static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth(
18664 vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
18665#ifdef __LITTLE_ENDIAN__
18666 return __builtin_altivec_vextdubvlx(__a, __b, __c);
18667#else
18668 vector unsigned long long __ret = __builtin_altivec_vextdubvrx(__a, __b, __c);
18669 return vec_sld(__ret, __ret, 8);
18670#endif
18671}
18672
18673static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth(
18674 vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
18675#ifdef __LITTLE_ENDIAN__
18676 return __builtin_altivec_vextduhvlx(__a, __b, __c);
18677#else
18678 vector unsigned long long __ret = __builtin_altivec_vextduhvrx(__a, __b, __c);
18679 return vec_sld(__ret, __ret, 8);
18680#endif
18681}
18682
18683static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth(
18684 vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
18685#ifdef __LITTLE_ENDIAN__
18686 return __builtin_altivec_vextduwvlx(__a, __b, __c);
18687#else
18688 vector unsigned long long __ret = __builtin_altivec_vextduwvrx(__a, __b, __c);
18689 return vec_sld(__ret, __ret, 8);
18690#endif
18691}
18692
18693static __inline__ vector unsigned long long __ATTRS_o_ai
18694vec_extracth(vector unsigned long long __a, vector unsigned long long __b,
18695 unsigned int __c) {
18696#ifdef __LITTLE_ENDIAN__
18697 return __builtin_altivec_vextddvlx(__a, __b, __c);
18698#else
18699 vector unsigned long long __ret = __builtin_altivec_vextddvrx(__a, __b, __c);
18700 return vec_sld(__ret, __ret, 8);
18701#endif
18702}
18703
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018704#ifdef __VSX__
18705
18706/* vec_permx */
18707
18708#define vec_permx(__a, __b, __c, __d) \
18709 __builtin_vsx_xxpermx((__a), (__b), (__c), (__d))
18710
18711/* vec_blendv */
18712
18713static __inline__ vector signed char __ATTRS_o_ai
18714vec_blendv(vector signed char __a, vector signed char __b,
18715 vector unsigned char __c) {
18716 return __builtin_vsx_xxblendvb(__a, __b, __c);
18717}
18718
18719static __inline__ vector unsigned char __ATTRS_o_ai
18720vec_blendv(vector unsigned char __a, vector unsigned char __b,
18721 vector unsigned char __c) {
18722 return __builtin_vsx_xxblendvb(__a, __b, __c);
18723}
18724
18725static __inline__ vector signed short __ATTRS_o_ai
18726vec_blendv(vector signed short __a, vector signed short __b,
18727 vector unsigned short __c) {
18728 return __builtin_vsx_xxblendvh(__a, __b, __c);
18729}
18730
18731static __inline__ vector unsigned short __ATTRS_o_ai
18732vec_blendv(vector unsigned short __a, vector unsigned short __b,
18733 vector unsigned short __c) {
18734 return __builtin_vsx_xxblendvh(__a, __b, __c);
18735}
18736
18737static __inline__ vector signed int __ATTRS_o_ai
18738vec_blendv(vector signed int __a, vector signed int __b,
18739 vector unsigned int __c) {
18740 return __builtin_vsx_xxblendvw(__a, __b, __c);
18741}
18742
18743static __inline__ vector unsigned int __ATTRS_o_ai
18744vec_blendv(vector unsigned int __a, vector unsigned int __b,
18745 vector unsigned int __c) {
18746 return __builtin_vsx_xxblendvw(__a, __b, __c);
18747}
18748
18749static __inline__ vector signed long long __ATTRS_o_ai
18750vec_blendv(vector signed long long __a, vector signed long long __b,
18751 vector unsigned long long __c) {
18752 return __builtin_vsx_xxblendvd(__a, __b, __c);
18753}
18754
18755static __inline__ vector unsigned long long __ATTRS_o_ai
18756vec_blendv(vector unsigned long long __a, vector unsigned long long __b,
18757 vector unsigned long long __c) {
18758 return __builtin_vsx_xxblendvd(__a, __b, __c);
18759}
18760
18761static __inline__ vector float __ATTRS_o_ai
18762vec_blendv(vector float __a, vector float __b, vector unsigned int __c) {
18763 return __builtin_vsx_xxblendvw(__a, __b, __c);
18764}
18765
18766static __inline__ vector double __ATTRS_o_ai
18767vec_blendv(vector double __a, vector double __b,
18768 vector unsigned long long __c) {
18769 return __builtin_vsx_xxblendvd(__a, __b, __c);
18770}
18771
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018772/* vec_replace_elt */
18773
18774#define vec_replace_elt __builtin_altivec_vec_replace_elt
18775
18776/* vec_replace_unaligned */
18777
18778#define vec_replace_unaligned __builtin_altivec_vec_replace_unaligned
18779
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018780/* vec_splati */
18781
18782#define vec_splati(__a) \
18783 _Generic((__a), signed int \
18784 : ((vector signed int)__a), unsigned int \
18785 : ((vector unsigned int)__a), float \
18786 : ((vector float)__a))
18787
18788/* vec_spatid */
18789
18790static __inline__ vector double __ATTRS_o_ai vec_splatid(const float __a) {
18791 return ((vector double)((double)__a));
18792}
18793
18794/* vec_splati_ins */
18795
18796static __inline__ vector signed int __ATTRS_o_ai vec_splati_ins(
18797 vector signed int __a, const unsigned int __b, const signed int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018798 const unsigned int __d = __b & 0x01;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018799#ifdef __LITTLE_ENDIAN__
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018800 __a[1 - __d] = __c;
18801 __a[3 - __d] = __c;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018802#else
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018803 __a[__d] = __c;
18804 __a[2 + __d] = __c;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018805#endif
18806 return __a;
18807}
18808
18809static __inline__ vector unsigned int __ATTRS_o_ai vec_splati_ins(
18810 vector unsigned int __a, const unsigned int __b, const unsigned int __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018811 const unsigned int __d = __b & 0x01;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018812#ifdef __LITTLE_ENDIAN__
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018813 __a[1 - __d] = __c;
18814 __a[3 - __d] = __c;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018815#else
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018816 __a[__d] = __c;
18817 __a[2 + __d] = __c;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018818#endif
18819 return __a;
18820}
18821
18822static __inline__ vector float __ATTRS_o_ai
18823vec_splati_ins(vector float __a, const unsigned int __b, const float __c) {
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018824 const unsigned int __d = __b & 0x01;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018825#ifdef __LITTLE_ENDIAN__
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018826 __a[1 - __d] = __c;
18827 __a[3 - __d] = __c;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018828#else
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080018829 __a[__d] = __c;
18830 __a[2 + __d] = __c;
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018831#endif
18832 return __a;
18833}
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018834
18835/* vec_test_lsbb_all_ones */
18836
18837static __inline__ int __ATTRS_o_ai
18838vec_test_lsbb_all_ones(vector unsigned char __a) {
18839 return __builtin_vsx_xvtlsbb(__a, 1);
18840}
18841
18842/* vec_test_lsbb_all_zeros */
18843
18844static __inline__ int __ATTRS_o_ai
18845vec_test_lsbb_all_zeros(vector unsigned char __a) {
18846 return __builtin_vsx_xvtlsbb(__a, 0);
18847}
Sasha Smundak0fc590b2020-10-07 08:11:59 -070018848#endif /* __VSX__ */
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018849
18850/* vec_stril */
18851
18852static __inline__ vector unsigned char __ATTRS_o_ai
18853vec_stril(vector unsigned char __a) {
18854#ifdef __LITTLE_ENDIAN__
18855 return __builtin_altivec_vstribr((vector signed char)__a);
18856#else
18857 return __builtin_altivec_vstribl((vector signed char)__a);
18858#endif
18859}
18860
18861static __inline__ vector signed char __ATTRS_o_ai
18862vec_stril(vector signed char __a) {
18863#ifdef __LITTLE_ENDIAN__
18864 return __builtin_altivec_vstribr(__a);
18865#else
18866 return __builtin_altivec_vstribl(__a);
18867#endif
18868}
18869
18870static __inline__ vector unsigned short __ATTRS_o_ai
18871vec_stril(vector unsigned short __a) {
18872#ifdef __LITTLE_ENDIAN__
18873 return __builtin_altivec_vstrihr((vector signed short)__a);
18874#else
18875 return __builtin_altivec_vstrihl((vector signed short)__a);
18876#endif
18877}
18878
18879static __inline__ vector signed short __ATTRS_o_ai
18880vec_stril(vector signed short __a) {
18881#ifdef __LITTLE_ENDIAN__
18882 return __builtin_altivec_vstrihr(__a);
18883#else
18884 return __builtin_altivec_vstrihl(__a);
18885#endif
18886}
18887
18888/* vec_stril_p */
18889
18890static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned char __a) {
18891#ifdef __LITTLE_ENDIAN__
18892 return __builtin_altivec_vstribr_p(__CR6_EQ, (vector signed char)__a);
18893#else
18894 return __builtin_altivec_vstribl_p(__CR6_EQ, (vector signed char)__a);
18895#endif
18896}
18897
18898static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed char __a) {
18899#ifdef __LITTLE_ENDIAN__
18900 return __builtin_altivec_vstribr_p(__CR6_EQ, __a);
18901#else
18902 return __builtin_altivec_vstribl_p(__CR6_EQ, __a);
18903#endif
18904}
18905
18906static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned short __a) {
18907#ifdef __LITTLE_ENDIAN__
18908 return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a);
18909#else
18910 return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a);
18911#endif
18912}
18913
18914static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed short __a) {
18915#ifdef __LITTLE_ENDIAN__
18916 return __builtin_altivec_vstrihr_p(__CR6_EQ, __a);
18917#else
18918 return __builtin_altivec_vstrihl_p(__CR6_EQ, __a);
18919#endif
18920}
18921
18922/* vec_strir */
18923
18924static __inline__ vector unsigned char __ATTRS_o_ai
18925vec_strir(vector unsigned char __a) {
18926#ifdef __LITTLE_ENDIAN__
18927 return __builtin_altivec_vstribl((vector signed char)__a);
18928#else
18929 return __builtin_altivec_vstribr((vector signed char)__a);
18930#endif
18931}
18932
18933static __inline__ vector signed char __ATTRS_o_ai
18934vec_strir(vector signed char __a) {
18935#ifdef __LITTLE_ENDIAN__
18936 return __builtin_altivec_vstribl(__a);
18937#else
18938 return __builtin_altivec_vstribr(__a);
18939#endif
18940}
18941
18942static __inline__ vector unsigned short __ATTRS_o_ai
18943vec_strir(vector unsigned short __a) {
18944#ifdef __LITTLE_ENDIAN__
18945 return __builtin_altivec_vstrihl((vector signed short)__a);
18946#else
18947 return __builtin_altivec_vstrihr((vector signed short)__a);
18948#endif
18949}
18950
18951static __inline__ vector signed short __ATTRS_o_ai
18952vec_strir(vector signed short __a) {
18953#ifdef __LITTLE_ENDIAN__
18954 return __builtin_altivec_vstrihl(__a);
18955#else
18956 return __builtin_altivec_vstrihr(__a);
18957#endif
18958}
18959
18960/* vec_strir_p */
18961
18962static __inline__ int __ATTRS_o_ai vec_strir_p(vector unsigned char __a) {
18963#ifdef __LITTLE_ENDIAN__
18964 return __builtin_altivec_vstribl_p(__CR6_EQ, (vector signed char)__a);
18965#else
18966 return __builtin_altivec_vstribr_p(__CR6_EQ, (vector signed char)__a);
18967#endif
18968}
18969
18970static __inline__ int __ATTRS_o_ai vec_strir_p(vector signed char __a) {
18971#ifdef __LITTLE_ENDIAN__
18972 return __builtin_altivec_vstribl_p(__CR6_EQ, __a);
18973#else
18974 return __builtin_altivec_vstribr_p(__CR6_EQ, __a);
18975#endif
18976}
18977
18978static __inline__ int __ATTRS_o_ai vec_strir_p(vector unsigned short __a) {
18979#ifdef __LITTLE_ENDIAN__
18980 return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a);
18981#else
18982 return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a);
18983#endif
18984}
18985
18986static __inline__ int __ATTRS_o_ai vec_strir_p(vector signed short __a) {
18987#ifdef __LITTLE_ENDIAN__
18988 return __builtin_altivec_vstrihl_p(__CR6_EQ, __a);
18989#else
18990 return __builtin_altivec_vstrihr_p(__CR6_EQ, __a);
18991#endif
18992}
18993
18994/* vs[l | r | ra] */
18995
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070018996#ifdef __SIZEOF_INT128__
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080018997static __inline__ vector unsigned __int128 __ATTRS_o_ai
18998vec_sl(vector unsigned __int128 __a, vector unsigned __int128 __b) {
18999 return __a << (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
19000 __CHAR_BIT__));
19001}
19002
19003static __inline__ vector signed __int128 __ATTRS_o_ai
19004vec_sl(vector signed __int128 __a, vector unsigned __int128 __b) {
19005 return __a << (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
19006 __CHAR_BIT__));
19007}
19008
19009static __inline__ vector unsigned __int128 __ATTRS_o_ai
19010vec_sr(vector unsigned __int128 __a, vector unsigned __int128 __b) {
19011 return __a >> (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
19012 __CHAR_BIT__));
19013}
19014
19015static __inline__ vector signed __int128 __ATTRS_o_ai
19016vec_sr(vector signed __int128 __a, vector unsigned __int128 __b) {
19017 return (
19018 vector signed __int128)(((vector unsigned __int128)__a) >>
19019 (__b %
19020 (vector unsigned __int128)(sizeof(
19021 unsigned __int128) *
19022 __CHAR_BIT__)));
19023}
19024
19025static __inline__ vector unsigned __int128 __ATTRS_o_ai
19026vec_sra(vector unsigned __int128 __a, vector unsigned __int128 __b) {
19027 return (
19028 vector unsigned __int128)(((vector signed __int128)__a) >>
19029 (__b %
19030 (vector unsigned __int128)(sizeof(
19031 unsigned __int128) *
19032 __CHAR_BIT__)));
19033}
19034
19035static __inline__ vector signed __int128 __ATTRS_o_ai
19036vec_sra(vector signed __int128 __a, vector unsigned __int128 __b) {
19037 return __a >> (__b % (vector unsigned __int128)(sizeof(unsigned __int128) *
19038 __CHAR_BIT__));
19039}
19040
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -070019041#endif /* __SIZEOF_INT128__ */
Sasha Smundak0fc590b2020-10-07 08:11:59 -070019042#endif /* __POWER10_VECTOR__ */
19043
Pirama Arumuga Nainarec8c89d2022-02-23 09:26:16 -080019044#ifdef __POWER8_VECTOR__
19045#define __bcdadd(__a, __b, __ps) __builtin_ppc_bcdadd((__a), (__b), (__ps))
19046#define __bcdsub(__a, __b, __ps) __builtin_ppc_bcdsub((__a), (__b), (__ps))
19047
19048static __inline__ long __bcdadd_ofl(vector unsigned char __a,
19049 vector unsigned char __b) {
19050 return __builtin_ppc_bcdadd_p(__CR6_SO, __a, __b);
19051}
19052
19053static __inline__ long __bcdsub_ofl(vector unsigned char __a,
19054 vector unsigned char __b) {
19055 return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __b);
19056}
19057
19058static __inline__ long __bcd_invalid(vector unsigned char __a) {
19059 return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __a);
19060}
19061
19062static __inline__ long __bcdcmpeq(vector unsigned char __a,
19063 vector unsigned char __b) {
19064 return __builtin_ppc_bcdsub_p(__CR6_EQ, __a, __b);
19065}
19066
19067static __inline__ long __bcdcmplt(vector unsigned char __a,
19068 vector unsigned char __b) {
19069 return __builtin_ppc_bcdsub_p(__CR6_LT, __a, __b);
19070}
19071
19072static __inline__ long __bcdcmpgt(vector unsigned char __a,
19073 vector unsigned char __b) {
19074 return __builtin_ppc_bcdsub_p(__CR6_GT, __a, __b);
19075}
19076
19077static __inline__ long __bcdcmple(vector unsigned char __a,
19078 vector unsigned char __b) {
19079 return __builtin_ppc_bcdsub_p(__CR6_GT_REV, __a, __b);
19080}
19081
19082static __inline__ long __bcdcmpge(vector unsigned char __a,
19083 vector unsigned char __b) {
19084 return __builtin_ppc_bcdsub_p(__CR6_LT_REV, __a, __b);
19085}
19086
19087#endif // __POWER8_VECTOR__
19088
Logan Chien2833ffb2018-10-09 10:03:24 +080019089#undef __ATTRS_o_ai
19090
19091#endif /* __ALTIVEC_H */