clang 19.0.0git
altivec.h
Go to the documentation of this file.
1/*===---- altivec.h - Standard header for type generic math ---------------===*\
2 *
3 * 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
6 *
7\*===----------------------------------------------------------------------===*/
8
9#ifndef __ALTIVEC_H
10#define __ALTIVEC_H
11
12#ifndef __ALTIVEC__
13#error "AltiVec support not enabled"
14#endif
15
16/* Constants for mapping CR6 bits to predicate result. */
17
18#define __CR6_EQ 0
19#define __CR6_EQ_REV 1
20#define __CR6_LT 2
21#define __CR6_LT_REV 3
22#define __CR6_GT 4
23#define __CR6_GT_REV 5
24#define __CR6_SO 6
25#define __CR6_SO_REV 7
26
27/* 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
46#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
47
48#include <stddef.h>
49
50static __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
131#ifdef __POWER8_VECTOR__
132static __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
148#ifdef __VSX__
149static __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
177/* 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
197/* 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
289#ifdef __POWER8_VECTOR__
290static __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
300#ifdef __SIZEOF_INT128__
301static __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}
310#endif
311
312static __inline__ vector unsigned char __attribute__((__always_inline__))
313vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
314 return (vector unsigned char)__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) {
319#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
324 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);
328 __carry = (vector unsigned int)__builtin_shufflevector(
329 (vector unsigned char)__carry, (vector unsigned char)__carry, 0, 0, 0, 7,
330 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0);
331 return (vector signed long long)(__res + __carry);
332#endif
333}
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}
340#endif // __POWER8_VECTOR__
341
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
356#ifdef __POWER8_VECTOR__
357#ifdef __SIZEOF_INT128__
358static __inline__ vector signed __int128 __ATTRS_o_ai
359vec_adde(vector signed __int128 __a, vector signed __int128 __b,
360 vector signed __int128 __c) {
361 return (vector signed __int128)__builtin_altivec_vaddeuqm(
362 (vector unsigned __int128)__a, (vector unsigned __int128)__b,
363 (vector unsigned __int128)__c);
364}
365
366static __inline__ vector unsigned __int128 __ATTRS_o_ai
367vec_adde(vector unsigned __int128 __a, vector unsigned __int128 __b,
368 vector unsigned __int128 __c) {
369 return __builtin_altivec_vaddeuqm(__a, __b, __c);
370}
371#endif
372
373static __inline__ vector unsigned char __attribute__((__always_inline__))
374vec_adde_u128(vector unsigned char __a, vector unsigned char __b,
375 vector unsigned char __c) {
376 return (vector unsigned char)__builtin_altivec_vaddeuqm_c(
377 (vector unsigned char)__a, (vector unsigned char)__b,
378 (vector unsigned char)__c);
379}
380#endif
381
382static __inline__ vector signed int __ATTRS_o_ai
383vec_adde(vector signed int __a, vector signed int __b,
384 vector signed int __c) {
385 vector signed int __mask = {1, 1, 1, 1};
386 vector signed int __carry = __c & __mask;
387 return vec_add(vec_add(__a, __b), __carry);
388}
389
390static __inline__ vector unsigned int __ATTRS_o_ai
391vec_adde(vector unsigned int __a, vector unsigned int __b,
392 vector unsigned int __c) {
393 vector unsigned int __mask = {1, 1, 1, 1};
394 vector unsigned int __carry = __c & __mask;
395 return vec_add(vec_add(__a, __b), __carry);
396}
397
398/* vec_addec */
399
400#ifdef __POWER8_VECTOR__
401#ifdef __SIZEOF_INT128__
402static __inline__ vector signed __int128 __ATTRS_o_ai
403vec_addec(vector signed __int128 __a, vector signed __int128 __b,
404 vector signed __int128 __c) {
405 return (vector signed __int128)__builtin_altivec_vaddecuq(
406 (vector unsigned __int128)__a, (vector unsigned __int128)__b,
407 (vector unsigned __int128)__c);
408}
409
410static __inline__ vector unsigned __int128 __ATTRS_o_ai
411vec_addec(vector unsigned __int128 __a, vector unsigned __int128 __b,
412 vector unsigned __int128 __c) {
413 return __builtin_altivec_vaddecuq(__a, __b, __c);
414}
415#endif
416
417static __inline__ vector unsigned char __attribute__((__always_inline__))
418vec_addec_u128(vector unsigned char __a, vector unsigned char __b,
419 vector unsigned char __c) {
420 return (vector unsigned char)__builtin_altivec_vaddecuq_c(
421 (vector unsigned char)__a, (vector unsigned char)__b,
422 (vector unsigned char)__c);
423}
424
425#ifdef __powerpc64__
426static __inline__ vector signed int __ATTRS_o_ai
427vec_addec(vector signed int __a, vector signed int __b,
428 vector signed int __c) {
429
430 signed int __result[4];
431 for (int i = 0; i < 4; i++) {
432 unsigned int __tempa = (unsigned int) __a[i];
433 unsigned int __tempb = (unsigned int) __b[i];
434 unsigned int __tempc = (unsigned int) __c[i];
435 __tempc = __tempc & 0x00000001;
436 unsigned long long __longa = (unsigned long long) __tempa;
437 unsigned long long __longb = (unsigned long long) __tempb;
438 unsigned long long __longc = (unsigned long long) __tempc;
439 unsigned long long __sum = __longa + __longb + __longc;
440 unsigned long long __res = (__sum >> 32) & 0x01;
441 unsigned long long __tempres = (unsigned int) __res;
442 __result[i] = (signed int) __tempres;
443 }
444
445 vector signed int ret = { __result[0], __result[1], __result[2], __result[3] };
446 return ret;
447}
448
449static __inline__ vector unsigned int __ATTRS_o_ai
450vec_addec(vector unsigned int __a, vector unsigned int __b,
451 vector unsigned int __c) {
452
453 unsigned int __result[4];
454 for (int i = 0; i < 4; i++) {
455 unsigned int __tempc = __c[i] & 1;
456 unsigned long long __longa = (unsigned long long) __a[i];
457 unsigned long long __longb = (unsigned long long) __b[i];
458 unsigned long long __longc = (unsigned long long) __tempc;
459 unsigned long long __sum = __longa + __longb + __longc;
460 unsigned long long __res = (__sum >> 32) & 0x01;
461 unsigned long long __tempres = (unsigned int) __res;
462 __result[i] = (signed int) __tempres;
463 }
464
465 vector unsigned int ret = { __result[0], __result[1], __result[2], __result[3] };
466 return ret;
467}
468#endif // __powerpc64__
469#endif // __POWER8_VECTOR__
470
471/* vec_vaddubm */
472
473#define __builtin_altivec_vaddubm vec_vaddubm
474
475static __inline__ vector signed char __ATTRS_o_ai
476vec_vaddubm(vector signed char __a, vector signed char __b) {
477 return __a + __b;
478}
479
480static __inline__ vector signed char __ATTRS_o_ai
481vec_vaddubm(vector bool char __a, vector signed char __b) {
482 return (vector signed char)__a + __b;
483}
484
485static __inline__ vector signed char __ATTRS_o_ai
486vec_vaddubm(vector signed char __a, vector bool char __b) {
487 return __a + (vector signed char)__b;
488}
489
490static __inline__ vector unsigned char __ATTRS_o_ai
491vec_vaddubm(vector unsigned char __a, vector unsigned char __b) {
492 return __a + __b;
493}
494
495static __inline__ vector unsigned char __ATTRS_o_ai
496vec_vaddubm(vector bool char __a, vector unsigned char __b) {
497 return (vector unsigned char)__a + __b;
498}
499
500static __inline__ vector unsigned char __ATTRS_o_ai
501vec_vaddubm(vector unsigned char __a, vector bool char __b) {
502 return __a + (vector unsigned char)__b;
503}
504
505/* vec_vadduhm */
506
507#define __builtin_altivec_vadduhm vec_vadduhm
508
509static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
510 vector short __b) {
511 return __a + __b;
512}
513
514static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector bool short __a,
515 vector short __b) {
516 return (vector short)__a + __b;
517}
518
519static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
520 vector bool short __b) {
521 return __a + (vector short)__b;
522}
523
524static __inline__ vector unsigned short __ATTRS_o_ai
525vec_vadduhm(vector unsigned short __a, vector unsigned short __b) {
526 return __a + __b;
527}
528
529static __inline__ vector unsigned short __ATTRS_o_ai
530vec_vadduhm(vector bool short __a, vector unsigned short __b) {
531 return (vector unsigned short)__a + __b;
532}
533
534static __inline__ vector unsigned short __ATTRS_o_ai
535vec_vadduhm(vector unsigned short __a, vector bool short __b) {
536 return __a + (vector unsigned short)__b;
537}
538
539/* vec_vadduwm */
540
541#define __builtin_altivec_vadduwm vec_vadduwm
542
543static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
544 vector int __b) {
545 return __a + __b;
546}
547
548static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector bool int __a,
549 vector int __b) {
550 return (vector int)__a + __b;
551}
552
553static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
554 vector bool int __b) {
555 return __a + (vector int)__b;
556}
557
558static __inline__ vector unsigned int __ATTRS_o_ai
559vec_vadduwm(vector unsigned int __a, vector unsigned int __b) {
560 return __a + __b;
561}
562
563static __inline__ vector unsigned int __ATTRS_o_ai
564vec_vadduwm(vector bool int __a, vector unsigned int __b) {
565 return (vector unsigned int)__a + __b;
566}
567
568static __inline__ vector unsigned int __ATTRS_o_ai
569vec_vadduwm(vector unsigned int __a, vector bool int __b) {
570 return __a + (vector unsigned int)__b;
571}
572
573/* vec_vaddfp */
574
575#define __builtin_altivec_vaddfp vec_vaddfp
576
577static __inline__ vector float __attribute__((__always_inline__))
578vec_vaddfp(vector float __a, vector float __b) {
579 return __a + __b;
580}
581
582/* vec_addc */
583
584static __inline__ vector signed int __ATTRS_o_ai
585vec_addc(vector signed int __a, vector signed int __b) {
586 return (vector signed int)__builtin_altivec_vaddcuw((vector unsigned int)__a,
587 (vector unsigned int)__b);
588}
589
590static __inline__ vector unsigned int __ATTRS_o_ai
591vec_addc(vector unsigned int __a, vector unsigned int __b) {
592 return __builtin_altivec_vaddcuw(__a, __b);
593}
594
595#ifdef __POWER8_VECTOR__
596#ifdef __SIZEOF_INT128__
597static __inline__ vector signed __int128 __ATTRS_o_ai
598vec_addc(vector signed __int128 __a, vector signed __int128 __b) {
599 return (vector signed __int128)__builtin_altivec_vaddcuq(
600 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
601}
602
603static __inline__ vector unsigned __int128 __ATTRS_o_ai
604vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
605 return __builtin_altivec_vaddcuq(__a, __b);
606}
607#endif
608
609static __inline__ vector unsigned char __attribute__((__always_inline__))
610vec_addc_u128(vector unsigned char __a, vector unsigned char __b) {
611 return (vector unsigned char)__builtin_altivec_vaddcuq_c(
612 (vector unsigned char)__a, (vector unsigned char)__b);
613}
614#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
615
616/* vec_vaddcuw */
617
618static __inline__ vector unsigned int __attribute__((__always_inline__))
619vec_vaddcuw(vector unsigned int __a, vector unsigned int __b) {
620 return __builtin_altivec_vaddcuw(__a, __b);
621}
622
623/* vec_adds */
624
625static __inline__ vector signed char __ATTRS_o_ai
626vec_adds(vector signed char __a, vector signed char __b) {
627 return __builtin_altivec_vaddsbs(__a, __b);
628}
629
630static __inline__ vector signed char __ATTRS_o_ai
631vec_adds(vector bool char __a, vector signed char __b) {
632 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
633}
634
635static __inline__ vector signed char __ATTRS_o_ai
636vec_adds(vector signed char __a, vector bool char __b) {
637 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
638}
639
640static __inline__ vector unsigned char __ATTRS_o_ai
641vec_adds(vector unsigned char __a, vector unsigned char __b) {
642 return __builtin_altivec_vaddubs(__a, __b);
643}
644
645static __inline__ vector unsigned char __ATTRS_o_ai
646vec_adds(vector bool char __a, vector unsigned char __b) {
647 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
648}
649
650static __inline__ vector unsigned char __ATTRS_o_ai
651vec_adds(vector unsigned char __a, vector bool char __b) {
652 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
653}
654
655static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
656 vector short __b) {
657 return __builtin_altivec_vaddshs(__a, __b);
658}
659
660static __inline__ vector short __ATTRS_o_ai vec_adds(vector bool short __a,
661 vector short __b) {
662 return __builtin_altivec_vaddshs((vector short)__a, __b);
663}
664
665static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
666 vector bool short __b) {
667 return __builtin_altivec_vaddshs(__a, (vector short)__b);
668}
669
670static __inline__ vector unsigned short __ATTRS_o_ai
671vec_adds(vector unsigned short __a, vector unsigned short __b) {
672 return __builtin_altivec_vadduhs(__a, __b);
673}
674
675static __inline__ vector unsigned short __ATTRS_o_ai
676vec_adds(vector bool short __a, vector unsigned short __b) {
677 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
678}
679
680static __inline__ vector unsigned short __ATTRS_o_ai
681vec_adds(vector unsigned short __a, vector bool short __b) {
682 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
683}
684
685static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
686 vector int __b) {
687 return __builtin_altivec_vaddsws(__a, __b);
688}
689
690static __inline__ vector int __ATTRS_o_ai vec_adds(vector bool int __a,
691 vector int __b) {
692 return __builtin_altivec_vaddsws((vector int)__a, __b);
693}
694
695static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
696 vector bool int __b) {
697 return __builtin_altivec_vaddsws(__a, (vector int)__b);
698}
699
700static __inline__ vector unsigned int __ATTRS_o_ai
701vec_adds(vector unsigned int __a, vector unsigned int __b) {
702 return __builtin_altivec_vadduws(__a, __b);
703}
704
705static __inline__ vector unsigned int __ATTRS_o_ai
706vec_adds(vector bool int __a, vector unsigned int __b) {
707 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
708}
709
710static __inline__ vector unsigned int __ATTRS_o_ai
711vec_adds(vector unsigned int __a, vector bool int __b) {
712 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
713}
714
715/* vec_vaddsbs */
716
717static __inline__ vector signed char __ATTRS_o_ai
718vec_vaddsbs(vector signed char __a, vector signed char __b) {
719 return __builtin_altivec_vaddsbs(__a, __b);
720}
721
722static __inline__ vector signed char __ATTRS_o_ai
723vec_vaddsbs(vector bool char __a, vector signed char __b) {
724 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
725}
726
727static __inline__ vector signed char __ATTRS_o_ai
728vec_vaddsbs(vector signed char __a, vector bool char __b) {
729 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
730}
731
732/* vec_vaddubs */
733
734static __inline__ vector unsigned char __ATTRS_o_ai
735vec_vaddubs(vector unsigned char __a, vector unsigned char __b) {
736 return __builtin_altivec_vaddubs(__a, __b);
737}
738
739static __inline__ vector unsigned char __ATTRS_o_ai
740vec_vaddubs(vector bool char __a, vector unsigned char __b) {
741 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
742}
743
744static __inline__ vector unsigned char __ATTRS_o_ai
745vec_vaddubs(vector unsigned char __a, vector bool char __b) {
746 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
747}
748
749/* vec_vaddshs */
750
751static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
752 vector short __b) {
753 return __builtin_altivec_vaddshs(__a, __b);
754}
755
756static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector bool short __a,
757 vector short __b) {
758 return __builtin_altivec_vaddshs((vector short)__a, __b);
759}
760
761static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
762 vector bool short __b) {
763 return __builtin_altivec_vaddshs(__a, (vector short)__b);
764}
765
766/* vec_vadduhs */
767
768static __inline__ vector unsigned short __ATTRS_o_ai
769vec_vadduhs(vector unsigned short __a, vector unsigned short __b) {
770 return __builtin_altivec_vadduhs(__a, __b);
771}
772
773static __inline__ vector unsigned short __ATTRS_o_ai
774vec_vadduhs(vector bool short __a, vector unsigned short __b) {
775 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
776}
777
778static __inline__ vector unsigned short __ATTRS_o_ai
779vec_vadduhs(vector unsigned short __a, vector bool short __b) {
780 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
781}
782
783/* vec_vaddsws */
784
785static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
786 vector int __b) {
787 return __builtin_altivec_vaddsws(__a, __b);
788}
789
790static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector bool int __a,
791 vector int __b) {
792 return __builtin_altivec_vaddsws((vector int)__a, __b);
793}
794
795static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
796 vector bool int __b) {
797 return __builtin_altivec_vaddsws(__a, (vector int)__b);
798}
799
800/* vec_vadduws */
801
802static __inline__ vector unsigned int __ATTRS_o_ai
803vec_vadduws(vector unsigned int __a, vector unsigned int __b) {
804 return __builtin_altivec_vadduws(__a, __b);
805}
806
807static __inline__ vector unsigned int __ATTRS_o_ai
808vec_vadduws(vector bool int __a, vector unsigned int __b) {
809 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
810}
811
812static __inline__ vector unsigned int __ATTRS_o_ai
813vec_vadduws(vector unsigned int __a, vector bool int __b) {
814 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
815}
816
817#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
818 defined(__SIZEOF_INT128__)
819/* vec_vadduqm */
820
821static __inline__ vector signed __int128 __ATTRS_o_ai
822vec_vadduqm(vector signed __int128 __a, vector signed __int128 __b) {
823 return __a + __b;
824}
825
826static __inline__ vector unsigned __int128 __ATTRS_o_ai
827vec_vadduqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
828 return __a + __b;
829}
830
831/* vec_vaddeuqm */
832
833static __inline__ vector signed __int128 __ATTRS_o_ai
834vec_vaddeuqm(vector signed __int128 __a, vector signed __int128 __b,
835 vector signed __int128 __c) {
836 return (vector signed __int128)__builtin_altivec_vaddeuqm(
837 (vector unsigned __int128)__a, (vector unsigned __int128)__b,
838 (vector unsigned __int128)__c);
839}
840
841static __inline__ vector unsigned __int128 __ATTRS_o_ai
842vec_vaddeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
843 vector unsigned __int128 __c) {
844 return __builtin_altivec_vaddeuqm(__a, __b, __c);
845}
846
847/* vec_vaddcuq */
848
849static __inline__ vector signed __int128 __ATTRS_o_ai
850vec_vaddcuq(vector signed __int128 __a, vector signed __int128 __b) {
851 return (vector signed __int128)__builtin_altivec_vaddcuq(
852 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
853}
854
855static __inline__ vector unsigned __int128 __ATTRS_o_ai
856vec_vaddcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
857 return __builtin_altivec_vaddcuq(__a, __b);
858}
859
860/* vec_vaddecuq */
861
862static __inline__ vector signed __int128 __ATTRS_o_ai
863vec_vaddecuq(vector signed __int128 __a, vector signed __int128 __b,
864 vector signed __int128 __c) {
865 return (vector signed __int128)__builtin_altivec_vaddecuq(
866 (vector unsigned __int128)__a, (vector unsigned __int128)__b,
867 (vector unsigned __int128)__c);
868}
869
870static __inline__ vector unsigned __int128 __ATTRS_o_ai
871vec_vaddecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
872 vector unsigned __int128 __c) {
873 return __builtin_altivec_vaddecuq(__a, __b, __c);
874}
875#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
876
877/* vec_and */
878
879#define __builtin_altivec_vand vec_and
880
881static __inline__ vector signed char __ATTRS_o_ai
882vec_and(vector signed char __a, vector signed char __b) {
883 return __a & __b;
884}
885
886static __inline__ vector signed char __ATTRS_o_ai
887vec_and(vector bool char __a, vector signed char __b) {
888 return (vector signed char)__a & __b;
889}
890
891static __inline__ vector signed char __ATTRS_o_ai
892vec_and(vector signed char __a, vector bool char __b) {
893 return __a & (vector signed char)__b;
894}
895
896static __inline__ vector unsigned char __ATTRS_o_ai
897vec_and(vector unsigned char __a, vector unsigned char __b) {
898 return __a & __b;
899}
900
901static __inline__ vector unsigned char __ATTRS_o_ai
902vec_and(vector bool char __a, vector unsigned char __b) {
903 return (vector unsigned char)__a & __b;
904}
905
906static __inline__ vector unsigned char __ATTRS_o_ai
907vec_and(vector unsigned char __a, vector bool char __b) {
908 return __a & (vector unsigned char)__b;
909}
910
911static __inline__ vector bool char __ATTRS_o_ai vec_and(vector bool char __a,
912 vector bool char __b) {
913 return __a & __b;
914}
915
916static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
917 vector short __b) {
918 return __a & __b;
919}
920
921static __inline__ vector short __ATTRS_o_ai vec_and(vector bool short __a,
922 vector short __b) {
923 return (vector short)__a & __b;
924}
925
926static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
927 vector bool short __b) {
928 return __a & (vector short)__b;
929}
930
931static __inline__ vector unsigned short __ATTRS_o_ai
932vec_and(vector unsigned short __a, vector unsigned short __b) {
933 return __a & __b;
934}
935
936static __inline__ vector unsigned short __ATTRS_o_ai
937vec_and(vector bool short __a, vector unsigned short __b) {
938 return (vector unsigned short)__a & __b;
939}
940
941static __inline__ vector unsigned short __ATTRS_o_ai
942vec_and(vector unsigned short __a, vector bool short __b) {
943 return __a & (vector unsigned short)__b;
944}
945
946static __inline__ vector bool short __ATTRS_o_ai
947vec_and(vector bool short __a, vector bool short __b) {
948 return __a & __b;
949}
950
951static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
952 vector int __b) {
953 return __a & __b;
954}
955
956static __inline__ vector int __ATTRS_o_ai vec_and(vector bool int __a,
957 vector int __b) {
958 return (vector int)__a & __b;
959}
960
961static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
962 vector bool int __b) {
963 return __a & (vector int)__b;
964}
965
966static __inline__ vector unsigned int __ATTRS_o_ai
967vec_and(vector unsigned int __a, vector unsigned int __b) {
968 return __a & __b;
969}
970
971static __inline__ vector unsigned int __ATTRS_o_ai
972vec_and(vector bool int __a, vector unsigned int __b) {
973 return (vector unsigned int)__a & __b;
974}
975
976static __inline__ vector unsigned int __ATTRS_o_ai
977vec_and(vector unsigned int __a, vector bool int __b) {
978 return __a & (vector unsigned int)__b;
979}
980
981static __inline__ vector bool int __ATTRS_o_ai vec_and(vector bool int __a,
982 vector bool int __b) {
983 return __a & __b;
984}
985
986static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
987 vector float __b) {
988 vector unsigned int __res =
989 (vector unsigned int)__a & (vector unsigned int)__b;
990 return (vector float)__res;
991}
992
993static __inline__ vector float __ATTRS_o_ai vec_and(vector bool int __a,
994 vector float __b) {
995 vector unsigned int __res =
996 (vector unsigned int)__a & (vector unsigned int)__b;
997 return (vector float)__res;
998}
999
1000static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
1001 vector bool int __b) {
1002 vector unsigned int __res =
1003 (vector unsigned int)__a & (vector unsigned int)__b;
1004 return (vector float)__res;
1005}
1006
1007#ifdef __VSX__
1008static __inline__ vector double __ATTRS_o_ai vec_and(vector bool long long __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 double __ATTRS_o_ai
1016vec_and(vector double __a, vector bool long long __b) {
1017 vector unsigned long long __res =
1018 (vector unsigned long long)__a & (vector unsigned long long)__b;
1019 return (vector double)__res;
1020}
1021
1022static __inline__ vector double __ATTRS_o_ai vec_and(vector double __a,
1023 vector double __b) {
1024 vector unsigned long long __res =
1025 (vector unsigned long long)__a & (vector unsigned long long)__b;
1026 return (vector double)__res;
1027}
1028
1029static __inline__ vector signed long long __ATTRS_o_ai
1030vec_and(vector signed long long __a, vector signed long long __b) {
1031 return __a & __b;
1032}
1033
1034static __inline__ vector signed long long __ATTRS_o_ai
1035vec_and(vector bool long long __a, vector signed long long __b) {
1036 return (vector signed long long)__a & __b;
1037}
1038
1039static __inline__ vector signed long long __ATTRS_o_ai
1040vec_and(vector signed long long __a, vector bool long long __b) {
1041 return __a & (vector signed long long)__b;
1042}
1043
1044static __inline__ vector unsigned long long __ATTRS_o_ai
1045vec_and(vector unsigned long long __a, vector unsigned long long __b) {
1046 return __a & __b;
1047}
1048
1049static __inline__ vector unsigned long long __ATTRS_o_ai
1050vec_and(vector bool long long __a, vector unsigned long long __b) {
1051 return (vector unsigned long long)__a & __b;
1052}
1053
1054static __inline__ vector unsigned long long __ATTRS_o_ai
1055vec_and(vector unsigned long long __a, vector bool long long __b) {
1056 return __a & (vector unsigned long long)__b;
1057}
1058
1059static __inline__ vector bool long long __ATTRS_o_ai
1060vec_and(vector bool long long __a, vector bool long long __b) {
1061 return __a & __b;
1062}
1063#endif
1064
1065/* vec_vand */
1066
1067static __inline__ vector signed char __ATTRS_o_ai
1068vec_vand(vector signed char __a, vector signed char __b) {
1069 return __a & __b;
1070}
1071
1072static __inline__ vector signed char __ATTRS_o_ai
1073vec_vand(vector bool char __a, vector signed char __b) {
1074 return (vector signed char)__a & __b;
1075}
1076
1077static __inline__ vector signed char __ATTRS_o_ai
1078vec_vand(vector signed char __a, vector bool char __b) {
1079 return __a & (vector signed char)__b;
1080}
1081
1082static __inline__ vector unsigned char __ATTRS_o_ai
1083vec_vand(vector unsigned char __a, vector unsigned char __b) {
1084 return __a & __b;
1085}
1086
1087static __inline__ vector unsigned char __ATTRS_o_ai
1088vec_vand(vector bool char __a, vector unsigned char __b) {
1089 return (vector unsigned char)__a & __b;
1090}
1091
1092static __inline__ vector unsigned char __ATTRS_o_ai
1093vec_vand(vector unsigned char __a, vector bool char __b) {
1094 return __a & (vector unsigned char)__b;
1095}
1096
1097static __inline__ vector bool char __ATTRS_o_ai vec_vand(vector bool char __a,
1098 vector bool char __b) {
1099 return __a & __b;
1100}
1101
1102static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
1103 vector short __b) {
1104 return __a & __b;
1105}
1106
1107static __inline__ vector short __ATTRS_o_ai vec_vand(vector bool short __a,
1108 vector short __b) {
1109 return (vector short)__a & __b;
1110}
1111
1112static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
1113 vector bool short __b) {
1114 return __a & (vector short)__b;
1115}
1116
1117static __inline__ vector unsigned short __ATTRS_o_ai
1118vec_vand(vector unsigned short __a, vector unsigned short __b) {
1119 return __a & __b;
1120}
1121
1122static __inline__ vector unsigned short __ATTRS_o_ai
1123vec_vand(vector bool short __a, vector unsigned short __b) {
1124 return (vector unsigned short)__a & __b;
1125}
1126
1127static __inline__ vector unsigned short __ATTRS_o_ai
1128vec_vand(vector unsigned short __a, vector bool short __b) {
1129 return __a & (vector unsigned short)__b;
1130}
1131
1132static __inline__ vector bool short __ATTRS_o_ai
1133vec_vand(vector bool short __a, vector bool short __b) {
1134 return __a & __b;
1135}
1136
1137static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
1138 vector int __b) {
1139 return __a & __b;
1140}
1141
1142static __inline__ vector int __ATTRS_o_ai vec_vand(vector bool int __a,
1143 vector int __b) {
1144 return (vector int)__a & __b;
1145}
1146
1147static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
1148 vector bool int __b) {
1149 return __a & (vector int)__b;
1150}
1151
1152static __inline__ vector unsigned int __ATTRS_o_ai
1153vec_vand(vector unsigned int __a, vector unsigned int __b) {
1154 return __a & __b;
1155}
1156
1157static __inline__ vector unsigned int __ATTRS_o_ai
1158vec_vand(vector bool int __a, vector unsigned int __b) {
1159 return (vector unsigned int)__a & __b;
1160}
1161
1162static __inline__ vector unsigned int __ATTRS_o_ai
1163vec_vand(vector unsigned int __a, vector bool int __b) {
1164 return __a & (vector unsigned int)__b;
1165}
1166
1167static __inline__ vector bool int __ATTRS_o_ai vec_vand(vector bool int __a,
1168 vector bool int __b) {
1169 return __a & __b;
1170}
1171
1172static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1173 vector float __b) {
1174 vector unsigned int __res =
1175 (vector unsigned int)__a & (vector unsigned int)__b;
1176 return (vector float)__res;
1177}
1178
1179static __inline__ vector float __ATTRS_o_ai vec_vand(vector bool int __a,
1180 vector float __b) {
1181 vector unsigned int __res =
1182 (vector unsigned int)__a & (vector unsigned int)__b;
1183 return (vector float)__res;
1184}
1185
1186static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1187 vector bool int __b) {
1188 vector unsigned int __res =
1189 (vector unsigned int)__a & (vector unsigned int)__b;
1190 return (vector float)__res;
1191}
1192
1193#ifdef __VSX__
1194static __inline__ vector signed long long __ATTRS_o_ai
1195vec_vand(vector signed long long __a, vector signed long long __b) {
1196 return __a & __b;
1197}
1198
1199static __inline__ vector signed long long __ATTRS_o_ai
1200vec_vand(vector bool long long __a, vector signed long long __b) {
1201 return (vector signed long long)__a & __b;
1202}
1203
1204static __inline__ vector signed long long __ATTRS_o_ai
1205vec_vand(vector signed long long __a, vector bool long long __b) {
1206 return __a & (vector signed long long)__b;
1207}
1208
1209static __inline__ vector unsigned long long __ATTRS_o_ai
1210vec_vand(vector unsigned long long __a, vector unsigned long long __b) {
1211 return __a & __b;
1212}
1213
1214static __inline__ vector unsigned long long __ATTRS_o_ai
1215vec_vand(vector bool long long __a, vector unsigned long long __b) {
1216 return (vector unsigned long long)__a & __b;
1217}
1218
1219static __inline__ vector unsigned long long __ATTRS_o_ai
1220vec_vand(vector unsigned long long __a, vector bool long long __b) {
1221 return __a & (vector unsigned long long)__b;
1222}
1223
1224static __inline__ vector bool long long __ATTRS_o_ai
1225vec_vand(vector bool long long __a, vector bool long long __b) {
1226 return __a & __b;
1227}
1228#endif
1229
1230/* vec_andc */
1231
1232#define __builtin_altivec_vandc vec_andc
1233
1234static __inline__ vector signed char __ATTRS_o_ai
1235vec_andc(vector signed char __a, vector signed char __b) {
1236 return __a & ~__b;
1237}
1238
1239static __inline__ vector signed char __ATTRS_o_ai
1240vec_andc(vector bool char __a, vector signed char __b) {
1241 return (vector signed char)__a & ~__b;
1242}
1243
1244static __inline__ vector signed char __ATTRS_o_ai
1245vec_andc(vector signed char __a, vector bool char __b) {
1246 return __a & ~(vector signed char)__b;
1247}
1248
1249static __inline__ vector unsigned char __ATTRS_o_ai
1250vec_andc(vector unsigned char __a, vector unsigned char __b) {
1251 return __a & ~__b;
1252}
1253
1254static __inline__ vector unsigned char __ATTRS_o_ai
1255vec_andc(vector bool char __a, vector unsigned char __b) {
1256 return (vector unsigned char)__a & ~__b;
1257}
1258
1259static __inline__ vector unsigned char __ATTRS_o_ai
1260vec_andc(vector unsigned char __a, vector bool char __b) {
1261 return __a & ~(vector unsigned char)__b;
1262}
1263
1264static __inline__ vector bool char __ATTRS_o_ai vec_andc(vector bool char __a,
1265 vector bool char __b) {
1266 return __a & ~__b;
1267}
1268
1269static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1270 vector short __b) {
1271 return __a & ~__b;
1272}
1273
1274static __inline__ vector short __ATTRS_o_ai vec_andc(vector bool short __a,
1275 vector short __b) {
1276 return (vector short)__a & ~__b;
1277}
1278
1279static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1280 vector bool short __b) {
1281 return __a & ~(vector short)__b;
1282}
1283
1284static __inline__ vector unsigned short __ATTRS_o_ai
1285vec_andc(vector unsigned short __a, vector unsigned short __b) {
1286 return __a & ~__b;
1287}
1288
1289static __inline__ vector unsigned short __ATTRS_o_ai
1290vec_andc(vector bool short __a, vector unsigned short __b) {
1291 return (vector unsigned short)__a & ~__b;
1292}
1293
1294static __inline__ vector unsigned short __ATTRS_o_ai
1295vec_andc(vector unsigned short __a, vector bool short __b) {
1296 return __a & ~(vector unsigned short)__b;
1297}
1298
1299static __inline__ vector bool short __ATTRS_o_ai
1300vec_andc(vector bool short __a, vector bool short __b) {
1301 return __a & ~__b;
1302}
1303
1304static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1305 vector int __b) {
1306 return __a & ~__b;
1307}
1308
1309static __inline__ vector int __ATTRS_o_ai vec_andc(vector bool int __a,
1310 vector int __b) {
1311 return (vector int)__a & ~__b;
1312}
1313
1314static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1315 vector bool int __b) {
1316 return __a & ~(vector int)__b;
1317}
1318
1319static __inline__ vector unsigned int __ATTRS_o_ai
1320vec_andc(vector unsigned int __a, vector unsigned int __b) {
1321 return __a & ~__b;
1322}
1323
1324static __inline__ vector unsigned int __ATTRS_o_ai
1325vec_andc(vector bool int __a, vector unsigned int __b) {
1326 return (vector unsigned int)__a & ~__b;
1327}
1328
1329static __inline__ vector unsigned int __ATTRS_o_ai
1330vec_andc(vector unsigned int __a, vector bool int __b) {
1331 return __a & ~(vector unsigned int)__b;
1332}
1333
1334static __inline__ vector bool int __ATTRS_o_ai vec_andc(vector bool int __a,
1335 vector bool int __b) {
1336 return __a & ~__b;
1337}
1338
1339static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1340 vector float __b) {
1341 vector unsigned int __res =
1342 (vector unsigned int)__a & ~(vector unsigned int)__b;
1343 return (vector float)__res;
1344}
1345
1346static __inline__ vector float __ATTRS_o_ai vec_andc(vector bool int __a,
1347 vector float __b) {
1348 vector unsigned int __res =
1349 (vector unsigned int)__a & ~(vector unsigned int)__b;
1350 return (vector float)__res;
1351}
1352
1353static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1354 vector bool int __b) {
1355 vector unsigned int __res =
1356 (vector unsigned int)__a & ~(vector unsigned int)__b;
1357 return (vector float)__res;
1358}
1359
1360#ifdef __VSX__
1361static __inline__ vector double __ATTRS_o_ai vec_andc(vector bool long long __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 double __ATTRS_o_ai
1369vec_andc(vector double __a, vector bool long long __b) {
1370 vector unsigned long long __res =
1371 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1372 return (vector double)__res;
1373}
1374
1375static __inline__ vector double __ATTRS_o_ai vec_andc(vector double __a,
1376 vector double __b) {
1377 vector unsigned long long __res =
1378 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1379 return (vector double)__res;
1380}
1381
1382static __inline__ vector signed long long __ATTRS_o_ai
1383vec_andc(vector signed long long __a, vector signed long long __b) {
1384 return __a & ~__b;
1385}
1386
1387static __inline__ vector signed long long __ATTRS_o_ai
1388vec_andc(vector bool long long __a, vector signed long long __b) {
1389 return (vector signed long long)__a & ~__b;
1390}
1391
1392static __inline__ vector signed long long __ATTRS_o_ai
1393vec_andc(vector signed long long __a, vector bool long long __b) {
1394 return __a & ~(vector signed long long)__b;
1395}
1396
1397static __inline__ vector unsigned long long __ATTRS_o_ai
1398vec_andc(vector unsigned long long __a, vector unsigned long long __b) {
1399 return __a & ~__b;
1400}
1401
1402static __inline__ vector unsigned long long __ATTRS_o_ai
1403vec_andc(vector bool long long __a, vector unsigned long long __b) {
1404 return (vector unsigned long long)__a & ~__b;
1405}
1406
1407static __inline__ vector unsigned long long __ATTRS_o_ai
1408vec_andc(vector unsigned long long __a, vector bool long long __b) {
1409 return __a & ~(vector unsigned long long)__b;
1410}
1411
1412static __inline__ vector bool long long __ATTRS_o_ai
1413vec_andc(vector bool long long __a, vector bool long long __b) {
1414 return __a & ~__b;
1415}
1416#endif
1417
1418/* vec_vandc */
1419
1420static __inline__ vector signed char __ATTRS_o_ai
1421vec_vandc(vector signed char __a, vector signed char __b) {
1422 return __a & ~__b;
1423}
1424
1425static __inline__ vector signed char __ATTRS_o_ai
1426vec_vandc(vector bool char __a, vector signed char __b) {
1427 return (vector signed char)__a & ~__b;
1428}
1429
1430static __inline__ vector signed char __ATTRS_o_ai
1431vec_vandc(vector signed char __a, vector bool char __b) {
1432 return __a & ~(vector signed char)__b;
1433}
1434
1435static __inline__ vector unsigned char __ATTRS_o_ai
1436vec_vandc(vector unsigned char __a, vector unsigned char __b) {
1437 return __a & ~__b;
1438}
1439
1440static __inline__ vector unsigned char __ATTRS_o_ai
1441vec_vandc(vector bool char __a, vector unsigned char __b) {
1442 return (vector unsigned char)__a & ~__b;
1443}
1444
1445static __inline__ vector unsigned char __ATTRS_o_ai
1446vec_vandc(vector unsigned char __a, vector bool char __b) {
1447 return __a & ~(vector unsigned char)__b;
1448}
1449
1450static __inline__ vector bool char __ATTRS_o_ai
1451vec_vandc(vector bool char __a, vector bool char __b) {
1452 return __a & ~__b;
1453}
1454
1455static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1456 vector short __b) {
1457 return __a & ~__b;
1458}
1459
1460static __inline__ vector short __ATTRS_o_ai vec_vandc(vector bool short __a,
1461 vector short __b) {
1462 return (vector short)__a & ~__b;
1463}
1464
1465static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1466 vector bool short __b) {
1467 return __a & ~(vector short)__b;
1468}
1469
1470static __inline__ vector unsigned short __ATTRS_o_ai
1471vec_vandc(vector unsigned short __a, vector unsigned short __b) {
1472 return __a & ~__b;
1473}
1474
1475static __inline__ vector unsigned short __ATTRS_o_ai
1476vec_vandc(vector bool short __a, vector unsigned short __b) {
1477 return (vector unsigned short)__a & ~__b;
1478}
1479
1480static __inline__ vector unsigned short __ATTRS_o_ai
1481vec_vandc(vector unsigned short __a, vector bool short __b) {
1482 return __a & ~(vector unsigned short)__b;
1483}
1484
1485static __inline__ vector bool short __ATTRS_o_ai
1486vec_vandc(vector bool short __a, vector bool short __b) {
1487 return __a & ~__b;
1488}
1489
1490static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1491 vector int __b) {
1492 return __a & ~__b;
1493}
1494
1495static __inline__ vector int __ATTRS_o_ai vec_vandc(vector bool int __a,
1496 vector int __b) {
1497 return (vector int)__a & ~__b;
1498}
1499
1500static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1501 vector bool int __b) {
1502 return __a & ~(vector int)__b;
1503}
1504
1505static __inline__ vector unsigned int __ATTRS_o_ai
1506vec_vandc(vector unsigned int __a, vector unsigned int __b) {
1507 return __a & ~__b;
1508}
1509
1510static __inline__ vector unsigned int __ATTRS_o_ai
1511vec_vandc(vector bool int __a, vector unsigned int __b) {
1512 return (vector unsigned int)__a & ~__b;
1513}
1514
1515static __inline__ vector unsigned int __ATTRS_o_ai
1516vec_vandc(vector unsigned int __a, vector bool int __b) {
1517 return __a & ~(vector unsigned int)__b;
1518}
1519
1520static __inline__ vector bool int __ATTRS_o_ai vec_vandc(vector bool int __a,
1521 vector bool int __b) {
1522 return __a & ~__b;
1523}
1524
1525static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1526 vector float __b) {
1527 vector unsigned int __res =
1528 (vector unsigned int)__a & ~(vector unsigned int)__b;
1529 return (vector float)__res;
1530}
1531
1532static __inline__ vector float __ATTRS_o_ai vec_vandc(vector bool int __a,
1533 vector float __b) {
1534 vector unsigned int __res =
1535 (vector unsigned int)__a & ~(vector unsigned int)__b;
1536 return (vector float)__res;
1537}
1538
1539static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1540 vector bool int __b) {
1541 vector unsigned int __res =
1542 (vector unsigned int)__a & ~(vector unsigned int)__b;
1543 return (vector float)__res;
1544}
1545
1546#ifdef __VSX__
1547static __inline__ vector signed long long __ATTRS_o_ai
1548vec_vandc(vector signed long long __a, vector signed long long __b) {
1549 return __a & ~__b;
1550}
1551
1552static __inline__ vector signed long long __ATTRS_o_ai
1553vec_vandc(vector bool long long __a, vector signed long long __b) {
1554 return (vector signed long long)__a & ~__b;
1555}
1556
1557static __inline__ vector signed long long __ATTRS_o_ai
1558vec_vandc(vector signed long long __a, vector bool long long __b) {
1559 return __a & ~(vector signed long long)__b;
1560}
1561
1562static __inline__ vector unsigned long long __ATTRS_o_ai
1563vec_vandc(vector unsigned long long __a, vector unsigned long long __b) {
1564 return __a & ~__b;
1565}
1566
1567static __inline__ vector unsigned long long __ATTRS_o_ai
1568vec_vandc(vector bool long long __a, vector unsigned long long __b) {
1569 return (vector unsigned long long)__a & ~__b;
1570}
1571
1572static __inline__ vector unsigned long long __ATTRS_o_ai
1573vec_vandc(vector unsigned long long __a, vector bool long long __b) {
1574 return __a & ~(vector unsigned long long)__b;
1575}
1576
1577static __inline__ vector bool long long __ATTRS_o_ai
1578vec_vandc(vector bool long long __a, vector bool long long __b) {
1579 return __a & ~__b;
1580}
1581#endif
1582
1583/* vec_avg */
1584
1585static __inline__ vector signed char __ATTRS_o_ai
1586vec_avg(vector signed char __a, vector signed char __b) {
1587 return __builtin_altivec_vavgsb(__a, __b);
1588}
1589
1590static __inline__ vector unsigned char __ATTRS_o_ai
1591vec_avg(vector unsigned char __a, vector unsigned char __b) {
1592 return __builtin_altivec_vavgub(__a, __b);
1593}
1594
1595static __inline__ vector short __ATTRS_o_ai vec_avg(vector short __a,
1596 vector short __b) {
1597 return __builtin_altivec_vavgsh(__a, __b);
1598}
1599
1600static __inline__ vector unsigned short __ATTRS_o_ai
1601vec_avg(vector unsigned short __a, vector unsigned short __b) {
1602 return __builtin_altivec_vavguh(__a, __b);
1603}
1604
1605static __inline__ vector int __ATTRS_o_ai vec_avg(vector int __a,
1606 vector int __b) {
1607 return __builtin_altivec_vavgsw(__a, __b);
1608}
1609
1610static __inline__ vector unsigned int __ATTRS_o_ai
1611vec_avg(vector unsigned int __a, vector unsigned int __b) {
1612 return __builtin_altivec_vavguw(__a, __b);
1613}
1614
1615/* vec_vavgsb */
1616
1617static __inline__ vector signed char __attribute__((__always_inline__))
1618vec_vavgsb(vector signed char __a, vector signed char __b) {
1619 return __builtin_altivec_vavgsb(__a, __b);
1620}
1621
1622/* vec_vavgub */
1623
1624static __inline__ vector unsigned char __attribute__((__always_inline__))
1625vec_vavgub(vector unsigned char __a, vector unsigned char __b) {
1626 return __builtin_altivec_vavgub(__a, __b);
1627}
1628
1629/* vec_vavgsh */
1630
1631static __inline__ vector short __attribute__((__always_inline__))
1632vec_vavgsh(vector short __a, vector short __b) {
1633 return __builtin_altivec_vavgsh(__a, __b);
1634}
1635
1636/* vec_vavguh */
1637
1638static __inline__ vector unsigned short __attribute__((__always_inline__))
1639vec_vavguh(vector unsigned short __a, vector unsigned short __b) {
1640 return __builtin_altivec_vavguh(__a, __b);
1641}
1642
1643/* vec_vavgsw */
1644
1645static __inline__ vector int __attribute__((__always_inline__))
1646vec_vavgsw(vector int __a, vector int __b) {
1647 return __builtin_altivec_vavgsw(__a, __b);
1648}
1649
1650/* vec_vavguw */
1651
1652static __inline__ vector unsigned int __attribute__((__always_inline__))
1653vec_vavguw(vector unsigned int __a, vector unsigned int __b) {
1654 return __builtin_altivec_vavguw(__a, __b);
1655}
1656
1657/* vec_ceil */
1658
1659static __inline__ vector float __ATTRS_o_ai vec_ceil(vector float __a) {
1660#ifdef __VSX__
1661 return __builtin_vsx_xvrspip(__a);
1662#else
1663 return __builtin_altivec_vrfip(__a);
1664#endif
1665}
1666
1667#ifdef __VSX__
1668static __inline__ vector double __ATTRS_o_ai vec_ceil(vector double __a) {
1669 return __builtin_vsx_xvrdpip(__a);
1670}
1671#endif
1672
1673/* vec_roundp */
1674static __inline__ vector float __ATTRS_o_ai vec_roundp(vector float __a) {
1675 return vec_ceil(__a);
1676}
1677
1678#ifdef __VSX__
1679static __inline__ vector double __ATTRS_o_ai vec_roundp(vector double __a) {
1680 return vec_ceil(__a);
1681}
1682#endif
1683
1684/* vec_vrfip */
1685
1686static __inline__ vector float __attribute__((__always_inline__))
1687vec_vrfip(vector float __a) {
1688 return __builtin_altivec_vrfip(__a);
1689}
1690
1691/* vec_cmpb */
1692
1693static __inline__ vector int __attribute__((__always_inline__))
1694vec_cmpb(vector float __a, vector float __b) {
1695 return __builtin_altivec_vcmpbfp(__a, __b);
1696}
1697
1698/* vec_vcmpbfp */
1699
1700static __inline__ vector int __attribute__((__always_inline__))
1701vec_vcmpbfp(vector float __a, vector float __b) {
1702 return __builtin_altivec_vcmpbfp(__a, __b);
1703}
1704
1705/* vec_cmpeq */
1706
1707static __inline__ vector bool char __ATTRS_o_ai
1708vec_cmpeq(vector signed char __a, vector signed char __b) {
1709 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1710 (vector char)__b);
1711}
1712
1713static __inline__ vector bool char __ATTRS_o_ai
1714vec_cmpeq(vector unsigned char __a, vector unsigned char __b) {
1715 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1716 (vector char)__b);
1717}
1718
1719static __inline__ vector bool char __ATTRS_o_ai
1720vec_cmpeq(vector bool char __a, vector bool char __b) {
1721 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1722 (vector char)__b);
1723}
1724
1725static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
1726 vector short __b) {
1727 return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
1728}
1729
1730static __inline__ vector bool short __ATTRS_o_ai
1731vec_cmpeq(vector unsigned short __a, vector unsigned short __b) {
1732 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1733 (vector short)__b);
1734}
1735
1736static __inline__ vector bool short __ATTRS_o_ai
1737vec_cmpeq(vector bool short __a, vector bool short __b) {
1738 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1739 (vector short)__b);
1740}
1741
1742static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
1743 vector int __b) {
1744 return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
1745}
1746
1747static __inline__ vector bool int __ATTRS_o_ai
1748vec_cmpeq(vector unsigned int __a, vector unsigned int __b) {
1749 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1750 (vector int)__b);
1751}
1752
1753static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
1754 vector bool int __b) {
1755 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1756 (vector int)__b);
1757}
1758
1759#ifdef __POWER8_VECTOR__
1760static __inline__ vector bool long long __ATTRS_o_ai
1761vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1762 return (vector bool long long)__builtin_altivec_vcmpequd(__a, __b);
1763}
1764
1765static __inline__ vector bool long long __ATTRS_o_ai
1766vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1767 return (vector bool long long)__builtin_altivec_vcmpequd(
1768 (vector long long)__a, (vector long long)__b);
1769}
1770
1771static __inline__ vector bool long long __ATTRS_o_ai
1772vec_cmpeq(vector bool long long __a, vector bool long long __b) {
1773 return (vector bool long long)__builtin_altivec_vcmpequd(
1774 (vector long long)__a, (vector long long)__b);
1775}
1776#elif defined(__VSX__)
1777static __inline__ vector bool long long __ATTRS_o_ai
1778vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1779 vector bool int __wordcmp =
1780 vec_cmpeq((vector signed int)__a, (vector signed int)__b);
1781#ifdef __LITTLE_ENDIAN__
1782 __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2);
1783 return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 1,
1784 1, 3, 3);
1785#else
1786 __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0);
1787 return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 0,
1788 0, 2, 2);
1789#endif
1790}
1791
1792static __inline__ vector bool long long __ATTRS_o_ai
1793vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1794 return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
1795}
1796
1797static __inline__ vector bool long long __ATTRS_o_ai
1798vec_cmpeq(vector bool long long __a, vector bool long long __b) {
1799 return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b);
1800}
1801#endif
1802
1803static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
1804 vector float __b) {
1805#ifdef __VSX__
1806 return (vector bool int)__builtin_vsx_xvcmpeqsp(__a, __b);
1807#else
1808 return (vector bool int)__builtin_altivec_vcmpeqfp(__a, __b);
1809#endif
1810}
1811
1812#ifdef __VSX__
1813static __inline__ vector bool long long __ATTRS_o_ai
1814vec_cmpeq(vector double __a, vector double __b) {
1815 return (vector bool long long)__builtin_vsx_xvcmpeqdp(__a, __b);
1816}
1817#endif
1818
1819#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
1820static __inline__ vector bool __int128 __ATTRS_o_ai
1821vec_cmpeq(vector signed __int128 __a, vector signed __int128 __b) {
1822 return (vector bool __int128)__builtin_altivec_vcmpequq(
1823 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
1824}
1825
1826static __inline__ vector bool __int128 __ATTRS_o_ai
1827vec_cmpeq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
1828 return (vector bool __int128)__builtin_altivec_vcmpequq(
1829 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
1830}
1831
1832static __inline__ vector bool __int128 __ATTRS_o_ai
1833vec_cmpeq(vector bool __int128 __a, vector bool __int128 __b) {
1834 return (vector bool __int128)__builtin_altivec_vcmpequq(
1835 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
1836}
1837#endif
1838
1839#ifdef __POWER9_VECTOR__
1840/* vec_cmpne */
1841
1842static __inline__ vector bool char __ATTRS_o_ai
1843vec_cmpne(vector bool char __a, vector bool char __b) {
1844 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1845 (vector char)__b);
1846}
1847
1848static __inline__ vector bool char __ATTRS_o_ai
1849vec_cmpne(vector signed char __a, vector signed char __b) {
1850 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1851 (vector char)__b);
1852}
1853
1854static __inline__ vector bool char __ATTRS_o_ai
1855vec_cmpne(vector unsigned char __a, vector unsigned char __b) {
1856 return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a,
1857 (vector char)__b);
1858}
1859
1860static __inline__ vector bool short __ATTRS_o_ai
1861vec_cmpne(vector bool short __a, vector bool short __b) {
1862 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1863 (vector short)__b);
1864}
1865
1866static __inline__ vector bool short __ATTRS_o_ai
1867vec_cmpne(vector signed short __a, vector signed short __b) {
1868 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1869 (vector short)__b);
1870}
1871
1872static __inline__ vector bool short __ATTRS_o_ai
1873vec_cmpne(vector unsigned short __a, vector unsigned short __b) {
1874 return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a,
1875 (vector short)__b);
1876}
1877
1878static __inline__ vector bool int __ATTRS_o_ai
1879vec_cmpne(vector bool int __a, vector bool int __b) {
1880 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1881 (vector int)__b);
1882}
1883
1884static __inline__ vector bool int __ATTRS_o_ai
1885vec_cmpne(vector signed int __a, vector signed int __b) {
1886 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1887 (vector int)__b);
1888}
1889
1890static __inline__ vector bool int __ATTRS_o_ai
1891vec_cmpne(vector unsigned int __a, vector unsigned int __b) {
1892 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1893 (vector int)__b);
1894}
1895
1896static __inline__ vector bool int __ATTRS_o_ai
1897vec_cmpne(vector float __a, vector float __b) {
1898 return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a,
1899 (vector int)__b);
1900}
1901
1902#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
1903static __inline__ vector bool __int128 __ATTRS_o_ai
1904vec_cmpne(vector unsigned __int128 __a, vector unsigned __int128 __b) {
1905 return (vector bool __int128)~(__builtin_altivec_vcmpequq(
1906 (vector unsigned __int128)__a, (vector unsigned __int128)__b));
1907}
1908
1909static __inline__ vector bool __int128 __ATTRS_o_ai
1910vec_cmpne(vector signed __int128 __a, vector signed __int128 __b) {
1911 return (vector bool __int128)~(__builtin_altivec_vcmpequq(
1912 (vector unsigned __int128)__a, (vector unsigned __int128)__b));
1913}
1914
1915static __inline__ vector bool __int128 __ATTRS_o_ai
1916vec_cmpne(vector bool __int128 __a, vector bool __int128 __b) {
1917 return (vector bool __int128)~(__builtin_altivec_vcmpequq(
1918 (vector unsigned __int128)__a, (vector unsigned __int128)__b));
1919}
1920#endif
1921
1922/* vec_cmpnez */
1923
1924static __inline__ vector bool char __ATTRS_o_ai
1925vec_cmpnez(vector signed char __a, vector signed char __b) {
1926 return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a,
1927 (vector char)__b);
1928}
1929
1930static __inline__ vector bool char __ATTRS_o_ai
1931vec_cmpnez(vector unsigned char __a, vector unsigned char __b) {
1932 return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a,
1933 (vector char)__b);
1934}
1935
1936static __inline__ vector bool short __ATTRS_o_ai
1937vec_cmpnez(vector signed short __a, vector signed short __b) {
1938 return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a,
1939 (vector short)__b);
1940}
1941
1942static __inline__ vector bool short __ATTRS_o_ai
1943vec_cmpnez(vector unsigned short __a, vector unsigned short __b) {
1944 return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a,
1945 (vector short)__b);
1946}
1947
1948static __inline__ vector bool int __ATTRS_o_ai
1949vec_cmpnez(vector signed int __a, vector signed int __b) {
1950 return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a,
1951 (vector int)__b);
1952}
1953
1954static __inline__ vector bool int __ATTRS_o_ai
1955vec_cmpnez(vector unsigned int __a, vector unsigned int __b) {
1956 return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a,
1957 (vector int)__b);
1958}
1959
1960static __inline__ signed int __ATTRS_o_ai
1961vec_cntlz_lsbb(vector signed char __a) {
1962#ifdef __LITTLE_ENDIAN__
1963 return __builtin_altivec_vctzlsbb((vector unsigned char)__a);
1964#else
1965 return __builtin_altivec_vclzlsbb((vector unsigned char)__a);
1966#endif
1967}
1968
1969static __inline__ signed int __ATTRS_o_ai
1970vec_cntlz_lsbb(vector unsigned char __a) {
1971#ifdef __LITTLE_ENDIAN__
1972 return __builtin_altivec_vctzlsbb((vector unsigned char)__a);
1973#else
1974 return __builtin_altivec_vclzlsbb(__a);
1975#endif
1976}
1977
1978static __inline__ signed int __ATTRS_o_ai
1979vec_cnttz_lsbb(vector signed char __a) {
1980#ifdef __LITTLE_ENDIAN__
1981 return __builtin_altivec_vclzlsbb((vector unsigned char)__a);
1982#else
1983 return __builtin_altivec_vctzlsbb((vector unsigned char)__a);
1984#endif
1985}
1986
1987static __inline__ signed int __ATTRS_o_ai
1988vec_cnttz_lsbb(vector unsigned char __a) {
1989#ifdef __LITTLE_ENDIAN__
1990 return __builtin_altivec_vclzlsbb(__a);
1991#else
1992 return __builtin_altivec_vctzlsbb(__a);
1993#endif
1994}
1995
1996static __inline__ vector unsigned int __ATTRS_o_ai
1997vec_parity_lsbb(vector unsigned int __a) {
1998 return __builtin_altivec_vprtybw(__a);
1999}
2000
2001static __inline__ vector unsigned int __ATTRS_o_ai
2002vec_parity_lsbb(vector signed int __a) {
2003 return __builtin_altivec_vprtybw((vector unsigned int)__a);
2004}
2005
2006#ifdef __SIZEOF_INT128__
2007static __inline__ vector unsigned __int128 __ATTRS_o_ai
2008vec_parity_lsbb(vector unsigned __int128 __a) {
2009 return __builtin_altivec_vprtybq(__a);
2010}
2011
2012static __inline__ vector unsigned __int128 __ATTRS_o_ai
2013vec_parity_lsbb(vector signed __int128 __a) {
2014 return __builtin_altivec_vprtybq((vector unsigned __int128)__a);
2015}
2016#endif
2017
2018static __inline__ vector unsigned long long __ATTRS_o_ai
2019vec_parity_lsbb(vector unsigned long long __a) {
2020 return __builtin_altivec_vprtybd(__a);
2021}
2022
2023static __inline__ vector unsigned long long __ATTRS_o_ai
2024vec_parity_lsbb(vector signed long long __a) {
2025 return __builtin_altivec_vprtybd((vector unsigned long long)__a);
2026}
2027
2028#else
2029/* vec_cmpne */
2030
2031static __inline__ vector bool char __ATTRS_o_ai
2032vec_cmpne(vector bool char __a, vector bool char __b) {
2033 return ~(vec_cmpeq(__a, __b));
2034}
2035
2036static __inline__ vector bool char __ATTRS_o_ai
2037vec_cmpne(vector signed char __a, vector signed char __b) {
2038 return ~(vec_cmpeq(__a, __b));
2039}
2040
2041static __inline__ vector bool char __ATTRS_o_ai
2042vec_cmpne(vector unsigned char __a, vector unsigned char __b) {
2043 return ~(vec_cmpeq(__a, __b));
2044}
2045
2046static __inline__ vector bool short __ATTRS_o_ai
2047vec_cmpne(vector bool short __a, vector bool short __b) {
2048 return ~(vec_cmpeq(__a, __b));
2049}
2050
2051static __inline__ vector bool short __ATTRS_o_ai
2052vec_cmpne(vector signed short __a, vector signed short __b) {
2053 return ~(vec_cmpeq(__a, __b));
2054}
2055
2056static __inline__ vector bool short __ATTRS_o_ai
2057vec_cmpne(vector unsigned short __a, vector unsigned short __b) {
2058 return ~(vec_cmpeq(__a, __b));
2059}
2060
2061static __inline__ vector bool int __ATTRS_o_ai
2062vec_cmpne(vector bool int __a, vector bool int __b) {
2063 return ~(vec_cmpeq(__a, __b));
2064}
2065
2066static __inline__ vector bool int __ATTRS_o_ai
2067vec_cmpne(vector signed int __a, vector signed int __b) {
2068 return ~(vec_cmpeq(__a, __b));
2069}
2070
2071static __inline__ vector bool int __ATTRS_o_ai
2072vec_cmpne(vector unsigned int __a, vector unsigned int __b) {
2073 return ~(vec_cmpeq(__a, __b));
2074}
2075
2076static __inline__ vector bool int __ATTRS_o_ai
2077vec_cmpne(vector float __a, vector float __b) {
2078 return ~(vec_cmpeq(__a, __b));
2079}
2080#endif
2081
2082#ifdef __POWER8_VECTOR__
2083static __inline__ vector bool long long __ATTRS_o_ai
2084vec_cmpne(vector bool long long __a, vector bool long long __b) {
2085 return (vector bool long long)
2086 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2087}
2088
2089static __inline__ vector bool long long __ATTRS_o_ai
2090vec_cmpne(vector signed long long __a, vector signed long long __b) {
2091 return (vector bool long long)
2092 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2093}
2094
2095static __inline__ vector bool long long __ATTRS_o_ai
2096vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
2097 return (vector bool long long)
2098 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2099}
2100#elif defined(__VSX__)
2101static __inline__ vector bool long long __ATTRS_o_ai
2102vec_cmpne(vector bool long long __a, vector bool long long __b) {
2103 return (vector bool long long)~(
2104 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2105}
2106
2107static __inline__ vector bool long long __ATTRS_o_ai
2108vec_cmpne(vector signed long long __a, vector signed long long __b) {
2109 return (vector bool long long)~(
2110 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2111}
2112
2113static __inline__ vector bool long long __ATTRS_o_ai
2114vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) {
2115 return (vector bool long long)~(
2116 vec_cmpeq((vector signed long long)__a, (vector signed long long)__b));
2117}
2118#endif
2119
2120#ifdef __VSX__
2121static __inline__ vector bool long long __ATTRS_o_ai
2122vec_cmpne(vector double __a, vector double __b) {
2123 return (vector bool long long)
2124 ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b));
2125}
2126#endif
2127
2128/* vec_cmpgt */
2129
2130static __inline__ vector bool char __ATTRS_o_ai
2131vec_cmpgt(vector signed char __a, vector signed char __b) {
2132 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
2133}
2134
2135static __inline__ vector bool char __ATTRS_o_ai
2136vec_cmpgt(vector unsigned char __a, vector unsigned char __b) {
2137 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
2138}
2139
2140static __inline__ vector bool short __ATTRS_o_ai vec_cmpgt(vector short __a,
2141 vector short __b) {
2142 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
2143}
2144
2145static __inline__ vector bool short __ATTRS_o_ai
2146vec_cmpgt(vector unsigned short __a, vector unsigned short __b) {
2147 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
2148}
2149
2150static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector int __a,
2151 vector int __b) {
2152 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
2153}
2154
2155static __inline__ vector bool int __ATTRS_o_ai
2156vec_cmpgt(vector unsigned int __a, vector unsigned int __b) {
2157 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
2158}
2159
2160#ifdef __POWER8_VECTOR__
2161static __inline__ vector bool long long __ATTRS_o_ai
2162vec_cmpgt(vector signed long long __a, vector signed long long __b) {
2163 return (vector bool long long)__builtin_altivec_vcmpgtsd(__a, __b);
2164}
2165
2166static __inline__ vector bool long long __ATTRS_o_ai
2167vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
2168 return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b);
2169}
2170#elif defined(__VSX__)
2171static __inline__ vector bool long long __ATTRS_o_ai
2172vec_cmpgt(vector signed long long __a, vector signed long long __b) {
2173 vector signed int __sgtw = (vector signed int)vec_cmpgt(
2174 (vector signed int)__a, (vector signed int)__b);
2175 vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt(
2176 (vector unsigned int)__a, (vector unsigned int)__b);
2177 vector unsigned int __eqw = (vector unsigned int)vec_cmpeq(
2178 (vector signed int)__a, (vector signed int)__b);
2179#ifdef __LITTLE_ENDIAN__
2180 __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw;
2181 __sgtw |= (vector signed int)__ugtw;
2182 return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 1, 1, 3,
2183 3);
2184#else
2185 __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw;
2186 __sgtw |= (vector signed int)__ugtw;
2187 return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 0, 0, 2,
2188 2);
2189#endif
2190}
2191
2192static __inline__ vector bool long long __ATTRS_o_ai
2193vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
2194 vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt(
2195 (vector unsigned int)__a, (vector unsigned int)__b);
2196 vector unsigned int __eqw = (vector unsigned int)vec_cmpeq(
2197 (vector signed int)__a, (vector signed int)__b);
2198#ifdef __LITTLE_ENDIAN__
2199 __eqw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw;
2200 __ugtw |= __eqw;
2201 return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 1, 1, 3,
2202 3);
2203#else
2204 __eqw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw;
2205 __ugtw |= __eqw;
2206 return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 0, 0, 2,
2207 2);
2208#endif
2209}
2210#endif
2211
2212static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector float __a,
2213 vector float __b) {
2214#ifdef __VSX__
2215 return (vector bool int)__builtin_vsx_xvcmpgtsp(__a, __b);
2216#else
2217 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
2218#endif
2219}
2220
2221#ifdef __VSX__
2222static __inline__ vector bool long long __ATTRS_o_ai
2223vec_cmpgt(vector double __a, vector double __b) {
2224 return (vector bool long long)__builtin_vsx_xvcmpgtdp(__a, __b);
2225}
2226#endif
2227
2228#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
2229static __inline__ vector bool __int128 __ATTRS_o_ai
2230vec_cmpgt(vector signed __int128 __a, vector signed __int128 __b) {
2231 return (vector bool __int128)__builtin_altivec_vcmpgtsq(__a, __b);
2232}
2233
2234static __inline__ vector bool __int128 __ATTRS_o_ai
2235vec_cmpgt(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2236 return (vector bool __int128)__builtin_altivec_vcmpgtuq(__a, __b);
2237}
2238#endif
2239
2240/* vec_cmpge */
2241
2242static __inline__ vector bool char __ATTRS_o_ai
2243vec_cmpge(vector signed char __a, vector signed char __b) {
2244 return ~(vec_cmpgt(__b, __a));
2245}
2246
2247static __inline__ vector bool char __ATTRS_o_ai
2248vec_cmpge(vector unsigned char __a, vector unsigned char __b) {
2249 return ~(vec_cmpgt(__b, __a));
2250}
2251
2252static __inline__ vector bool short __ATTRS_o_ai
2253vec_cmpge(vector signed short __a, vector signed short __b) {
2254 return ~(vec_cmpgt(__b, __a));
2255}
2256
2257static __inline__ vector bool short __ATTRS_o_ai
2258vec_cmpge(vector unsigned short __a, vector unsigned short __b) {
2259 return ~(vec_cmpgt(__b, __a));
2260}
2261
2262static __inline__ vector bool int __ATTRS_o_ai
2263vec_cmpge(vector signed int __a, vector signed int __b) {
2264 return ~(vec_cmpgt(__b, __a));
2265}
2266
2267static __inline__ vector bool int __ATTRS_o_ai
2268vec_cmpge(vector unsigned int __a, vector unsigned int __b) {
2269 return ~(vec_cmpgt(__b, __a));
2270}
2271
2272static __inline__ vector bool int __ATTRS_o_ai vec_cmpge(vector float __a,
2273 vector float __b) {
2274#ifdef __VSX__
2275 return (vector bool int)__builtin_vsx_xvcmpgesp(__a, __b);
2276#else
2277 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
2278#endif
2279}
2280
2281#ifdef __VSX__
2282static __inline__ vector bool long long __ATTRS_o_ai
2283vec_cmpge(vector double __a, vector double __b) {
2284 return (vector bool long long)__builtin_vsx_xvcmpgedp(__a, __b);
2285}
2286
2287static __inline__ vector bool long long __ATTRS_o_ai
2288vec_cmpge(vector signed long long __a, vector signed long long __b) {
2289 return ~(vec_cmpgt(__b, __a));
2290}
2291
2292static __inline__ vector bool long long __ATTRS_o_ai
2293vec_cmpge(vector unsigned long long __a, vector unsigned long long __b) {
2294 return ~(vec_cmpgt(__b, __a));
2295}
2296#endif
2297
2298#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
2299static __inline__ vector bool __int128 __ATTRS_o_ai
2300vec_cmpge(vector signed __int128 __a, vector signed __int128 __b) {
2301 return ~(vec_cmpgt(__b, __a));
2302}
2303
2304static __inline__ vector bool __int128 __ATTRS_o_ai
2305vec_cmpge(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2306 return ~(vec_cmpgt(__b, __a));
2307}
2308#endif
2309
2310/* vec_vcmpgefp */
2311
2312static __inline__ vector bool int __attribute__((__always_inline__))
2313vec_vcmpgefp(vector float __a, vector float __b) {
2314 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
2315}
2316
2317/* vec_vcmpgtsb */
2318
2319static __inline__ vector bool char __attribute__((__always_inline__))
2320vec_vcmpgtsb(vector signed char __a, vector signed char __b) {
2321 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
2322}
2323
2324/* vec_vcmpgtub */
2325
2326static __inline__ vector bool char __attribute__((__always_inline__))
2327vec_vcmpgtub(vector unsigned char __a, vector unsigned char __b) {
2328 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
2329}
2330
2331/* vec_vcmpgtsh */
2332
2333static __inline__ vector bool short __attribute__((__always_inline__))
2334vec_vcmpgtsh(vector short __a, vector short __b) {
2335 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
2336}
2337
2338/* vec_vcmpgtuh */
2339
2340static __inline__ vector bool short __attribute__((__always_inline__))
2341vec_vcmpgtuh(vector unsigned short __a, vector unsigned short __b) {
2342 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
2343}
2344
2345/* vec_vcmpgtsw */
2346
2347static __inline__ vector bool int __attribute__((__always_inline__))
2348vec_vcmpgtsw(vector int __a, vector int __b) {
2349 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
2350}
2351
2352/* vec_vcmpgtuw */
2353
2354static __inline__ vector bool int __attribute__((__always_inline__))
2355vec_vcmpgtuw(vector unsigned int __a, vector unsigned int __b) {
2356 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
2357}
2358
2359/* vec_vcmpgtfp */
2360
2361static __inline__ vector bool int __attribute__((__always_inline__))
2362vec_vcmpgtfp(vector float __a, vector float __b) {
2363 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
2364}
2365
2366/* vec_cmple */
2367
2368static __inline__ vector bool char __ATTRS_o_ai
2369vec_cmple(vector signed char __a, vector signed char __b) {
2370 return vec_cmpge(__b, __a);
2371}
2372
2373static __inline__ vector bool char __ATTRS_o_ai
2374vec_cmple(vector unsigned char __a, vector unsigned char __b) {
2375 return vec_cmpge(__b, __a);
2376}
2377
2378static __inline__ vector bool short __ATTRS_o_ai
2379vec_cmple(vector signed short __a, vector signed short __b) {
2380 return vec_cmpge(__b, __a);
2381}
2382
2383static __inline__ vector bool short __ATTRS_o_ai
2384vec_cmple(vector unsigned short __a, vector unsigned short __b) {
2385 return vec_cmpge(__b, __a);
2386}
2387
2388static __inline__ vector bool int __ATTRS_o_ai
2389vec_cmple(vector signed int __a, vector signed int __b) {
2390 return vec_cmpge(__b, __a);
2391}
2392
2393static __inline__ vector bool int __ATTRS_o_ai
2394vec_cmple(vector unsigned int __a, vector unsigned int __b) {
2395 return vec_cmpge(__b, __a);
2396}
2397
2398static __inline__ vector bool int __ATTRS_o_ai vec_cmple(vector float __a,
2399 vector float __b) {
2400 return vec_cmpge(__b, __a);
2401}
2402
2403#ifdef __VSX__
2404static __inline__ vector bool long long __ATTRS_o_ai
2405vec_cmple(vector double __a, vector double __b) {
2406 return vec_cmpge(__b, __a);
2407}
2408
2409static __inline__ vector bool long long __ATTRS_o_ai
2410vec_cmple(vector signed long long __a, vector signed long long __b) {
2411 return vec_cmpge(__b, __a);
2412}
2413
2414static __inline__ vector bool long long __ATTRS_o_ai
2415vec_cmple(vector unsigned long long __a, vector unsigned long long __b) {
2416 return vec_cmpge(__b, __a);
2417}
2418#endif
2419
2420#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
2421static __inline__ vector bool __int128 __ATTRS_o_ai
2422vec_cmple(vector signed __int128 __a, vector signed __int128 __b) {
2423 return vec_cmpge(__b, __a);
2424}
2425
2426static __inline__ vector bool __int128 __ATTRS_o_ai
2427vec_cmple(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2428 return vec_cmpge(__b, __a);
2429}
2430#endif
2431
2432/* vec_cmplt */
2433
2434static __inline__ vector bool char __ATTRS_o_ai
2435vec_cmplt(vector signed char __a, vector signed char __b) {
2436 return vec_cmpgt(__b, __a);
2437}
2438
2439static __inline__ vector bool char __ATTRS_o_ai
2440vec_cmplt(vector unsigned char __a, vector unsigned char __b) {
2441 return vec_cmpgt(__b, __a);
2442}
2443
2444static __inline__ vector bool short __ATTRS_o_ai vec_cmplt(vector short __a,
2445 vector short __b) {
2446 return vec_cmpgt(__b, __a);
2447}
2448
2449static __inline__ vector bool short __ATTRS_o_ai
2450vec_cmplt(vector unsigned short __a, vector unsigned short __b) {
2451 return vec_cmpgt(__b, __a);
2452}
2453
2454static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector int __a,
2455 vector int __b) {
2456 return vec_cmpgt(__b, __a);
2457}
2458
2459static __inline__ vector bool int __ATTRS_o_ai
2460vec_cmplt(vector unsigned int __a, vector unsigned int __b) {
2461 return vec_cmpgt(__b, __a);
2462}
2463
2464static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector float __a,
2465 vector float __b) {
2466 return vec_cmpgt(__b, __a);
2467}
2468
2469#ifdef __VSX__
2470static __inline__ vector bool long long __ATTRS_o_ai
2471vec_cmplt(vector double __a, vector double __b) {
2472 return vec_cmpgt(__b, __a);
2473}
2474#endif
2475
2476#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
2477static __inline__ vector bool __int128 __ATTRS_o_ai
2478vec_cmplt(vector signed __int128 __a, vector signed __int128 __b) {
2479 return vec_cmpgt(__b, __a);
2480}
2481
2482static __inline__ vector bool __int128 __ATTRS_o_ai
2483vec_cmplt(vector unsigned __int128 __a, vector unsigned __int128 __b) {
2484 return vec_cmpgt(__b, __a);
2485}
2486#endif
2487
2488#ifdef __VSX__
2489static __inline__ vector bool long long __ATTRS_o_ai
2490vec_cmplt(vector signed long long __a, vector signed long long __b) {
2491 return vec_cmpgt(__b, __a);
2492}
2493
2494static __inline__ vector bool long long __ATTRS_o_ai
2495vec_cmplt(vector unsigned long long __a, vector unsigned long long __b) {
2496 return vec_cmpgt(__b, __a);
2497}
2498#endif
2499
2500#ifdef __POWER8_VECTOR__
2501/* vec_popcnt */
2502
2503static __inline__ vector unsigned char __ATTRS_o_ai
2504vec_popcnt(vector signed char __a) {
2505 return (vector unsigned char)__builtin_altivec_vpopcntb(
2506 (vector unsigned char)__a);
2507}
2508static __inline__ vector unsigned char __ATTRS_o_ai
2509vec_popcnt(vector unsigned char __a) {
2510 return __builtin_altivec_vpopcntb(__a);
2511}
2512static __inline__ vector unsigned short __ATTRS_o_ai
2513vec_popcnt(vector signed short __a) {
2514 return (vector unsigned short)__builtin_altivec_vpopcnth(
2515 (vector unsigned short)__a);
2516}
2517static __inline__ vector unsigned short __ATTRS_o_ai
2518vec_popcnt(vector unsigned short __a) {
2519 return __builtin_altivec_vpopcnth(__a);
2520}
2521static __inline__ vector unsigned int __ATTRS_o_ai
2522vec_popcnt(vector signed int __a) {
2523 return __builtin_altivec_vpopcntw((vector unsigned int)__a);
2524}
2525static __inline__ vector unsigned int __ATTRS_o_ai
2526vec_popcnt(vector unsigned int __a) {
2527 return __builtin_altivec_vpopcntw(__a);
2528}
2529static __inline__ vector unsigned long long __ATTRS_o_ai
2530vec_popcnt(vector signed long long __a) {
2531 return __builtin_altivec_vpopcntd((vector unsigned long long)__a);
2532}
2533static __inline__ vector unsigned long long __ATTRS_o_ai
2534vec_popcnt(vector unsigned long long __a) {
2535 return __builtin_altivec_vpopcntd(__a);
2536}
2537
2538#define vec_vclz vec_cntlz
2539/* vec_cntlz */
2540
2541static __inline__ vector signed char __ATTRS_o_ai
2542vec_cntlz(vector signed char __a) {
2543 return (vector signed char)__builtin_altivec_vclzb((vector unsigned char)__a);
2544}
2545static __inline__ vector unsigned char __ATTRS_o_ai
2546vec_cntlz(vector unsigned char __a) {
2547 return __builtin_altivec_vclzb(__a);
2548}
2549static __inline__ vector signed short __ATTRS_o_ai
2550vec_cntlz(vector signed short __a) {
2551 return (vector signed short)__builtin_altivec_vclzh(
2552 (vector unsigned short)__a);
2553}
2554static __inline__ vector unsigned short __ATTRS_o_ai
2555vec_cntlz(vector unsigned short __a) {
2556 return __builtin_altivec_vclzh(__a);
2557}
2558static __inline__ vector signed int __ATTRS_o_ai
2559vec_cntlz(vector signed int __a) {
2560 return (vector signed int)__builtin_altivec_vclzw((vector unsigned int)__a);
2561}
2562static __inline__ vector unsigned int __ATTRS_o_ai
2563vec_cntlz(vector unsigned int __a) {
2564 return __builtin_altivec_vclzw(__a);
2565}
2566static __inline__ vector signed long long __ATTRS_o_ai
2567vec_cntlz(vector signed long long __a) {
2568 return (vector signed long long)__builtin_altivec_vclzd(
2569 (vector unsigned long long)__a);
2570}
2571static __inline__ vector unsigned long long __ATTRS_o_ai
2572vec_cntlz(vector unsigned long long __a) {
2573 return __builtin_altivec_vclzd(__a);
2574}
2575#endif
2576
2577#ifdef __POWER9_VECTOR__
2578
2579/* vec_cnttz */
2580
2581static __inline__ vector signed char __ATTRS_o_ai
2582vec_cnttz(vector signed char __a) {
2583 return (vector signed char)__builtin_altivec_vctzb((vector unsigned char)__a);
2584}
2585static __inline__ vector unsigned char __ATTRS_o_ai
2586vec_cnttz(vector unsigned char __a) {
2587 return __builtin_altivec_vctzb(__a);
2588}
2589static __inline__ vector signed short __ATTRS_o_ai
2590vec_cnttz(vector signed short __a) {
2591 return (vector signed short)__builtin_altivec_vctzh(
2592 (vector unsigned short)__a);
2593}
2594static __inline__ vector unsigned short __ATTRS_o_ai
2595vec_cnttz(vector unsigned short __a) {
2596 return __builtin_altivec_vctzh(__a);
2597}
2598static __inline__ vector signed int __ATTRS_o_ai
2599vec_cnttz(vector signed int __a) {
2600 return (vector signed int)__builtin_altivec_vctzw((vector unsigned int)__a);
2601}
2602static __inline__ vector unsigned int __ATTRS_o_ai
2603vec_cnttz(vector unsigned int __a) {
2604 return __builtin_altivec_vctzw(__a);
2605}
2606static __inline__ vector signed long long __ATTRS_o_ai
2607vec_cnttz(vector signed long long __a) {
2608 return (vector signed long long)__builtin_altivec_vctzd(
2609 (vector unsigned long long)__a);
2610}
2611static __inline__ vector unsigned long long __ATTRS_o_ai
2612vec_cnttz(vector unsigned long long __a) {
2613 return __builtin_altivec_vctzd(__a);
2614}
2615
2616/* vec_first_match_index */
2617
2618static __inline__ unsigned __ATTRS_o_ai
2619vec_first_match_index(vector signed char __a, vector signed char __b) {
2620 vector unsigned long long __res =
2621#ifdef __LITTLE_ENDIAN__
2622 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2623#else
2624 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2625#endif
2626 if (__res[0] == 64) {
2627 return (__res[1] + 64) >> 3;
2628 }
2629 return __res[0] >> 3;
2630}
2631
2632static __inline__ unsigned __ATTRS_o_ai
2633vec_first_match_index(vector unsigned char __a, vector unsigned char __b) {
2634 vector unsigned long long __res =
2635#ifdef __LITTLE_ENDIAN__
2636 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2637#else
2638 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2639#endif
2640 if (__res[0] == 64) {
2641 return (__res[1] + 64) >> 3;
2642 }
2643 return __res[0] >> 3;
2644}
2645
2646static __inline__ unsigned __ATTRS_o_ai
2647vec_first_match_index(vector signed short __a, vector signed short __b) {
2648 vector unsigned long long __res =
2649#ifdef __LITTLE_ENDIAN__
2650 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2651#else
2652 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2653#endif
2654 if (__res[0] == 64) {
2655 return (__res[1] + 64) >> 4;
2656 }
2657 return __res[0] >> 4;
2658}
2659
2660static __inline__ unsigned __ATTRS_o_ai
2661vec_first_match_index(vector unsigned short __a, vector unsigned short __b) {
2662 vector unsigned long long __res =
2663#ifdef __LITTLE_ENDIAN__
2664 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2665#else
2666 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2667#endif
2668 if (__res[0] == 64) {
2669 return (__res[1] + 64) >> 4;
2670 }
2671 return __res[0] >> 4;
2672}
2673
2674static __inline__ unsigned __ATTRS_o_ai
2675vec_first_match_index(vector signed int __a, vector signed int __b) {
2676 vector unsigned long long __res =
2677#ifdef __LITTLE_ENDIAN__
2678 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2679#else
2680 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2681#endif
2682 if (__res[0] == 64) {
2683 return (__res[1] + 64) >> 5;
2684 }
2685 return __res[0] >> 5;
2686}
2687
2688static __inline__ unsigned __ATTRS_o_ai
2689vec_first_match_index(vector unsigned int __a, vector unsigned int __b) {
2690 vector unsigned long long __res =
2691#ifdef __LITTLE_ENDIAN__
2692 vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b));
2693#else
2694 vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b));
2695#endif
2696 if (__res[0] == 64) {
2697 return (__res[1] + 64) >> 5;
2698 }
2699 return __res[0] >> 5;
2700}
2701
2702/* vec_first_match_or_eos_index */
2703
2704static __inline__ unsigned __ATTRS_o_ai
2705vec_first_match_or_eos_index(vector signed char __a, vector signed char __b) {
2706 /* Compare the result of the comparison of two vectors with either and OR the
2707 result. Either the elements are equal or one will equal the comparison
2708 result if either is zero.
2709 */
2710 vector bool char __tmp1 = vec_cmpeq(__a, __b);
2711 vector bool char __tmp2 = __tmp1 |
2712 vec_cmpeq((vector signed char)__tmp1, __a) |
2713 vec_cmpeq((vector signed 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 unsigned char __a,
2729 vector unsigned char __b) {
2730 vector bool char __tmp1 = vec_cmpeq(__a, __b);
2731 vector bool char __tmp2 = __tmp1 |
2732 vec_cmpeq((vector unsigned char)__tmp1, __a) |
2733 vec_cmpeq((vector unsigned char)__tmp1, __b);
2734
2735 vector unsigned long long __res =
2736#ifdef __LITTLE_ENDIAN__
2737 vec_cnttz((vector unsigned long long)__tmp2);
2738#else
2739 vec_cntlz((vector unsigned long long)__tmp2);
2740#endif
2741 if (__res[0] == 64) {
2742 return (__res[1] + 64) >> 3;
2743 }
2744 return __res[0] >> 3;
2745}
2746
2747static __inline__ unsigned __ATTRS_o_ai
2748vec_first_match_or_eos_index(vector signed short __a, vector signed short __b) {
2749 vector bool short __tmp1 = vec_cmpeq(__a, __b);
2750 vector bool short __tmp2 = __tmp1 |
2751 vec_cmpeq((vector signed short)__tmp1, __a) |
2752 vec_cmpeq((vector signed 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 unsigned short __a,
2768 vector unsigned short __b) {
2769 vector bool short __tmp1 = vec_cmpeq(__a, __b);
2770 vector bool short __tmp2 = __tmp1 |
2771 vec_cmpeq((vector unsigned short)__tmp1, __a) |
2772 vec_cmpeq((vector unsigned short)__tmp1, __b);
2773
2774 vector unsigned long long __res =
2775#ifdef __LITTLE_ENDIAN__
2776 vec_cnttz((vector unsigned long long)__tmp2);
2777#else
2778 vec_cntlz((vector unsigned long long)__tmp2);
2779#endif
2780 if (__res[0] == 64) {
2781 return (__res[1] + 64) >> 4;
2782 }
2783 return __res[0] >> 4;
2784}
2785
2786static __inline__ unsigned __ATTRS_o_ai
2787vec_first_match_or_eos_index(vector signed int __a, vector signed int __b) {
2788 vector bool int __tmp1 = vec_cmpeq(__a, __b);
2789 vector bool int __tmp2 = __tmp1 | vec_cmpeq((vector signed int)__tmp1, __a) |
2790 vec_cmpeq((vector signed int)__tmp1, __b);
2791
2792 vector unsigned long long __res =
2793#ifdef __LITTLE_ENDIAN__
2794 vec_cnttz((vector unsigned long long)__tmp2);
2795#else
2796 vec_cntlz((vector unsigned long long)__tmp2);
2797#endif
2798 if (__res[0] == 64) {
2799 return (__res[1] + 64) >> 5;
2800 }
2801 return __res[0] >> 5;
2802}
2803
2804static __inline__ unsigned __ATTRS_o_ai
2805vec_first_match_or_eos_index(vector unsigned int __a, vector unsigned int __b) {
2806 vector bool int __tmp1 = vec_cmpeq(__a, __b);
2807 vector bool int __tmp2 = __tmp1 |
2808 vec_cmpeq((vector unsigned int)__tmp1, __a) |
2809 vec_cmpeq((vector unsigned int)__tmp1, __b);
2810
2811 vector unsigned long long __res =
2812#ifdef __LITTLE_ENDIAN__
2813 vec_cnttz((vector unsigned long long)__tmp2);
2814#else
2815 vec_cntlz((vector unsigned long long)__tmp2);
2816#endif
2817 if (__res[0] == 64) {
2818 return (__res[1] + 64) >> 5;
2819 }
2820 return __res[0] >> 5;
2821}
2822
2823/* vec_first_mismatch_index */
2824
2825static __inline__ unsigned __ATTRS_o_ai
2826vec_first_mismatch_index(vector signed char __a, vector signed char __b) {
2827 vector unsigned long long __res =
2828#ifdef __LITTLE_ENDIAN__
2829 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2830#else
2831 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2832#endif
2833 if (__res[0] == 64) {
2834 return (__res[1] + 64) >> 3;
2835 }
2836 return __res[0] >> 3;
2837}
2838
2839static __inline__ unsigned __ATTRS_o_ai
2840vec_first_mismatch_index(vector unsigned char __a, vector unsigned char __b) {
2841 vector unsigned long long __res =
2842#ifdef __LITTLE_ENDIAN__
2843 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2844#else
2845 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2846#endif
2847 if (__res[0] == 64) {
2848 return (__res[1] + 64) >> 3;
2849 }
2850 return __res[0] >> 3;
2851}
2852
2853static __inline__ unsigned __ATTRS_o_ai
2854vec_first_mismatch_index(vector signed short __a, vector signed short __b) {
2855 vector unsigned long long __res =
2856#ifdef __LITTLE_ENDIAN__
2857 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2858#else
2859 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2860#endif
2861 if (__res[0] == 64) {
2862 return (__res[1] + 64) >> 4;
2863 }
2864 return __res[0] >> 4;
2865}
2866
2867static __inline__ unsigned __ATTRS_o_ai
2868vec_first_mismatch_index(vector unsigned short __a, vector unsigned short __b) {
2869 vector unsigned long long __res =
2870#ifdef __LITTLE_ENDIAN__
2871 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2872#else
2873 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2874#endif
2875 if (__res[0] == 64) {
2876 return (__res[1] + 64) >> 4;
2877 }
2878 return __res[0] >> 4;
2879}
2880
2881static __inline__ unsigned __ATTRS_o_ai
2882vec_first_mismatch_index(vector signed int __a, vector signed int __b) {
2883 vector unsigned long long __res =
2884#ifdef __LITTLE_ENDIAN__
2885 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2886#else
2887 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2888#endif
2889 if (__res[0] == 64) {
2890 return (__res[1] + 64) >> 5;
2891 }
2892 return __res[0] >> 5;
2893}
2894
2895static __inline__ unsigned __ATTRS_o_ai
2896vec_first_mismatch_index(vector unsigned int __a, vector unsigned int __b) {
2897 vector unsigned long long __res =
2898#ifdef __LITTLE_ENDIAN__
2899 vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b));
2900#else
2901 vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b));
2902#endif
2903 if (__res[0] == 64) {
2904 return (__res[1] + 64) >> 5;
2905 }
2906 return __res[0] >> 5;
2907}
2908
2909/* vec_first_mismatch_or_eos_index */
2910
2911static __inline__ unsigned __ATTRS_o_ai
2912vec_first_mismatch_or_eos_index(vector signed char __a,
2913 vector signed char __b) {
2914 vector unsigned long long __res =
2915#ifdef __LITTLE_ENDIAN__
2916 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2917#else
2918 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2919#endif
2920 if (__res[0] == 64) {
2921 return (__res[1] + 64) >> 3;
2922 }
2923 return __res[0] >> 3;
2924}
2925
2926static __inline__ unsigned __ATTRS_o_ai
2927vec_first_mismatch_or_eos_index(vector unsigned char __a,
2928 vector unsigned char __b) {
2929 vector unsigned long long __res =
2930#ifdef __LITTLE_ENDIAN__
2931 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2932#else
2933 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2934#endif
2935 if (__res[0] == 64) {
2936 return (__res[1] + 64) >> 3;
2937 }
2938 return __res[0] >> 3;
2939}
2940
2941static __inline__ unsigned __ATTRS_o_ai
2942vec_first_mismatch_or_eos_index(vector signed short __a,
2943 vector signed short __b) {
2944 vector unsigned long long __res =
2945#ifdef __LITTLE_ENDIAN__
2946 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2947#else
2948 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2949#endif
2950 if (__res[0] == 64) {
2951 return (__res[1] + 64) >> 4;
2952 }
2953 return __res[0] >> 4;
2954}
2955
2956static __inline__ unsigned __ATTRS_o_ai
2957vec_first_mismatch_or_eos_index(vector unsigned short __a,
2958 vector unsigned short __b) {
2959 vector unsigned long long __res =
2960#ifdef __LITTLE_ENDIAN__
2961 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2962#else
2963 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2964#endif
2965 if (__res[0] == 64) {
2966 return (__res[1] + 64) >> 4;
2967 }
2968 return __res[0] >> 4;
2969}
2970
2971static __inline__ unsigned __ATTRS_o_ai
2972vec_first_mismatch_or_eos_index(vector signed int __a, vector signed int __b) {
2973 vector unsigned long long __res =
2974#ifdef __LITTLE_ENDIAN__
2975 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2976#else
2977 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2978#endif
2979 if (__res[0] == 64) {
2980 return (__res[1] + 64) >> 5;
2981 }
2982 return __res[0] >> 5;
2983}
2984
2985static __inline__ unsigned __ATTRS_o_ai
2986vec_first_mismatch_or_eos_index(vector unsigned int __a,
2987 vector unsigned int __b) {
2988 vector unsigned long long __res =
2989#ifdef __LITTLE_ENDIAN__
2990 vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b));
2991#else
2992 vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b));
2993#endif
2994 if (__res[0] == 64) {
2995 return (__res[1] + 64) >> 5;
2996 }
2997 return __res[0] >> 5;
2998}
2999
3000static __inline__ vector double __ATTRS_o_ai
3001vec_insert_exp(vector double __a, vector unsigned long long __b) {
3002 return __builtin_vsx_xviexpdp((vector unsigned long long)__a,__b);
3003}
3004
3005static __inline__ vector double __ATTRS_o_ai
3006vec_insert_exp(vector unsigned long long __a, vector unsigned long long __b) {
3007 return __builtin_vsx_xviexpdp(__a,__b);
3008}
3009
3010static __inline__ vector float __ATTRS_o_ai
3011vec_insert_exp(vector float __a, vector unsigned int __b) {
3012 return __builtin_vsx_xviexpsp((vector unsigned int)__a,__b);
3013}
3014
3015static __inline__ vector float __ATTRS_o_ai
3016vec_insert_exp(vector unsigned int __a, vector unsigned int __b) {
3017 return __builtin_vsx_xviexpsp(__a,__b);
3018}
3019
3020#if defined(__powerpc64__)
3021static __inline__ vector signed char __ATTRS_o_ai vec_xl_len(const signed char *__a,
3022 size_t __b) {
3023 return (vector signed char)__builtin_vsx_lxvl(__a, (__b << 56));
3024}
3025
3026static __inline__ vector unsigned char __ATTRS_o_ai
3027vec_xl_len(const unsigned char *__a, size_t __b) {
3028 return (vector unsigned char)__builtin_vsx_lxvl(__a, (__b << 56));
3029}
3030
3031static __inline__ vector signed short __ATTRS_o_ai vec_xl_len(const signed short *__a,
3032 size_t __b) {
3033 return (vector signed short)__builtin_vsx_lxvl(__a, (__b << 56));
3034}
3035
3036static __inline__ vector unsigned short __ATTRS_o_ai
3037vec_xl_len(const unsigned short *__a, size_t __b) {
3038 return (vector unsigned short)__builtin_vsx_lxvl(__a, (__b << 56));
3039}
3040
3041static __inline__ vector signed int __ATTRS_o_ai vec_xl_len(const signed int *__a,
3042 size_t __b) {
3043 return (vector signed int)__builtin_vsx_lxvl(__a, (__b << 56));
3044}
3045
3046static __inline__ vector unsigned int __ATTRS_o_ai vec_xl_len(const unsigned int *__a,
3047 size_t __b) {
3048 return (vector unsigned int)__builtin_vsx_lxvl(__a, (__b << 56));
3049}
3050
3051static __inline__ vector float __ATTRS_o_ai vec_xl_len(const float *__a, size_t __b) {
3052 return (vector float)__builtin_vsx_lxvl(__a, (__b << 56));
3053}
3054
3055#ifdef __SIZEOF_INT128__
3056static __inline__ vector signed __int128 __ATTRS_o_ai
3057vec_xl_len(const signed __int128 *__a, size_t __b) {
3058 return (vector signed __int128)__builtin_vsx_lxvl(__a, (__b << 56));
3059}
3060
3061static __inline__ vector unsigned __int128 __ATTRS_o_ai
3062vec_xl_len(const unsigned __int128 *__a, size_t __b) {
3063 return (vector unsigned __int128)__builtin_vsx_lxvl(__a, (__b << 56));
3064}
3065#endif
3066
3067static __inline__ vector signed long long __ATTRS_o_ai
3068vec_xl_len(const signed long long *__a, size_t __b) {
3069 return (vector signed long long)__builtin_vsx_lxvl(__a, (__b << 56));
3070}
3071
3072static __inline__ vector unsigned long long __ATTRS_o_ai
3073vec_xl_len(const unsigned long long *__a, size_t __b) {
3074 return (vector unsigned long long)__builtin_vsx_lxvl(__a, (__b << 56));
3075}
3076
3077static __inline__ vector double __ATTRS_o_ai vec_xl_len(const double *__a,
3078 size_t __b) {
3079 return (vector double)__builtin_vsx_lxvl(__a, (__b << 56));
3080}
3081
3082static __inline__ vector unsigned char __ATTRS_o_ai
3083vec_xl_len_r(const unsigned char *__a, size_t __b) {
3084 vector unsigned char __res =
3085 (vector unsigned char)__builtin_vsx_lxvll(__a, (__b << 56));
3086 vector unsigned char __mask =
3087 (vector unsigned char)__builtin_altivec_lvsr(16 - __b, (int *)NULL);
3088 return (vector unsigned char)__builtin_altivec_vperm_4si(
3089 (vector int)__res, (vector int)__res, __mask);
3090}
3091
3092// vec_xst_len
3093static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned char __a,
3094 unsigned char *__b,
3095 size_t __c) {
3096 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3097}
3098
3099static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed char __a,
3100 signed char *__b, size_t __c) {
3101 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3102}
3103
3104static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed short __a,
3105 signed short *__b, size_t __c) {
3106 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3107}
3108
3109static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned short __a,
3110 unsigned short *__b,
3111 size_t __c) {
3112 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3113}
3114
3115static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed int __a,
3116 signed int *__b, size_t __c) {
3117 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3118}
3119
3120static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned int __a,
3121 unsigned int *__b, size_t __c) {
3122 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3123}
3124
3125static __inline__ void __ATTRS_o_ai vec_xst_len(vector float __a, float *__b,
3126 size_t __c) {
3127 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3128}
3129
3130#ifdef __SIZEOF_INT128__
3131static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed __int128 __a,
3132 signed __int128 *__b,
3133 size_t __c) {
3134 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3135}
3136
3137static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned __int128 __a,
3138 unsigned __int128 *__b,
3139 size_t __c) {
3140 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3141}
3142#endif
3143
3144static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed long long __a,
3145 signed long long *__b,
3146 size_t __c) {
3147 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3148}
3149
3150static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned long long __a,
3151 unsigned long long *__b,
3152 size_t __c) {
3153 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3154}
3155
3156static __inline__ void __ATTRS_o_ai vec_xst_len(vector double __a, double *__b,
3157 size_t __c) {
3158 return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56));
3159}
3160
3161static __inline__ void __ATTRS_o_ai vec_xst_len_r(vector unsigned char __a,
3162 unsigned char *__b,
3163 size_t __c) {
3164 vector unsigned char __mask =
3165 (vector unsigned char)__builtin_altivec_lvsl(16 - __c, (int *)NULL);
3166 vector unsigned char __res =
3167 (vector unsigned char)__builtin_altivec_vperm_4si(
3168 (vector int)__a, (vector int)__a, __mask);
3169 return __builtin_vsx_stxvll((vector int)__res, __b, (__c << 56));
3170}
3171#endif
3172#endif
3173
3174#if defined(__POWER9_VECTOR__) && defined(__powerpc64__)
3175#define __vec_ldrmb(PTR, CNT) vec_xl_len_r((const unsigned char *)(PTR), (CNT))
3176#define __vec_strmb(PTR, CNT, VAL) \
3177 vec_xst_len_r((VAL), (unsigned char *)(PTR), (CNT))
3178#else
3179#define __vec_ldrmb __builtin_vsx_ldrmb
3180#define __vec_strmb __builtin_vsx_strmb
3181#endif
3182
3183/* vec_cpsgn */
3184
3185#ifdef __VSX__
3186static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a,
3187 vector float __b) {
3188 return __builtin_vsx_xvcpsgnsp(__b, __a);
3189}
3190
3191static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
3192 vector double __b) {
3193 return __builtin_vsx_xvcpsgndp(__b, __a);
3194}
3195#endif
3196
3197/* vec_ctf */
3198
3199#ifdef __VSX__
3200// There are some functions that have different signatures with the XL compiler
3201// from those in Clang/GCC and documented in the PVIPR. This macro ensures that
3202// the XL-compatible signatures are used for those functions.
3203#ifdef __XL_COMPAT_ALTIVEC__
3204#define vec_ctf(__a, __b) \
3205 _Generic((__a), \
3206 vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \
3207 ((__b)&0x1F)), \
3208 vector unsigned int: (vector float)__builtin_altivec_vcfux( \
3209 (vector unsigned int)(__a), ((__b)&0x1F)), \
3210 vector unsigned long long: ( \
3211 vector float)(__builtin_vsx_xvcvuxdsp( \
3212 (vector unsigned long long)(__a)) * \
3213 (vector float)(vector unsigned)((0x7f - \
3214 ((__b)&0x1F)) \
3215 << 23)), \
3216 vector signed long long: ( \
3217 vector float)(__builtin_vsx_xvcvsxdsp( \
3218 (vector signed long long)(__a)) * \
3219 (vector float)(vector unsigned)((0x7f - \
3220 ((__b)&0x1F)) \
3221 << 23)))
3222#else // __XL_COMPAT_ALTIVEC__
3223#define vec_ctf(__a, __b) \
3224 _Generic( \
3225 (__a), \
3226 vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \
3227 ((__b)&0x1F)), \
3228 vector unsigned int: (vector float)__builtin_altivec_vcfux( \
3229 (vector unsigned int)(__a), ((__b)&0x1F)), \
3230 vector unsigned long long: ( \
3231 vector float)(__builtin_convertvector( \
3232 (vector unsigned long long)(__a), vector double) * \
3233 (vector double)(vector unsigned long long)((0x3ffULL - \
3234 ((__b)&0x1F)) \
3235 << 52)), \
3236 vector signed long long: ( \
3237 vector float)(__builtin_convertvector( \
3238 (vector signed long long)(__a), vector double) * \
3239 (vector double)(vector unsigned long long)((0x3ffULL - \
3240 ((__b)&0x1F)) \
3241 << 52)))
3242#endif // __XL_COMPAT_ALTIVEC__
3243#else
3244#define vec_ctf(__a, __b) \
3245 _Generic((__a), \
3246 vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \
3247 ((__b)&0x1F)), \
3248 vector unsigned int: (vector float)__builtin_altivec_vcfux( \
3249 (vector unsigned int)(__a), ((__b)&0x1F)))
3250#endif
3251
3252/* vec_ctd */
3253#ifdef __VSX__
3254#define vec_ctd(__a, __b) \
3255 _Generic((__a), \
3256 vector signed int: ( \
3257 vec_doublee((vector signed int)(__a)) * \
3258 (vector double)(vector unsigned long long)((0x3ffULL - \
3259 ((__b)&0x1F)) \
3260 << 52)), \
3261 vector unsigned int: ( \
3262 vec_doublee((vector unsigned int)(__a)) * \
3263 (vector double)(vector unsigned long long)((0x3ffULL - \
3264 ((__b)&0x1F)) \
3265 << 52)), \
3266 vector unsigned long long: ( \
3267 __builtin_convertvector((vector unsigned long long)(__a), \
3268 vector double) * \
3269 (vector double)(vector unsigned long long)((0x3ffULL - \
3270 ((__b)&0x1F)) \
3271 << 52)), \
3272 vector signed long long: ( \
3273 __builtin_convertvector((vector signed long long)(__a), \
3274 vector double) * \
3275 (vector double)(vector unsigned long long)((0x3ffULL - \
3276 ((__b)&0x1F)) \
3277 << 52)))
3278#endif // __VSX__
3279
3280/* vec_vcfsx */
3281
3282#define vec_vcfux __builtin_altivec_vcfux
3283/* vec_vcfux */
3284
3285#define vec_vcfsx(__a, __b) __builtin_altivec_vcfsx((vector int)(__a), (__b))
3286
3287/* vec_cts */
3288
3289#ifdef __VSX__
3290#ifdef __XL_COMPAT_ALTIVEC__
3291#define vec_cts(__a, __b) \
3292 _Generic((__a), \
3293 vector float: (vector signed int)__builtin_altivec_vctsxs( \
3294 (vector float)(__a), ((__b)&0x1F)), \
3295 vector double: __extension__({ \
3296 vector double __ret = \
3297 (vector double)(__a) * \
3298 (vector double)(vector unsigned long long)((0x3ffULL + \
3299 ((__b)&0x1F)) \
3300 << 52); \
3301 (vector signed long long)__builtin_vsx_xvcvdpsxws(__ret); \
3302 }))
3303#else // __XL_COMPAT_ALTIVEC__
3304#define vec_cts(__a, __b) \
3305 _Generic((__a), \
3306 vector float: (vector signed int)__builtin_altivec_vctsxs( \
3307 (vector float)(__a), ((__b)&0x1F)), \
3308 vector double: __extension__({ \
3309 vector double __ret = \
3310 (vector double)(__a) * \
3311 (vector double)(vector unsigned long long)((0x3ffULL + \
3312 ((__b)&0x1F)) \
3313 << 52); \
3314 (vector signed long long)__builtin_convertvector( \
3315 __ret, vector signed long long); \
3316 }))
3317#endif // __XL_COMPAT_ALTIVEC__
3318#else
3319#define vec_cts __builtin_altivec_vctsxs
3320#endif
3321
3322/* vec_vctsxs */
3323
3324#define vec_vctsxs __builtin_altivec_vctsxs
3325
3326/* vec_ctu */
3327
3328#ifdef __VSX__
3329#ifdef __XL_COMPAT_ALTIVEC__
3330#define vec_ctu(__a, __b) \
3331 _Generic((__a), \
3332 vector float: (vector unsigned int)__builtin_altivec_vctuxs( \
3333 (vector float)(__a), ((__b)&0x1F)), \
3334 vector double: __extension__({ \
3335 vector double __ret = \
3336 (vector double)(__a) * \
3337 (vector double)(vector unsigned long long)((0x3ffULL + \
3338 ((__b)&0x1F)) \
3339 << 52); \
3340 (vector unsigned long long)__builtin_vsx_xvcvdpuxws(__ret); \
3341 }))
3342#else // __XL_COMPAT_ALTIVEC__
3343#define vec_ctu(__a, __b) \
3344 _Generic((__a), \
3345 vector float: (vector unsigned int)__builtin_altivec_vctuxs( \
3346 (vector float)(__a), ((__b)&0x1F)), \
3347 vector double: __extension__({ \
3348 vector double __ret = \
3349 (vector double)(__a) * \
3350 (vector double)(vector unsigned long long)((0x3ffULL + \
3351 ((__b)&0x1F)) \
3352 << 52); \
3353 (vector unsigned long long)__builtin_convertvector( \
3354 __ret, vector unsigned long long); \
3355 }))
3356#endif // __XL_COMPAT_ALTIVEC__
3357#else
3358#define vec_ctu __builtin_altivec_vctuxs
3359#endif
3360
3361#ifdef __LITTLE_ENDIAN__
3362/* vec_ctsl */
3363
3364#ifdef __VSX__
3365#define vec_ctsl(__a, __b) \
3366 _Generic( \
3367 (__a), vector float \
3368 : __extension__({ \
3369 vector float __ret = \
3370 (vector float)(__a) * \
3371 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \
3372 __builtin_vsx_xvcvspsxds(__builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3373 }), \
3374 vector double \
3375 : __extension__({ \
3376 vector double __ret = \
3377 (vector double)(__a) * \
3378 (vector double)(vector unsigned long long)((0x3ffULL + \
3379 ((__b)&0x1F)) \
3380 << 52); \
3381 __builtin_convertvector(__ret, vector signed long long); \
3382 }))
3383
3384/* vec_ctul */
3385
3386#define vec_ctul(__a, __b) \
3387 _Generic( \
3388 (__a), vector float \
3389 : __extension__({ \
3390 vector float __ret = \
3391 (vector float)(__a) * \
3392 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \
3393 __builtin_vsx_xvcvspuxds(__builtin_vsx_xxsldwi(__ret, __ret, 1)); \
3394 }), \
3395 vector double \
3396 : __extension__({ \
3397 vector double __ret = \
3398 (vector double)(__a) * \
3399 (vector double)(vector unsigned long long)((0x3ffULL + \
3400 ((__b)&0x1F)) \
3401 << 52); \
3402 __builtin_convertvector(__ret, vector unsigned long long); \
3403 }))
3404#endif
3405#else // __LITTLE_ENDIAN__
3406/* vec_ctsl */
3407
3408#ifdef __VSX__
3409#define vec_ctsl(__a, __b) \
3410 _Generic((__a), \
3411 vector float: __extension__({ \
3412 vector float __ret = \
3413 (vector float)(__a) * \
3414 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \
3415 __builtin_vsx_xvcvspsxds(__ret); \
3416 }), \
3417 vector double: __extension__({ \
3418 vector double __ret = \
3419 (vector double)(__a) * \
3420 (vector double)(vector unsigned long long)((0x3ffULL + \
3421 ((__b)&0x1F)) \
3422 << 52); \
3423 __builtin_convertvector(__ret, vector signed long long); \
3424 }))
3425
3426/* vec_ctul */
3427
3428#define vec_ctul(__a, __b) \
3429 _Generic((__a), vector float \
3430 : __extension__({ \
3431 vector float __ret = \
3432 (vector float)(__a) * \
3433 (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) \
3434 << 23); \
3435 __builtin_vsx_xvcvspuxds(__ret); \
3436 }), \
3437 vector double \
3438 : __extension__({ \
3439 vector double __ret = \
3440 (vector double)(__a) * \
3441 (vector double)(vector unsigned long long)((0x3ffULL + \
3442 ((__b)&0x1F)) \
3443 << 52); \
3444 __builtin_convertvector(__ret, vector unsigned long long); \
3445 }))
3446#endif
3447#endif // __LITTLE_ENDIAN__
3448
3449/* vec_vctuxs */
3450
3451#define vec_vctuxs __builtin_altivec_vctuxs
3452
3453/* vec_signext */
3454
3455#ifdef __POWER9_VECTOR__
3456static __inline__ vector signed int __ATTRS_o_ai
3457vec_signexti(vector signed char __a) {
3458 return __builtin_altivec_vextsb2w(__a);
3459}
3460
3461static __inline__ vector signed int __ATTRS_o_ai
3462vec_signexti(vector signed short __a) {
3463 return __builtin_altivec_vextsh2w(__a);
3464}
3465
3466static __inline__ vector signed long long __ATTRS_o_ai
3467vec_signextll(vector signed char __a) {
3468 return __builtin_altivec_vextsb2d(__a);
3469}
3470
3471static __inline__ vector signed long long __ATTRS_o_ai
3472vec_signextll(vector signed short __a) {
3473 return __builtin_altivec_vextsh2d(__a);
3474}
3475
3476static __inline__ vector signed long long __ATTRS_o_ai
3477vec_signextll(vector signed int __a) {
3478 return __builtin_altivec_vextsw2d(__a);
3479}
3480#endif
3481
3482#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
3483static __inline__ vector signed __int128 __ATTRS_o_ai
3484vec_signextq(vector signed long long __a) {
3485 return __builtin_altivec_vextsd2q(__a);
3486}
3487#endif
3488
3489/* vec_signed */
3490
3491static __inline__ vector signed int __ATTRS_o_ai
3492vec_sld(vector signed int, vector signed int, unsigned const int __c);
3493
3494static __inline__ vector signed int __ATTRS_o_ai
3495vec_signed(vector float __a) {
3496 return __builtin_convertvector(__a, vector signed int);
3497}
3498
3499#ifdef __VSX__
3500static __inline__ vector signed long long __ATTRS_o_ai
3501vec_signed(vector double __a) {
3502 return __builtin_convertvector(__a, vector signed long long);
3503}
3504
3505static __inline__ vector signed int __attribute__((__always_inline__))
3506vec_signed2(vector double __a, vector double __b) {
3507 return (vector signed int) { __a[0], __a[1], __b[0], __b[1] };
3508}
3509
3510static __inline__ vector signed int __ATTRS_o_ai
3511vec_signede(vector double __a) {
3512#ifdef __LITTLE_ENDIAN__
3513 vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a);
3514 return vec_sld(__ret, __ret, 12);
3515#else
3516 return __builtin_vsx_xvcvdpsxws(__a);
3517#endif
3518}
3519
3520static __inline__ vector signed int __ATTRS_o_ai
3521vec_signedo(vector double __a) {
3522#ifdef __LITTLE_ENDIAN__
3523 return __builtin_vsx_xvcvdpsxws(__a);
3524#else
3525 vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a);
3526 return vec_sld(__ret, __ret, 12);
3527#endif
3528}
3529#endif
3530
3531/* vec_unsigned */
3532
3533static __inline__ vector unsigned int __ATTRS_o_ai
3534vec_sld(vector unsigned int, vector unsigned int, unsigned const int __c);
3535
3536static __inline__ vector unsigned int __ATTRS_o_ai
3537vec_unsigned(vector float __a) {
3538 return __builtin_convertvector(__a, vector unsigned int);
3539}
3540
3541#ifdef __VSX__
3542static __inline__ vector unsigned long long __ATTRS_o_ai
3543vec_unsigned(vector double __a) {
3544 return __builtin_convertvector(__a, vector unsigned long long);
3545}
3546
3547static __inline__ vector unsigned int __attribute__((__always_inline__))
3548vec_unsigned2(vector double __a, vector double __b) {
3549 return (vector unsigned int) { __a[0], __a[1], __b[0], __b[1] };
3550}
3551
3552static __inline__ vector unsigned int __ATTRS_o_ai
3553vec_unsignede(vector double __a) {
3554#ifdef __LITTLE_ENDIAN__
3555 vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a);
3556 return vec_sld(__ret, __ret, 12);
3557#else
3558 return __builtin_vsx_xvcvdpuxws(__a);
3559#endif
3560}
3561
3562static __inline__ vector unsigned int __ATTRS_o_ai
3563vec_unsignedo(vector double __a) {
3564#ifdef __LITTLE_ENDIAN__
3565 return __builtin_vsx_xvcvdpuxws(__a);
3566#else
3567 vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a);
3568 return vec_sld(__ret, __ret, 12);
3569#endif
3570}
3571#endif
3572
3573/* vec_float */
3574
3575static __inline__ vector float __ATTRS_o_ai
3576vec_sld(vector float, vector float, unsigned const int __c);
3577
3578static __inline__ vector float __ATTRS_o_ai
3579vec_float(vector signed int __a) {
3580 return __builtin_convertvector(__a, vector float);
3581}
3582
3583static __inline__ vector float __ATTRS_o_ai
3584vec_float(vector unsigned int __a) {
3585 return __builtin_convertvector(__a, vector float);
3586}
3587
3588#ifdef __VSX__
3589static __inline__ vector float __ATTRS_o_ai
3590vec_float2(vector signed long long __a, vector signed long long __b) {
3591 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3592}
3593
3594static __inline__ vector float __ATTRS_o_ai
3595vec_float2(vector unsigned long long __a, vector unsigned long long __b) {
3596 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3597}
3598
3599static __inline__ vector float __ATTRS_o_ai
3600vec_float2(vector double __a, vector double __b) {
3601 return (vector float) { __a[0], __a[1], __b[0], __b[1] };
3602}
3603
3604static __inline__ vector float __ATTRS_o_ai
3605vec_floate(vector signed long long __a) {
3606#ifdef __LITTLE_ENDIAN__
3607 vector float __ret = __builtin_vsx_xvcvsxdsp(__a);
3608 return vec_sld(__ret, __ret, 12);
3609#else
3610 return __builtin_vsx_xvcvsxdsp(__a);
3611#endif
3612}
3613
3614static __inline__ vector float __ATTRS_o_ai
3615vec_floate(vector unsigned long long __a) {
3616#ifdef __LITTLE_ENDIAN__
3617 vector float __ret = __builtin_vsx_xvcvuxdsp(__a);
3618 return vec_sld(__ret, __ret, 12);
3619#else
3620 return __builtin_vsx_xvcvuxdsp(__a);
3621#endif
3622}
3623
3624static __inline__ vector float __ATTRS_o_ai
3625vec_floate(vector double __a) {
3626#ifdef __LITTLE_ENDIAN__
3627 vector float __ret = __builtin_vsx_xvcvdpsp(__a);
3628 return vec_sld(__ret, __ret, 12);
3629#else
3630 return __builtin_vsx_xvcvdpsp(__a);
3631#endif
3632}
3633
3634static __inline__ vector float __ATTRS_o_ai
3635vec_floato(vector signed long long __a) {
3636#ifdef __LITTLE_ENDIAN__
3637 return __builtin_vsx_xvcvsxdsp(__a);
3638#else
3639 vector float __ret = __builtin_vsx_xvcvsxdsp(__a);
3640 return vec_sld(__ret, __ret, 12);
3641#endif
3642}
3643
3644static __inline__ vector float __ATTRS_o_ai
3645vec_floato(vector unsigned long long __a) {
3646#ifdef __LITTLE_ENDIAN__
3647 return __builtin_vsx_xvcvuxdsp(__a);
3648#else
3649 vector float __ret = __builtin_vsx_xvcvuxdsp(__a);
3650 return vec_sld(__ret, __ret, 12);
3651#endif
3652}
3653
3654static __inline__ vector float __ATTRS_o_ai
3655vec_floato(vector double __a) {
3656#ifdef __LITTLE_ENDIAN__
3657 return __builtin_vsx_xvcvdpsp(__a);
3658#else
3659 vector float __ret = __builtin_vsx_xvcvdpsp(__a);
3660 return vec_sld(__ret, __ret, 12);
3661#endif
3662}
3663#endif
3664
3665/* vec_double */
3666
3667#ifdef __VSX__
3668static __inline__ vector double __ATTRS_o_ai
3669vec_double(vector signed long long __a) {
3670 return __builtin_convertvector(__a, vector double);
3671}
3672
3673static __inline__ vector double __ATTRS_o_ai
3674vec_double(vector unsigned long long __a) {
3675 return __builtin_convertvector(__a, vector double);
3676}
3677
3678static __inline__ vector double __ATTRS_o_ai
3679vec_doublee(vector signed int __a) {
3680#ifdef __LITTLE_ENDIAN__
3681 return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4));
3682#else
3683 return __builtin_vsx_xvcvsxwdp(__a);
3684#endif
3685}
3686
3687static __inline__ vector double __ATTRS_o_ai
3688vec_doublee(vector unsigned int __a) {
3689#ifdef __LITTLE_ENDIAN__
3690 return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4));
3691#else
3692 return __builtin_vsx_xvcvuxwdp(__a);
3693#endif
3694}
3695
3696static __inline__ vector double __ATTRS_o_ai
3697vec_doublee(vector float __a) {
3698#ifdef __LITTLE_ENDIAN__
3699 return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4));
3700#else
3701 return __builtin_vsx_xvcvspdp(__a);
3702#endif
3703}
3704
3705static __inline__ vector double __ATTRS_o_ai
3706vec_doubleh(vector signed int __a) {
3707 vector double __ret = {__a[0], __a[1]};
3708 return __ret;
3709}
3710
3711static __inline__ vector double __ATTRS_o_ai
3712vec_doubleh(vector unsigned int __a) {
3713 vector double __ret = {__a[0], __a[1]};
3714 return __ret;
3715}
3716
3717static __inline__ vector double __ATTRS_o_ai
3718vec_doubleh(vector float __a) {
3719 vector double __ret = {__a[0], __a[1]};
3720 return __ret;
3721}
3722
3723static __inline__ vector double __ATTRS_o_ai
3724vec_doublel(vector signed int __a) {
3725 vector double __ret = {__a[2], __a[3]};
3726 return __ret;
3727}
3728
3729static __inline__ vector double __ATTRS_o_ai
3730vec_doublel(vector unsigned int __a) {
3731 vector double __ret = {__a[2], __a[3]};
3732 return __ret;
3733}
3734
3735static __inline__ vector double __ATTRS_o_ai
3736vec_doublel(vector float __a) {
3737 vector double __ret = {__a[2], __a[3]};
3738 return __ret;
3739}
3740
3741static __inline__ vector double __ATTRS_o_ai
3742vec_doubleo(vector signed int __a) {
3743#ifdef __LITTLE_ENDIAN__
3744 return __builtin_vsx_xvcvsxwdp(__a);
3745#else
3746 return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4));
3747#endif
3748}
3749
3750static __inline__ vector double __ATTRS_o_ai
3751vec_doubleo(vector unsigned int __a) {
3752#ifdef __LITTLE_ENDIAN__
3753 return __builtin_vsx_xvcvuxwdp(__a);
3754#else
3755 return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4));
3756#endif
3757}
3758
3759static __inline__ vector double __ATTRS_o_ai
3760vec_doubleo(vector float __a) {
3761#ifdef __LITTLE_ENDIAN__
3762 return __builtin_vsx_xvcvspdp(__a);
3763#else
3764 return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4));
3765#endif
3766}
3767
3768/* vec_cvf */
3769static __inline__ vector double __ATTRS_o_ai vec_cvf(vector float __a) {
3770 return vec_doublee(__a);
3771}
3772
3773static __inline__ vector float __ATTRS_o_ai vec_cvf(vector double __a) {
3774 return vec_floate(__a);
3775}
3776#endif
3777
3778/* vec_div */
3779
3780/* Integer vector divides (vectors are scalarized, elements divided
3781 and the vectors reassembled).
3782*/
3783static __inline__ vector signed char __ATTRS_o_ai
3784vec_div(vector signed char __a, vector signed char __b) {
3785 return __a / __b;
3786}
3787
3788static __inline__ vector unsigned char __ATTRS_o_ai
3789vec_div(vector unsigned char __a, vector unsigned char __b) {
3790 return __a / __b;
3791}
3792
3793static __inline__ vector signed short __ATTRS_o_ai
3794vec_div(vector signed short __a, vector signed short __b) {
3795 return __a / __b;
3796}
3797
3798static __inline__ vector unsigned short __ATTRS_o_ai
3799vec_div(vector unsigned short __a, vector unsigned short __b) {
3800 return __a / __b;
3801}
3802
3803static __inline__ vector signed int __ATTRS_o_ai
3804vec_div(vector signed int __a, vector signed int __b) {
3805 return __a / __b;
3806}
3807
3808static __inline__ vector unsigned int __ATTRS_o_ai
3809vec_div(vector unsigned int __a, vector unsigned int __b) {
3810 return __a / __b;
3811}
3812
3813#ifdef __VSX__
3814static __inline__ vector signed long long __ATTRS_o_ai
3815vec_div(vector signed long long __a, vector signed long long __b) {
3816 return __a / __b;
3817}
3818
3819static __inline__ vector unsigned long long __ATTRS_o_ai
3820vec_div(vector unsigned long long __a, vector unsigned long long __b) {
3821 return __a / __b;
3822}
3823
3824static __inline__ vector float __ATTRS_o_ai vec_div(vector float __a,
3825 vector float __b) {
3826 return __a / __b;
3827}
3828
3829static __inline__ vector double __ATTRS_o_ai vec_div(vector double __a,
3830 vector double __b) {
3831 return __a / __b;
3832}
3833#endif
3834
3835/* vec_dive */
3836
3837#ifdef __POWER10_VECTOR__
3838static __inline__ vector signed int __ATTRS_o_ai
3839vec_dive(vector signed int __a, vector signed int __b) {
3840 return __builtin_altivec_vdivesw(__a, __b);
3841}
3842
3843static __inline__ vector unsigned int __ATTRS_o_ai
3844vec_dive(vector unsigned int __a, vector unsigned int __b) {
3845 return __builtin_altivec_vdiveuw(__a, __b);
3846}
3847
3848static __inline__ vector signed long long __ATTRS_o_ai
3849vec_dive(vector signed long long __a, vector signed long long __b) {
3850 return __builtin_altivec_vdivesd(__a, __b);
3851}
3852
3853static __inline__ vector unsigned long long __ATTRS_o_ai
3854vec_dive(vector unsigned long long __a, vector unsigned long long __b) {
3855 return __builtin_altivec_vdiveud(__a, __b);
3856}
3857
3858#ifdef __SIZEOF_INT128__
3859static __inline__ vector unsigned __int128 __ATTRS_o_ai
3860vec_dive(vector unsigned __int128 __a, vector unsigned __int128 __b) {
3861 return __builtin_altivec_vdiveuq(__a, __b);
3862}
3863
3864static __inline__ vector signed __int128 __ATTRS_o_ai
3865vec_dive(vector signed __int128 __a, vector signed __int128 __b) {
3866 return __builtin_altivec_vdivesq(__a, __b);
3867}
3868#endif
3869#endif
3870
3871#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__)
3872static __inline__ vector unsigned __int128 __ATTRS_o_ai
3873vec_div(vector unsigned __int128 __a, vector unsigned __int128 __b) {
3874 return __a / __b;
3875}
3876
3877static __inline__ vector signed __int128 __ATTRS_o_ai
3878vec_div(vector signed __int128 __a, vector signed __int128 __b) {
3879 return __a / __b;
3880}
3881#endif /* __POWER10_VECTOR__ */
3882
3883/* vec_xvtdiv */
3884
3885#ifdef __VSX__
3886static __inline__ int __ATTRS_o_ai vec_test_swdiv(vector double __a,
3887 vector double __b) {
3888 return __builtin_vsx_xvtdivdp(__a, __b);
3889}
3890
3891static __inline__ int __ATTRS_o_ai vec_test_swdivs(vector float __a,
3892 vector float __b) {
3893 return __builtin_vsx_xvtdivsp(__a, __b);
3894}
3895#endif
3896
3897/* vec_dss */
3898
3899#define vec_dss __builtin_altivec_dss
3900
3901/* vec_dssall */
3902
3903static __inline__ void __attribute__((__always_inline__)) vec_dssall(void) {
3904 __builtin_altivec_dssall();
3905}
3906
3907/* vec_dst */
3908#define vec_dst(__PTR, __CW, __STR) \
3909 __builtin_altivec_dst((const void *)(__PTR), (__CW), (__STR))
3910
3911/* vec_dstst */
3912#define vec_dstst(__PTR, __CW, __STR) \
3913 __builtin_altivec_dstst((const void *)(__PTR), (__CW), (__STR))
3914
3915/* vec_dststt */
3916#define vec_dststt(__PTR, __CW, __STR) \
3917 __builtin_altivec_dststt((const void *)(__PTR), (__CW), (__STR))
3918
3919/* vec_dstt */
3920#define vec_dstt(__PTR, __CW, __STR) \
3921 __builtin_altivec_dstt((const void *)(__PTR), (__CW), (__STR))
3922
3923/* vec_eqv */
3924
3925#ifdef __POWER8_VECTOR__
3926static __inline__ vector signed char __ATTRS_o_ai
3927vec_eqv(vector signed char __a, vector signed char __b) {
3928 return (vector signed char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3929 (vector unsigned int)__b);
3930}
3931
3932static __inline__ vector unsigned char __ATTRS_o_ai
3933vec_eqv(vector unsigned char __a, vector unsigned char __b) {
3934 return (vector unsigned char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3935 (vector unsigned int)__b);
3936}
3937
3938static __inline__ vector bool char __ATTRS_o_ai vec_eqv(vector bool char __a,
3939 vector bool char __b) {
3940 return (vector bool char)__builtin_vsx_xxleqv((vector unsigned int)__a,
3941 (vector unsigned int)__b);
3942}
3943
3944static __inline__ vector signed short __ATTRS_o_ai
3945vec_eqv(vector signed short __a, vector signed short __b) {
3946 return (vector signed short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3947 (vector unsigned int)__b);
3948}
3949
3950static __inline__ vector unsigned short __ATTRS_o_ai
3951vec_eqv(vector unsigned short __a, vector unsigned short __b) {
3952 return (vector unsigned short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3953 (vector unsigned int)__b);
3954}
3955
3956static __inline__ vector bool short __ATTRS_o_ai
3957vec_eqv(vector bool short __a, vector bool short __b) {
3958 return (vector bool short)__builtin_vsx_xxleqv((vector unsigned int)__a,
3959 (vector unsigned int)__b);
3960}
3961
3962static __inline__ vector signed int __ATTRS_o_ai
3963vec_eqv(vector signed int __a, vector signed int __b) {
3964 return (vector signed int)__builtin_vsx_xxleqv((vector unsigned int)__a,
3965 (vector unsigned int)__b);
3966}
3967
3968static __inline__ vector unsigned int __ATTRS_o_ai
3969vec_eqv(vector unsigned int __a, vector unsigned int __b) {
3970 return __builtin_vsx_xxleqv(__a, __b);
3971}
3972
3973static __inline__ vector bool int __ATTRS_o_ai vec_eqv(vector bool int __a,
3974 vector bool int __b) {
3975 return (vector bool int)__builtin_vsx_xxleqv((vector unsigned int)__a,
3976 (vector unsigned int)__b);
3977}
3978
3979static __inline__ vector signed long long __ATTRS_o_ai
3980vec_eqv(vector signed long long __a, vector signed long long __b) {
3981 return (vector signed long long)__builtin_vsx_xxleqv(
3982 (vector unsigned int)__a, (vector unsigned int)__b);
3983}
3984
3985static __inline__ vector unsigned long long __ATTRS_o_ai
3986vec_eqv(vector unsigned long long __a, vector unsigned long long __b) {
3987 return (vector unsigned long long)__builtin_vsx_xxleqv(
3988 (vector unsigned int)__a, (vector unsigned int)__b);
3989}
3990
3991static __inline__ vector bool long long __ATTRS_o_ai
3992vec_eqv(vector bool long long __a, vector bool long long __b) {
3993 return (vector bool long long)__builtin_vsx_xxleqv((vector unsigned int)__a,
3994 (vector unsigned int)__b);
3995}
3996
3997static __inline__ vector float __ATTRS_o_ai vec_eqv(vector float __a,
3998 vector float __b) {
3999 return (vector float)__builtin_vsx_xxleqv((vector unsigned int)__a,
4000 (vector unsigned int)__b);
4001}
4002
4003static __inline__ vector double __ATTRS_o_ai vec_eqv(vector double __a,
4004 vector double __b) {
4005 return (vector double)__builtin_vsx_xxleqv((vector unsigned int)__a,
4006 (vector unsigned int)__b);
4007}
4008#endif
4009
4010/* vec_expte */
4011
4012static __inline__ vector float __attribute__((__always_inline__))
4013vec_expte(vector float __a) {
4014 return __builtin_altivec_vexptefp(__a);
4015}
4016
4017/* vec_vexptefp */
4018
4019static __inline__ vector float __attribute__((__always_inline__))
4020vec_vexptefp(vector float __a) {
4021 return __builtin_altivec_vexptefp(__a);
4022}
4023
4024/* vec_floor */
4025
4026static __inline__ vector float __ATTRS_o_ai vec_floor(vector float __a) {
4027#ifdef __VSX__
4028 return __builtin_vsx_xvrspim(__a);
4029#else
4030 return __builtin_altivec_vrfim(__a);
4031#endif
4032}
4033
4034#ifdef __VSX__
4035static __inline__ vector double __ATTRS_o_ai vec_floor(vector double __a) {
4036 return __builtin_vsx_xvrdpim(__a);
4037}
4038#endif
4039
4040/* vec_roundm */
4041static __inline__ vector float __ATTRS_o_ai vec_roundm(vector float __a) {
4042 return vec_floor(__a);
4043}
4044
4045#ifdef __VSX__
4046static __inline__ vector double __ATTRS_o_ai vec_roundm(vector double __a) {
4047 return vec_floor(__a);
4048}
4049#endif
4050
4051/* vec_vrfim */
4052
4053static __inline__ vector float __attribute__((__always_inline__))
4054vec_vrfim(vector float __a) {
4055 return __builtin_altivec_vrfim(__a);
4056}
4057
4058/* vec_ld */
4059
4060static __inline__ vector signed char __ATTRS_o_ai
4061vec_ld(long __a, const vector signed char *__b) {
4062 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4063}
4064
4065static __inline__ vector signed char __ATTRS_o_ai
4066vec_ld(long __a, const signed char *__b) {
4067 return (vector signed char)__builtin_altivec_lvx(__a, __b);
4068}
4069
4070static __inline__ vector unsigned char __ATTRS_o_ai
4071vec_ld(long __a, const vector unsigned char *__b) {
4072 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4073}
4074
4075static __inline__ vector unsigned char __ATTRS_o_ai
4076vec_ld(long __a, const unsigned char *__b) {
4077 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
4078}
4079
4080static __inline__ vector bool char __ATTRS_o_ai
4081vec_ld(long __a, const vector bool char *__b) {
4082 return (vector bool char)__builtin_altivec_lvx(__a, __b);
4083}
4084
4085static __inline__ vector short __ATTRS_o_ai vec_ld(long __a,
4086 const vector short *__b) {
4087 return (vector short)__builtin_altivec_lvx(__a, __b);
4088}
4089
4090static __inline__ vector short __ATTRS_o_ai vec_ld(long __a, const short *__b) {
4091 return (vector short)__builtin_altivec_lvx(__a, __b);
4092}
4093
4094static __inline__ vector unsigned short __ATTRS_o_ai
4095vec_ld(long __a, const vector unsigned short *