blob: 77bc92861591ce23456bd78b46a78e689f3ffe2a [file] [log] [blame]
Chris Lattnerdad40622010-04-14 03:54:58 +00001/*===---- altivec.h - Standard header for type generic math ---------------===*\
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21\*===----------------------------------------------------------------------===*/
22
23#ifndef __ALTIVEC_H
24#define __ALTIVEC_H
25
26#ifndef __ALTIVEC__
27#error "AltiVec support not enabled"
28#endif
29
Eric Christopher7f7d9be2015-12-28 19:07:46 +000030/* Constants for mapping CR6 bits to predicate result. */
Chris Lattnerdad40622010-04-14 03:54:58 +000031
Bill Seurer703e8482015-06-09 14:39:47 +000032#define __CR6_EQ 0
Chris Lattnerdad40622010-04-14 03:54:58 +000033#define __CR6_EQ_REV 1
Bill Seurer703e8482015-06-09 14:39:47 +000034#define __CR6_LT 2
Chris Lattnerdad40622010-04-14 03:54:58 +000035#define __CR6_LT_REV 3
36
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000037#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
38
Daniel Jasperbe508362016-03-11 22:13:28 +000039static __inline__ vector signed char __ATTRS_o_ai vec_perm(
40 vector signed char __a, vector signed char __b, vector unsigned char __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000041
Daniel Jasperbe508362016-03-11 22:13:28 +000042static __inline__ vector unsigned char __ATTRS_o_ai
43vec_perm(vector unsigned char __a, vector unsigned char __b,
44 vector unsigned char __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000045
Daniel Jasperbe508362016-03-11 22:13:28 +000046static __inline__ vector bool char __ATTRS_o_ai
47vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c);
Anton Yartsev9e968982010-08-19 03:00:09 +000048
Daniel Jasperbe508362016-03-11 22:13:28 +000049static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a,
50 vector signed short __b,
51 vector unsigned char __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000052
Daniel Jasperbe508362016-03-11 22:13:28 +000053static __inline__ vector unsigned short __ATTRS_o_ai
54vec_perm(vector unsigned short __a, vector unsigned short __b,
55 vector unsigned char __c);
56
57static __inline__ vector bool short __ATTRS_o_ai vec_perm(
58 vector bool short __a, vector bool short __b, vector unsigned char __c);
59
60static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a,
61 vector pixel __b,
62 vector unsigned char __c);
63
64static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a,
65 vector signed int __b,
Bill Seurer703e8482015-06-09 14:39:47 +000066 vector unsigned char __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000067
Daniel Jasperbe508362016-03-11 22:13:28 +000068static __inline__ vector unsigned int __ATTRS_o_ai vec_perm(
69 vector unsigned int __a, vector unsigned int __b, vector unsigned char __c);
Anton Yartsev9e968982010-08-19 03:00:09 +000070
Daniel Jasperbe508362016-03-11 22:13:28 +000071static __inline__ vector bool int __ATTRS_o_ai
72vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c);
Anton Yartsev9e968982010-08-19 03:00:09 +000073
Daniel Jasperbe508362016-03-11 22:13:28 +000074static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a,
75 vector float __b,
76 vector unsigned char __c);
Chris Lattnerdad40622010-04-14 03:54:58 +000077
Bill Schmidt41e14c42015-05-16 01:02:25 +000078#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000079static __inline__ vector long long __ATTRS_o_ai
80vec_perm(vector signed long long __a, vector signed long long __b,
81 vector unsigned char __c);
Bill Schmidt41e14c42015-05-16 01:02:25 +000082
Daniel Jasperbe508362016-03-11 22:13:28 +000083static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Schmidt41e14c42015-05-16 01:02:25 +000084vec_perm(vector unsigned long long __a, vector unsigned long long __b,
85 vector unsigned char __c);
86
Daniel Jasperbe508362016-03-11 22:13:28 +000087static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic26c35342015-07-10 13:11:34 +000088vec_perm(vector bool long long __a, vector bool long long __b,
89 vector unsigned char __c);
90
Daniel Jasperbe508362016-03-11 22:13:28 +000091static __inline__ vector double __ATTRS_o_ai vec_perm(vector double __a,
92 vector double __b,
93 vector unsigned char __c);
Bill Schmidt41e14c42015-05-16 01:02:25 +000094#endif
95
Daniel Jasperbe508362016-03-11 22:13:28 +000096static __inline__ vector unsigned char __ATTRS_o_ai
97vec_xor(vector unsigned char __a, vector unsigned char __b);
Bill Schmidtf7e289c2014-06-05 19:07:40 +000098
Chris Lattnerdad40622010-04-14 03:54:58 +000099/* vec_abs */
100
Chris Lattnerdad40622010-04-14 03:54:58 +0000101#define __builtin_altivec_abs_v16qi vec_abs
Bill Seurer703e8482015-06-09 14:39:47 +0000102#define __builtin_altivec_abs_v8hi vec_abs
103#define __builtin_altivec_abs_v4si vec_abs
Chris Lattnerdad40622010-04-14 03:54:58 +0000104
Daniel Jasperbe508362016-03-11 22:13:28 +0000105static __inline__ vector signed char __ATTRS_o_ai
106vec_abs(vector signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000107 return __builtin_altivec_vmaxsb(__a, -__a);
Chris Lattnerdad40622010-04-14 03:54:58 +0000108}
109
Daniel Jasperbe508362016-03-11 22:13:28 +0000110static __inline__ vector signed short __ATTRS_o_ai
111vec_abs(vector signed short __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000112 return __builtin_altivec_vmaxsh(__a, -__a);
Chris Lattnerdad40622010-04-14 03:54:58 +0000113}
114
Daniel Jasperbe508362016-03-11 22:13:28 +0000115static __inline__ vector signed int __ATTRS_o_ai
116vec_abs(vector signed int __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000117 return __builtin_altivec_vmaxsw(__a, -__a);
Chris Lattnerdad40622010-04-14 03:54:58 +0000118}
119
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000120#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +0000121static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000122vec_abs(vector signed long long __a) {
123 return __builtin_altivec_vmaxsd(__a, -__a);
124}
125#endif
126
Daniel Jasperbe508362016-03-11 22:13:28 +0000127static __inline__ vector float __ATTRS_o_ai vec_abs(vector float __a) {
Kit Bartonfbab1582016-03-09 19:28:31 +0000128#ifdef __VSX__
129 return __builtin_vsx_xvabssp(__a);
130#else
Bill Seurer703e8482015-06-09 14:39:47 +0000131 vector unsigned int __res =
132 (vector unsigned int)__a & (vector unsigned int)(0x7FFFFFFF);
David Blaikie3302f2b2013-01-16 23:08:36 +0000133 return (vector float)__res;
Kit Bartonfbab1582016-03-09 19:28:31 +0000134#endif
Chris Lattnerdad40622010-04-14 03:54:58 +0000135}
136
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000137#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +0000138static __inline__ vector double __ATTRS_o_ai vec_abs(vector double __a) {
Kit Bartonfbab1582016-03-09 19:28:31 +0000139 return __builtin_vsx_xvabsdp(__a);
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000140}
141#endif
Chris Lattnerdad40622010-04-14 03:54:58 +0000142
Sean Silvae4c37602015-09-12 02:55:19 +0000143/* vec_abss */
Chris Lattnerdad40622010-04-14 03:54:58 +0000144#define __builtin_altivec_abss_v16qi vec_abss
Bill Seurer703e8482015-06-09 14:39:47 +0000145#define __builtin_altivec_abss_v8hi vec_abss
146#define __builtin_altivec_abss_v4si vec_abss
Chris Lattnerdad40622010-04-14 03:54:58 +0000147
Daniel Jasperbe508362016-03-11 22:13:28 +0000148static __inline__ vector signed char __ATTRS_o_ai
149vec_abss(vector signed char __a) {
Bill Seurer703e8482015-06-09 14:39:47 +0000150 return __builtin_altivec_vmaxsb(
151 __a, __builtin_altivec_vsubsbs((vector signed char)(0), __a));
Chris Lattnerdad40622010-04-14 03:54:58 +0000152}
153
Daniel Jasperbe508362016-03-11 22:13:28 +0000154static __inline__ vector signed short __ATTRS_o_ai
155vec_abss(vector signed short __a) {
Bill Seurer703e8482015-06-09 14:39:47 +0000156 return __builtin_altivec_vmaxsh(
157 __a, __builtin_altivec_vsubshs((vector signed short)(0), __a));
Chris Lattnerdad40622010-04-14 03:54:58 +0000158}
159
Daniel Jasperbe508362016-03-11 22:13:28 +0000160static __inline__ vector signed int __ATTRS_o_ai
161vec_abss(vector signed int __a) {
Bill Seurer703e8482015-06-09 14:39:47 +0000162 return __builtin_altivec_vmaxsw(
163 __a, __builtin_altivec_vsubsws((vector signed int)(0), __a));
Chris Lattnerdad40622010-04-14 03:54:58 +0000164}
165
166/* vec_add */
167
Daniel Jasperbe508362016-03-11 22:13:28 +0000168static __inline__ vector signed char __ATTRS_o_ai
169vec_add(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000170 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000171}
172
Daniel Jasperbe508362016-03-11 22:13:28 +0000173static __inline__ vector signed char __ATTRS_o_ai
174vec_add(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000175 return (vector signed char)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000176}
177
Daniel Jasperbe508362016-03-11 22:13:28 +0000178static __inline__ vector signed char __ATTRS_o_ai
179vec_add(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000180 return __a + (vector signed char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000181}
182
Daniel Jasperbe508362016-03-11 22:13:28 +0000183static __inline__ vector unsigned char __ATTRS_o_ai
184vec_add(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000185 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000186}
187
Daniel Jasperbe508362016-03-11 22:13:28 +0000188static __inline__ vector unsigned char __ATTRS_o_ai
189vec_add(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000190 return (vector unsigned char)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000191}
192
Daniel Jasperbe508362016-03-11 22:13:28 +0000193static __inline__ vector unsigned char __ATTRS_o_ai
194vec_add(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000195 return __a + (vector unsigned char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000196}
197
Daniel Jasperbe508362016-03-11 22:13:28 +0000198static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a,
199 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000200 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000201}
202
Daniel Jasperbe508362016-03-11 22:13:28 +0000203static __inline__ vector short __ATTRS_o_ai vec_add(vector bool short __a,
204 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000205 return (vector short)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000206}
207
Daniel Jasperbe508362016-03-11 22:13:28 +0000208static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a,
209 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000210 return __a + (vector short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000211}
212
Daniel Jasperbe508362016-03-11 22:13:28 +0000213static __inline__ vector unsigned short __ATTRS_o_ai
214vec_add(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000215 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000216}
217
Daniel Jasperbe508362016-03-11 22:13:28 +0000218static __inline__ vector unsigned short __ATTRS_o_ai
219vec_add(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000220 return (vector unsigned short)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000221}
222
Daniel Jasperbe508362016-03-11 22:13:28 +0000223static __inline__ vector unsigned short __ATTRS_o_ai
224vec_add(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000225 return __a + (vector unsigned short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000226}
227
Daniel Jasperbe508362016-03-11 22:13:28 +0000228static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a,
229 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000230 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000231}
232
Daniel Jasperbe508362016-03-11 22:13:28 +0000233static __inline__ vector int __ATTRS_o_ai vec_add(vector bool int __a,
234 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000235 return (vector int)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000236}
237
Daniel Jasperbe508362016-03-11 22:13:28 +0000238static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a,
239 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000240 return __a + (vector int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000241}
242
Daniel Jasperbe508362016-03-11 22:13:28 +0000243static __inline__ vector unsigned int __ATTRS_o_ai
244vec_add(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000245 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000246}
247
Daniel Jasperbe508362016-03-11 22:13:28 +0000248static __inline__ vector unsigned int __ATTRS_o_ai
249vec_add(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000250 return (vector unsigned int)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000251}
252
Daniel Jasperbe508362016-03-11 22:13:28 +0000253static __inline__ vector unsigned int __ATTRS_o_ai
254vec_add(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000255 return __a + (vector unsigned int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000256}
257
Kit Barton5944ee212015-05-25 15:52:45 +0000258#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +0000259static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000260vec_add(vector signed long long __a, vector signed long long __b) {
261 return __a + __b;
262}
263
Daniel Jasperbe508362016-03-11 22:13:28 +0000264static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000265vec_add(vector unsigned long long __a, vector unsigned long long __b) {
266 return __a + __b;
267}
268
Daniel Jasperbe508362016-03-11 22:13:28 +0000269static __inline__ vector signed __int128 __ATTRS_o_ai
270vec_add(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +0000271 return __a + __b;
272}
273
Daniel Jasperbe508362016-03-11 22:13:28 +0000274static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000275vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +0000276 return __a + __b;
277}
278#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
279
Daniel Jasperbe508362016-03-11 22:13:28 +0000280static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
281 vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000282 return __a + __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000283}
284
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000285#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +0000286static __inline__ vector double __ATTRS_o_ai vec_add(vector double __a,
287 vector double __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000288 return __a + __b;
289}
290#endif // __VSX__
291
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000292/* vec_adde */
293
294#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +0000295static __inline__ vector signed __int128 __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000296vec_adde(vector signed __int128 __a, vector signed __int128 __b,
297 vector signed __int128 __c) {
298 return __builtin_altivec_vaddeuqm(__a, __b, __c);
299}
300
Daniel Jasperbe508362016-03-11 22:13:28 +0000301static __inline__ vector unsigned __int128 __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000302vec_adde(vector unsigned __int128 __a, vector unsigned __int128 __b,
303 vector unsigned __int128 __c) {
304 return __builtin_altivec_vaddeuqm(__a, __b, __c);
305}
306#endif
307
308/* vec_addec */
309
310#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +0000311static __inline__ vector signed __int128 __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000312vec_addec(vector signed __int128 __a, vector signed __int128 __b,
313 vector signed __int128 __c) {
314 return __builtin_altivec_vaddecuq(__a, __b, __c);
315}
316
Daniel Jasperbe508362016-03-11 22:13:28 +0000317static __inline__ vector unsigned __int128 __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000318vec_addec(vector unsigned __int128 __a, vector unsigned __int128 __b,
319 vector unsigned __int128 __c) {
320 return __builtin_altivec_vaddecuq(__a, __b, __c);
321}
322#endif
323
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000324/* vec_vaddubm */
325
326#define __builtin_altivec_vaddubm vec_vaddubm
327
Daniel Jasperbe508362016-03-11 22:13:28 +0000328static __inline__ vector signed char __ATTRS_o_ai
329vec_vaddubm(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000330 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000331}
332
Daniel Jasperbe508362016-03-11 22:13:28 +0000333static __inline__ vector signed char __ATTRS_o_ai
334vec_vaddubm(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000335 return (vector signed char)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000336}
337
Daniel Jasperbe508362016-03-11 22:13:28 +0000338static __inline__ vector signed char __ATTRS_o_ai
339vec_vaddubm(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000340 return __a + (vector signed char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000341}
342
Daniel Jasperbe508362016-03-11 22:13:28 +0000343static __inline__ vector unsigned char __ATTRS_o_ai
344vec_vaddubm(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000345 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000346}
347
Daniel Jasperbe508362016-03-11 22:13:28 +0000348static __inline__ vector unsigned char __ATTRS_o_ai
349vec_vaddubm(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000350 return (vector unsigned char)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000351}
352
Daniel Jasperbe508362016-03-11 22:13:28 +0000353static __inline__ vector unsigned char __ATTRS_o_ai
354vec_vaddubm(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000355 return __a + (vector unsigned char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000356}
357
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000358/* vec_vadduhm */
359
360#define __builtin_altivec_vadduhm vec_vadduhm
361
Daniel Jasperbe508362016-03-11 22:13:28 +0000362static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
363 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000364 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000365}
366
Daniel Jasperbe508362016-03-11 22:13:28 +0000367static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector bool short __a,
368 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000369 return (vector short)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000370}
371
Daniel Jasperbe508362016-03-11 22:13:28 +0000372static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a,
373 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000374 return __a + (vector short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000375}
376
Daniel Jasperbe508362016-03-11 22:13:28 +0000377static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000378vec_vadduhm(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000379 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000380}
381
Daniel Jasperbe508362016-03-11 22:13:28 +0000382static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000383vec_vadduhm(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000384 return (vector unsigned short)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000385}
386
Daniel Jasperbe508362016-03-11 22:13:28 +0000387static __inline__ vector unsigned short __ATTRS_o_ai
388vec_vadduhm(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000389 return __a + (vector unsigned short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000390}
391
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000392/* vec_vadduwm */
393
394#define __builtin_altivec_vadduwm vec_vadduwm
395
Daniel Jasperbe508362016-03-11 22:13:28 +0000396static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
397 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000398 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000399}
400
Daniel Jasperbe508362016-03-11 22:13:28 +0000401static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector bool int __a,
402 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000403 return (vector int)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000404}
405
Daniel Jasperbe508362016-03-11 22:13:28 +0000406static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a,
407 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000408 return __a + (vector int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000409}
410
Daniel Jasperbe508362016-03-11 22:13:28 +0000411static __inline__ vector unsigned int __ATTRS_o_ai
412vec_vadduwm(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000413 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000414}
415
Daniel Jasperbe508362016-03-11 22:13:28 +0000416static __inline__ vector unsigned int __ATTRS_o_ai
417vec_vadduwm(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000418 return (vector unsigned int)__a + __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000419}
420
Daniel Jasperbe508362016-03-11 22:13:28 +0000421static __inline__ vector unsigned int __ATTRS_o_ai
422vec_vadduwm(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000423 return __a + (vector unsigned int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000424}
425
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000426/* vec_vaddfp */
427
Bill Seurer703e8482015-06-09 14:39:47 +0000428#define __builtin_altivec_vaddfp vec_vaddfp
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000429
Daniel Jasperbe508362016-03-11 22:13:28 +0000430static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +0000431vec_vaddfp(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000432 return __a + __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000433}
434
Chris Lattnerdad40622010-04-14 03:54:58 +0000435/* vec_addc */
436
Daniel Jasperbe508362016-03-11 22:13:28 +0000437static __inline__ vector signed int __ATTRS_o_ai
438vec_addc(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000439 return (vector signed int)__builtin_altivec_vaddcuw((vector unsigned int)__a,
440 (vector unsigned int)__b);
441}
442
Daniel Jasperbe508362016-03-11 22:13:28 +0000443static __inline__ vector unsigned int __ATTRS_o_ai
444vec_addc(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000445 return __builtin_altivec_vaddcuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000446}
447
Kit Barton5944ee212015-05-25 15:52:45 +0000448#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +0000449static __inline__ vector signed __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +0000450vec_addc(vector signed __int128 __a, vector signed __int128 __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +0000451 return (vector signed __int128)__builtin_altivec_vaddcuq(
Daniel Jasperbe508362016-03-11 22:13:28 +0000452 (vector unsigned __int128)__a, (vector unsigned __int128)__b);
Kit Barton5944ee212015-05-25 15:52:45 +0000453}
454
Daniel Jasperbe508362016-03-11 22:13:28 +0000455static __inline__ vector unsigned __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +0000456vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
457 return __builtin_altivec_vaddcuq(__a, __b);
458}
459#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
460
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000461/* vec_vaddcuw */
462
Daniel Jasperbe508362016-03-11 22:13:28 +0000463static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +0000464vec_vaddcuw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000465 return __builtin_altivec_vaddcuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000466}
Chris Lattnerdad40622010-04-14 03:54:58 +0000467
468/* vec_adds */
469
Daniel Jasperbe508362016-03-11 22:13:28 +0000470static __inline__ vector signed char __ATTRS_o_ai
471vec_adds(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000472 return __builtin_altivec_vaddsbs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000473}
474
Daniel Jasperbe508362016-03-11 22:13:28 +0000475static __inline__ vector signed char __ATTRS_o_ai
476vec_adds(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000477 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000478}
479
Daniel Jasperbe508362016-03-11 22:13:28 +0000480static __inline__ vector signed char __ATTRS_o_ai
481vec_adds(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000482 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000483}
484
Daniel Jasperbe508362016-03-11 22:13:28 +0000485static __inline__ vector unsigned char __ATTRS_o_ai
486vec_adds(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000487 return __builtin_altivec_vaddubs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000488}
489
Daniel Jasperbe508362016-03-11 22:13:28 +0000490static __inline__ vector unsigned char __ATTRS_o_ai
491vec_adds(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000492 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000493}
494
Daniel Jasperbe508362016-03-11 22:13:28 +0000495static __inline__ vector unsigned char __ATTRS_o_ai
496vec_adds(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000497 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000498}
499
Daniel Jasperbe508362016-03-11 22:13:28 +0000500static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
501 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000502 return __builtin_altivec_vaddshs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000503}
504
Daniel Jasperbe508362016-03-11 22:13:28 +0000505static __inline__ vector short __ATTRS_o_ai vec_adds(vector bool short __a,
506 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000507 return __builtin_altivec_vaddshs((vector short)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000508}
509
Daniel Jasperbe508362016-03-11 22:13:28 +0000510static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a,
511 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000512 return __builtin_altivec_vaddshs(__a, (vector short)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000513}
514
Daniel Jasperbe508362016-03-11 22:13:28 +0000515static __inline__ vector unsigned short __ATTRS_o_ai
516vec_adds(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000517 return __builtin_altivec_vadduhs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000518}
519
Daniel Jasperbe508362016-03-11 22:13:28 +0000520static __inline__ vector unsigned short __ATTRS_o_ai
521vec_adds(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000522 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000523}
524
Daniel Jasperbe508362016-03-11 22:13:28 +0000525static __inline__ vector unsigned short __ATTRS_o_ai
526vec_adds(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000527 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000528}
529
Daniel Jasperbe508362016-03-11 22:13:28 +0000530static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
531 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000532 return __builtin_altivec_vaddsws(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000533}
534
Daniel Jasperbe508362016-03-11 22:13:28 +0000535static __inline__ vector int __ATTRS_o_ai vec_adds(vector bool int __a,
536 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000537 return __builtin_altivec_vaddsws((vector int)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000538}
539
Daniel Jasperbe508362016-03-11 22:13:28 +0000540static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a,
541 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000542 return __builtin_altivec_vaddsws(__a, (vector int)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000543}
544
Daniel Jasperbe508362016-03-11 22:13:28 +0000545static __inline__ vector unsigned int __ATTRS_o_ai
546vec_adds(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000547 return __builtin_altivec_vadduws(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000548}
549
Daniel Jasperbe508362016-03-11 22:13:28 +0000550static __inline__ vector unsigned int __ATTRS_o_ai
551vec_adds(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000552 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000553}
554
Daniel Jasperbe508362016-03-11 22:13:28 +0000555static __inline__ vector unsigned int __ATTRS_o_ai
556vec_adds(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000557 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000558}
559
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000560/* vec_vaddsbs */
Chris Lattnerdad40622010-04-14 03:54:58 +0000561
Daniel Jasperbe508362016-03-11 22:13:28 +0000562static __inline__ vector signed char __ATTRS_o_ai
563vec_vaddsbs(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000564 return __builtin_altivec_vaddsbs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000565}
566
Daniel Jasperbe508362016-03-11 22:13:28 +0000567static __inline__ vector signed char __ATTRS_o_ai
568vec_vaddsbs(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000569 return __builtin_altivec_vaddsbs((vector signed char)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000570}
571
Daniel Jasperbe508362016-03-11 22:13:28 +0000572static __inline__ vector signed char __ATTRS_o_ai
573vec_vaddsbs(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000574 return __builtin_altivec_vaddsbs(__a, (vector signed char)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000575}
576
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000577/* vec_vaddubs */
578
Daniel Jasperbe508362016-03-11 22:13:28 +0000579static __inline__ vector unsigned char __ATTRS_o_ai
580vec_vaddubs(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000581 return __builtin_altivec_vaddubs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000582}
583
Daniel Jasperbe508362016-03-11 22:13:28 +0000584static __inline__ vector unsigned char __ATTRS_o_ai
585vec_vaddubs(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000586 return __builtin_altivec_vaddubs((vector unsigned char)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000587}
588
Daniel Jasperbe508362016-03-11 22:13:28 +0000589static __inline__ vector unsigned char __ATTRS_o_ai
590vec_vaddubs(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000591 return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000592}
593
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000594/* vec_vaddshs */
595
Daniel Jasperbe508362016-03-11 22:13:28 +0000596static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
597 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000598 return __builtin_altivec_vaddshs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000599}
600
Daniel Jasperbe508362016-03-11 22:13:28 +0000601static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector bool short __a,
602 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000603 return __builtin_altivec_vaddshs((vector short)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000604}
605
Daniel Jasperbe508362016-03-11 22:13:28 +0000606static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a,
607 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000608 return __builtin_altivec_vaddshs(__a, (vector short)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000609}
610
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000611/* vec_vadduhs */
612
Daniel Jasperbe508362016-03-11 22:13:28 +0000613static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000614vec_vadduhs(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000615 return __builtin_altivec_vadduhs(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000616}
617
Daniel Jasperbe508362016-03-11 22:13:28 +0000618static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000619vec_vadduhs(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000620 return __builtin_altivec_vadduhs((vector unsigned short)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000621}
622
Daniel Jasperbe508362016-03-11 22:13:28 +0000623static __inline__ vector unsigned short __ATTRS_o_ai
624vec_vadduhs(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000625 return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000626}
627
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000628/* vec_vaddsws */
629
Daniel Jasperbe508362016-03-11 22:13:28 +0000630static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
631 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000632 return __builtin_altivec_vaddsws(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000633}
634
Daniel Jasperbe508362016-03-11 22:13:28 +0000635static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector bool int __a,
636 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000637 return __builtin_altivec_vaddsws((vector int)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000638}
639
Daniel Jasperbe508362016-03-11 22:13:28 +0000640static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a,
641 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000642 return __builtin_altivec_vaddsws(__a, (vector int)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000643}
644
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000645/* vec_vadduws */
646
Daniel Jasperbe508362016-03-11 22:13:28 +0000647static __inline__ vector unsigned int __ATTRS_o_ai
648vec_vadduws(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000649 return __builtin_altivec_vadduws(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +0000650}
651
Daniel Jasperbe508362016-03-11 22:13:28 +0000652static __inline__ vector unsigned int __ATTRS_o_ai
653vec_vadduws(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000654 return __builtin_altivec_vadduws((vector unsigned int)__a, __b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000655}
656
Daniel Jasperbe508362016-03-11 22:13:28 +0000657static __inline__ vector unsigned int __ATTRS_o_ai
658vec_vadduws(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000659 return __builtin_altivec_vadduws(__a, (vector unsigned int)__b);
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000660}
661
Kit Barton5944ee212015-05-25 15:52:45 +0000662#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
663/* vec_vadduqm */
664
Daniel Jasperbe508362016-03-11 22:13:28 +0000665static __inline__ vector signed __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000666vec_vadduqm(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +0000667 return __a + __b;
668}
669
Daniel Jasperbe508362016-03-11 22:13:28 +0000670static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000671vec_vadduqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +0000672 return __a + __b;
673}
674
675/* vec_vaddeuqm */
676
Daniel Jasperbe508362016-03-11 22:13:28 +0000677static __inline__ vector signed __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +0000678vec_vaddeuqm(vector signed __int128 __a, vector signed __int128 __b,
679 vector signed __int128 __c) {
680 return __builtin_altivec_vaddeuqm(__a, __b, __c);
681}
682
Daniel Jasperbe508362016-03-11 22:13:28 +0000683static __inline__ vector unsigned __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +0000684vec_vaddeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
685 vector unsigned __int128 __c) {
686 return __builtin_altivec_vaddeuqm(__a, __b, __c);
687}
688
689/* vec_vaddcuq */
690
Daniel Jasperbe508362016-03-11 22:13:28 +0000691static __inline__ vector signed __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000692vec_vaddcuq(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +0000693 return __builtin_altivec_vaddcuq(__a, __b);
694}
695
Daniel Jasperbe508362016-03-11 22:13:28 +0000696static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000697vec_vaddcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +0000698 return __builtin_altivec_vaddcuq(__a, __b);
699}
700
701/* vec_vaddecuq */
702
Daniel Jasperbe508362016-03-11 22:13:28 +0000703static __inline__ vector signed __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +0000704vec_vaddecuq(vector signed __int128 __a, vector signed __int128 __b,
705 vector signed __int128 __c) {
706 return __builtin_altivec_vaddecuq(__a, __b, __c);
707}
708
Daniel Jasperbe508362016-03-11 22:13:28 +0000709static __inline__ vector unsigned __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +0000710vec_vaddecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
711 vector unsigned __int128 __c) {
712 return __builtin_altivec_vaddecuq(__a, __b, __c);
713}
714#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
715
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000716/* vec_and */
717
718#define __builtin_altivec_vand vec_and
719
Daniel Jasperbe508362016-03-11 22:13:28 +0000720static __inline__ vector signed char __ATTRS_o_ai
721vec_and(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000722 return __a & __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000723}
724
Daniel Jasperbe508362016-03-11 22:13:28 +0000725static __inline__ vector signed char __ATTRS_o_ai
726vec_and(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000727 return (vector signed char)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000728}
729
Daniel Jasperbe508362016-03-11 22:13:28 +0000730static __inline__ vector signed char __ATTRS_o_ai
731vec_and(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000732 return __a & (vector signed char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000733}
734
Daniel Jasperbe508362016-03-11 22:13:28 +0000735static __inline__ vector unsigned char __ATTRS_o_ai
736vec_and(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000737 return __a & __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000738}
739
Daniel Jasperbe508362016-03-11 22:13:28 +0000740static __inline__ vector unsigned char __ATTRS_o_ai
741vec_and(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000742 return (vector unsigned char)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000743}
744
Daniel Jasperbe508362016-03-11 22:13:28 +0000745static __inline__ vector unsigned char __ATTRS_o_ai
746vec_and(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000747 return __a & (vector unsigned char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000748}
749
Daniel Jasperbe508362016-03-11 22:13:28 +0000750static __inline__ vector bool char __ATTRS_o_ai vec_and(vector bool char __a,
751 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000752 return __a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000753}
754
Daniel Jasperbe508362016-03-11 22:13:28 +0000755static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
756 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000757 return __a & __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000758}
759
Daniel Jasperbe508362016-03-11 22:13:28 +0000760static __inline__ vector short __ATTRS_o_ai vec_and(vector bool short __a,
761 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000762 return (vector short)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000763}
764
Daniel Jasperbe508362016-03-11 22:13:28 +0000765static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a,
766 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000767 return __a & (vector short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000768}
769
Daniel Jasperbe508362016-03-11 22:13:28 +0000770static __inline__ vector unsigned short __ATTRS_o_ai
771vec_and(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000772 return __a & __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000773}
774
Daniel Jasperbe508362016-03-11 22:13:28 +0000775static __inline__ vector unsigned short __ATTRS_o_ai
776vec_and(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000777 return (vector unsigned short)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000778}
779
Daniel Jasperbe508362016-03-11 22:13:28 +0000780static __inline__ vector unsigned short __ATTRS_o_ai
781vec_and(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000782 return __a & (vector unsigned short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000783}
784
Daniel Jasperbe508362016-03-11 22:13:28 +0000785static __inline__ vector bool short __ATTRS_o_ai
786vec_and(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000787 return __a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000788}
789
Daniel Jasperbe508362016-03-11 22:13:28 +0000790static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
791 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000792 return __a & __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000793}
794
Daniel Jasperbe508362016-03-11 22:13:28 +0000795static __inline__ vector int __ATTRS_o_ai vec_and(vector bool int __a,
796 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000797 return (vector int)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000798}
799
Daniel Jasperbe508362016-03-11 22:13:28 +0000800static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a,
801 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000802 return __a & (vector int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000803}
804
Daniel Jasperbe508362016-03-11 22:13:28 +0000805static __inline__ vector unsigned int __ATTRS_o_ai
806vec_and(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000807 return __a & __b;
Chris Lattnerdad40622010-04-14 03:54:58 +0000808}
809
Daniel Jasperbe508362016-03-11 22:13:28 +0000810static __inline__ vector unsigned int __ATTRS_o_ai
811vec_and(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000812 return (vector unsigned int)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000813}
814
Daniel Jasperbe508362016-03-11 22:13:28 +0000815static __inline__ vector unsigned int __ATTRS_o_ai
816vec_and(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000817 return __a & (vector unsigned int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000818}
819
Daniel Jasperbe508362016-03-11 22:13:28 +0000820static __inline__ vector bool int __ATTRS_o_ai vec_and(vector bool int __a,
821 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000822 return __a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000823}
824
Daniel Jasperbe508362016-03-11 22:13:28 +0000825static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
826 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +0000827 vector unsigned int __res =
828 (vector unsigned int)__a & (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +0000829 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000830}
831
Daniel Jasperbe508362016-03-11 22:13:28 +0000832static __inline__ vector float __ATTRS_o_ai vec_and(vector bool int __a,
833 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +0000834 vector unsigned int __res =
835 (vector unsigned int)__a & (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +0000836 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000837}
838
Daniel Jasperbe508362016-03-11 22:13:28 +0000839static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a,
840 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +0000841 vector unsigned int __res =
842 (vector unsigned int)__a & (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +0000843 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000844}
845
Bill Seurer8be14f12015-06-04 18:45:44 +0000846#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +0000847static __inline__ vector double __ATTRS_o_ai vec_and(vector bool long long __a,
848 vector double __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000849 vector unsigned long long __res =
850 (vector unsigned long long)__a & (vector unsigned long long)__b;
851 return (vector double)__res;
852}
853
Daniel Jasperbe508362016-03-11 22:13:28 +0000854static __inline__ vector double __ATTRS_o_ai
855vec_and(vector double __a, vector bool long long __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000856 vector unsigned long long __res =
857 (vector unsigned long long)__a & (vector unsigned long long)__b;
858 return (vector double)__res;
859}
860
Daniel Jasperbe508362016-03-11 22:13:28 +0000861static __inline__ vector double __ATTRS_o_ai vec_and(vector double __a,
862 vector double __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +0000863 vector unsigned long long __res =
864 (vector unsigned long long)__a & (vector unsigned long long)__b;
865 return (vector double)__res;
866}
867
Daniel Jasperbe508362016-03-11 22:13:28 +0000868static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000869vec_and(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000870 return __a & __b;
871}
872
Daniel Jasperbe508362016-03-11 22:13:28 +0000873static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000874vec_and(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000875 return (vector signed long long)__a & __b;
876}
877
Daniel Jasperbe508362016-03-11 22:13:28 +0000878static __inline__ vector signed long long __ATTRS_o_ai
879vec_and(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000880 return __a & (vector signed long long)__b;
881}
882
Daniel Jasperbe508362016-03-11 22:13:28 +0000883static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000884vec_and(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000885 return __a & __b;
886}
887
Daniel Jasperbe508362016-03-11 22:13:28 +0000888static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000889vec_and(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000890 return (vector unsigned long long)__a & __b;
891}
892
Daniel Jasperbe508362016-03-11 22:13:28 +0000893static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +0000894vec_and(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000895 return __a & (vector unsigned long long)__b;
896}
897
Daniel Jasperbe508362016-03-11 22:13:28 +0000898static __inline__ vector bool long long __ATTRS_o_ai
899vec_and(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +0000900 return __a & __b;
901}
902#endif
903
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000904/* vec_vand */
905
Daniel Jasperbe508362016-03-11 22:13:28 +0000906static __inline__ vector signed char __ATTRS_o_ai
907vec_vand(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000908 return __a & __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000909}
910
Daniel Jasperbe508362016-03-11 22:13:28 +0000911static __inline__ vector signed char __ATTRS_o_ai
912vec_vand(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000913 return (vector signed char)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000914}
915
Daniel Jasperbe508362016-03-11 22:13:28 +0000916static __inline__ vector signed char __ATTRS_o_ai
917vec_vand(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000918 return __a & (vector signed char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000919}
920
Daniel Jasperbe508362016-03-11 22:13:28 +0000921static __inline__ vector unsigned char __ATTRS_o_ai
922vec_vand(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000923 return __a & __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000924}
925
Daniel Jasperbe508362016-03-11 22:13:28 +0000926static __inline__ vector unsigned char __ATTRS_o_ai
927vec_vand(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000928 return (vector unsigned char)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000929}
930
Daniel Jasperbe508362016-03-11 22:13:28 +0000931static __inline__ vector unsigned char __ATTRS_o_ai
932vec_vand(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000933 return __a & (vector unsigned char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000934}
935
Daniel Jasperbe508362016-03-11 22:13:28 +0000936static __inline__ vector bool char __ATTRS_o_ai vec_vand(vector bool char __a,
937 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000938 return __a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000939}
940
Daniel Jasperbe508362016-03-11 22:13:28 +0000941static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
942 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000943 return __a & __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000944}
945
Daniel Jasperbe508362016-03-11 22:13:28 +0000946static __inline__ vector short __ATTRS_o_ai vec_vand(vector bool short __a,
947 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000948 return (vector short)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000949}
950
Daniel Jasperbe508362016-03-11 22:13:28 +0000951static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a,
952 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000953 return __a & (vector short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000954}
955
Daniel Jasperbe508362016-03-11 22:13:28 +0000956static __inline__ vector unsigned short __ATTRS_o_ai
957vec_vand(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000958 return __a & __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000959}
960
Daniel Jasperbe508362016-03-11 22:13:28 +0000961static __inline__ vector unsigned short __ATTRS_o_ai
962vec_vand(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000963 return (vector unsigned short)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000964}
965
Daniel Jasperbe508362016-03-11 22:13:28 +0000966static __inline__ vector unsigned short __ATTRS_o_ai
967vec_vand(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000968 return __a & (vector unsigned short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000969}
970
Daniel Jasperbe508362016-03-11 22:13:28 +0000971static __inline__ vector bool short __ATTRS_o_ai
972vec_vand(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000973 return __a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000974}
975
Daniel Jasperbe508362016-03-11 22:13:28 +0000976static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
977 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000978 return __a & __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000979}
980
Daniel Jasperbe508362016-03-11 22:13:28 +0000981static __inline__ vector int __ATTRS_o_ai vec_vand(vector bool int __a,
982 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000983 return (vector int)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000984}
985
Daniel Jasperbe508362016-03-11 22:13:28 +0000986static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a,
987 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000988 return __a & (vector int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000989}
990
Daniel Jasperbe508362016-03-11 22:13:28 +0000991static __inline__ vector unsigned int __ATTRS_o_ai
992vec_vand(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000993 return __a & __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +0000994}
995
Daniel Jasperbe508362016-03-11 22:13:28 +0000996static __inline__ vector unsigned int __ATTRS_o_ai
997vec_vand(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +0000998 return (vector unsigned int)__a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +0000999}
1000
Daniel Jasperbe508362016-03-11 22:13:28 +00001001static __inline__ vector unsigned int __ATTRS_o_ai
1002vec_vand(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001003 return __a & (vector unsigned int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001004}
1005
Daniel Jasperbe508362016-03-11 22:13:28 +00001006static __inline__ vector bool int __ATTRS_o_ai vec_vand(vector bool int __a,
1007 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001008 return __a & __b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001009}
1010
Daniel Jasperbe508362016-03-11 22:13:28 +00001011static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1012 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001013 vector unsigned int __res =
1014 (vector unsigned int)__a & (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001015 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001016}
1017
Daniel Jasperbe508362016-03-11 22:13:28 +00001018static __inline__ vector float __ATTRS_o_ai vec_vand(vector bool int __a,
1019 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001020 vector unsigned int __res =
1021 (vector unsigned int)__a & (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001022 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001023}
1024
Daniel Jasperbe508362016-03-11 22:13:28 +00001025static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a,
1026 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001027 vector unsigned int __res =
1028 (vector unsigned int)__a & (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001029 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001030}
1031
Bill Seurer8be14f12015-06-04 18:45:44 +00001032#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001033static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001034vec_vand(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001035 return __a & __b;
1036}
1037
Daniel Jasperbe508362016-03-11 22:13:28 +00001038static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001039vec_vand(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001040 return (vector signed long long)__a & __b;
1041}
1042
Daniel Jasperbe508362016-03-11 22:13:28 +00001043static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001044vec_vand(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001045 return __a & (vector signed long long)__b;
1046}
1047
Daniel Jasperbe508362016-03-11 22:13:28 +00001048static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001049vec_vand(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001050 return __a & __b;
1051}
1052
Daniel Jasperbe508362016-03-11 22:13:28 +00001053static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001054vec_vand(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001055 return (vector unsigned long long)__a & __b;
1056}
1057
Daniel Jasperbe508362016-03-11 22:13:28 +00001058static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001059vec_vand(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001060 return __a & (vector unsigned long long)__b;
1061}
1062
Daniel Jasperbe508362016-03-11 22:13:28 +00001063static __inline__ vector bool long long __ATTRS_o_ai
1064vec_vand(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001065 return __a & __b;
1066}
1067#endif
1068
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001069/* vec_andc */
1070
1071#define __builtin_altivec_vandc vec_andc
1072
Daniel Jasperbe508362016-03-11 22:13:28 +00001073static __inline__ vector signed char __ATTRS_o_ai
1074vec_andc(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001075 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001076}
1077
Daniel Jasperbe508362016-03-11 22:13:28 +00001078static __inline__ vector signed char __ATTRS_o_ai
1079vec_andc(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001080 return (vector signed char)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001081}
1082
Daniel Jasperbe508362016-03-11 22:13:28 +00001083static __inline__ vector signed char __ATTRS_o_ai
1084vec_andc(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001085 return __a & ~(vector signed char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001086}
1087
Daniel Jasperbe508362016-03-11 22:13:28 +00001088static __inline__ vector unsigned char __ATTRS_o_ai
1089vec_andc(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001090 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001091}
1092
Daniel Jasperbe508362016-03-11 22:13:28 +00001093static __inline__ vector unsigned char __ATTRS_o_ai
1094vec_andc(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001095 return (vector unsigned char)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001096}
1097
Daniel Jasperbe508362016-03-11 22:13:28 +00001098static __inline__ vector unsigned char __ATTRS_o_ai
1099vec_andc(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001100 return __a & ~(vector unsigned char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001101}
1102
Daniel Jasperbe508362016-03-11 22:13:28 +00001103static __inline__ vector bool char __ATTRS_o_ai vec_andc(vector bool char __a,
1104 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001105 return __a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001106}
1107
Daniel Jasperbe508362016-03-11 22:13:28 +00001108static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1109 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001110 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001111}
1112
Daniel Jasperbe508362016-03-11 22:13:28 +00001113static __inline__ vector short __ATTRS_o_ai vec_andc(vector bool short __a,
1114 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001115 return (vector short)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001116}
1117
Daniel Jasperbe508362016-03-11 22:13:28 +00001118static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a,
1119 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001120 return __a & ~(vector short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001121}
1122
Daniel Jasperbe508362016-03-11 22:13:28 +00001123static __inline__ vector unsigned short __ATTRS_o_ai
1124vec_andc(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001125 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001126}
1127
Daniel Jasperbe508362016-03-11 22:13:28 +00001128static __inline__ vector unsigned short __ATTRS_o_ai
1129vec_andc(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001130 return (vector unsigned short)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001131}
1132
Daniel Jasperbe508362016-03-11 22:13:28 +00001133static __inline__ vector unsigned short __ATTRS_o_ai
1134vec_andc(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001135 return __a & ~(vector unsigned short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001136}
1137
Daniel Jasperbe508362016-03-11 22:13:28 +00001138static __inline__ vector bool short __ATTRS_o_ai
1139vec_andc(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001140 return __a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001141}
1142
Daniel Jasperbe508362016-03-11 22:13:28 +00001143static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1144 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001145 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001146}
1147
Daniel Jasperbe508362016-03-11 22:13:28 +00001148static __inline__ vector int __ATTRS_o_ai vec_andc(vector bool int __a,
1149 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001150 return (vector int)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001151}
1152
Daniel Jasperbe508362016-03-11 22:13:28 +00001153static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a,
1154 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001155 return __a & ~(vector int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001156}
1157
Daniel Jasperbe508362016-03-11 22:13:28 +00001158static __inline__ vector unsigned int __ATTRS_o_ai
1159vec_andc(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001160 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001161}
1162
Daniel Jasperbe508362016-03-11 22:13:28 +00001163static __inline__ vector unsigned int __ATTRS_o_ai
1164vec_andc(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001165 return (vector unsigned int)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001166}
1167
Daniel Jasperbe508362016-03-11 22:13:28 +00001168static __inline__ vector unsigned int __ATTRS_o_ai
1169vec_andc(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001170 return __a & ~(vector unsigned int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001171}
1172
Daniel Jasperbe508362016-03-11 22:13:28 +00001173static __inline__ vector bool int __ATTRS_o_ai vec_andc(vector bool int __a,
1174 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001175 return __a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001176}
1177
Daniel Jasperbe508362016-03-11 22:13:28 +00001178static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1179 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001180 vector unsigned int __res =
1181 (vector unsigned int)__a & ~(vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001182 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001183}
1184
Daniel Jasperbe508362016-03-11 22:13:28 +00001185static __inline__ vector float __ATTRS_o_ai vec_andc(vector bool int __a,
1186 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001187 vector unsigned int __res =
1188 (vector unsigned int)__a & ~(vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001189 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001190}
1191
Daniel Jasperbe508362016-03-11 22:13:28 +00001192static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a,
1193 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001194 vector unsigned int __res =
1195 (vector unsigned int)__a & ~(vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001196 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001197}
1198
Bill Seurer8be14f12015-06-04 18:45:44 +00001199#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001200static __inline__ vector double __ATTRS_o_ai vec_andc(vector bool long long __a,
1201 vector double __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001202 vector unsigned long long __res =
1203 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1204 return (vector double)__res;
1205}
1206
Daniel Jasperbe508362016-03-11 22:13:28 +00001207static __inline__ vector double __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001208vec_andc(vector double __a, vector bool long long __b) {
1209 vector unsigned long long __res =
1210 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1211 return (vector double)__res;
1212}
1213
Daniel Jasperbe508362016-03-11 22:13:28 +00001214static __inline__ vector double __ATTRS_o_ai vec_andc(vector double __a,
1215 vector double __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001216 vector unsigned long long __res =
1217 (vector unsigned long long)__a & ~(vector unsigned long long)__b;
1218 return (vector double)__res;
1219}
1220
Daniel Jasperbe508362016-03-11 22:13:28 +00001221static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001222vec_andc(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001223 return __a & ~__b;
1224}
1225
Daniel Jasperbe508362016-03-11 22:13:28 +00001226static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001227vec_andc(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001228 return (vector signed long long)__a & ~__b;
1229}
1230
Daniel Jasperbe508362016-03-11 22:13:28 +00001231static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001232vec_andc(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001233 return __a & ~(vector signed long long)__b;
1234}
1235
Daniel Jasperbe508362016-03-11 22:13:28 +00001236static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001237vec_andc(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001238 return __a & ~__b;
1239}
1240
Daniel Jasperbe508362016-03-11 22:13:28 +00001241static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001242vec_andc(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001243 return (vector unsigned long long)__a & ~__b;
1244}
1245
Daniel Jasperbe508362016-03-11 22:13:28 +00001246static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001247vec_andc(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001248 return __a & ~(vector unsigned long long)__b;
1249}
1250
Daniel Jasperbe508362016-03-11 22:13:28 +00001251static __inline__ vector bool long long __ATTRS_o_ai
1252vec_andc(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001253 return __a & ~__b;
1254}
1255#endif
1256
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001257/* vec_vandc */
1258
Daniel Jasperbe508362016-03-11 22:13:28 +00001259static __inline__ vector signed char __ATTRS_o_ai
1260vec_vandc(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001261 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001262}
1263
Daniel Jasperbe508362016-03-11 22:13:28 +00001264static __inline__ vector signed char __ATTRS_o_ai
1265vec_vandc(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001266 return (vector signed char)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001267}
1268
Daniel Jasperbe508362016-03-11 22:13:28 +00001269static __inline__ vector signed char __ATTRS_o_ai
1270vec_vandc(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001271 return __a & ~(vector signed char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001272}
1273
Daniel Jasperbe508362016-03-11 22:13:28 +00001274static __inline__ vector unsigned char __ATTRS_o_ai
1275vec_vandc(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001276 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001277}
1278
Daniel Jasperbe508362016-03-11 22:13:28 +00001279static __inline__ vector unsigned char __ATTRS_o_ai
1280vec_vandc(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001281 return (vector unsigned char)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001282}
1283
Daniel Jasperbe508362016-03-11 22:13:28 +00001284static __inline__ vector unsigned char __ATTRS_o_ai
1285vec_vandc(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001286 return __a & ~(vector unsigned char)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001287}
1288
Daniel Jasperbe508362016-03-11 22:13:28 +00001289static __inline__ vector bool char __ATTRS_o_ai
1290vec_vandc(vector bool char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001291 return __a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001292}
1293
Daniel Jasperbe508362016-03-11 22:13:28 +00001294static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1295 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001296 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001297}
1298
Daniel Jasperbe508362016-03-11 22:13:28 +00001299static __inline__ vector short __ATTRS_o_ai vec_vandc(vector bool short __a,
1300 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001301 return (vector short)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001302}
1303
Daniel Jasperbe508362016-03-11 22:13:28 +00001304static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a,
1305 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001306 return __a & ~(vector short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001307}
1308
Daniel Jasperbe508362016-03-11 22:13:28 +00001309static __inline__ vector unsigned short __ATTRS_o_ai
1310vec_vandc(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001311 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001312}
1313
Daniel Jasperbe508362016-03-11 22:13:28 +00001314static __inline__ vector unsigned short __ATTRS_o_ai
1315vec_vandc(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001316 return (vector unsigned short)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001317}
1318
Daniel Jasperbe508362016-03-11 22:13:28 +00001319static __inline__ vector unsigned short __ATTRS_o_ai
1320vec_vandc(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001321 return __a & ~(vector unsigned short)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001322}
1323
Daniel Jasperbe508362016-03-11 22:13:28 +00001324static __inline__ vector bool short __ATTRS_o_ai
1325vec_vandc(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001326 return __a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001327}
1328
Daniel Jasperbe508362016-03-11 22:13:28 +00001329static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1330 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001331 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001332}
1333
Daniel Jasperbe508362016-03-11 22:13:28 +00001334static __inline__ vector int __ATTRS_o_ai vec_vandc(vector bool int __a,
1335 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001336 return (vector int)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001337}
1338
Daniel Jasperbe508362016-03-11 22:13:28 +00001339static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a,
1340 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001341 return __a & ~(vector int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001342}
1343
Daniel Jasperbe508362016-03-11 22:13:28 +00001344static __inline__ vector unsigned int __ATTRS_o_ai
1345vec_vandc(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001346 return __a & ~__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001347}
1348
Daniel Jasperbe508362016-03-11 22:13:28 +00001349static __inline__ vector unsigned int __ATTRS_o_ai
1350vec_vandc(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001351 return (vector unsigned int)__a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001352}
1353
Daniel Jasperbe508362016-03-11 22:13:28 +00001354static __inline__ vector unsigned int __ATTRS_o_ai
1355vec_vandc(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001356 return __a & ~(vector unsigned int)__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001357}
1358
Daniel Jasperbe508362016-03-11 22:13:28 +00001359static __inline__ vector bool int __ATTRS_o_ai vec_vandc(vector bool int __a,
1360 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001361 return __a & ~__b;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001362}
1363
Daniel Jasperbe508362016-03-11 22:13:28 +00001364static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1365 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001366 vector unsigned int __res =
1367 (vector unsigned int)__a & ~(vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001368 return (vector float)__res;
Chris Lattnerdad40622010-04-14 03:54:58 +00001369}
1370
Daniel Jasperbe508362016-03-11 22:13:28 +00001371static __inline__ vector float __ATTRS_o_ai vec_vandc(vector bool int __a,
1372 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001373 vector unsigned int __res =
1374 (vector unsigned int)__a & ~(vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001375 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001376}
1377
Daniel Jasperbe508362016-03-11 22:13:28 +00001378static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a,
1379 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001380 vector unsigned int __res =
1381 (vector unsigned int)__a & ~(vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00001382 return (vector float)__res;
Anton Yartsev2cc136d2010-08-16 16:22:12 +00001383}
1384
Bill Seurer8be14f12015-06-04 18:45:44 +00001385#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001386static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001387vec_vandc(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001388 return __a & ~__b;
1389}
1390
Daniel Jasperbe508362016-03-11 22:13:28 +00001391static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001392vec_vandc(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001393 return (vector signed long long)__a & ~__b;
1394}
1395
Daniel Jasperbe508362016-03-11 22:13:28 +00001396static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001397vec_vandc(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001398 return __a & ~(vector signed long long)__b;
1399}
1400
Daniel Jasperbe508362016-03-11 22:13:28 +00001401static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001402vec_vandc(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001403 return __a & ~__b;
1404}
1405
Daniel Jasperbe508362016-03-11 22:13:28 +00001406static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001407vec_vandc(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001408 return (vector unsigned long long)__a & ~__b;
1409}
1410
Daniel Jasperbe508362016-03-11 22:13:28 +00001411static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001412vec_vandc(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001413 return __a & ~(vector unsigned long long)__b;
1414}
1415
Daniel Jasperbe508362016-03-11 22:13:28 +00001416static __inline__ vector bool long long __ATTRS_o_ai
1417vec_vandc(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00001418 return __a & ~__b;
1419}
1420#endif
1421
Chris Lattnerdad40622010-04-14 03:54:58 +00001422/* vec_avg */
1423
Daniel Jasperbe508362016-03-11 22:13:28 +00001424static __inline__ vector signed char __ATTRS_o_ai
1425vec_avg(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001426 return __builtin_altivec_vavgsb(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001427}
1428
Daniel Jasperbe508362016-03-11 22:13:28 +00001429static __inline__ vector unsigned char __ATTRS_o_ai
1430vec_avg(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001431 return __builtin_altivec_vavgub(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001432}
1433
Daniel Jasperbe508362016-03-11 22:13:28 +00001434static __inline__ vector short __ATTRS_o_ai vec_avg(vector short __a,
1435 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001436 return __builtin_altivec_vavgsh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001437}
1438
Daniel Jasperbe508362016-03-11 22:13:28 +00001439static __inline__ vector unsigned short __ATTRS_o_ai
1440vec_avg(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001441 return __builtin_altivec_vavguh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001442}
1443
Daniel Jasperbe508362016-03-11 22:13:28 +00001444static __inline__ vector int __ATTRS_o_ai vec_avg(vector int __a,
1445 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001446 return __builtin_altivec_vavgsw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001447}
1448
Daniel Jasperbe508362016-03-11 22:13:28 +00001449static __inline__ vector unsigned int __ATTRS_o_ai
1450vec_avg(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001451 return __builtin_altivec_vavguw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001452}
1453
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001454/* vec_vavgsb */
Chris Lattnerdad40622010-04-14 03:54:58 +00001455
Daniel Jasperbe508362016-03-11 22:13:28 +00001456static __inline__ vector signed char __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001457vec_vavgsb(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001458 return __builtin_altivec_vavgsb(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001459}
1460
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001461/* vec_vavgub */
1462
Daniel Jasperbe508362016-03-11 22:13:28 +00001463static __inline__ vector unsigned char __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001464vec_vavgub(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001465 return __builtin_altivec_vavgub(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001466}
1467
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001468/* vec_vavgsh */
1469
Daniel Jasperbe508362016-03-11 22:13:28 +00001470static __inline__ vector short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001471vec_vavgsh(vector short __a, vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001472 return __builtin_altivec_vavgsh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001473}
1474
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001475/* vec_vavguh */
1476
Daniel Jasperbe508362016-03-11 22:13:28 +00001477static __inline__ vector unsigned short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001478vec_vavguh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001479 return __builtin_altivec_vavguh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001480}
1481
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001482/* vec_vavgsw */
1483
Daniel Jasperbe508362016-03-11 22:13:28 +00001484static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001485vec_vavgsw(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001486 return __builtin_altivec_vavgsw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001487}
1488
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001489/* vec_vavguw */
1490
Daniel Jasperbe508362016-03-11 22:13:28 +00001491static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001492vec_vavguw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001493 return __builtin_altivec_vavguw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001494}
1495
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001496/* vec_ceil */
1497
Daniel Jasperbe508362016-03-11 22:13:28 +00001498static __inline__ vector float __ATTRS_o_ai vec_ceil(vector float __a) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001499#ifdef __VSX__
1500 return __builtin_vsx_xvrspip(__a);
1501#else
David Blaikie3302f2b2013-01-16 23:08:36 +00001502 return __builtin_altivec_vrfip(__a);
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001503#endif
Chris Lattnerdad40622010-04-14 03:54:58 +00001504}
1505
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001506#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001507static __inline__ vector double __ATTRS_o_ai vec_ceil(vector double __a) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001508 return __builtin_vsx_xvrdpip(__a);
1509}
1510#endif
1511
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001512/* vec_vrfip */
Chris Lattnerdad40622010-04-14 03:54:58 +00001513
Daniel Jasperbe508362016-03-11 22:13:28 +00001514static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001515vec_vrfip(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001516 return __builtin_altivec_vrfip(__a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001517}
1518
1519/* vec_cmpb */
1520
Daniel Jasperbe508362016-03-11 22:13:28 +00001521static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001522vec_cmpb(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001523 return __builtin_altivec_vcmpbfp(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001524}
1525
1526/* vec_vcmpbfp */
1527
Daniel Jasperbe508362016-03-11 22:13:28 +00001528static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001529vec_vcmpbfp(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001530 return __builtin_altivec_vcmpbfp(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001531}
Chris Lattnerdad40622010-04-14 03:54:58 +00001532
1533/* vec_cmpeq */
1534
Daniel Jasperbe508362016-03-11 22:13:28 +00001535static __inline__ vector bool char __ATTRS_o_ai
1536vec_cmpeq(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001537 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1538 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001539}
1540
Daniel Jasperbe508362016-03-11 22:13:28 +00001541static __inline__ vector bool char __ATTRS_o_ai
1542vec_cmpeq(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001543 return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
1544 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001545}
1546
Daniel Jasperbe508362016-03-11 22:13:28 +00001547static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
1548 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001549 return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001550}
1551
Daniel Jasperbe508362016-03-11 22:13:28 +00001552static __inline__ vector bool short __ATTRS_o_ai
1553vec_cmpeq(vector unsigned short __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001554 return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
1555 (vector short)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001556}
1557
Daniel Jasperbe508362016-03-11 22:13:28 +00001558static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
1559 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001560 return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001561}
1562
Daniel Jasperbe508362016-03-11 22:13:28 +00001563static __inline__ vector bool int __ATTRS_o_ai
1564vec_cmpeq(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00001565 return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
1566 (vector int)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001567}
1568
Kit Barton8553bec2015-03-11 15:57:19 +00001569#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00001570static __inline__ vector bool long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001571vec_cmpeq(vector signed long long __a, vector signed long long __b) {
1572 return (vector bool long long)__builtin_altivec_vcmpequd(__a, __b);
Kit Barton8553bec2015-03-11 15:57:19 +00001573}
1574
Daniel Jasperbe508362016-03-11 22:13:28 +00001575static __inline__ vector bool long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001576vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) {
1577 return (vector bool long long)__builtin_altivec_vcmpequd(
1578 (vector long long)__a, (vector long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +00001579}
1580#endif
1581
Daniel Jasperbe508362016-03-11 22:13:28 +00001582static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
1583 vector float __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001584#ifdef __VSX__
1585 return (vector bool int)__builtin_vsx_xvcmpeqsp(__a, __b);
1586#else
David Blaikie3302f2b2013-01-16 23:08:36 +00001587 return (vector bool int)__builtin_altivec_vcmpeqfp(__a, __b);
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001588#endif
Chris Lattnerdad40622010-04-14 03:54:58 +00001589}
1590
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001591#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001592static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001593vec_cmpeq(vector double __a, vector double __b) {
1594 return (vector bool long long)__builtin_vsx_xvcmpeqdp(__a, __b);
1595}
1596#endif
1597
Chris Lattnerdad40622010-04-14 03:54:58 +00001598/* vec_cmpgt */
1599
Daniel Jasperbe508362016-03-11 22:13:28 +00001600static __inline__ vector bool char __ATTRS_o_ai
1601vec_cmpgt(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001602 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001603}
1604
Daniel Jasperbe508362016-03-11 22:13:28 +00001605static __inline__ vector bool char __ATTRS_o_ai
1606vec_cmpgt(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001607 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001608}
1609
Daniel Jasperbe508362016-03-11 22:13:28 +00001610static __inline__ vector bool short __ATTRS_o_ai vec_cmpgt(vector short __a,
1611 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001612 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001613}
1614
Daniel Jasperbe508362016-03-11 22:13:28 +00001615static __inline__ vector bool short __ATTRS_o_ai
1616vec_cmpgt(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001617 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001618}
1619
Daniel Jasperbe508362016-03-11 22:13:28 +00001620static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector int __a,
1621 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001622 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001623}
1624
Daniel Jasperbe508362016-03-11 22:13:28 +00001625static __inline__ vector bool int __ATTRS_o_ai
1626vec_cmpgt(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001627 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00001628}
1629
Kit Barton8553bec2015-03-11 15:57:19 +00001630#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00001631static __inline__ vector bool long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001632vec_cmpgt(vector signed long long __a, vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00001633 return (vector bool long long)__builtin_altivec_vcmpgtsd(__a, __b);
1634}
1635
Daniel Jasperbe508362016-03-11 22:13:28 +00001636static __inline__ vector bool long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00001637vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00001638 return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b);
1639}
1640#endif
1641
Daniel Jasperbe508362016-03-11 22:13:28 +00001642static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector float __a,
1643 vector float __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001644#ifdef __VSX__
1645 return (vector bool int)__builtin_vsx_xvcmpgtsp(__a, __b);
1646#else
David Blaikie3302f2b2013-01-16 23:08:36 +00001647 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001648#endif
Chris Lattnerdad40622010-04-14 03:54:58 +00001649}
1650
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001651#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001652static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001653vec_cmpgt(vector double __a, vector double __b) {
1654 return (vector bool long long)__builtin_vsx_xvcmpgtdp(__a, __b);
1655}
1656#endif
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001657
1658/* vec_cmpge */
1659
Daniel Jasperbe508362016-03-11 22:13:28 +00001660static __inline__ vector bool char __ATTRS_o_ai
1661vec_cmpge(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001662 return ~(vec_cmpgt(__b, __a));
1663}
1664
Daniel Jasperbe508362016-03-11 22:13:28 +00001665static __inline__ vector bool char __ATTRS_o_ai
1666vec_cmpge(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001667 return ~(vec_cmpgt(__b, __a));
1668}
1669
Daniel Jasperbe508362016-03-11 22:13:28 +00001670static __inline__ vector bool short __ATTRS_o_ai
1671vec_cmpge(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001672 return ~(vec_cmpgt(__b, __a));
1673}
1674
Daniel Jasperbe508362016-03-11 22:13:28 +00001675static __inline__ vector bool short __ATTRS_o_ai
1676vec_cmpge(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001677 return ~(vec_cmpgt(__b, __a));
1678}
1679
Daniel Jasperbe508362016-03-11 22:13:28 +00001680static __inline__ vector bool int __ATTRS_o_ai
1681vec_cmpge(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001682 return ~(vec_cmpgt(__b, __a));
1683}
1684
Daniel Jasperbe508362016-03-11 22:13:28 +00001685static __inline__ vector bool int __ATTRS_o_ai
1686vec_cmpge(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001687 return ~(vec_cmpgt(__b, __a));
1688}
1689
Daniel Jasperbe508362016-03-11 22:13:28 +00001690static __inline__ vector bool int __ATTRS_o_ai vec_cmpge(vector float __a,
1691 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001692#ifdef __VSX__
1693 return (vector bool int)__builtin_vsx_xvcmpgesp(__a, __b);
1694#else
1695 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
1696#endif
1697}
1698
1699#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001700static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001701vec_cmpge(vector double __a, vector double __b) {
1702 return (vector bool long long)__builtin_vsx_xvcmpgedp(__a, __b);
1703}
1704#endif
1705
1706#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00001707static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001708vec_cmpge(vector signed long long __a, vector signed long long __b) {
1709 return ~(vec_cmpgt(__b, __a));
1710}
1711
Daniel Jasperbe508362016-03-11 22:13:28 +00001712static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001713vec_cmpge(vector unsigned long long __a, vector unsigned long long __b) {
1714 return ~(vec_cmpgt(__b, __a));
1715}
1716#endif
1717
1718/* vec_vcmpgefp */
1719
Daniel Jasperbe508362016-03-11 22:13:28 +00001720static __inline__ vector bool int __attribute__((__always_inline__))
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001721vec_vcmpgefp(vector float __a, vector float __b) {
1722 return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b);
1723}
1724
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001725/* vec_vcmpgtsb */
Chris Lattnerdad40622010-04-14 03:54:58 +00001726
Daniel Jasperbe508362016-03-11 22:13:28 +00001727static __inline__ vector bool char __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001728vec_vcmpgtsb(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001729 return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001730}
1731
1732/* vec_vcmpgtub */
1733
Daniel Jasperbe508362016-03-11 22:13:28 +00001734static __inline__ vector bool char __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001735vec_vcmpgtub(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001736 return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001737}
1738
1739/* vec_vcmpgtsh */
1740
Daniel Jasperbe508362016-03-11 22:13:28 +00001741static __inline__ vector bool short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001742vec_vcmpgtsh(vector short __a, vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001743 return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001744}
1745
1746/* vec_vcmpgtuh */
1747
Daniel Jasperbe508362016-03-11 22:13:28 +00001748static __inline__ vector bool short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001749vec_vcmpgtuh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001750 return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001751}
1752
1753/* vec_vcmpgtsw */
1754
Daniel Jasperbe508362016-03-11 22:13:28 +00001755static __inline__ vector bool int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001756vec_vcmpgtsw(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001757 return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001758}
1759
1760/* vec_vcmpgtuw */
1761
Daniel Jasperbe508362016-03-11 22:13:28 +00001762static __inline__ vector bool int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001763vec_vcmpgtuw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001764 return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001765}
1766
1767/* vec_vcmpgtfp */
1768
Daniel Jasperbe508362016-03-11 22:13:28 +00001769static __inline__ vector bool int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001770vec_vcmpgtfp(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001771 return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001772}
1773
1774/* vec_cmple */
Chris Lattnerdad40622010-04-14 03:54:58 +00001775
Daniel Jasperbe508362016-03-11 22:13:28 +00001776static __inline__ vector bool char __ATTRS_o_ai
1777vec_cmple(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001778 return vec_cmpge(__b, __a);
1779}
1780
Daniel Jasperbe508362016-03-11 22:13:28 +00001781static __inline__ vector bool char __ATTRS_o_ai
1782vec_cmple(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001783 return vec_cmpge(__b, __a);
1784}
1785
Daniel Jasperbe508362016-03-11 22:13:28 +00001786static __inline__ vector bool short __ATTRS_o_ai
1787vec_cmple(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001788 return vec_cmpge(__b, __a);
1789}
1790
Daniel Jasperbe508362016-03-11 22:13:28 +00001791static __inline__ vector bool short __ATTRS_o_ai
1792vec_cmple(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001793 return vec_cmpge(__b, __a);
1794}
1795
Daniel Jasperbe508362016-03-11 22:13:28 +00001796static __inline__ vector bool int __ATTRS_o_ai
1797vec_cmple(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001798 return vec_cmpge(__b, __a);
1799}
1800
Daniel Jasperbe508362016-03-11 22:13:28 +00001801static __inline__ vector bool int __ATTRS_o_ai
1802vec_cmple(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00001803 return vec_cmpge(__b, __a);
1804}
1805
Daniel Jasperbe508362016-03-11 22:13:28 +00001806static __inline__ vector bool int __ATTRS_o_ai vec_cmple(vector float __a,
1807 vector float __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001808 return vec_cmpge(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001809}
1810
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001811#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001812static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001813vec_cmple(vector double __a, vector double __b) {
1814 return vec_cmpge(__b, __a);
1815}
1816#endif
1817
1818#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00001819static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001820vec_cmple(vector signed long long __a, vector signed long long __b) {
1821 return vec_cmpge(__b, __a);
1822}
1823
Daniel Jasperbe508362016-03-11 22:13:28 +00001824static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001825vec_cmple(vector unsigned long long __a, vector unsigned long long __b) {
1826 return vec_cmpge(__b, __a);
1827}
1828#endif
1829
Chris Lattnerdad40622010-04-14 03:54:58 +00001830/* vec_cmplt */
1831
Daniel Jasperbe508362016-03-11 22:13:28 +00001832static __inline__ vector bool char __ATTRS_o_ai
1833vec_cmplt(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001834 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001835}
1836
Daniel Jasperbe508362016-03-11 22:13:28 +00001837static __inline__ vector bool char __ATTRS_o_ai
1838vec_cmplt(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001839 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001840}
1841
Daniel Jasperbe508362016-03-11 22:13:28 +00001842static __inline__ vector bool short __ATTRS_o_ai vec_cmplt(vector short __a,
1843 vector short __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001844 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001845}
1846
Daniel Jasperbe508362016-03-11 22:13:28 +00001847static __inline__ vector bool short __ATTRS_o_ai
1848vec_cmplt(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001849 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001850}
1851
Daniel Jasperbe508362016-03-11 22:13:28 +00001852static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector int __a,
1853 vector int __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001854 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001855}
1856
Daniel Jasperbe508362016-03-11 22:13:28 +00001857static __inline__ vector bool int __ATTRS_o_ai
1858vec_cmplt(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001859 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001860}
1861
Daniel Jasperbe508362016-03-11 22:13:28 +00001862static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector float __a,
1863 vector float __b) {
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001864 return vec_cmpgt(__b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +00001865}
1866
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001867#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001868static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001869vec_cmplt(vector double __a, vector double __b) {
1870 return vec_cmpgt(__b, __a);
1871}
1872#endif
1873
1874#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00001875static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001876vec_cmplt(vector signed long long __a, vector signed long long __b) {
1877 return vec_cmpgt(__b, __a);
1878}
1879
Daniel Jasperbe508362016-03-11 22:13:28 +00001880static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001881vec_cmplt(vector unsigned long long __a, vector unsigned long long __b) {
1882 return vec_cmpgt(__b, __a);
1883}
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001884
1885/* vec_cntlz */
1886
Daniel Jasperbe508362016-03-11 22:13:28 +00001887static __inline__ vector signed char __ATTRS_o_ai
1888vec_cntlz(vector signed char __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001889 return __builtin_altivec_vclzb(__a);
1890}
Daniel Jasperbe508362016-03-11 22:13:28 +00001891static __inline__ vector unsigned char __ATTRS_o_ai
1892vec_cntlz(vector unsigned char __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001893 return __builtin_altivec_vclzb(__a);
1894}
Daniel Jasperbe508362016-03-11 22:13:28 +00001895static __inline__ vector signed short __ATTRS_o_ai
1896vec_cntlz(vector signed short __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001897 return __builtin_altivec_vclzh(__a);
1898}
Daniel Jasperbe508362016-03-11 22:13:28 +00001899static __inline__ vector unsigned short __ATTRS_o_ai
1900vec_cntlz(vector unsigned short __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001901 return __builtin_altivec_vclzh(__a);
1902}
Daniel Jasperbe508362016-03-11 22:13:28 +00001903static __inline__ vector signed int __ATTRS_o_ai
1904vec_cntlz(vector signed int __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001905 return __builtin_altivec_vclzw(__a);
1906}
Daniel Jasperbe508362016-03-11 22:13:28 +00001907static __inline__ vector unsigned int __ATTRS_o_ai
1908vec_cntlz(vector unsigned int __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001909 return __builtin_altivec_vclzw(__a);
1910}
Daniel Jasperbe508362016-03-11 22:13:28 +00001911static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001912vec_cntlz(vector signed long long __a) {
1913 return __builtin_altivec_vclzd(__a);
1914}
Daniel Jasperbe508362016-03-11 22:13:28 +00001915static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001916vec_cntlz(vector unsigned long long __a) {
1917 return __builtin_altivec_vclzd(__a);
1918}
1919#endif
1920
1921/* vec_cpsgn */
1922
1923#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001924static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a,
1925 vector float __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001926 return __builtin_vsx_xvcpsgnsp(__a, __b);
1927}
1928
Daniel Jasperbe508362016-03-11 22:13:28 +00001929static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a,
1930 vector double __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00001931 return __builtin_vsx_xvcpsgndp(__a, __b);
1932}
Nemanja Ivanovic2f1f9262015-06-26 19:27:20 +00001933#endif
1934
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001935/* vec_ctf */
1936
Daniel Jasperbe508362016-03-11 22:13:28 +00001937static __inline__ vector float __ATTRS_o_ai vec_ctf(vector int __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001938 return __builtin_altivec_vcfsx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001939}
1940
Daniel Jasperbe508362016-03-11 22:13:28 +00001941static __inline__ vector float __ATTRS_o_ai vec_ctf(vector unsigned int __a,
1942 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001943 return __builtin_altivec_vcfux((vector int)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001944}
1945
Kyle Butt436ff852016-01-08 02:00:48 +00001946#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001947static __inline__ vector double __ATTRS_o_ai
1948vec_ctf(vector unsigned long long __a, int __b) {
Kyle Butt436ff852016-01-08 02:00:48 +00001949 vector double __ret = __builtin_convertvector(__a, vector double);
1950 __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
1951 return __ret;
1952}
1953
Daniel Jasperbe508362016-03-11 22:13:28 +00001954static __inline__ vector double __ATTRS_o_ai
1955vec_ctf(vector signed long long __a, int __b) {
Kyle Butt436ff852016-01-08 02:00:48 +00001956 vector double __ret = __builtin_convertvector(__a, vector double);
1957 __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
1958 return __ret;
1959}
1960#endif
1961
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001962/* vec_vcfsx */
1963
Daniel Jasperbe508362016-03-11 22:13:28 +00001964static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001965vec_vcfsx(vector int __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001966 return __builtin_altivec_vcfsx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001967}
1968
1969/* vec_vcfux */
1970
Daniel Jasperbe508362016-03-11 22:13:28 +00001971static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001972vec_vcfux(vector unsigned int __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001973 return __builtin_altivec_vcfux((vector int)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001974}
1975
1976/* vec_cts */
1977
Daniel Jasperbe508362016-03-11 22:13:28 +00001978static __inline__ vector int __ATTRS_o_ai vec_cts(vector float __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001979 return __builtin_altivec_vctsxs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001980}
1981
Kyle Butt436ff852016-01-08 02:00:48 +00001982#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00001983static __inline__ vector signed long long __ATTRS_o_ai
1984vec_cts(vector double __a, int __b) {
Kyle Butt436ff852016-01-08 02:00:48 +00001985 __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
1986 return __builtin_convertvector(__a, vector signed long long);
1987}
1988#endif
1989
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001990/* vec_vctsxs */
1991
Daniel Jasperbe508362016-03-11 22:13:28 +00001992static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00001993vec_vctsxs(vector float __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00001994 return __builtin_altivec_vctsxs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00001995}
1996
1997/* vec_ctu */
1998
Daniel Jasperbe508362016-03-11 22:13:28 +00001999static __inline__ vector unsigned int __ATTRS_o_ai vec_ctu(vector float __a,
2000 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002001 return __builtin_altivec_vctuxs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002002}
2003
Kyle Butt436ff852016-01-08 02:00:48 +00002004#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00002005static __inline__ vector unsigned long long __ATTRS_o_ai
2006vec_ctu(vector double __a, int __b) {
Kyle Butt436ff852016-01-08 02:00:48 +00002007 __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
2008 return __builtin_convertvector(__a, vector unsigned long long);
2009}
2010#endif
2011
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002012/* vec_vctuxs */
2013
Daniel Jasperbe508362016-03-11 22:13:28 +00002014static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002015vec_vctuxs(vector float __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002016 return __builtin_altivec_vctuxs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002017}
2018
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002019/* vec_double */
2020
2021#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00002022static __inline__ vector double __ATTRS_o_ai
2023vec_double(vector signed long long __a) {
2024 vector double __ret = {__a[0], __a[1]};
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002025 return __ret;
2026}
2027
Daniel Jasperbe508362016-03-11 22:13:28 +00002028static __inline__ vector double __ATTRS_o_ai
2029vec_double(vector unsigned long long __a) {
2030 vector double __ret = {__a[0], __a[1]};
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002031 return __ret;
2032}
2033#endif
2034
Bill Schmidtcee13a22014-11-14 12:10:51 +00002035/* vec_div */
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002036
2037/* Integer vector divides (vectors are scalarized, elements divided
2038 and the vectors reassembled).
2039*/
Daniel Jasperbe508362016-03-11 22:13:28 +00002040static __inline__ vector signed char __ATTRS_o_ai
2041vec_div(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002042 return __a / __b;
2043}
2044
Daniel Jasperbe508362016-03-11 22:13:28 +00002045static __inline__ vector unsigned char __ATTRS_o_ai
2046vec_div(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002047 return __a / __b;
2048}
2049
Daniel Jasperbe508362016-03-11 22:13:28 +00002050static __inline__ vector signed short __ATTRS_o_ai
2051vec_div(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002052 return __a / __b;
2053}
2054
Daniel Jasperbe508362016-03-11 22:13:28 +00002055static __inline__ vector unsigned short __ATTRS_o_ai
2056vec_div(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002057 return __a / __b;
2058}
2059
Daniel Jasperbe508362016-03-11 22:13:28 +00002060static __inline__ vector signed int __ATTRS_o_ai
2061vec_div(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002062 return __a / __b;
2063}
2064
Daniel Jasperbe508362016-03-11 22:13:28 +00002065static __inline__ vector unsigned int __ATTRS_o_ai
2066vec_div(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002067 return __a / __b;
2068}
2069
Bill Schmidtcee13a22014-11-14 12:10:51 +00002070#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00002071static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002072vec_div(vector signed long long __a, vector signed long long __b) {
2073 return __a / __b;
2074}
2075
Daniel Jasperbe508362016-03-11 22:13:28 +00002076static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002077vec_div(vector unsigned long long __a, vector unsigned long long __b) {
2078 return __a / __b;
2079}
2080
Daniel Jasperbe508362016-03-11 22:13:28 +00002081static __inline__ vector float __ATTRS_o_ai vec_div(vector float __a,
2082 vector float __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002083 return __a / __b;
Bill Schmidtcee13a22014-11-14 12:10:51 +00002084}
2085
Daniel Jasperbe508362016-03-11 22:13:28 +00002086static __inline__ vector double __ATTRS_o_ai vec_div(vector double __a,
2087 vector double __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00002088 return __a / __b;
Bill Schmidtcee13a22014-11-14 12:10:51 +00002089}
2090#endif
2091
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002092/* vec_dss */
2093
Daniel Jasperbe508362016-03-11 22:13:28 +00002094static __inline__ void __attribute__((__always_inline__)) vec_dss(int __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002095 __builtin_altivec_dss(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002096}
2097
2098/* vec_dssall */
2099
Daniel Jasperbe508362016-03-11 22:13:28 +00002100static __inline__ void __attribute__((__always_inline__)) vec_dssall(void) {
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002101 __builtin_altivec_dssall();
2102}
2103
2104/* vec_dst */
2105
Daniel Jasperbe508362016-03-11 22:13:28 +00002106static __inline__ void __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002107vec_dst(const void *__a, int __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002108 __builtin_altivec_dst(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002109}
2110
2111/* vec_dstst */
2112
Daniel Jasperbe508362016-03-11 22:13:28 +00002113static __inline__ void __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002114vec_dstst(const void *__a, int __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002115 __builtin_altivec_dstst(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002116}
2117
2118/* vec_dststt */
2119
Daniel Jasperbe508362016-03-11 22:13:28 +00002120static __inline__ void __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002121vec_dststt(const void *__a, int __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002122 __builtin_altivec_dststt(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002123}
2124
2125/* vec_dstt */
2126
Daniel Jasperbe508362016-03-11 22:13:28 +00002127static __inline__ void __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002128vec_dstt(const void *__a, int __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002129 __builtin_altivec_dstt(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002130}
2131
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002132/* vec_eqv */
2133
2134#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00002135static __inline__ vector signed char __ATTRS_o_ai
2136vec_eqv(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002137 return (vector signed char)__builtin_vsx_xxleqv((vector unsigned int)__a,
2138 (vector unsigned int)__b);
2139}
2140
Daniel Jasperbe508362016-03-11 22:13:28 +00002141static __inline__ vector unsigned char __ATTRS_o_ai
2142vec_eqv(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002143 return (vector unsigned char)__builtin_vsx_xxleqv((vector unsigned int)__a,
2144 (vector unsigned int)__b);
2145}
2146
Daniel Jasperbe508362016-03-11 22:13:28 +00002147static __inline__ vector bool char __ATTRS_o_ai vec_eqv(vector bool char __a,
2148 vector bool char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002149 return (vector bool char)__builtin_vsx_xxleqv((vector unsigned int)__a,
2150 (vector unsigned int)__b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002151}
2152
Daniel Jasperbe508362016-03-11 22:13:28 +00002153static __inline__ vector signed short __ATTRS_o_ai
2154vec_eqv(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002155 return (vector signed short)__builtin_vsx_xxleqv((vector unsigned int)__a,
2156 (vector unsigned int)__b);
2157}
2158
Daniel Jasperbe508362016-03-11 22:13:28 +00002159static __inline__ vector unsigned short __ATTRS_o_ai
2160vec_eqv(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002161 return (vector unsigned short)__builtin_vsx_xxleqv((vector unsigned int)__a,
2162 (vector unsigned int)__b);
2163}
2164
Daniel Jasperbe508362016-03-11 22:13:28 +00002165static __inline__ vector bool short __ATTRS_o_ai
2166vec_eqv(vector bool short __a, vector bool short __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002167 return (vector bool short)__builtin_vsx_xxleqv((vector unsigned int)__a,
2168 (vector unsigned int)__b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002169}
2170
Daniel Jasperbe508362016-03-11 22:13:28 +00002171static __inline__ vector signed int __ATTRS_o_ai
2172vec_eqv(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002173 return (vector signed int)__builtin_vsx_xxleqv((vector unsigned int)__a,
2174 (vector unsigned int)__b);
2175}
2176
Daniel Jasperbe508362016-03-11 22:13:28 +00002177static __inline__ vector unsigned int __ATTRS_o_ai
2178vec_eqv(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002179 return __builtin_vsx_xxleqv(__a, __b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002180}
2181
Daniel Jasperbe508362016-03-11 22:13:28 +00002182static __inline__ vector bool int __ATTRS_o_ai vec_eqv(vector bool int __a,
2183 vector bool int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002184 return (vector bool int)__builtin_vsx_xxleqv((vector unsigned int)__a,
Daniel Jasperbe508362016-03-11 22:13:28 +00002185 (vector unsigned int)__b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002186}
2187
Daniel Jasperbe508362016-03-11 22:13:28 +00002188static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002189vec_eqv(vector signed long long __a, vector signed long long __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00002190 return (vector signed long long)__builtin_vsx_xxleqv(
2191 (vector unsigned int)__a, (vector unsigned int)__b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002192}
2193
Daniel Jasperbe508362016-03-11 22:13:28 +00002194static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002195vec_eqv(vector unsigned long long __a, vector unsigned long long __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00002196 return (vector unsigned long long)__builtin_vsx_xxleqv(
2197 (vector unsigned int)__a, (vector unsigned int)__b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002198}
2199
Daniel Jasperbe508362016-03-11 22:13:28 +00002200static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002201vec_eqv(vector bool long long __a, vector bool long long __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00002202 return (vector bool long long)__builtin_vsx_xxleqv((vector unsigned int)__a,
2203 (vector unsigned int)__b);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002204}
2205
Daniel Jasperbe508362016-03-11 22:13:28 +00002206static __inline__ vector float __ATTRS_o_ai vec_eqv(vector float __a,
2207 vector float __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002208 return (vector float)__builtin_vsx_xxleqv((vector unsigned int)__a,
2209 (vector unsigned int)__b);
2210}
2211
Daniel Jasperbe508362016-03-11 22:13:28 +00002212static __inline__ vector double __ATTRS_o_ai vec_eqv(vector double __a,
2213 vector double __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002214 return (vector double)__builtin_vsx_xxleqv((vector unsigned int)__a,
2215 (vector unsigned int)__b);
2216}
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00002217#endif
2218
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002219/* vec_expte */
2220
Daniel Jasperbe508362016-03-11 22:13:28 +00002221static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002222vec_expte(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002223 return __builtin_altivec_vexptefp(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002224}
2225
2226/* vec_vexptefp */
2227
Daniel Jasperbe508362016-03-11 22:13:28 +00002228static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002229vec_vexptefp(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002230 return __builtin_altivec_vexptefp(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002231}
2232
2233/* vec_floor */
2234
Daniel Jasperbe508362016-03-11 22:13:28 +00002235static __inline__ vector float __ATTRS_o_ai vec_floor(vector float __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002236#ifdef __VSX__
2237 return __builtin_vsx_xvrspim(__a);
2238#else
David Blaikie3302f2b2013-01-16 23:08:36 +00002239 return __builtin_altivec_vrfim(__a);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002240#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002241}
2242
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002243#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00002244static __inline__ vector double __ATTRS_o_ai vec_floor(vector double __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002245 return __builtin_vsx_xvrdpim(__a);
2246}
2247#endif
2248
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002249/* vec_vrfim */
2250
Daniel Jasperbe508362016-03-11 22:13:28 +00002251static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002252vec_vrfim(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002253 return __builtin_altivec_vrfim(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002254}
2255
2256/* vec_ld */
2257
Daniel Jasperbe508362016-03-11 22:13:28 +00002258static __inline__ vector signed char __ATTRS_o_ai
2259vec_ld(int __a, const vector signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002260 return (vector signed char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002261}
2262
Daniel Jasperbe508362016-03-11 22:13:28 +00002263static __inline__ vector signed char __ATTRS_o_ai
2264vec_ld(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002265 return (vector signed char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002266}
2267
Daniel Jasperbe508362016-03-11 22:13:28 +00002268static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002269vec_ld(int __a, const vector unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002270 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002271}
2272
Daniel Jasperbe508362016-03-11 22:13:28 +00002273static __inline__ vector unsigned char __ATTRS_o_ai
2274vec_ld(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002275 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002276}
2277
Daniel Jasperbe508362016-03-11 22:13:28 +00002278static __inline__ vector bool char __ATTRS_o_ai
2279vec_ld(int __a, const vector bool char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002280 return (vector bool char)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002281}
2282
Daniel Jasperbe508362016-03-11 22:13:28 +00002283static __inline__ vector short __ATTRS_o_ai vec_ld(int __a,
2284 const vector short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002285 return (vector short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002286}
2287
Daniel Jasperbe508362016-03-11 22:13:28 +00002288static __inline__ vector short __ATTRS_o_ai vec_ld(int __a, const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002289 return (vector short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002290}
2291
Daniel Jasperbe508362016-03-11 22:13:28 +00002292static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002293vec_ld(int __a, const vector unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002294 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002295}
2296
Daniel Jasperbe508362016-03-11 22:13:28 +00002297static __inline__ vector unsigned short __ATTRS_o_ai
2298vec_ld(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002299 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002300}
2301
Daniel Jasperbe508362016-03-11 22:13:28 +00002302static __inline__ vector bool short __ATTRS_o_ai
2303vec_ld(int __a, const vector bool short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002304 return (vector bool short)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002305}
2306
Daniel Jasperbe508362016-03-11 22:13:28 +00002307static __inline__ vector pixel __ATTRS_o_ai vec_ld(int __a,
2308 const vector pixel *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002309 return (vector pixel)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002310}
2311
Daniel Jasperbe508362016-03-11 22:13:28 +00002312static __inline__ vector int __ATTRS_o_ai vec_ld(int __a,
2313 const vector int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002314 return (vector int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002315}
2316
Daniel Jasperbe508362016-03-11 22:13:28 +00002317static __inline__ vector int __ATTRS_o_ai vec_ld(int __a, const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002318 return (vector int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002319}
2320
Daniel Jasperbe508362016-03-11 22:13:28 +00002321static __inline__ vector unsigned int __ATTRS_o_ai
2322vec_ld(int __a, const vector unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002323 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002324}
2325
Daniel Jasperbe508362016-03-11 22:13:28 +00002326static __inline__ vector unsigned int __ATTRS_o_ai
2327vec_ld(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002328 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002329}
2330
Daniel Jasperbe508362016-03-11 22:13:28 +00002331static __inline__ vector bool int __ATTRS_o_ai
2332vec_ld(int __a, const vector bool int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002333 return (vector bool int)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002334}
2335
Daniel Jasperbe508362016-03-11 22:13:28 +00002336static __inline__ vector float __ATTRS_o_ai vec_ld(int __a,
2337 const vector float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002338 return (vector float)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002339}
2340
Daniel Jasperbe508362016-03-11 22:13:28 +00002341static __inline__ vector float __ATTRS_o_ai vec_ld(int __a, const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002342 return (vector float)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002343}
2344
2345/* vec_lvx */
2346
Daniel Jasperbe508362016-03-11 22:13:28 +00002347static __inline__ vector signed char __ATTRS_o_ai
2348vec_lvx(int __a, const vector signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002349 return (vector signed char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002350}
2351
Daniel Jasperbe508362016-03-11 22:13:28 +00002352static __inline__ vector signed char __ATTRS_o_ai
2353vec_lvx(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002354 return (vector signed char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002355}
2356
Daniel Jasperbe508362016-03-11 22:13:28 +00002357static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002358vec_lvx(int __a, const vector unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002359 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002360}
2361
Daniel Jasperbe508362016-03-11 22:13:28 +00002362static __inline__ vector unsigned char __ATTRS_o_ai
2363vec_lvx(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002364 return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002365}
2366
Daniel Jasperbe508362016-03-11 22:13:28 +00002367static __inline__ vector bool char __ATTRS_o_ai
2368vec_lvx(int __a, const vector bool char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002369 return (vector bool char)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002370}
2371
Daniel Jasperbe508362016-03-11 22:13:28 +00002372static __inline__ vector short __ATTRS_o_ai vec_lvx(int __a,
2373 const vector short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002374 return (vector short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002375}
2376
Daniel Jasperbe508362016-03-11 22:13:28 +00002377static __inline__ vector short __ATTRS_o_ai vec_lvx(int __a, const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002378 return (vector short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002379}
2380
Daniel Jasperbe508362016-03-11 22:13:28 +00002381static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002382vec_lvx(int __a, const vector unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002383 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002384}
2385
Daniel Jasperbe508362016-03-11 22:13:28 +00002386static __inline__ vector unsigned short __ATTRS_o_ai
2387vec_lvx(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002388 return (vector unsigned short)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002389}
2390
Daniel Jasperbe508362016-03-11 22:13:28 +00002391static __inline__ vector bool short __ATTRS_o_ai
2392vec_lvx(int __a, const vector bool short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002393 return (vector bool short)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002394}
2395
Daniel Jasperbe508362016-03-11 22:13:28 +00002396static __inline__ vector pixel __ATTRS_o_ai vec_lvx(int __a,
2397 const vector pixel *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002398 return (vector pixel)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002399}
2400
Daniel Jasperbe508362016-03-11 22:13:28 +00002401static __inline__ vector int __ATTRS_o_ai vec_lvx(int __a,
2402 const vector int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002403 return (vector int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002404}
2405
Daniel Jasperbe508362016-03-11 22:13:28 +00002406static __inline__ vector int __ATTRS_o_ai vec_lvx(int __a, const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002407 return (vector int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002408}
2409
Daniel Jasperbe508362016-03-11 22:13:28 +00002410static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002411vec_lvx(int __a, const vector unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002412 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002413}
2414
Daniel Jasperbe508362016-03-11 22:13:28 +00002415static __inline__ vector unsigned int __ATTRS_o_ai
2416vec_lvx(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002417 return (vector unsigned int)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002418}
2419
Daniel Jasperbe508362016-03-11 22:13:28 +00002420static __inline__ vector bool int __ATTRS_o_ai
2421vec_lvx(int __a, const vector bool int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002422 return (vector bool int)__builtin_altivec_lvx(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002423}
2424
Daniel Jasperbe508362016-03-11 22:13:28 +00002425static __inline__ vector float __ATTRS_o_ai vec_lvx(int __a,
2426 const vector float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002427 return (vector float)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002428}
2429
Daniel Jasperbe508362016-03-11 22:13:28 +00002430static __inline__ vector float __ATTRS_o_ai vec_lvx(int __a, const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002431 return (vector float)__builtin_altivec_lvx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002432}
2433
2434/* vec_lde */
2435
Daniel Jasperbe508362016-03-11 22:13:28 +00002436static __inline__ vector signed char __ATTRS_o_ai
2437vec_lde(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002438 return (vector signed char)__builtin_altivec_lvebx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002439}
2440
Daniel Jasperbe508362016-03-11 22:13:28 +00002441static __inline__ vector unsigned char __ATTRS_o_ai
2442vec_lde(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002443 return (vector unsigned char)__builtin_altivec_lvebx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002444}
2445
Daniel Jasperbe508362016-03-11 22:13:28 +00002446static __inline__ vector short __ATTRS_o_ai vec_lde(int __a, const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002447 return (vector short)__builtin_altivec_lvehx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002448}
2449
Daniel Jasperbe508362016-03-11 22:13:28 +00002450static __inline__ vector unsigned short __ATTRS_o_ai
2451vec_lde(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002452 return (vector unsigned short)__builtin_altivec_lvehx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002453}
2454
Daniel Jasperbe508362016-03-11 22:13:28 +00002455static __inline__ vector int __ATTRS_o_ai vec_lde(int __a, const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002456 return (vector int)__builtin_altivec_lvewx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002457}
2458
Daniel Jasperbe508362016-03-11 22:13:28 +00002459static __inline__ vector unsigned int __ATTRS_o_ai
2460vec_lde(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002461 return (vector unsigned int)__builtin_altivec_lvewx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002462}
2463
Daniel Jasperbe508362016-03-11 22:13:28 +00002464static __inline__ vector float __ATTRS_o_ai vec_lde(int __a, const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002465 return (vector float)__builtin_altivec_lvewx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002466}
2467
2468/* vec_lvebx */
2469
Daniel Jasperbe508362016-03-11 22:13:28 +00002470static __inline__ vector signed char __ATTRS_o_ai
2471vec_lvebx(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002472 return (vector signed char)__builtin_altivec_lvebx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002473}
2474
Daniel Jasperbe508362016-03-11 22:13:28 +00002475static __inline__ vector unsigned char __ATTRS_o_ai
2476vec_lvebx(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002477 return (vector unsigned char)__builtin_altivec_lvebx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002478}
2479
2480/* vec_lvehx */
2481
Daniel Jasperbe508362016-03-11 22:13:28 +00002482static __inline__ vector short __ATTRS_o_ai vec_lvehx(int __a,
2483 const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002484 return (vector short)__builtin_altivec_lvehx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002485}
2486
Daniel Jasperbe508362016-03-11 22:13:28 +00002487static __inline__ vector unsigned short __ATTRS_o_ai
2488vec_lvehx(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002489 return (vector unsigned short)__builtin_altivec_lvehx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002490}
2491
2492/* vec_lvewx */
2493
Daniel Jasperbe508362016-03-11 22:13:28 +00002494static __inline__ vector int __ATTRS_o_ai vec_lvewx(int __a, const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002495 return (vector int)__builtin_altivec_lvewx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002496}
2497
Daniel Jasperbe508362016-03-11 22:13:28 +00002498static __inline__ vector unsigned int __ATTRS_o_ai
2499vec_lvewx(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002500 return (vector unsigned int)__builtin_altivec_lvewx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002501}
2502
Daniel Jasperbe508362016-03-11 22:13:28 +00002503static __inline__ vector float __ATTRS_o_ai vec_lvewx(int __a,
2504 const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002505 return (vector float)__builtin_altivec_lvewx(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002506}
2507
2508/* vec_ldl */
2509
Daniel Jasperbe508362016-03-11 22:13:28 +00002510static __inline__ vector signed char __ATTRS_o_ai
2511vec_ldl(int __a, const vector signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002512 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002513}
2514
Daniel Jasperbe508362016-03-11 22:13:28 +00002515static __inline__ vector signed char __ATTRS_o_ai
2516vec_ldl(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002517 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002518}
2519
Daniel Jasperbe508362016-03-11 22:13:28 +00002520static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002521vec_ldl(int __a, const vector unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002522 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002523}
2524
Daniel Jasperbe508362016-03-11 22:13:28 +00002525static __inline__ vector unsigned char __ATTRS_o_ai
2526vec_ldl(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002527 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002528}
2529
Daniel Jasperbe508362016-03-11 22:13:28 +00002530static __inline__ vector bool char __ATTRS_o_ai
2531vec_ldl(int __a, const vector bool char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002532 return (vector bool char)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002533}
2534
Daniel Jasperbe508362016-03-11 22:13:28 +00002535static __inline__ vector short __ATTRS_o_ai vec_ldl(int __a,
2536 const vector short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002537 return (vector short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002538}
2539
Daniel Jasperbe508362016-03-11 22:13:28 +00002540static __inline__ vector short __ATTRS_o_ai vec_ldl(int __a, const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002541 return (vector short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002542}
2543
Daniel Jasperbe508362016-03-11 22:13:28 +00002544static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002545vec_ldl(int __a, const vector unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002546 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002547}
2548
Daniel Jasperbe508362016-03-11 22:13:28 +00002549static __inline__ vector unsigned short __ATTRS_o_ai
2550vec_ldl(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002551 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002552}
2553
Daniel Jasperbe508362016-03-11 22:13:28 +00002554static __inline__ vector bool short __ATTRS_o_ai
2555vec_ldl(int __a, const vector bool short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002556 return (vector bool short)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002557}
2558
Daniel Jasperbe508362016-03-11 22:13:28 +00002559static __inline__ vector pixel __ATTRS_o_ai vec_ldl(int __a,
2560 const vector pixel *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002561 return (vector pixel short)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002562}
2563
Daniel Jasperbe508362016-03-11 22:13:28 +00002564static __inline__ vector int __ATTRS_o_ai vec_ldl(int __a,
2565 const vector int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002566 return (vector int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002567}
2568
Daniel Jasperbe508362016-03-11 22:13:28 +00002569static __inline__ vector int __ATTRS_o_ai vec_ldl(int __a, const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002570 return (vector int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002571}
2572
Daniel Jasperbe508362016-03-11 22:13:28 +00002573static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002574vec_ldl(int __a, const vector unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002575 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002576}
2577
Daniel Jasperbe508362016-03-11 22:13:28 +00002578static __inline__ vector unsigned int __ATTRS_o_ai
2579vec_ldl(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002580 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002581}
2582
Daniel Jasperbe508362016-03-11 22:13:28 +00002583static __inline__ vector bool int __ATTRS_o_ai
2584vec_ldl(int __a, const vector bool int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002585 return (vector bool int)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002586}
2587
Daniel Jasperbe508362016-03-11 22:13:28 +00002588static __inline__ vector float __ATTRS_o_ai vec_ldl(int __a,
2589 const vector float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002590 return (vector float)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002591}
2592
Daniel Jasperbe508362016-03-11 22:13:28 +00002593static __inline__ vector float __ATTRS_o_ai vec_ldl(int __a, const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002594 return (vector float)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002595}
2596
2597/* vec_lvxl */
2598
Daniel Jasperbe508362016-03-11 22:13:28 +00002599static __inline__ vector signed char __ATTRS_o_ai
2600vec_lvxl(int __a, const vector signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002601 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002602}
2603
Daniel Jasperbe508362016-03-11 22:13:28 +00002604static __inline__ vector signed char __ATTRS_o_ai
2605vec_lvxl(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002606 return (vector signed char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002607}
2608
Daniel Jasperbe508362016-03-11 22:13:28 +00002609static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002610vec_lvxl(int __a, const vector unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002611 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002612}
2613
Daniel Jasperbe508362016-03-11 22:13:28 +00002614static __inline__ vector unsigned char __ATTRS_o_ai
2615vec_lvxl(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002616 return (vector unsigned char)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002617}
2618
Daniel Jasperbe508362016-03-11 22:13:28 +00002619static __inline__ vector bool char __ATTRS_o_ai
2620vec_lvxl(int __a, const vector bool char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002621 return (vector bool char)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002622}
2623
Daniel Jasperbe508362016-03-11 22:13:28 +00002624static __inline__ vector short __ATTRS_o_ai vec_lvxl(int __a,
2625 const vector short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002626 return (vector short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002627}
2628
Daniel Jasperbe508362016-03-11 22:13:28 +00002629static __inline__ vector short __ATTRS_o_ai vec_lvxl(int __a,
2630 const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002631 return (vector short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002632}
2633
Daniel Jasperbe508362016-03-11 22:13:28 +00002634static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002635vec_lvxl(int __a, const vector unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002636 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002637}
2638
Daniel Jasperbe508362016-03-11 22:13:28 +00002639static __inline__ vector unsigned short __ATTRS_o_ai
2640vec_lvxl(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002641 return (vector unsigned short)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002642}
2643
Daniel Jasperbe508362016-03-11 22:13:28 +00002644static __inline__ vector bool short __ATTRS_o_ai
2645vec_lvxl(int __a, const vector bool short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002646 return (vector bool short)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002647}
2648
Daniel Jasperbe508362016-03-11 22:13:28 +00002649static __inline__ vector pixel __ATTRS_o_ai vec_lvxl(int __a,
2650 const vector pixel *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002651 return (vector pixel)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002652}
2653
Daniel Jasperbe508362016-03-11 22:13:28 +00002654static __inline__ vector int __ATTRS_o_ai vec_lvxl(int __a,
2655 const vector int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002656 return (vector int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002657}
2658
Daniel Jasperbe508362016-03-11 22:13:28 +00002659static __inline__ vector int __ATTRS_o_ai vec_lvxl(int __a, const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002660 return (vector int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002661}
2662
Daniel Jasperbe508362016-03-11 22:13:28 +00002663static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002664vec_lvxl(int __a, const vector unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002665 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002666}
2667
Daniel Jasperbe508362016-03-11 22:13:28 +00002668static __inline__ vector unsigned int __ATTRS_o_ai
2669vec_lvxl(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002670 return (vector unsigned int)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002671}
2672
Daniel Jasperbe508362016-03-11 22:13:28 +00002673static __inline__ vector bool int __ATTRS_o_ai
2674vec_lvxl(int __a, const vector bool int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002675 return (vector bool int)__builtin_altivec_lvxl(__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00002676}
2677
Daniel Jasperbe508362016-03-11 22:13:28 +00002678static __inline__ vector float __ATTRS_o_ai vec_lvxl(int __a,
2679 const vector float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002680 return (vector float)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002681}
2682
Daniel Jasperbe508362016-03-11 22:13:28 +00002683static __inline__ vector float __ATTRS_o_ai vec_lvxl(int __a,
2684 const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002685 return (vector float)__builtin_altivec_lvxl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002686}
2687
2688/* vec_loge */
2689
Daniel Jasperbe508362016-03-11 22:13:28 +00002690static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002691vec_loge(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002692 return __builtin_altivec_vlogefp(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002693}
2694
2695/* vec_vlogefp */
2696
Daniel Jasperbe508362016-03-11 22:13:28 +00002697static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002698vec_vlogefp(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002699 return __builtin_altivec_vlogefp(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002700}
2701
2702/* vec_lvsl */
2703
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002704#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002705static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002706 __attribute__((__deprecated__("use assignment for unaligned little endian \
2707loads/stores"))) vec_lvsl(int __a, const signed char *__b) {
2708 vector unsigned char mask =
2709 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2710 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2711 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002712 return vec_perm(mask, mask, reverse);
2713}
2714#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002715static __inline__ vector unsigned char __ATTRS_o_ai
2716vec_lvsl(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002717 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002718}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002719#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002720
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002721#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002722static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002723 __attribute__((__deprecated__("use assignment for unaligned little endian \
2724loads/stores"))) vec_lvsl(int __a, const unsigned char *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002725 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002726 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2727 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2728 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002729 return vec_perm(mask, mask, reverse);
2730}
2731#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002732static __inline__ vector unsigned char __ATTRS_o_ai
2733vec_lvsl(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002734 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002735}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002736#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002737
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002738#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002739static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002740 __attribute__((__deprecated__("use assignment for unaligned little endian \
2741loads/stores"))) vec_lvsl(int __a, const short *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002742 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002743 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2744 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2745 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002746 return vec_perm(mask, mask, reverse);
2747}
2748#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002749static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
2750 const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002751 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002752}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002753#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002754
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002755#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002756static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002757 __attribute__((__deprecated__("use assignment for unaligned little endian \
2758loads/stores"))) vec_lvsl(int __a, const unsigned short *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002759 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002760 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2761 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2762 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002763 return vec_perm(mask, mask, reverse);
2764}
2765#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002766static __inline__ vector unsigned char __ATTRS_o_ai
2767vec_lvsl(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002768 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002769}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002770#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002771
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002772#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002773static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002774 __attribute__((__deprecated__("use assignment for unaligned little endian \
2775loads/stores"))) vec_lvsl(int __a, const int *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002776 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002777 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2778 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2779 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002780 return vec_perm(mask, mask, reverse);
2781}
2782#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002783static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
2784 const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002785 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002786}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002787#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002788
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002789#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002790static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002791 __attribute__((__deprecated__("use assignment for unaligned little endian \
2792loads/stores"))) vec_lvsl(int __a, const unsigned int *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002793 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002794 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2795 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2796 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002797 return vec_perm(mask, mask, reverse);
2798}
2799#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002800static __inline__ vector unsigned char __ATTRS_o_ai
2801vec_lvsl(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002802 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002803}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002804#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002805
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002806#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002807static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002808 __attribute__((__deprecated__("use assignment for unaligned little endian \
2809loads/stores"))) vec_lvsl(int __a, const float *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002810 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002811 (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
2812 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2813 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002814 return vec_perm(mask, mask, reverse);
2815}
2816#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002817static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a,
2818 const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002819 return (vector unsigned char)__builtin_altivec_lvsl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002820}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002821#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002822
2823/* vec_lvsr */
2824
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002825#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002826static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002827 __attribute__((__deprecated__("use assignment for unaligned little endian \
2828loads/stores"))) vec_lvsr(int __a, const signed char *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002829 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002830 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2831 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2832 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002833 return vec_perm(mask, mask, reverse);
2834}
2835#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002836static __inline__ vector unsigned char __ATTRS_o_ai
2837vec_lvsr(int __a, const signed char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002838 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002839}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002840#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002841
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002842#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002843static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002844 __attribute__((__deprecated__("use assignment for unaligned little endian \
2845loads/stores"))) vec_lvsr(int __a, const unsigned char *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002846 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002847 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2848 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2849 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002850 return vec_perm(mask, mask, reverse);
2851}
2852#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002853static __inline__ vector unsigned char __ATTRS_o_ai
2854vec_lvsr(int __a, const unsigned char *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002855 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002856}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002857#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002858
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002859#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002860static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002861 __attribute__((__deprecated__("use assignment for unaligned little endian \
2862loads/stores"))) vec_lvsr(int __a, const short *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002863 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002864 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2865 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2866 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002867 return vec_perm(mask, mask, reverse);
2868}
2869#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002870static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
2871 const short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002872 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002873}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002874#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002875
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002876#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002877static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002878 __attribute__((__deprecated__("use assignment for unaligned little endian \
2879loads/stores"))) vec_lvsr(int __a, const unsigned short *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002880 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002881 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2882 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2883 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002884 return vec_perm(mask, mask, reverse);
2885}
2886#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002887static __inline__ vector unsigned char __ATTRS_o_ai
2888vec_lvsr(int __a, const unsigned short *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002889 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002890}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002891#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002892
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002893#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002894static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002895 __attribute__((__deprecated__("use assignment for unaligned little endian \
2896loads/stores"))) vec_lvsr(int __a, const int *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002897 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002898 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2899 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2900 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002901 return vec_perm(mask, mask, reverse);
2902}
2903#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002904static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
2905 const int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002906 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002907}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002908#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002909
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002910#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002911static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002912 __attribute__((__deprecated__("use assignment for unaligned little endian \
2913loads/stores"))) vec_lvsr(int __a, const unsigned int *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002914 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002915 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2916 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2917 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002918 return vec_perm(mask, mask, reverse);
2919}
2920#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002921static __inline__ vector unsigned char __ATTRS_o_ai
2922vec_lvsr(int __a, const unsigned int *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002923 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002924}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002925#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002926
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002927#ifdef __LITTLE_ENDIAN__
Daniel Jasperbe508362016-03-11 22:13:28 +00002928static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00002929 __attribute__((__deprecated__("use assignment for unaligned little endian \
2930loads/stores"))) vec_lvsr(int __a, const float *__b) {
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002931 vector unsigned char mask =
Bill Seurer703e8482015-06-09 14:39:47 +00002932 (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
2933 vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8,
2934 7, 6, 5, 4, 3, 2, 1, 0};
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002935 return vec_perm(mask, mask, reverse);
2936}
2937#else
Daniel Jasperbe508362016-03-11 22:13:28 +00002938static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a,
2939 const float *__b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002940 return (vector unsigned char)__builtin_altivec_lvsr(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002941}
Bill Schmidtcad3a5f2014-10-06 19:02:20 +00002942#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002943
2944/* vec_madd */
Daniel Jasperbe508362016-03-11 22:13:28 +00002945static __inline__ vector signed short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002946vec_mladd(vector signed short, vector signed short, vector signed short);
Daniel Jasperbe508362016-03-11 22:13:28 +00002947static __inline__ vector signed short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002948vec_mladd(vector signed short, vector unsigned short, vector unsigned short);
Daniel Jasperbe508362016-03-11 22:13:28 +00002949static __inline__ vector signed short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002950vec_mladd(vector unsigned short, vector signed short, vector signed short);
Daniel Jasperbe508362016-03-11 22:13:28 +00002951static __inline__ vector unsigned short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002952vec_mladd(vector unsigned short, vector unsigned short, vector unsigned short);
2953
Daniel Jasperbe508362016-03-11 22:13:28 +00002954static __inline__ vector signed short __ATTRS_o_ai vec_madd(
2955 vector signed short __a, vector signed short __b, vector signed short __c) {
2956 return vec_mladd(__a, __b, __c);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002957}
2958
Daniel Jasperbe508362016-03-11 22:13:28 +00002959static __inline__ vector signed short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002960vec_madd(vector signed short __a, vector unsigned short __b,
2961 vector unsigned short __c) {
2962 return vec_mladd(__a, __b, __c);
2963}
2964
Daniel Jasperbe508362016-03-11 22:13:28 +00002965static __inline__ vector signed short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002966vec_madd(vector unsigned short __a, vector signed short __b,
2967 vector signed short __c) {
2968 return vec_mladd(__a, __b, __c);
2969}
2970
Daniel Jasperbe508362016-03-11 22:13:28 +00002971static __inline__ vector unsigned short __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00002972vec_madd(vector unsigned short __a, vector unsigned short __b,
2973 vector unsigned short __c) {
2974 return vec_mladd(__a, __b, __c);
2975}
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002976
Daniel Jasperbe508362016-03-11 22:13:28 +00002977static __inline__ vector float __ATTRS_o_ai vec_madd(vector float __a,
2978 vector float __b,
2979 vector float __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002980#ifdef __VSX__
2981 return __builtin_vsx_xvmaddasp(__a, __b, __c);
2982#else
David Blaikie3302f2b2013-01-16 23:08:36 +00002983 return __builtin_altivec_vmaddfp(__a, __b, __c);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002984#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002985}
2986
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002987#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00002988static __inline__ vector double __ATTRS_o_ai vec_madd(vector double __a,
2989 vector double __b,
2990 vector double __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00002991 return __builtin_vsx_xvmaddadp(__a, __b, __c);
2992}
2993#endif
2994
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00002995/* vec_vmaddfp */
2996
Daniel Jasperbe508362016-03-11 22:13:28 +00002997static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00002998vec_vmaddfp(vector float __a, vector float __b, vector float __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00002999 return __builtin_altivec_vmaddfp(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003000}
3001
3002/* vec_madds */
3003
Daniel Jasperbe508362016-03-11 22:13:28 +00003004static __inline__ vector signed short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00003005vec_madds(vector signed short __a, vector signed short __b,
3006 vector signed short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003007 return __builtin_altivec_vmhaddshs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003008}
3009
3010/* vec_vmhaddshs */
Daniel Jasperbe508362016-03-11 22:13:28 +00003011static __inline__ vector signed short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00003012vec_vmhaddshs(vector signed short __a, vector signed short __b,
3013 vector signed short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003014 return __builtin_altivec_vmhaddshs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003015}
3016
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00003017/* vec_msub */
3018
3019#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00003020static __inline__ vector float __ATTRS_o_ai vec_msub(vector float __a,
3021 vector float __b,
3022 vector float __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00003023 return __builtin_vsx_xvmsubasp(__a, __b, __c);
3024}
3025
Daniel Jasperbe508362016-03-11 22:13:28 +00003026static __inline__ vector double __ATTRS_o_ai vec_msub(vector double __a,
3027 vector double __b,
3028 vector double __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00003029 return __builtin_vsx_xvmsubadp(__a, __b, __c);
3030}
3031#endif
3032
Chris Lattnerdad40622010-04-14 03:54:58 +00003033/* vec_max */
3034
Daniel Jasperbe508362016-03-11 22:13:28 +00003035static __inline__ vector signed char __ATTRS_o_ai
3036vec_max(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003037 return __builtin_altivec_vmaxsb(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003038}
3039
Daniel Jasperbe508362016-03-11 22:13:28 +00003040static __inline__ vector signed char __ATTRS_o_ai
3041vec_max(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003042 return __builtin_altivec_vmaxsb((vector signed char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003043}
3044
Daniel Jasperbe508362016-03-11 22:13:28 +00003045static __inline__ vector signed char __ATTRS_o_ai
3046vec_max(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003047 return __builtin_altivec_vmaxsb(__a, (vector signed char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003048}
3049
Daniel Jasperbe508362016-03-11 22:13:28 +00003050static __inline__ vector unsigned char __ATTRS_o_ai
3051vec_max(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003052 return __builtin_altivec_vmaxub(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003053}
3054
Daniel Jasperbe508362016-03-11 22:13:28 +00003055static __inline__ vector unsigned char __ATTRS_o_ai
3056vec_max(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003057 return __builtin_altivec_vmaxub((vector unsigned char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003058}
3059
Daniel Jasperbe508362016-03-11 22:13:28 +00003060static __inline__ vector unsigned char __ATTRS_o_ai
3061vec_max(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003062 return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003063}
3064
Daniel Jasperbe508362016-03-11 22:13:28 +00003065static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a,
3066 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003067 return __builtin_altivec_vmaxsh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003068}
3069
Daniel Jasperbe508362016-03-11 22:13:28 +00003070static __inline__ vector short __ATTRS_o_ai vec_max(vector bool short __a,
3071 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003072 return __builtin_altivec_vmaxsh((vector short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003073}
3074
Daniel Jasperbe508362016-03-11 22:13:28 +00003075static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a,
3076 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003077 return __builtin_altivec_vmaxsh(__a, (vector short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003078}
3079
Daniel Jasperbe508362016-03-11 22:13:28 +00003080static __inline__ vector unsigned short __ATTRS_o_ai
3081vec_max(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003082 return __builtin_altivec_vmaxuh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003083}
3084
Daniel Jasperbe508362016-03-11 22:13:28 +00003085static __inline__ vector unsigned short __ATTRS_o_ai
3086vec_max(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003087 return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003088}
3089
Daniel Jasperbe508362016-03-11 22:13:28 +00003090static __inline__ vector unsigned short __ATTRS_o_ai
3091vec_max(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003092 return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003093}
3094
Daniel Jasperbe508362016-03-11 22:13:28 +00003095static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a,
3096 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003097 return __builtin_altivec_vmaxsw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003098}
3099
Daniel Jasperbe508362016-03-11 22:13:28 +00003100static __inline__ vector int __ATTRS_o_ai vec_max(vector bool int __a,
3101 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003102 return __builtin_altivec_vmaxsw((vector int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003103}
3104
Daniel Jasperbe508362016-03-11 22:13:28 +00003105static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a,
3106 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003107 return __builtin_altivec_vmaxsw(__a, (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003108}
3109
Daniel Jasperbe508362016-03-11 22:13:28 +00003110static __inline__ vector unsigned int __ATTRS_o_ai
3111vec_max(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003112 return __builtin_altivec_vmaxuw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003113}
3114
Daniel Jasperbe508362016-03-11 22:13:28 +00003115static __inline__ vector unsigned int __ATTRS_o_ai
3116vec_max(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003117 return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003118}
3119
Daniel Jasperbe508362016-03-11 22:13:28 +00003120static __inline__ vector unsigned int __ATTRS_o_ai
3121vec_max(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003122 return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003123}
3124
Kit Barton8553bec2015-03-11 15:57:19 +00003125#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00003126static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003127vec_max(vector signed long long __a, vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00003128 return __builtin_altivec_vmaxsd(__a, __b);
3129}
3130
Daniel Jasperbe508362016-03-11 22:13:28 +00003131static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003132vec_max(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003133 return __builtin_altivec_vmaxsd((vector signed long long)__a, __b);
3134}
3135
Daniel Jasperbe508362016-03-11 22:13:28 +00003136static __inline__ vector signed long long __ATTRS_o_ai
3137vec_max(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003138 return __builtin_altivec_vmaxsd(__a, (vector signed long long)__b);
3139}
3140
Daniel Jasperbe508362016-03-11 22:13:28 +00003141static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003142vec_max(vector unsigned long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00003143 return __builtin_altivec_vmaxud(__a, __b);
3144}
Bill Seurer8be14f12015-06-04 18:45:44 +00003145
Daniel Jasperbe508362016-03-11 22:13:28 +00003146static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003147vec_max(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003148 return __builtin_altivec_vmaxud((vector unsigned long long)__a, __b);
3149}
3150
Daniel Jasperbe508362016-03-11 22:13:28 +00003151static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003152vec_max(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003153 return __builtin_altivec_vmaxud(__a, (vector unsigned long long)__b);
3154}
Kit Barton8553bec2015-03-11 15:57:19 +00003155#endif
3156
Daniel Jasperbe508362016-03-11 22:13:28 +00003157static __inline__ vector float __ATTRS_o_ai vec_max(vector float __a,
3158 vector float __b) {
Bill Schmidt691e01d2014-10-31 19:19:24 +00003159#ifdef __VSX__
3160 return __builtin_vsx_xvmaxsp(__a, __b);
3161#else
David Blaikie3302f2b2013-01-16 23:08:36 +00003162 return __builtin_altivec_vmaxfp(__a, __b);
Bill Schmidt691e01d2014-10-31 19:19:24 +00003163#endif
Chris Lattnerdad40622010-04-14 03:54:58 +00003164}
3165
Bill Schmidt691e01d2014-10-31 19:19:24 +00003166#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00003167static __inline__ vector double __ATTRS_o_ai vec_max(vector double __a,
3168 vector double __b) {
Bill Schmidt691e01d2014-10-31 19:19:24 +00003169 return __builtin_vsx_xvmaxdp(__a, __b);
3170}
3171#endif
3172
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003173/* vec_vmaxsb */
3174
Daniel Jasperbe508362016-03-11 22:13:28 +00003175static __inline__ vector signed char __ATTRS_o_ai
3176vec_vmaxsb(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003177 return __builtin_altivec_vmaxsb(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003178}
3179
Daniel Jasperbe508362016-03-11 22:13:28 +00003180static __inline__ vector signed char __ATTRS_o_ai
3181vec_vmaxsb(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003182 return __builtin_altivec_vmaxsb((vector signed char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003183}
3184
Daniel Jasperbe508362016-03-11 22:13:28 +00003185static __inline__ vector signed char __ATTRS_o_ai
3186vec_vmaxsb(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003187 return __builtin_altivec_vmaxsb(__a, (vector signed char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003188}
3189
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003190/* vec_vmaxub */
3191
Daniel Jasperbe508362016-03-11 22:13:28 +00003192static __inline__ vector unsigned char __ATTRS_o_ai
3193vec_vmaxub(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003194 return __builtin_altivec_vmaxub(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003195}
3196
Daniel Jasperbe508362016-03-11 22:13:28 +00003197static __inline__ vector unsigned char __ATTRS_o_ai
3198vec_vmaxub(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003199 return __builtin_altivec_vmaxub((vector unsigned char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003200}
3201
Daniel Jasperbe508362016-03-11 22:13:28 +00003202static __inline__ vector unsigned char __ATTRS_o_ai
3203vec_vmaxub(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003204 return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003205}
3206
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003207/* vec_vmaxsh */
3208
Daniel Jasperbe508362016-03-11 22:13:28 +00003209static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a,
3210 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003211 return __builtin_altivec_vmaxsh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003212}
3213
Daniel Jasperbe508362016-03-11 22:13:28 +00003214static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector bool short __a,
3215 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003216 return __builtin_altivec_vmaxsh((vector short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003217}
3218
Daniel Jasperbe508362016-03-11 22:13:28 +00003219static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a,
3220 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003221 return __builtin_altivec_vmaxsh(__a, (vector short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003222}
3223
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003224/* vec_vmaxuh */
3225
Daniel Jasperbe508362016-03-11 22:13:28 +00003226static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003227vec_vmaxuh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003228 return __builtin_altivec_vmaxuh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003229}
3230
Daniel Jasperbe508362016-03-11 22:13:28 +00003231static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003232vec_vmaxuh(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003233 return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003234}
3235
Daniel Jasperbe508362016-03-11 22:13:28 +00003236static __inline__ vector unsigned short __ATTRS_o_ai
3237vec_vmaxuh(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003238 return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003239}
3240
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003241/* vec_vmaxsw */
3242
Daniel Jasperbe508362016-03-11 22:13:28 +00003243static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a,
3244 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003245 return __builtin_altivec_vmaxsw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003246}
3247
Daniel Jasperbe508362016-03-11 22:13:28 +00003248static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector bool int __a,
3249 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003250 return __builtin_altivec_vmaxsw((vector int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003251}
3252
Daniel Jasperbe508362016-03-11 22:13:28 +00003253static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a,
3254 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003255 return __builtin_altivec_vmaxsw(__a, (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003256}
3257
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003258/* vec_vmaxuw */
3259
Daniel Jasperbe508362016-03-11 22:13:28 +00003260static __inline__ vector unsigned int __ATTRS_o_ai
3261vec_vmaxuw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003262 return __builtin_altivec_vmaxuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003263}
3264
Daniel Jasperbe508362016-03-11 22:13:28 +00003265static __inline__ vector unsigned int __ATTRS_o_ai
3266vec_vmaxuw(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003267 return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003268}
3269
Daniel Jasperbe508362016-03-11 22:13:28 +00003270static __inline__ vector unsigned int __ATTRS_o_ai
3271vec_vmaxuw(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003272 return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003273}
3274
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003275/* vec_vmaxfp */
3276
Daniel Jasperbe508362016-03-11 22:13:28 +00003277static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00003278vec_vmaxfp(vector float __a, vector float __b) {
Bill Schmidt691e01d2014-10-31 19:19:24 +00003279#ifdef __VSX__
3280 return __builtin_vsx_xvmaxsp(__a, __b);
3281#else
David Blaikie3302f2b2013-01-16 23:08:36 +00003282 return __builtin_altivec_vmaxfp(__a, __b);
Bill Schmidt691e01d2014-10-31 19:19:24 +00003283#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003284}
3285
3286/* vec_mergeh */
3287
Daniel Jasperbe508362016-03-11 22:13:28 +00003288static __inline__ vector signed char __ATTRS_o_ai
3289vec_mergeh(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003290 return vec_perm(__a, __b,
3291 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
3292 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
3293 0x06, 0x16, 0x07, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003294}
3295
Daniel Jasperbe508362016-03-11 22:13:28 +00003296static __inline__ vector unsigned char __ATTRS_o_ai
3297vec_mergeh(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003298 return vec_perm(__a, __b,
3299 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
3300 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
3301 0x06, 0x16, 0x07, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003302}
3303
Daniel Jasperbe508362016-03-11 22:13:28 +00003304static __inline__ vector bool char __ATTRS_o_ai
3305vec_mergeh(vector bool char __a, vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003306 return vec_perm(__a, __b,
3307 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
3308 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
3309 0x06, 0x16, 0x07, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003310}
3311
Daniel Jasperbe508362016-03-11 22:13:28 +00003312static __inline__ vector short __ATTRS_o_ai vec_mergeh(vector short __a,
3313 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003314 return vec_perm(__a, __b,
3315 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3316 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3317 0x06, 0x07, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003318}
3319
Daniel Jasperbe508362016-03-11 22:13:28 +00003320static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003321vec_mergeh(vector unsigned short __a, vector unsigned short __b) {
3322 return vec_perm(__a, __b,
3323 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3324 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3325 0x06, 0x07, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003326}
3327
Daniel Jasperbe508362016-03-11 22:13:28 +00003328static __inline__ vector bool short __ATTRS_o_ai
3329vec_mergeh(vector bool short __a, vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003330 return vec_perm(__a, __b,
3331 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3332 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3333 0x06, 0x07, 0x16, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003334}
3335
Daniel Jasperbe508362016-03-11 22:13:28 +00003336static __inline__ vector pixel __ATTRS_o_ai vec_mergeh(vector pixel __a,
3337 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003338 return vec_perm(__a, __b,
3339 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3340 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3341 0x06, 0x07, 0x16, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003342}
3343
Daniel Jasperbe508362016-03-11 22:13:28 +00003344static __inline__ vector int __ATTRS_o_ai vec_mergeh(vector int __a,
3345 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003346 return vec_perm(__a, __b,
3347 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3348 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3349 0x14, 0x15, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003350}
3351
Daniel Jasperbe508362016-03-11 22:13:28 +00003352static __inline__ vector unsigned int __ATTRS_o_ai
3353vec_mergeh(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003354 return vec_perm(__a, __b,
3355 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3356 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3357 0x14, 0x15, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003358}
3359
Daniel Jasperbe508362016-03-11 22:13:28 +00003360static __inline__ vector bool int __ATTRS_o_ai vec_mergeh(vector bool int __a,
3361 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003362 return vec_perm(__a, __b,
3363 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3364 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3365 0x14, 0x15, 0x16, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003366}
3367
Daniel Jasperbe508362016-03-11 22:13:28 +00003368static __inline__ vector float __ATTRS_o_ai vec_mergeh(vector float __a,
3369 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003370 return vec_perm(__a, __b,
3371 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3372 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3373 0x14, 0x15, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003374}
3375
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003376#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00003377static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003378vec_mergeh(vector signed long long __a, vector signed long long __b) {
3379 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003380 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3381 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003382 0x14, 0x15, 0x16, 0x17));
3383}
3384
Daniel Jasperbe508362016-03-11 22:13:28 +00003385static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003386vec_mergeh(vector signed long long __a, vector bool long long __b) {
3387 return vec_perm(__a, (vector signed long long)__b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003388 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3389 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003390 0x14, 0x15, 0x16, 0x17));
3391}
3392
Daniel Jasperbe508362016-03-11 22:13:28 +00003393static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003394vec_mergeh(vector bool long long __a, vector signed long long __b) {
3395 return vec_perm((vector signed long long)__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003396 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3397 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003398 0x14, 0x15, 0x16, 0x17));
3399}
3400
Daniel Jasperbe508362016-03-11 22:13:28 +00003401static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003402vec_mergeh(vector unsigned long long __a, vector unsigned long long __b) {
3403 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003404 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3405 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003406 0x14, 0x15, 0x16, 0x17));
3407}
3408
Daniel Jasperbe508362016-03-11 22:13:28 +00003409static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003410vec_mergeh(vector unsigned long long __a, vector bool long long __b) {
3411 return vec_perm(__a, (vector unsigned long long)__b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003412 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3413 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003414 0x14, 0x15, 0x16, 0x17));
3415}
3416
Daniel Jasperbe508362016-03-11 22:13:28 +00003417static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003418vec_mergeh(vector bool long long __a, vector unsigned long long __b) {
3419 return vec_perm((vector unsigned long long)__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003420 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3421 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003422 0x14, 0x15, 0x16, 0x17));
3423}
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00003424
Daniel Jasperbe508362016-03-11 22:13:28 +00003425static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00003426vec_mergeh(vector bool long long __a, vector bool long long __b) {
3427 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003428 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3429 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
3430 0x14, 0x15, 0x16, 0x17));
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00003431}
3432
Daniel Jasperbe508362016-03-11 22:13:28 +00003433static __inline__ vector double __ATTRS_o_ai vec_mergeh(vector double __a,
3434 vector double __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003435 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003436 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3437 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003438 0x14, 0x15, 0x16, 0x17));
3439}
Daniel Jasperbe508362016-03-11 22:13:28 +00003440static __inline__ vector double __ATTRS_o_ai
3441vec_mergeh(vector double __a, vector bool long long __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003442 return vec_perm(__a, (vector double)__b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003443 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3444 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003445 0x14, 0x15, 0x16, 0x17));
3446}
Daniel Jasperbe508362016-03-11 22:13:28 +00003447static __inline__ vector double __ATTRS_o_ai
3448vec_mergeh(vector bool long long __a, vector double __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003449 return vec_perm((vector double)__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003450 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
3451 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003452 0x14, 0x15, 0x16, 0x17));
3453}
3454#endif
3455
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003456/* vec_vmrghb */
3457
3458#define __builtin_altivec_vmrghb vec_vmrghb
3459
Daniel Jasperbe508362016-03-11 22:13:28 +00003460static __inline__ vector signed char __ATTRS_o_ai
3461vec_vmrghb(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003462 return vec_perm(__a, __b,
3463 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
3464 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
3465 0x06, 0x16, 0x07, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003466}
3467
Daniel Jasperbe508362016-03-11 22:13:28 +00003468static __inline__ vector unsigned char __ATTRS_o_ai
3469vec_vmrghb(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003470 return vec_perm(__a, __b,
3471 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
3472 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
3473 0x06, 0x16, 0x07, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003474}
3475
Daniel Jasperbe508362016-03-11 22:13:28 +00003476static __inline__ vector bool char __ATTRS_o_ai
3477vec_vmrghb(vector bool char __a, vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003478 return vec_perm(__a, __b,
3479 (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12,
3480 0x03, 0x13, 0x04, 0x14, 0x05, 0x15,
3481 0x06, 0x16, 0x07, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003482}
3483
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003484/* vec_vmrghh */
3485
3486#define __builtin_altivec_vmrghh vec_vmrghh
3487
Daniel Jasperbe508362016-03-11 22:13:28 +00003488static __inline__ vector short __ATTRS_o_ai vec_vmrghh(vector short __a,
3489 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003490 return vec_perm(__a, __b,
3491 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3492 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3493 0x06, 0x07, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003494}
3495
Daniel Jasperbe508362016-03-11 22:13:28 +00003496static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003497vec_vmrghh(vector unsigned short __a, vector unsigned short __b) {
3498 return vec_perm(__a, __b,
3499 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3500 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3501 0x06, 0x07, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003502}
3503
Daniel Jasperbe508362016-03-11 22:13:28 +00003504static __inline__ vector bool short __ATTRS_o_ai
3505vec_vmrghh(vector bool short __a, vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003506 return vec_perm(__a, __b,
3507 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3508 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3509 0x06, 0x07, 0x16, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003510}
3511
Daniel Jasperbe508362016-03-11 22:13:28 +00003512static __inline__ vector pixel __ATTRS_o_ai vec_vmrghh(vector pixel __a,
3513 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003514 return vec_perm(__a, __b,
3515 (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03,
3516 0x12, 0x13, 0x04, 0x05, 0x14, 0x15,
3517 0x06, 0x07, 0x16, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003518}
3519
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003520/* vec_vmrghw */
3521
3522#define __builtin_altivec_vmrghw vec_vmrghw
3523
Daniel Jasperbe508362016-03-11 22:13:28 +00003524static __inline__ vector int __ATTRS_o_ai vec_vmrghw(vector int __a,
3525 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003526 return vec_perm(__a, __b,
3527 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3528 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3529 0x14, 0x15, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003530}
3531
Daniel Jasperbe508362016-03-11 22:13:28 +00003532static __inline__ vector unsigned int __ATTRS_o_ai
3533vec_vmrghw(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003534 return vec_perm(__a, __b,
3535 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3536 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3537 0x14, 0x15, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003538}
3539
Daniel Jasperbe508362016-03-11 22:13:28 +00003540static __inline__ vector bool int __ATTRS_o_ai vec_vmrghw(vector bool int __a,
3541 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003542 return vec_perm(__a, __b,
3543 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3544 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3545 0x14, 0x15, 0x16, 0x17));
Anton Yartsev9e968982010-08-19 03:00:09 +00003546}
3547
Daniel Jasperbe508362016-03-11 22:13:28 +00003548static __inline__ vector float __ATTRS_o_ai vec_vmrghw(vector float __a,
3549 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003550 return vec_perm(__a, __b,
3551 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3552 0x12, 0x13, 0x04, 0x05, 0x06, 0x07,
3553 0x14, 0x15, 0x16, 0x17));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003554}
3555
3556/* vec_mergel */
3557
Daniel Jasperbe508362016-03-11 22:13:28 +00003558static __inline__ vector signed char __ATTRS_o_ai
3559vec_mergel(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003560 return vec_perm(__a, __b,
3561 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
3562 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
3563 0x0E, 0x1E, 0x0F, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003564}
3565
Daniel Jasperbe508362016-03-11 22:13:28 +00003566static __inline__ vector unsigned char __ATTRS_o_ai
3567vec_mergel(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003568 return vec_perm(__a, __b,
3569 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
3570 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
3571 0x0E, 0x1E, 0x0F, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003572}
3573
Daniel Jasperbe508362016-03-11 22:13:28 +00003574static __inline__ vector bool char __ATTRS_o_ai
3575vec_mergel(vector bool char __a, vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003576 return vec_perm(__a, __b,
3577 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
3578 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
3579 0x0E, 0x1E, 0x0F, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003580}
3581
Daniel Jasperbe508362016-03-11 22:13:28 +00003582static __inline__ vector short __ATTRS_o_ai vec_mergel(vector short __a,
3583 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003584 return vec_perm(__a, __b,
3585 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3586 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3587 0x0E, 0x0F, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003588}
3589
Daniel Jasperbe508362016-03-11 22:13:28 +00003590static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003591vec_mergel(vector unsigned short __a, vector unsigned short __b) {
3592 return vec_perm(__a, __b,
3593 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3594 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3595 0x0E, 0x0F, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003596}
3597
Daniel Jasperbe508362016-03-11 22:13:28 +00003598static __inline__ vector bool short __ATTRS_o_ai
3599vec_mergel(vector bool short __a, vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003600 return vec_perm(__a, __b,
3601 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3602 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3603 0x0E, 0x0F, 0x1E, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003604}
3605
Daniel Jasperbe508362016-03-11 22:13:28 +00003606static __inline__ vector pixel __ATTRS_o_ai vec_mergel(vector pixel __a,
3607 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003608 return vec_perm(__a, __b,
3609 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3610 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3611 0x0E, 0x0F, 0x1E, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003612}
3613
Daniel Jasperbe508362016-03-11 22:13:28 +00003614static __inline__ vector int __ATTRS_o_ai vec_mergel(vector int __a,
3615 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003616 return vec_perm(__a, __b,
3617 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3618 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3619 0x1C, 0x1D, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003620}
3621
Daniel Jasperbe508362016-03-11 22:13:28 +00003622static __inline__ vector unsigned int __ATTRS_o_ai
3623vec_mergel(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003624 return vec_perm(__a, __b,
3625 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3626 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3627 0x1C, 0x1D, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003628}
3629
Daniel Jasperbe508362016-03-11 22:13:28 +00003630static __inline__ vector bool int __ATTRS_o_ai vec_mergel(vector bool int __a,
3631 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003632 return vec_perm(__a, __b,
3633 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3634 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3635 0x1C, 0x1D, 0x1E, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003636}
3637
Daniel Jasperbe508362016-03-11 22:13:28 +00003638static __inline__ vector float __ATTRS_o_ai vec_mergel(vector float __a,
3639 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003640 return vec_perm(__a, __b,
3641 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3642 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3643 0x1C, 0x1D, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003644}
3645
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003646#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00003647static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003648vec_mergel(vector signed long long __a, vector signed long long __b) {
3649 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003650 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3651 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003652 0x1C, 0x1D, 0x1E, 0x1F));
3653}
Daniel Jasperbe508362016-03-11 22:13:28 +00003654static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003655vec_mergel(vector signed long long __a, vector bool long long __b) {
3656 return vec_perm(__a, (vector signed long long)__b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003657 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3658 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003659 0x1C, 0x1D, 0x1E, 0x1F));
3660}
Daniel Jasperbe508362016-03-11 22:13:28 +00003661static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003662vec_mergel(vector bool long long __a, vector signed long long __b) {
3663 return vec_perm((vector signed long long)__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003664 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3665 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003666 0x1C, 0x1D, 0x1E, 0x1F));
3667}
Daniel Jasperbe508362016-03-11 22:13:28 +00003668static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003669vec_mergel(vector unsigned long long __a, vector unsigned long long __b) {
3670 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003671 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3672 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003673 0x1C, 0x1D, 0x1E, 0x1F));
3674}
Daniel Jasperbe508362016-03-11 22:13:28 +00003675static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003676vec_mergel(vector unsigned long long __a, vector bool long long __b) {
3677 return vec_perm(__a, (vector unsigned long long)__b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003678 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3679 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003680 0x1C, 0x1D, 0x1E, 0x1F));
3681}
Daniel Jasperbe508362016-03-11 22:13:28 +00003682static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003683vec_mergel(vector bool long long __a, vector unsigned long long __b) {
3684 return vec_perm((vector unsigned long long)__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003685 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3686 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003687 0x1C, 0x1D, 0x1E, 0x1F));
3688}
Daniel Jasperbe508362016-03-11 22:13:28 +00003689static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00003690vec_mergel(vector bool long long __a, vector bool long long __b) {
3691 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003692 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3693 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00003694 0x1C, 0x1D, 0x1E, 0x1F));
3695}
Daniel Jasperbe508362016-03-11 22:13:28 +00003696static __inline__ vector double __ATTRS_o_ai vec_mergel(vector double __a,
3697 vector double __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003698 return vec_perm(__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003699 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3700 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003701 0x1C, 0x1D, 0x1E, 0x1F));
3702}
Daniel Jasperbe508362016-03-11 22:13:28 +00003703static __inline__ vector double __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003704vec_mergel(vector double __a, vector bool long long __b) {
3705 return vec_perm(__a, (vector double)__b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003706 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3707 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003708 0x1C, 0x1D, 0x1E, 0x1F));
3709}
Daniel Jasperbe508362016-03-11 22:13:28 +00003710static __inline__ vector double __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003711vec_mergel(vector bool long long __a, vector double __b) {
3712 return vec_perm((vector double)__a, __b,
Daniel Jasperbe508362016-03-11 22:13:28 +00003713 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
3714 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B,
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00003715 0x1C, 0x1D, 0x1E, 0x1F));
3716}
3717#endif
3718
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003719/* vec_vmrglb */
3720
3721#define __builtin_altivec_vmrglb vec_vmrglb
3722
Daniel Jasperbe508362016-03-11 22:13:28 +00003723static __inline__ vector signed char __ATTRS_o_ai
3724vec_vmrglb(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003725 return vec_perm(__a, __b,
3726 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
3727 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
3728 0x0E, 0x1E, 0x0F, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003729}
3730
Daniel Jasperbe508362016-03-11 22:13:28 +00003731static __inline__ vector unsigned char __ATTRS_o_ai
3732vec_vmrglb(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003733 return vec_perm(__a, __b,
3734 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
3735 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
3736 0x0E, 0x1E, 0x0F, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003737}
3738
Daniel Jasperbe508362016-03-11 22:13:28 +00003739static __inline__ vector bool char __ATTRS_o_ai
3740vec_vmrglb(vector bool char __a, vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003741 return vec_perm(__a, __b,
3742 (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A,
3743 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D,
3744 0x0E, 0x1E, 0x0F, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003745}
3746
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003747/* vec_vmrglh */
3748
3749#define __builtin_altivec_vmrglh vec_vmrglh
3750
Daniel Jasperbe508362016-03-11 22:13:28 +00003751static __inline__ vector short __ATTRS_o_ai vec_vmrglh(vector short __a,
3752 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003753 return vec_perm(__a, __b,
3754 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3755 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3756 0x0E, 0x0F, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003757}
3758
Daniel Jasperbe508362016-03-11 22:13:28 +00003759static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003760vec_vmrglh(vector unsigned short __a, vector unsigned short __b) {
3761 return vec_perm(__a, __b,
3762 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3763 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3764 0x0E, 0x0F, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003765}
3766
Daniel Jasperbe508362016-03-11 22:13:28 +00003767static __inline__ vector bool short __ATTRS_o_ai
3768vec_vmrglh(vector bool short __a, vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003769 return vec_perm(__a, __b,
3770 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3771 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3772 0x0E, 0x0F, 0x1E, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003773}
3774
Daniel Jasperbe508362016-03-11 22:13:28 +00003775static __inline__ vector pixel __ATTRS_o_ai vec_vmrglh(vector pixel __a,
3776 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003777 return vec_perm(__a, __b,
3778 (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B,
3779 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D,
3780 0x0E, 0x0F, 0x1E, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003781}
3782
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003783/* vec_vmrglw */
3784
3785#define __builtin_altivec_vmrglw vec_vmrglw
3786
Daniel Jasperbe508362016-03-11 22:13:28 +00003787static __inline__ vector int __ATTRS_o_ai vec_vmrglw(vector int __a,
3788 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003789 return vec_perm(__a, __b,
3790 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3791 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3792 0x1C, 0x1D, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003793}
3794
Daniel Jasperbe508362016-03-11 22:13:28 +00003795static __inline__ vector unsigned int __ATTRS_o_ai
3796vec_vmrglw(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003797 return vec_perm(__a, __b,
3798 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3799 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3800 0x1C, 0x1D, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003801}
3802
Daniel Jasperbe508362016-03-11 22:13:28 +00003803static __inline__ vector bool int __ATTRS_o_ai vec_vmrglw(vector bool int __a,
3804 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003805 return vec_perm(__a, __b,
3806 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3807 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3808 0x1C, 0x1D, 0x1E, 0x1F));
Anton Yartsev9e968982010-08-19 03:00:09 +00003809}
3810
Daniel Jasperbe508362016-03-11 22:13:28 +00003811static __inline__ vector float __ATTRS_o_ai vec_vmrglw(vector float __a,
3812 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00003813 return vec_perm(__a, __b,
3814 (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19,
3815 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F,
3816 0x1C, 0x1D, 0x1E, 0x1F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003817}
3818
Kit Bartonb61173e2015-07-02 19:29:05 +00003819#ifdef __POWER8_VECTOR__
3820/* vec_mergee */
3821
Daniel Jasperbe508362016-03-11 22:13:28 +00003822static __inline__ vector bool int __ATTRS_o_ai vec_mergee(vector bool int __a,
3823 vector bool int __b) {
3824 return vec_perm(__a, __b,
3825 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3826 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
3827 0x18, 0x19, 0x1A, 0x1B));
Kit Bartonb61173e2015-07-02 19:29:05 +00003828}
3829
Daniel Jasperbe508362016-03-11 22:13:28 +00003830static __inline__ vector signed int __ATTRS_o_ai
Kit Bartonb61173e2015-07-02 19:29:05 +00003831vec_mergee(vector signed int __a, vector signed int __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00003832 return vec_perm(__a, __b,
3833 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3834 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
3835 0x18, 0x19, 0x1A, 0x1B));
Kit Bartonb61173e2015-07-02 19:29:05 +00003836}
3837
Daniel Jasperbe508362016-03-11 22:13:28 +00003838static __inline__ vector unsigned int __ATTRS_o_ai
Kit Bartonb61173e2015-07-02 19:29:05 +00003839vec_mergee(vector unsigned int __a, vector unsigned int __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00003840 return vec_perm(__a, __b,
3841 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11,
3842 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B,
3843 0x18, 0x19, 0x1A, 0x1B));
Kit Bartonb61173e2015-07-02 19:29:05 +00003844}
3845
3846/* vec_mergeo */
3847
Daniel Jasperbe508362016-03-11 22:13:28 +00003848static __inline__ vector bool int __ATTRS_o_ai vec_mergeo(vector bool int __a,
3849 vector bool int __b) {
3850 return vec_perm(__a, __b,
3851 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
3852 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
3853 0x1C, 0x1D, 0x1E, 0x1F));
Kit Bartonb61173e2015-07-02 19:29:05 +00003854}
3855
Daniel Jasperbe508362016-03-11 22:13:28 +00003856static __inline__ vector signed int __ATTRS_o_ai
Kit Bartonb61173e2015-07-02 19:29:05 +00003857vec_mergeo(vector signed int __a, vector signed int __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00003858 return vec_perm(__a, __b,
3859 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
3860 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
3861 0x1C, 0x1D, 0x1E, 0x1F));
Kit Bartonb61173e2015-07-02 19:29:05 +00003862}
3863
Daniel Jasperbe508362016-03-11 22:13:28 +00003864static __inline__ vector unsigned int __ATTRS_o_ai
Kit Bartonb61173e2015-07-02 19:29:05 +00003865vec_mergeo(vector unsigned int __a, vector unsigned int __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00003866 return vec_perm(__a, __b,
3867 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15,
3868 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F,
3869 0x1C, 0x1D, 0x1E, 0x1F));
Kit Bartonb61173e2015-07-02 19:29:05 +00003870}
3871
3872#endif
3873
Chris Lattnerdad40622010-04-14 03:54:58 +00003874/* vec_mfvscr */
3875
Daniel Jasperbe508362016-03-11 22:13:28 +00003876static __inline__ vector unsigned short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00003877vec_mfvscr(void) {
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00003878 return __builtin_altivec_mfvscr();
3879}
Chris Lattnerdad40622010-04-14 03:54:58 +00003880
3881/* vec_min */
3882
Daniel Jasperbe508362016-03-11 22:13:28 +00003883static __inline__ vector signed char __ATTRS_o_ai
3884vec_min(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003885 return __builtin_altivec_vminsb(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003886}
3887
Daniel Jasperbe508362016-03-11 22:13:28 +00003888static __inline__ vector signed char __ATTRS_o_ai
3889vec_min(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003890 return __builtin_altivec_vminsb((vector signed char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003891}
3892
Daniel Jasperbe508362016-03-11 22:13:28 +00003893static __inline__ vector signed char __ATTRS_o_ai
3894vec_min(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003895 return __builtin_altivec_vminsb(__a, (vector signed char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003896}
3897
Daniel Jasperbe508362016-03-11 22:13:28 +00003898static __inline__ vector unsigned char __ATTRS_o_ai
3899vec_min(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003900 return __builtin_altivec_vminub(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003901}
3902
Daniel Jasperbe508362016-03-11 22:13:28 +00003903static __inline__ vector unsigned char __ATTRS_o_ai
3904vec_min(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003905 return __builtin_altivec_vminub((vector unsigned char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003906}
3907
Daniel Jasperbe508362016-03-11 22:13:28 +00003908static __inline__ vector unsigned char __ATTRS_o_ai
3909vec_min(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003910 return __builtin_altivec_vminub(__a, (vector unsigned char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003911}
3912
Daniel Jasperbe508362016-03-11 22:13:28 +00003913static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a,
3914 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003915 return __builtin_altivec_vminsh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003916}
3917
Daniel Jasperbe508362016-03-11 22:13:28 +00003918static __inline__ vector short __ATTRS_o_ai vec_min(vector bool short __a,
3919 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003920 return __builtin_altivec_vminsh((vector short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003921}
3922
Daniel Jasperbe508362016-03-11 22:13:28 +00003923static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a,
3924 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003925 return __builtin_altivec_vminsh(__a, (vector short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003926}
3927
Daniel Jasperbe508362016-03-11 22:13:28 +00003928static __inline__ vector unsigned short __ATTRS_o_ai
3929vec_min(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003930 return __builtin_altivec_vminuh(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003931}
3932
Daniel Jasperbe508362016-03-11 22:13:28 +00003933static __inline__ vector unsigned short __ATTRS_o_ai
3934vec_min(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003935 return __builtin_altivec_vminuh((vector unsigned short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003936}
3937
Daniel Jasperbe508362016-03-11 22:13:28 +00003938static __inline__ vector unsigned short __ATTRS_o_ai
3939vec_min(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003940 return __builtin_altivec_vminuh(__a, (vector unsigned short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003941}
3942
Daniel Jasperbe508362016-03-11 22:13:28 +00003943static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a,
3944 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003945 return __builtin_altivec_vminsw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003946}
3947
Daniel Jasperbe508362016-03-11 22:13:28 +00003948static __inline__ vector int __ATTRS_o_ai vec_min(vector bool int __a,
3949 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003950 return __builtin_altivec_vminsw((vector int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003951}
3952
Daniel Jasperbe508362016-03-11 22:13:28 +00003953static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a,
3954 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003955 return __builtin_altivec_vminsw(__a, (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003956}
3957
Daniel Jasperbe508362016-03-11 22:13:28 +00003958static __inline__ vector unsigned int __ATTRS_o_ai
3959vec_min(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003960 return __builtin_altivec_vminuw(__a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +00003961}
3962
Daniel Jasperbe508362016-03-11 22:13:28 +00003963static __inline__ vector unsigned int __ATTRS_o_ai
3964vec_min(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003965 return __builtin_altivec_vminuw((vector unsigned int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003966}
3967
Daniel Jasperbe508362016-03-11 22:13:28 +00003968static __inline__ vector unsigned int __ATTRS_o_ai
3969vec_min(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00003970 return __builtin_altivec_vminuw(__a, (vector unsigned int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00003971}
3972
Kit Barton8553bec2015-03-11 15:57:19 +00003973#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00003974static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003975vec_min(vector signed long long __a, vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00003976 return __builtin_altivec_vminsd(__a, __b);
3977}
3978
Daniel Jasperbe508362016-03-11 22:13:28 +00003979static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003980vec_min(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003981 return __builtin_altivec_vminsd((vector signed long long)__a, __b);
3982}
3983
Daniel Jasperbe508362016-03-11 22:13:28 +00003984static __inline__ vector signed long long __ATTRS_o_ai
3985vec_min(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003986 return __builtin_altivec_vminsd(__a, (vector signed long long)__b);
3987}
3988
Daniel Jasperbe508362016-03-11 22:13:28 +00003989static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003990vec_min(vector unsigned long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00003991 return __builtin_altivec_vminud(__a, __b);
3992}
Bill Seurer8be14f12015-06-04 18:45:44 +00003993
Daniel Jasperbe508362016-03-11 22:13:28 +00003994static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00003995vec_min(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00003996 return __builtin_altivec_vminud((vector unsigned long long)__a, __b);
3997}
3998
Daniel Jasperbe508362016-03-11 22:13:28 +00003999static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004000vec_min(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00004001 return __builtin_altivec_vminud(__a, (vector unsigned long long)__b);
4002}
Kit Barton8553bec2015-03-11 15:57:19 +00004003#endif
4004
Daniel Jasperbe508362016-03-11 22:13:28 +00004005static __inline__ vector float __ATTRS_o_ai vec_min(vector float __a,
4006 vector float __b) {
Bill Schmidt691e01d2014-10-31 19:19:24 +00004007#ifdef __VSX__
4008 return __builtin_vsx_xvminsp(__a, __b);
4009#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004010 return __builtin_altivec_vminfp(__a, __b);
Bill Schmidt691e01d2014-10-31 19:19:24 +00004011#endif
Chris Lattnerdad40622010-04-14 03:54:58 +00004012}
4013
Bill Schmidt691e01d2014-10-31 19:19:24 +00004014#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004015static __inline__ vector double __ATTRS_o_ai vec_min(vector double __a,
4016 vector double __b) {
Bill Schmidt691e01d2014-10-31 19:19:24 +00004017 return __builtin_vsx_xvmindp(__a, __b);
4018}
4019#endif
4020
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004021/* vec_vminsb */
4022
Daniel Jasperbe508362016-03-11 22:13:28 +00004023static __inline__ vector signed char __ATTRS_o_ai
4024vec_vminsb(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004025 return __builtin_altivec_vminsb(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004026}
4027
Daniel Jasperbe508362016-03-11 22:13:28 +00004028static __inline__ vector signed char __ATTRS_o_ai
4029vec_vminsb(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004030 return __builtin_altivec_vminsb((vector signed char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004031}
4032
Daniel Jasperbe508362016-03-11 22:13:28 +00004033static __inline__ vector signed char __ATTRS_o_ai
4034vec_vminsb(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004035 return __builtin_altivec_vminsb(__a, (vector signed char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004036}
4037
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004038/* vec_vminub */
4039
Daniel Jasperbe508362016-03-11 22:13:28 +00004040static __inline__ vector unsigned char __ATTRS_o_ai
4041vec_vminub(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004042 return __builtin_altivec_vminub(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004043}
4044
Daniel Jasperbe508362016-03-11 22:13:28 +00004045static __inline__ vector unsigned char __ATTRS_o_ai
4046vec_vminub(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004047 return __builtin_altivec_vminub((vector unsigned char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004048}
4049
Daniel Jasperbe508362016-03-11 22:13:28 +00004050static __inline__ vector unsigned char __ATTRS_o_ai
4051vec_vminub(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004052 return __builtin_altivec_vminub(__a, (vector unsigned char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004053}
4054
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004055/* vec_vminsh */
4056
Daniel Jasperbe508362016-03-11 22:13:28 +00004057static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a,
4058 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004059 return __builtin_altivec_vminsh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004060}
4061
Daniel Jasperbe508362016-03-11 22:13:28 +00004062static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector bool short __a,
4063 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004064 return __builtin_altivec_vminsh((vector short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004065}
4066
Daniel Jasperbe508362016-03-11 22:13:28 +00004067static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a,
4068 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004069 return __builtin_altivec_vminsh(__a, (vector short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004070}
4071
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004072/* vec_vminuh */
4073
Daniel Jasperbe508362016-03-11 22:13:28 +00004074static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004075vec_vminuh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004076 return __builtin_altivec_vminuh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004077}
4078
Daniel Jasperbe508362016-03-11 22:13:28 +00004079static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004080vec_vminuh(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004081 return __builtin_altivec_vminuh((vector unsigned short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004082}
4083
Daniel Jasperbe508362016-03-11 22:13:28 +00004084static __inline__ vector unsigned short __ATTRS_o_ai
4085vec_vminuh(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004086 return __builtin_altivec_vminuh(__a, (vector unsigned short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004087}
4088
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004089/* vec_vminsw */
4090
Daniel Jasperbe508362016-03-11 22:13:28 +00004091static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a,
4092 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004093 return __builtin_altivec_vminsw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004094}
4095
Daniel Jasperbe508362016-03-11 22:13:28 +00004096static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector bool int __a,
4097 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004098 return __builtin_altivec_vminsw((vector int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004099}
4100
Daniel Jasperbe508362016-03-11 22:13:28 +00004101static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a,
4102 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004103 return __builtin_altivec_vminsw(__a, (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004104}
4105
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004106/* vec_vminuw */
4107
Daniel Jasperbe508362016-03-11 22:13:28 +00004108static __inline__ vector unsigned int __ATTRS_o_ai
4109vec_vminuw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004110 return __builtin_altivec_vminuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004111}
4112
Daniel Jasperbe508362016-03-11 22:13:28 +00004113static __inline__ vector unsigned int __ATTRS_o_ai
4114vec_vminuw(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004115 return __builtin_altivec_vminuw((vector unsigned int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004116}
4117
Daniel Jasperbe508362016-03-11 22:13:28 +00004118static __inline__ vector unsigned int __ATTRS_o_ai
4119vec_vminuw(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004120 return __builtin_altivec_vminuw(__a, (vector unsigned int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004121}
4122
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004123/* vec_vminfp */
4124
Daniel Jasperbe508362016-03-11 22:13:28 +00004125static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004126vec_vminfp(vector float __a, vector float __b) {
Bill Schmidt691e01d2014-10-31 19:19:24 +00004127#ifdef __VSX__
4128 return __builtin_vsx_xvminsp(__a, __b);
4129#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004130 return __builtin_altivec_vminfp(__a, __b);
Bill Schmidt691e01d2014-10-31 19:19:24 +00004131#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004132}
4133
4134/* vec_mladd */
4135
4136#define __builtin_altivec_vmladduhm vec_mladd
4137
Daniel Jasperbe508362016-03-11 22:13:28 +00004138static __inline__ vector short __ATTRS_o_ai vec_mladd(vector short __a,
4139 vector short __b,
4140 vector short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004141 return __a * __b + __c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004142}
4143
Daniel Jasperbe508362016-03-11 22:13:28 +00004144static __inline__ vector short __ATTRS_o_ai vec_mladd(
4145 vector short __a, vector unsigned short __b, vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004146 return __a * (vector short)__b + (vector short)__c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004147}
4148
Daniel Jasperbe508362016-03-11 22:13:28 +00004149static __inline__ vector short __ATTRS_o_ai vec_mladd(vector unsigned short __a,
4150 vector short __b,
4151 vector short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004152 return (vector short)__a * __b + __c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004153}
4154
Daniel Jasperbe508362016-03-11 22:13:28 +00004155static __inline__ vector unsigned short __ATTRS_o_ai
4156vec_mladd(vector unsigned short __a, vector unsigned short __b,
4157 vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004158 return __a * __b + __c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004159}
4160
4161/* vec_vmladduhm */
4162
Daniel Jasperbe508362016-03-11 22:13:28 +00004163static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(vector short __a,
4164 vector short __b,
4165 vector short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004166 return __a * __b + __c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004167}
4168
Daniel Jasperbe508362016-03-11 22:13:28 +00004169static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(
4170 vector short __a, vector unsigned short __b, vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004171 return __a * (vector short)__b + (vector short)__c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004172}
4173
Daniel Jasperbe508362016-03-11 22:13:28 +00004174static __inline__ vector short __ATTRS_o_ai
4175vec_vmladduhm(vector unsigned short __a, vector short __b, vector short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004176 return (vector short)__a * __b + __c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004177}
4178
Daniel Jasperbe508362016-03-11 22:13:28 +00004179static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004180vec_vmladduhm(vector unsigned short __a, vector unsigned short __b,
4181 vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004182 return __a * __b + __c;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004183}
4184
4185/* vec_mradds */
4186
Daniel Jasperbe508362016-03-11 22:13:28 +00004187static __inline__ vector short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004188vec_mradds(vector short __a, vector short __b, vector short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004189 return __builtin_altivec_vmhraddshs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004190}
4191
4192/* vec_vmhraddshs */
4193
Daniel Jasperbe508362016-03-11 22:13:28 +00004194static __inline__ vector short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004195vec_vmhraddshs(vector short __a, vector short __b, vector short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004196 return __builtin_altivec_vmhraddshs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004197}
4198
4199/* vec_msum */
4200
Daniel Jasperbe508362016-03-11 22:13:28 +00004201static __inline__ vector int __ATTRS_o_ai vec_msum(vector signed char __a,
4202 vector unsigned char __b,
4203 vector int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004204 return __builtin_altivec_vmsummbm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004205}
4206
Daniel Jasperbe508362016-03-11 22:13:28 +00004207static __inline__ vector unsigned int __ATTRS_o_ai
4208vec_msum(vector unsigned char __a, vector unsigned char __b,
4209 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004210 return __builtin_altivec_vmsumubm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004211}
4212
Daniel Jasperbe508362016-03-11 22:13:28 +00004213static __inline__ vector int __ATTRS_o_ai vec_msum(vector short __a,
4214 vector short __b,
4215 vector int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004216 return __builtin_altivec_vmsumshm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004217}
4218
Daniel Jasperbe508362016-03-11 22:13:28 +00004219static __inline__ vector unsigned int __ATTRS_o_ai
4220vec_msum(vector unsigned short __a, vector unsigned short __b,
4221 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004222 return __builtin_altivec_vmsumuhm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004223}
4224
4225/* vec_vmsummbm */
4226
Daniel Jasperbe508362016-03-11 22:13:28 +00004227static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004228vec_vmsummbm(vector signed char __a, vector unsigned char __b, vector int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004229 return __builtin_altivec_vmsummbm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004230}
4231
4232/* vec_vmsumubm */
4233
Daniel Jasperbe508362016-03-11 22:13:28 +00004234static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004235vec_vmsumubm(vector unsigned char __a, vector unsigned char __b,
4236 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004237 return __builtin_altivec_vmsumubm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004238}
4239
4240/* vec_vmsumshm */
4241
Daniel Jasperbe508362016-03-11 22:13:28 +00004242static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004243vec_vmsumshm(vector short __a, vector short __b, vector int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004244 return __builtin_altivec_vmsumshm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004245}
4246
4247/* vec_vmsumuhm */
4248
Daniel Jasperbe508362016-03-11 22:13:28 +00004249static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004250vec_vmsumuhm(vector unsigned short __a, vector unsigned short __b,
4251 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004252 return __builtin_altivec_vmsumuhm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004253}
4254
4255/* vec_msums */
4256
Daniel Jasperbe508362016-03-11 22:13:28 +00004257static __inline__ vector int __ATTRS_o_ai vec_msums(vector short __a,
4258 vector short __b,
4259 vector int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004260 return __builtin_altivec_vmsumshs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004261}
4262
Daniel Jasperbe508362016-03-11 22:13:28 +00004263static __inline__ vector unsigned int __ATTRS_o_ai
4264vec_msums(vector unsigned short __a, vector unsigned short __b,
4265 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004266 return __builtin_altivec_vmsumuhs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004267}
4268
4269/* vec_vmsumshs */
4270
Daniel Jasperbe508362016-03-11 22:13:28 +00004271static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004272vec_vmsumshs(vector short __a, vector short __b, vector int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004273 return __builtin_altivec_vmsumshs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004274}
4275
4276/* vec_vmsumuhs */
4277
Daniel Jasperbe508362016-03-11 22:13:28 +00004278static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004279vec_vmsumuhs(vector unsigned short __a, vector unsigned short __b,
4280 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004281 return __builtin_altivec_vmsumuhs(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004282}
4283
Chris Lattnerdad40622010-04-14 03:54:58 +00004284/* vec_mtvscr */
4285
Daniel Jasperbe508362016-03-11 22:13:28 +00004286static __inline__ void __ATTRS_o_ai vec_mtvscr(vector signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004287 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004288}
4289
Daniel Jasperbe508362016-03-11 22:13:28 +00004290static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004291 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004292}
4293
Daniel Jasperbe508362016-03-11 22:13:28 +00004294static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004295 __builtin_altivec_mtvscr((vector int)__a);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004296}
4297
Daniel Jasperbe508362016-03-11 22:13:28 +00004298static __inline__ void __ATTRS_o_ai vec_mtvscr(vector short __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004299 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004300}
4301
Daniel Jasperbe508362016-03-11 22:13:28 +00004302static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned short __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004303 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004304}
4305
Daniel Jasperbe508362016-03-11 22:13:28 +00004306static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool short __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004307 __builtin_altivec_mtvscr((vector int)__a);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004308}
4309
Daniel Jasperbe508362016-03-11 22:13:28 +00004310static __inline__ void __ATTRS_o_ai vec_mtvscr(vector pixel __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004311 __builtin_altivec_mtvscr((vector int)__a);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004312}
4313
Daniel Jasperbe508362016-03-11 22:13:28 +00004314static __inline__ void __ATTRS_o_ai vec_mtvscr(vector int __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004315 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004316}
4317
Daniel Jasperbe508362016-03-11 22:13:28 +00004318static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned int __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004319 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004320}
4321
Daniel Jasperbe508362016-03-11 22:13:28 +00004322static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool int __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004323 __builtin_altivec_mtvscr((vector int)__a);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004324}
4325
Daniel Jasperbe508362016-03-11 22:13:28 +00004326static __inline__ void __ATTRS_o_ai vec_mtvscr(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004327 __builtin_altivec_mtvscr((vector int)__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004328}
4329
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004330/* vec_mul */
Nemanja Ivanovice00fa612015-07-05 10:54:10 +00004331
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004332/* Integer vector multiplication will involve multiplication of the odd/even
4333 elements separately, then truncating the results and moving to the
4334 result vector.
4335*/
Daniel Jasperbe508362016-03-11 22:13:28 +00004336static __inline__ vector signed char __ATTRS_o_ai
4337vec_mul(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004338 return __a * __b;
4339}
4340
Daniel Jasperbe508362016-03-11 22:13:28 +00004341static __inline__ vector unsigned char __ATTRS_o_ai
4342vec_mul(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004343 return __a * __b;
4344}
4345
Daniel Jasperbe508362016-03-11 22:13:28 +00004346static __inline__ vector signed short __ATTRS_o_ai
4347vec_mul(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004348 return __a * __b;
4349}
4350
Daniel Jasperbe508362016-03-11 22:13:28 +00004351static __inline__ vector unsigned short __ATTRS_o_ai
4352vec_mul(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004353 return __a * __b;
4354}
4355
Daniel Jasperbe508362016-03-11 22:13:28 +00004356static __inline__ vector signed int __ATTRS_o_ai
4357vec_mul(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004358 return __a * __b;
4359}
4360
Daniel Jasperbe508362016-03-11 22:13:28 +00004361static __inline__ vector unsigned int __ATTRS_o_ai
4362vec_mul(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004363 return __a * __b;
4364}
4365
4366#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004367static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004368vec_mul(vector signed long long __a, vector signed long long __b) {
4369 return __a * __b;
4370}
4371
Daniel Jasperbe508362016-03-11 22:13:28 +00004372static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004373vec_mul(vector unsigned long long __a, vector unsigned long long __b) {
4374 return __a * __b;
4375}
4376#endif
4377
Daniel Jasperbe508362016-03-11 22:13:28 +00004378static __inline__ vector float __ATTRS_o_ai vec_mul(vector float __a,
4379 vector float __b) {
Nemanja Ivanovice00fa612015-07-05 10:54:10 +00004380 return __a * __b;
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004381}
4382
4383#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004384static __inline__ vector double __ATTRS_o_ai vec_mul(vector double __a,
4385 vector double __b) {
Nemanja Ivanovice00fa612015-07-05 10:54:10 +00004386 return __a * __b;
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004387}
4388#endif
4389
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004390/* The vmulos* and vmules* instructions have a big endian bias, so
4391 we must reverse the meaning of "even" and "odd" for little endian. */
4392
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004393/* vec_mule */
4394
Daniel Jasperbe508362016-03-11 22:13:28 +00004395static __inline__ vector short __ATTRS_o_ai vec_mule(vector signed char __a,
4396 vector signed char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004397#ifdef __LITTLE_ENDIAN__
4398 return __builtin_altivec_vmulosb(__a, __b);
4399#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004400 return __builtin_altivec_vmulesb(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004401#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004402}
4403
Daniel Jasperbe508362016-03-11 22:13:28 +00004404static __inline__ vector unsigned short __ATTRS_o_ai
4405vec_mule(vector unsigned char __a, vector unsigned char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004406#ifdef __LITTLE_ENDIAN__
4407 return __builtin_altivec_vmuloub(__a, __b);
4408#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004409 return __builtin_altivec_vmuleub(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004410#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004411}
4412
Daniel Jasperbe508362016-03-11 22:13:28 +00004413static __inline__ vector int __ATTRS_o_ai vec_mule(vector short __a,
4414 vector short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004415#ifdef __LITTLE_ENDIAN__
4416 return __builtin_altivec_vmulosh(__a, __b);
4417#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004418 return __builtin_altivec_vmulesh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004419#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004420}
4421
Daniel Jasperbe508362016-03-11 22:13:28 +00004422static __inline__ vector unsigned int __ATTRS_o_ai
4423vec_mule(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004424#ifdef __LITTLE_ENDIAN__
4425 return __builtin_altivec_vmulouh(__a, __b);
4426#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004427 return __builtin_altivec_vmuleuh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004428#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004429}
4430
Kit Barton8553bec2015-03-11 15:57:19 +00004431#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00004432static __inline__ vector signed long long __ATTRS_o_ai
4433vec_mule(vector signed int __a, vector signed int __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00004434#ifdef __LITTLE_ENDIAN__
4435 return __builtin_altivec_vmulosw(__a, __b);
4436#else
4437 return __builtin_altivec_vmulesw(__a, __b);
4438#endif
4439}
4440
Daniel Jasperbe508362016-03-11 22:13:28 +00004441static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004442vec_mule(vector unsigned int __a, vector unsigned int __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00004443#ifdef __LITTLE_ENDIAN__
4444 return __builtin_altivec_vmulouw(__a, __b);
4445#else
4446 return __builtin_altivec_vmuleuw(__a, __b);
4447#endif
4448}
4449#endif
4450
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004451/* vec_vmulesb */
4452
Daniel Jasperbe508362016-03-11 22:13:28 +00004453static __inline__ vector short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004454vec_vmulesb(vector signed char __a, vector signed char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004455#ifdef __LITTLE_ENDIAN__
4456 return __builtin_altivec_vmulosb(__a, __b);
4457#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004458 return __builtin_altivec_vmulesb(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004459#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004460}
4461
4462/* vec_vmuleub */
4463
Daniel Jasperbe508362016-03-11 22:13:28 +00004464static __inline__ vector unsigned short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004465vec_vmuleub(vector unsigned char __a, vector unsigned char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004466#ifdef __LITTLE_ENDIAN__
4467 return __builtin_altivec_vmuloub(__a, __b);
4468#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004469 return __builtin_altivec_vmuleub(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004470#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004471}
4472
4473/* vec_vmulesh */
4474
Daniel Jasperbe508362016-03-11 22:13:28 +00004475static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004476vec_vmulesh(vector short __a, vector short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004477#ifdef __LITTLE_ENDIAN__
4478 return __builtin_altivec_vmulosh(__a, __b);
4479#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004480 return __builtin_altivec_vmulesh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004481#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004482}
4483
4484/* vec_vmuleuh */
4485
Daniel Jasperbe508362016-03-11 22:13:28 +00004486static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004487vec_vmuleuh(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004488#ifdef __LITTLE_ENDIAN__
4489 return __builtin_altivec_vmulouh(__a, __b);
4490#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004491 return __builtin_altivec_vmuleuh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004492#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004493}
4494
4495/* vec_mulo */
4496
Daniel Jasperbe508362016-03-11 22:13:28 +00004497static __inline__ vector short __ATTRS_o_ai vec_mulo(vector signed char __a,
4498 vector signed char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004499#ifdef __LITTLE_ENDIAN__
4500 return __builtin_altivec_vmulesb(__a, __b);
4501#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004502 return __builtin_altivec_vmulosb(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004503#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004504}
4505
Daniel Jasperbe508362016-03-11 22:13:28 +00004506static __inline__ vector unsigned short __ATTRS_o_ai
4507vec_mulo(vector unsigned char __a, vector unsigned char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004508#ifdef __LITTLE_ENDIAN__
4509 return __builtin_altivec_vmuleub(__a, __b);
4510#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004511 return __builtin_altivec_vmuloub(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004512#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004513}
4514
Daniel Jasperbe508362016-03-11 22:13:28 +00004515static __inline__ vector int __ATTRS_o_ai vec_mulo(vector short __a,
4516 vector short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004517#ifdef __LITTLE_ENDIAN__
4518 return __builtin_altivec_vmulesh(__a, __b);
4519#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004520 return __builtin_altivec_vmulosh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004521#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004522}
4523
Daniel Jasperbe508362016-03-11 22:13:28 +00004524static __inline__ vector unsigned int __ATTRS_o_ai
4525vec_mulo(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004526#ifdef __LITTLE_ENDIAN__
4527 return __builtin_altivec_vmuleuh(__a, __b);
4528#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004529 return __builtin_altivec_vmulouh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004530#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004531}
4532
Kit Barton8553bec2015-03-11 15:57:19 +00004533#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00004534static __inline__ vector signed long long __ATTRS_o_ai
4535vec_mulo(vector signed int __a, vector signed int __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00004536#ifdef __LITTLE_ENDIAN__
4537 return __builtin_altivec_vmulesw(__a, __b);
4538#else
4539 return __builtin_altivec_vmulosw(__a, __b);
4540#endif
4541}
4542
Daniel Jasperbe508362016-03-11 22:13:28 +00004543static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004544vec_mulo(vector unsigned int __a, vector unsigned int __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00004545#ifdef __LITTLE_ENDIAN__
4546 return __builtin_altivec_vmuleuw(__a, __b);
4547#else
4548 return __builtin_altivec_vmulouw(__a, __b);
4549#endif
4550}
4551#endif
4552
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004553/* vec_vmulosb */
4554
Daniel Jasperbe508362016-03-11 22:13:28 +00004555static __inline__ vector short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004556vec_vmulosb(vector signed char __a, vector signed char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004557#ifdef __LITTLE_ENDIAN__
4558 return __builtin_altivec_vmulesb(__a, __b);
4559#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004560 return __builtin_altivec_vmulosb(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004561#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004562}
4563
4564/* vec_vmuloub */
4565
Daniel Jasperbe508362016-03-11 22:13:28 +00004566static __inline__ vector unsigned short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004567vec_vmuloub(vector unsigned char __a, vector unsigned char __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004568#ifdef __LITTLE_ENDIAN__
4569 return __builtin_altivec_vmuleub(__a, __b);
4570#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004571 return __builtin_altivec_vmuloub(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004572#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004573}
4574
4575/* vec_vmulosh */
4576
Daniel Jasperbe508362016-03-11 22:13:28 +00004577static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004578vec_vmulosh(vector short __a, vector short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004579#ifdef __LITTLE_ENDIAN__
4580 return __builtin_altivec_vmulesh(__a, __b);
4581#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004582 return __builtin_altivec_vmulosh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004583#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004584}
4585
4586/* vec_vmulouh */
4587
Daniel Jasperbe508362016-03-11 22:13:28 +00004588static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004589vec_vmulouh(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004590#ifdef __LITTLE_ENDIAN__
4591 return __builtin_altivec_vmuleuh(__a, __b);
4592#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004593 return __builtin_altivec_vmulouh(__a, __b);
Bill Schmidt7c0114f2014-06-06 14:45:06 +00004594#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004595}
4596
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004597/* vec_nand */
4598
4599#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00004600static __inline__ vector signed char __ATTRS_o_ai
4601vec_nand(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004602 return ~(__a & __b);
4603}
4604
Daniel Jasperbe508362016-03-11 22:13:28 +00004605static __inline__ vector signed char __ATTRS_o_ai
4606vec_nand(vector signed char __a, vector bool char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004607 return ~(__a & __b);
4608}
4609
Daniel Jasperbe508362016-03-11 22:13:28 +00004610static __inline__ vector signed char __ATTRS_o_ai
4611vec_nand(vector bool char __a, vector signed char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004612 return ~(__a & __b);
4613}
4614
Daniel Jasperbe508362016-03-11 22:13:28 +00004615static __inline__ vector unsigned char __ATTRS_o_ai
4616vec_nand(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004617 return ~(__a & __b);
4618}
4619
Daniel Jasperbe508362016-03-11 22:13:28 +00004620static __inline__ vector unsigned char __ATTRS_o_ai
4621vec_nand(vector unsigned char __a, vector bool char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004622 return ~(__a & __b);
4623}
4624
Daniel Jasperbe508362016-03-11 22:13:28 +00004625static __inline__ vector unsigned char __ATTRS_o_ai
4626vec_nand(vector bool char __a, vector unsigned char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00004627 return ~(__a & __b);
4628}
4629
Daniel Jasperbe508362016-03-11 22:13:28 +00004630static __inline__ vector bool char __ATTRS_o_ai vec_nand(vector bool char __a,
4631 vector bool char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004632 return ~(__a & __b);
4633}
4634
Daniel Jasperbe508362016-03-11 22:13:28 +00004635static __inline__ vector signed short __ATTRS_o_ai
4636vec_nand(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004637 return ~(__a & __b);
4638}
4639
Daniel Jasperbe508362016-03-11 22:13:28 +00004640static __inline__ vector signed short __ATTRS_o_ai
4641vec_nand(vector signed short __a, vector bool short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004642 return ~(__a & __b);
4643}
4644
Daniel Jasperbe508362016-03-11 22:13:28 +00004645static __inline__ vector signed short __ATTRS_o_ai
4646vec_nand(vector bool short __a, vector signed short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004647 return ~(__a & __b);
4648}
4649
Daniel Jasperbe508362016-03-11 22:13:28 +00004650static __inline__ vector unsigned short __ATTRS_o_ai
4651vec_nand(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004652 return ~(__a & __b);
4653}
4654
Daniel Jasperbe508362016-03-11 22:13:28 +00004655static __inline__ vector unsigned short __ATTRS_o_ai
4656vec_nand(vector unsigned short __a, vector bool short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004657 return ~(__a & __b);
4658}
4659
Daniel Jasperbe508362016-03-11 22:13:28 +00004660static __inline__ vector bool short __ATTRS_o_ai
4661vec_nand(vector bool short __a, vector bool short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004662 return ~(__a & __b);
4663}
4664
Daniel Jasperbe508362016-03-11 22:13:28 +00004665static __inline__ vector signed int __ATTRS_o_ai
4666vec_nand(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004667 return ~(__a & __b);
4668}
4669
Daniel Jasperbe508362016-03-11 22:13:28 +00004670static __inline__ vector signed int __ATTRS_o_ai vec_nand(vector signed int __a,
4671 vector bool int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004672 return ~(__a & __b);
4673}
4674
Daniel Jasperbe508362016-03-11 22:13:28 +00004675static __inline__ vector signed int __ATTRS_o_ai
4676vec_nand(vector bool int __a, vector signed int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004677 return ~(__a & __b);
4678}
4679
Daniel Jasperbe508362016-03-11 22:13:28 +00004680static __inline__ vector unsigned int __ATTRS_o_ai
4681vec_nand(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00004682 return ~(__a & __b);
4683}
4684
Daniel Jasperbe508362016-03-11 22:13:28 +00004685static __inline__ vector unsigned int __ATTRS_o_ai
4686vec_nand(vector unsigned int __a, vector bool int __b) {
4687 return ~(__a & __b);
4688}
4689
4690static __inline__ vector unsigned int __ATTRS_o_ai
4691vec_nand(vector bool int __a, vector unsigned int __b) {
4692 return ~(__a & __b);
4693}
4694
4695static __inline__ vector bool int __ATTRS_o_ai vec_nand(vector bool int __a,
4696 vector bool int __b) {
4697 return ~(__a & __b);
4698}
4699
4700static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004701vec_nand(vector signed long long __a, vector signed long long __b) {
4702 return ~(__a & __b);
4703}
4704
Daniel Jasperbe508362016-03-11 22:13:28 +00004705static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004706vec_nand(vector signed long long __a, vector bool long long __b) {
4707 return ~(__a & __b);
4708}
4709
Daniel Jasperbe508362016-03-11 22:13:28 +00004710static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004711vec_nand(vector bool long long __a, vector signed long long __b) {
4712 return ~(__a & __b);
4713}
4714
Daniel Jasperbe508362016-03-11 22:13:28 +00004715static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004716vec_nand(vector unsigned long long __a, vector unsigned long long __b) {
4717 return ~(__a & __b);
4718}
4719
Daniel Jasperbe508362016-03-11 22:13:28 +00004720static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004721vec_nand(vector unsigned long long __a, vector bool long long __b) {
4722 return ~(__a & __b);
4723}
4724
Daniel Jasperbe508362016-03-11 22:13:28 +00004725static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004726vec_nand(vector bool long long __a, vector unsigned long long __b) {
4727 return ~(__a & __b);
4728}
4729
Daniel Jasperbe508362016-03-11 22:13:28 +00004730static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00004731vec_nand(vector bool long long __a, vector bool long long __b) {
4732 return ~(__a & __b);
4733}
4734
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00004735#endif
4736
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004737/* vec_nmadd */
4738
4739#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004740static __inline__ vector float __ATTRS_o_ai vec_nmadd(vector float __a,
4741 vector float __b,
4742 vector float __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004743 return __builtin_vsx_xvnmaddasp(__a, __b, __c);
4744}
4745
Daniel Jasperbe508362016-03-11 22:13:28 +00004746static __inline__ vector double __ATTRS_o_ai vec_nmadd(vector double __a,
4747 vector double __b,
4748 vector double __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004749 return __builtin_vsx_xvnmaddadp(__a, __b, __c);
4750}
4751#endif
4752
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004753/* vec_nmsub */
4754
Daniel Jasperbe508362016-03-11 22:13:28 +00004755static __inline__ vector float __ATTRS_o_ai vec_nmsub(vector float __a,
4756 vector float __b,
4757 vector float __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004758#ifdef __VSX__
4759 return __builtin_vsx_xvnmsubasp(__a, __b, __c);
4760#else
David Blaikie3302f2b2013-01-16 23:08:36 +00004761 return __builtin_altivec_vnmsubfp(__a, __b, __c);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004762#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004763}
4764
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004765#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004766static __inline__ vector double __ATTRS_o_ai vec_nmsub(vector double __a,
4767 vector double __b,
4768 vector double __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004769 return __builtin_vsx_xvnmsubadp(__a, __b, __c);
4770}
4771#endif
4772
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004773/* vec_vnmsubfp */
4774
Daniel Jasperbe508362016-03-11 22:13:28 +00004775static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00004776vec_vnmsubfp(vector float __a, vector float __b, vector float __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004777 return __builtin_altivec_vnmsubfp(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004778}
4779
4780/* vec_nor */
4781
4782#define __builtin_altivec_vnor vec_nor
4783
Daniel Jasperbe508362016-03-11 22:13:28 +00004784static __inline__ vector signed char __ATTRS_o_ai
4785vec_nor(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004786 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004787}
4788
Daniel Jasperbe508362016-03-11 22:13:28 +00004789static __inline__ vector unsigned char __ATTRS_o_ai
4790vec_nor(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004791 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004792}
4793
Daniel Jasperbe508362016-03-11 22:13:28 +00004794static __inline__ vector bool char __ATTRS_o_ai vec_nor(vector bool char __a,
4795 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004796 return ~(__a | __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004797}
4798
Daniel Jasperbe508362016-03-11 22:13:28 +00004799static __inline__ vector short __ATTRS_o_ai vec_nor(vector short __a,
4800 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004801 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004802}
4803
Daniel Jasperbe508362016-03-11 22:13:28 +00004804static __inline__ vector unsigned short __ATTRS_o_ai
4805vec_nor(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004806 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004807}
4808
Daniel Jasperbe508362016-03-11 22:13:28 +00004809static __inline__ vector bool short __ATTRS_o_ai
4810vec_nor(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004811 return ~(__a | __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004812}
4813
Daniel Jasperbe508362016-03-11 22:13:28 +00004814static __inline__ vector int __ATTRS_o_ai vec_nor(vector int __a,
4815 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004816 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004817}
4818
Daniel Jasperbe508362016-03-11 22:13:28 +00004819static __inline__ vector unsigned int __ATTRS_o_ai
4820vec_nor(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004821 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004822}
4823
Daniel Jasperbe508362016-03-11 22:13:28 +00004824static __inline__ vector bool int __ATTRS_o_ai vec_nor(vector bool int __a,
4825 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004826 return ~(__a | __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004827}
4828
Daniel Jasperbe508362016-03-11 22:13:28 +00004829static __inline__ vector float __ATTRS_o_ai vec_nor(vector float __a,
4830 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00004831 vector unsigned int __res =
4832 ~((vector unsigned int)__a | (vector unsigned int)__b);
David Blaikie3302f2b2013-01-16 23:08:36 +00004833 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004834}
4835
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004836#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004837static __inline__ vector double __ATTRS_o_ai vec_nor(vector double __a,
4838 vector double __b) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00004839 vector unsigned long long __res =
4840 ~((vector unsigned long long)__a | (vector unsigned long long)__b);
4841 return (vector double)__res;
4842}
4843#endif
4844
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004845/* vec_vnor */
4846
Daniel Jasperbe508362016-03-11 22:13:28 +00004847static __inline__ vector signed char __ATTRS_o_ai
4848vec_vnor(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004849 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004850}
4851
Daniel Jasperbe508362016-03-11 22:13:28 +00004852static __inline__ vector unsigned char __ATTRS_o_ai
4853vec_vnor(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004854 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004855}
4856
Daniel Jasperbe508362016-03-11 22:13:28 +00004857static __inline__ vector bool char __ATTRS_o_ai vec_vnor(vector bool char __a,
4858 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004859 return ~(__a | __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004860}
4861
Daniel Jasperbe508362016-03-11 22:13:28 +00004862static __inline__ vector short __ATTRS_o_ai vec_vnor(vector short __a,
4863 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004864 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004865}
4866
Daniel Jasperbe508362016-03-11 22:13:28 +00004867static __inline__ vector unsigned short __ATTRS_o_ai
4868vec_vnor(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004869 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004870}
4871
Daniel Jasperbe508362016-03-11 22:13:28 +00004872static __inline__ vector bool short __ATTRS_o_ai
4873vec_vnor(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004874 return ~(__a | __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004875}
4876
Daniel Jasperbe508362016-03-11 22:13:28 +00004877static __inline__ vector int __ATTRS_o_ai vec_vnor(vector int __a,
4878 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004879 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004880}
4881
Daniel Jasperbe508362016-03-11 22:13:28 +00004882static __inline__ vector unsigned int __ATTRS_o_ai
4883vec_vnor(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004884 return ~(__a | __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004885}
4886
Daniel Jasperbe508362016-03-11 22:13:28 +00004887static __inline__ vector bool int __ATTRS_o_ai vec_vnor(vector bool int __a,
4888 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004889 return ~(__a | __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00004890}
4891
Daniel Jasperbe508362016-03-11 22:13:28 +00004892static __inline__ vector float __ATTRS_o_ai vec_vnor(vector float __a,
4893 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00004894 vector unsigned int __res =
4895 ~((vector unsigned int)__a | (vector unsigned int)__b);
David Blaikie3302f2b2013-01-16 23:08:36 +00004896 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004897}
4898
Bill Seurer8be14f12015-06-04 18:45:44 +00004899#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00004900static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004901vec_nor(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00004902 return ~(__a | __b);
4903}
4904
Daniel Jasperbe508362016-03-11 22:13:28 +00004905static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00004906vec_nor(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00004907 return ~(__a | __b);
4908}
4909
Daniel Jasperbe508362016-03-11 22:13:28 +00004910static __inline__ vector bool long long __ATTRS_o_ai
4911vec_nor(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00004912 return ~(__a | __b);
4913}
4914#endif
4915
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004916/* vec_or */
4917
4918#define __builtin_altivec_vor vec_or
4919
Daniel Jasperbe508362016-03-11 22:13:28 +00004920static __inline__ vector signed char __ATTRS_o_ai
4921vec_or(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004922 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004923}
4924
Daniel Jasperbe508362016-03-11 22:13:28 +00004925static __inline__ vector signed char __ATTRS_o_ai
4926vec_or(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004927 return (vector signed char)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004928}
4929
Daniel Jasperbe508362016-03-11 22:13:28 +00004930static __inline__ vector signed char __ATTRS_o_ai vec_or(vector signed char __a,
4931 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004932 return __a | (vector signed char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004933}
4934
Daniel Jasperbe508362016-03-11 22:13:28 +00004935static __inline__ vector unsigned char __ATTRS_o_ai
4936vec_or(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004937 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004938}
4939
Daniel Jasperbe508362016-03-11 22:13:28 +00004940static __inline__ vector unsigned char __ATTRS_o_ai
4941vec_or(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004942 return (vector unsigned char)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004943}
4944
Daniel Jasperbe508362016-03-11 22:13:28 +00004945static __inline__ vector unsigned char __ATTRS_o_ai
4946vec_or(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004947 return __a | (vector unsigned char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004948}
4949
Daniel Jasperbe508362016-03-11 22:13:28 +00004950static __inline__ vector bool char __ATTRS_o_ai vec_or(vector bool char __a,
4951 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004952 return __a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004953}
4954
Daniel Jasperbe508362016-03-11 22:13:28 +00004955static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a,
4956 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004957 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004958}
4959
Daniel Jasperbe508362016-03-11 22:13:28 +00004960static __inline__ vector short __ATTRS_o_ai vec_or(vector bool short __a,
4961 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004962 return (vector short)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004963}
4964
Daniel Jasperbe508362016-03-11 22:13:28 +00004965static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a,
4966 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004967 return __a | (vector short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004968}
4969
Daniel Jasperbe508362016-03-11 22:13:28 +00004970static __inline__ vector unsigned short __ATTRS_o_ai
4971vec_or(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004972 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004973}
4974
Daniel Jasperbe508362016-03-11 22:13:28 +00004975static __inline__ vector unsigned short __ATTRS_o_ai
4976vec_or(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004977 return (vector unsigned short)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004978}
4979
Daniel Jasperbe508362016-03-11 22:13:28 +00004980static __inline__ vector unsigned short __ATTRS_o_ai
4981vec_or(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004982 return __a | (vector unsigned short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004983}
4984
Daniel Jasperbe508362016-03-11 22:13:28 +00004985static __inline__ vector bool short __ATTRS_o_ai vec_or(vector bool short __a,
4986 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004987 return __a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004988}
4989
Daniel Jasperbe508362016-03-11 22:13:28 +00004990static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a,
4991 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004992 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00004993}
4994
Daniel Jasperbe508362016-03-11 22:13:28 +00004995static __inline__ vector int __ATTRS_o_ai vec_or(vector bool int __a,
4996 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00004997 return (vector int)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00004998}
4999
Daniel Jasperbe508362016-03-11 22:13:28 +00005000static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a,
5001 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005002 return __a | (vector int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005003}
5004
Daniel Jasperbe508362016-03-11 22:13:28 +00005005static __inline__ vector unsigned int __ATTRS_o_ai
5006vec_or(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005007 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005008}
5009
Daniel Jasperbe508362016-03-11 22:13:28 +00005010static __inline__ vector unsigned int __ATTRS_o_ai
5011vec_or(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005012 return (vector unsigned int)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005013}
5014
Daniel Jasperbe508362016-03-11 22:13:28 +00005015static __inline__ vector unsigned int __ATTRS_o_ai
5016vec_or(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005017 return __a | (vector unsigned int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005018}
5019
Daniel Jasperbe508362016-03-11 22:13:28 +00005020static __inline__ vector bool int __ATTRS_o_ai vec_or(vector bool int __a,
5021 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005022 return __a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005023}
5024
Daniel Jasperbe508362016-03-11 22:13:28 +00005025static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a,
5026 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00005027 vector unsigned int __res =
5028 (vector unsigned int)__a | (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00005029 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005030}
5031
Daniel Jasperbe508362016-03-11 22:13:28 +00005032static __inline__ vector float __ATTRS_o_ai vec_or(vector bool int __a,
5033 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00005034 vector unsigned int __res =
5035 (vector unsigned int)__a | (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00005036 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005037}
5038
Daniel Jasperbe508362016-03-11 22:13:28 +00005039static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a,
5040 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00005041 vector unsigned int __res =
5042 (vector unsigned int)__a | (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00005043 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005044}
5045
Bill Seurer8be14f12015-06-04 18:45:44 +00005046#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00005047static __inline__ vector double __ATTRS_o_ai vec_or(vector bool long long __a,
5048 vector double __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005049 return (vector unsigned long long)__a | (vector unsigned long long)__b;
5050}
5051
Daniel Jasperbe508362016-03-11 22:13:28 +00005052static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a,
5053 vector bool long long __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005054 return (vector unsigned long long)__a | (vector unsigned long long)__b;
5055}
5056
Daniel Jasperbe508362016-03-11 22:13:28 +00005057static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a,
5058 vector double __b) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00005059 vector unsigned long long __res =
5060 (vector unsigned long long)__a | (vector unsigned long long)__b;
5061 return (vector double)__res;
5062}
5063
Daniel Jasperbe508362016-03-11 22:13:28 +00005064static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005065vec_or(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005066 return __a | __b;
5067}
5068
Daniel Jasperbe508362016-03-11 22:13:28 +00005069static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005070vec_or(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005071 return (vector signed long long)__a | __b;
5072}
5073
Daniel Jasperbe508362016-03-11 22:13:28 +00005074static __inline__ vector signed long long __ATTRS_o_ai
5075vec_or(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005076 return __a | (vector signed long long)__b;
5077}
5078
Daniel Jasperbe508362016-03-11 22:13:28 +00005079static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005080vec_or(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005081 return __a | __b;
5082}
5083
Daniel Jasperbe508362016-03-11 22:13:28 +00005084static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005085vec_or(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005086 return (vector unsigned long long)__a | __b;
5087}
5088
Daniel Jasperbe508362016-03-11 22:13:28 +00005089static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005090vec_or(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005091 return __a | (vector unsigned long long)__b;
5092}
5093
Daniel Jasperbe508362016-03-11 22:13:28 +00005094static __inline__ vector bool long long __ATTRS_o_ai
5095vec_or(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005096 return __a | __b;
5097}
5098#endif
5099
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005100#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00005101static __inline__ vector signed char __ATTRS_o_ai
5102vec_orc(vector signed char __a, vector signed char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005103 return __a | ~__b;
5104}
5105
Daniel Jasperbe508362016-03-11 22:13:28 +00005106static __inline__ vector signed char __ATTRS_o_ai
5107vec_orc(vector signed char __a, vector bool char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005108 return __a | ~__b;
5109}
5110
Daniel Jasperbe508362016-03-11 22:13:28 +00005111static __inline__ vector signed char __ATTRS_o_ai
5112vec_orc(vector bool char __a, vector signed char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005113 return __a | ~__b;
5114}
5115
Daniel Jasperbe508362016-03-11 22:13:28 +00005116static __inline__ vector unsigned char __ATTRS_o_ai
5117vec_orc(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005118 return __a | ~__b;
5119}
5120
Daniel Jasperbe508362016-03-11 22:13:28 +00005121static __inline__ vector unsigned char __ATTRS_o_ai
5122vec_orc(vector unsigned char __a, vector bool char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005123 return __a | ~__b;
5124}
5125
Daniel Jasperbe508362016-03-11 22:13:28 +00005126static __inline__ vector unsigned char __ATTRS_o_ai
5127vec_orc(vector bool char __a, vector unsigned char __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005128 return __a | ~__b;
5129}
5130
Daniel Jasperbe508362016-03-11 22:13:28 +00005131static __inline__ vector bool char __ATTRS_o_ai vec_orc(vector bool char __a,
5132 vector bool char __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00005133 return __a | ~__b;
5134}
5135
Daniel Jasperbe508362016-03-11 22:13:28 +00005136static __inline__ vector signed short __ATTRS_o_ai
5137vec_orc(vector signed short __a, vector signed short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005138 return __a | ~__b;
5139}
5140
Daniel Jasperbe508362016-03-11 22:13:28 +00005141static __inline__ vector signed short __ATTRS_o_ai
5142vec_orc(vector signed short __a, vector bool short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005143 return __a | ~__b;
5144}
5145
Daniel Jasperbe508362016-03-11 22:13:28 +00005146static __inline__ vector signed short __ATTRS_o_ai
5147vec_orc(vector bool short __a, vector signed short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005148 return __a | ~__b;
5149}
5150
Daniel Jasperbe508362016-03-11 22:13:28 +00005151static __inline__ vector unsigned short __ATTRS_o_ai
5152vec_orc(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005153 return __a | ~__b;
5154}
5155
Daniel Jasperbe508362016-03-11 22:13:28 +00005156static __inline__ vector unsigned short __ATTRS_o_ai
5157vec_orc(vector unsigned short __a, vector bool short __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005158 return __a | ~__b;
5159}
5160
Daniel Jasperbe508362016-03-11 22:13:28 +00005161static __inline__ vector unsigned short __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005162vec_orc(vector bool short __a, vector unsigned short __b) {
5163 return __a | ~__b;
5164}
5165
Daniel Jasperbe508362016-03-11 22:13:28 +00005166static __inline__ vector bool short __ATTRS_o_ai
5167vec_orc(vector bool short __a, vector bool short __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00005168 return __a | ~__b;
5169}
5170
Daniel Jasperbe508362016-03-11 22:13:28 +00005171static __inline__ vector signed int __ATTRS_o_ai
5172vec_orc(vector signed int __a, vector signed int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005173 return __a | ~__b;
5174}
5175
Daniel Jasperbe508362016-03-11 22:13:28 +00005176static __inline__ vector signed int __ATTRS_o_ai vec_orc(vector signed int __a,
5177 vector bool int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005178 return __a | ~__b;
5179}
5180
Daniel Jasperbe508362016-03-11 22:13:28 +00005181static __inline__ vector signed int __ATTRS_o_ai
5182vec_orc(vector bool int __a, vector signed int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005183 return __a | ~__b;
5184}
5185
Daniel Jasperbe508362016-03-11 22:13:28 +00005186static __inline__ vector unsigned int __ATTRS_o_ai
5187vec_orc(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005188 return __a | ~__b;
5189}
5190
Daniel Jasperbe508362016-03-11 22:13:28 +00005191static __inline__ vector unsigned int __ATTRS_o_ai
5192vec_orc(vector unsigned int __a, vector bool int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005193 return __a | ~__b;
5194}
5195
Daniel Jasperbe508362016-03-11 22:13:28 +00005196static __inline__ vector unsigned int __ATTRS_o_ai
5197vec_orc(vector bool int __a, vector unsigned int __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005198 return __a | ~__b;
5199}
5200
Daniel Jasperbe508362016-03-11 22:13:28 +00005201static __inline__ vector bool int __ATTRS_o_ai vec_orc(vector bool int __a,
5202 vector bool int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00005203 return __a | ~__b;
5204}
5205
Daniel Jasperbe508362016-03-11 22:13:28 +00005206static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005207vec_orc(vector signed long long __a, vector signed long long __b) {
5208 return __a | ~__b;
5209}
5210
Daniel Jasperbe508362016-03-11 22:13:28 +00005211static __inline__ vector signed long long __ATTRS_o_ai
5212vec_orc(vector signed long long __a, vector bool long long __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005213 return __a | ~__b;
5214}
5215
Daniel Jasperbe508362016-03-11 22:13:28 +00005216static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005217vec_orc(vector bool long long __a, vector signed long long __b) {
5218 return __a | ~__b;
5219}
5220
Daniel Jasperbe508362016-03-11 22:13:28 +00005221static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005222vec_orc(vector unsigned long long __a, vector unsigned long long __b) {
5223 return __a | ~__b;
5224}
5225
Daniel Jasperbe508362016-03-11 22:13:28 +00005226static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005227vec_orc(vector unsigned long long __a, vector bool long long __b) {
5228 return __a | ~__b;
5229}
5230
Daniel Jasperbe508362016-03-11 22:13:28 +00005231static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005232vec_orc(vector bool long long __a, vector unsigned long long __b) {
5233 return __a | ~__b;
5234}
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00005235
Daniel Jasperbe508362016-03-11 22:13:28 +00005236static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00005237vec_orc(vector bool long long __a, vector bool long long __b) {
5238 return __a | ~__b;
5239}
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005240#endif
5241
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005242/* vec_vor */
5243
Daniel Jasperbe508362016-03-11 22:13:28 +00005244static __inline__ vector signed char __ATTRS_o_ai
5245vec_vor(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005246 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005247}
5248
Daniel Jasperbe508362016-03-11 22:13:28 +00005249static __inline__ vector signed char __ATTRS_o_ai
5250vec_vor(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005251 return (vector signed char)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005252}
5253
Daniel Jasperbe508362016-03-11 22:13:28 +00005254static __inline__ vector signed char __ATTRS_o_ai
5255vec_vor(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005256 return __a | (vector signed char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005257}
5258
Daniel Jasperbe508362016-03-11 22:13:28 +00005259static __inline__ vector unsigned char __ATTRS_o_ai
5260vec_vor(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005261 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005262}
5263
Daniel Jasperbe508362016-03-11 22:13:28 +00005264static __inline__ vector unsigned char __ATTRS_o_ai
5265vec_vor(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005266 return (vector unsigned char)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005267}
5268
Daniel Jasperbe508362016-03-11 22:13:28 +00005269static __inline__ vector unsigned char __ATTRS_o_ai
5270vec_vor(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005271 return __a | (vector unsigned char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005272}
5273
Daniel Jasperbe508362016-03-11 22:13:28 +00005274static __inline__ vector bool char __ATTRS_o_ai vec_vor(vector bool char __a,
5275 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005276 return __a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005277}
5278
Daniel Jasperbe508362016-03-11 22:13:28 +00005279static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a,
5280 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005281 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005282}
5283
Daniel Jasperbe508362016-03-11 22:13:28 +00005284static __inline__ vector short __ATTRS_o_ai vec_vor(vector bool short __a,
5285 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005286 return (vector short)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005287}
5288
Daniel Jasperbe508362016-03-11 22:13:28 +00005289static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a,
5290 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005291 return __a | (vector short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005292}
5293
Daniel Jasperbe508362016-03-11 22:13:28 +00005294static __inline__ vector unsigned short __ATTRS_o_ai
5295vec_vor(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005296 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005297}
5298
Daniel Jasperbe508362016-03-11 22:13:28 +00005299static __inline__ vector unsigned short __ATTRS_o_ai
5300vec_vor(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005301 return (vector unsigned short)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005302}
5303
Daniel Jasperbe508362016-03-11 22:13:28 +00005304static __inline__ vector unsigned short __ATTRS_o_ai
5305vec_vor(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005306 return __a | (vector unsigned short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005307}
5308
Daniel Jasperbe508362016-03-11 22:13:28 +00005309static __inline__ vector bool short __ATTRS_o_ai
5310vec_vor(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005311 return __a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005312}
5313
Daniel Jasperbe508362016-03-11 22:13:28 +00005314static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a,
5315 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005316 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005317}
5318
Daniel Jasperbe508362016-03-11 22:13:28 +00005319static __inline__ vector int __ATTRS_o_ai vec_vor(vector bool int __a,
5320 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005321 return (vector int)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005322}
5323
Daniel Jasperbe508362016-03-11 22:13:28 +00005324static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a,
5325 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005326 return __a | (vector int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005327}
5328
Daniel Jasperbe508362016-03-11 22:13:28 +00005329static __inline__ vector unsigned int __ATTRS_o_ai
5330vec_vor(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005331 return __a | __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005332}
5333
Daniel Jasperbe508362016-03-11 22:13:28 +00005334static __inline__ vector unsigned int __ATTRS_o_ai
5335vec_vor(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005336 return (vector unsigned int)__a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005337}
5338
Daniel Jasperbe508362016-03-11 22:13:28 +00005339static __inline__ vector unsigned int __ATTRS_o_ai
5340vec_vor(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005341 return __a | (vector unsigned int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005342}
5343
Daniel Jasperbe508362016-03-11 22:13:28 +00005344static __inline__ vector bool int __ATTRS_o_ai vec_vor(vector bool int __a,
5345 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00005346 return __a | __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005347}
5348
Daniel Jasperbe508362016-03-11 22:13:28 +00005349static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a,
5350 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00005351 vector unsigned int __res =
5352 (vector unsigned int)__a | (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00005353 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005354}
5355
Daniel Jasperbe508362016-03-11 22:13:28 +00005356static __inline__ vector float __ATTRS_o_ai vec_vor(vector bool int __a,
5357 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00005358 vector unsigned int __res =
5359 (vector unsigned int)__a | (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00005360 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005361}
5362
Daniel Jasperbe508362016-03-11 22:13:28 +00005363static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a,
5364 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00005365 vector unsigned int __res =
5366 (vector unsigned int)__a | (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +00005367 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +00005368}
5369
Bill Seurer8be14f12015-06-04 18:45:44 +00005370#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00005371static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005372vec_vor(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005373 return __a | __b;
5374}
5375
Daniel Jasperbe508362016-03-11 22:13:28 +00005376static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005377vec_vor(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005378 return (vector signed long long)__a | __b;
5379}
5380
Daniel Jasperbe508362016-03-11 22:13:28 +00005381static __inline__ vector signed long long __ATTRS_o_ai
5382vec_vor(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005383 return __a | (vector signed long long)__b;
5384}
5385
Daniel Jasperbe508362016-03-11 22:13:28 +00005386static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005387vec_vor(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005388 return __a | __b;
5389}
5390
Daniel Jasperbe508362016-03-11 22:13:28 +00005391static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005392vec_vor(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005393 return (vector unsigned long long)__a | __b;
5394}
5395
Daniel Jasperbe508362016-03-11 22:13:28 +00005396static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005397vec_vor(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005398 return __a | (vector unsigned long long)__b;
5399}
5400
Daniel Jasperbe508362016-03-11 22:13:28 +00005401static __inline__ vector bool long long __ATTRS_o_ai
5402vec_vor(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +00005403 return __a | __b;
5404}
5405#endif
5406
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005407/* vec_pack */
5408
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005409/* The various vector pack instructions have a big-endian bias, so for
5410 little endian we must handle reversed element numbering. */
5411
Daniel Jasperbe508362016-03-11 22:13:28 +00005412static __inline__ vector signed char __ATTRS_o_ai
5413vec_pack(vector signed short __a, vector signed short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005414#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005415 return (vector signed char)vec_perm(
5416 __a, __b,
5417 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
5418 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005419#else
Bill Seurer703e8482015-06-09 14:39:47 +00005420 return (vector signed char)vec_perm(
5421 __a, __b,
5422 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
5423 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005424#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005425}
5426
Daniel Jasperbe508362016-03-11 22:13:28 +00005427static __inline__ vector unsigned char __ATTRS_o_ai
5428vec_pack(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005429#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005430 return (vector unsigned char)vec_perm(
5431 __a, __b,
5432 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
5433 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005434#else
Bill Seurer703e8482015-06-09 14:39:47 +00005435 return (vector unsigned char)vec_perm(
5436 __a, __b,
5437 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
5438 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005439#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005440}
5441
Daniel Jasperbe508362016-03-11 22:13:28 +00005442static __inline__ vector bool char __ATTRS_o_ai
5443vec_pack(vector bool short __a, vector bool short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005444#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005445 return (vector bool char)vec_perm(
5446 __a, __b,
5447 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
5448 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005449#else
Bill Seurer703e8482015-06-09 14:39:47 +00005450 return (vector bool char)vec_perm(
5451 __a, __b,
5452 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
5453 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005454#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00005455}
5456
Daniel Jasperbe508362016-03-11 22:13:28 +00005457static __inline__ vector short __ATTRS_o_ai vec_pack(vector int __a,
5458 vector int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005459#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005460 return (vector short)vec_perm(
5461 __a, __b,
5462 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
5463 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005464#else
Bill Seurer703e8482015-06-09 14:39:47 +00005465 return (vector short)vec_perm(
5466 __a, __b,
5467 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
5468 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005469#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005470}
5471
Daniel Jasperbe508362016-03-11 22:13:28 +00005472static __inline__ vector unsigned short __ATTRS_o_ai
5473vec_pack(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005474#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005475 return (vector unsigned short)vec_perm(
5476 __a, __b,
5477 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
5478 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005479#else
Bill Seurer703e8482015-06-09 14:39:47 +00005480 return (vector unsigned short)vec_perm(
5481 __a, __b,
5482 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
5483 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005484#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005485}
5486
Daniel Jasperbe508362016-03-11 22:13:28 +00005487static __inline__ vector bool short __ATTRS_o_ai vec_pack(vector bool int __a,
5488 vector bool int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005489#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005490 return (vector bool short)vec_perm(
5491 __a, __b,
5492 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
5493 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005494#else
Bill Seurer703e8482015-06-09 14:39:47 +00005495 return (vector bool short)vec_perm(
5496 __a, __b,
5497 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
5498 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005499#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00005500}
5501
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005502#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00005503static __inline__ vector signed int __ATTRS_o_ai
5504vec_pack(vector signed long long __a, vector signed long long __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005505#ifdef __LITTLE_ENDIAN__
5506 return (vector signed int)vec_perm(
5507 __a, __b,
5508 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
5509 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
5510#else
5511 return (vector signed int)vec_perm(
5512 __a, __b,
5513 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
5514 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
5515#endif
5516}
Daniel Jasperbe508362016-03-11 22:13:28 +00005517static __inline__ vector unsigned int __ATTRS_o_ai
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005518vec_pack(vector unsigned long long __a, vector unsigned long long __b) {
5519#ifdef __LITTLE_ENDIAN__
5520 return (vector unsigned int)vec_perm(
5521 __a, __b,
5522 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
5523 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
5524#else
5525 return (vector unsigned int)vec_perm(
5526 __a, __b,
5527 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
5528 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
5529#endif
5530}
5531
Daniel Jasperbe508362016-03-11 22:13:28 +00005532static __inline__ vector bool int __ATTRS_o_ai
5533vec_pack(vector bool long long __a, vector bool long long __b) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00005534#ifdef __LITTLE_ENDIAN__
5535 return (vector bool int)vec_perm(
5536 __a, __b,
5537 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
5538 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
5539#else
5540 return (vector bool int)vec_perm(
5541 __a, __b,
5542 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
5543 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
5544#endif
5545}
5546
5547#endif
5548
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005549/* vec_vpkuhum */
5550
5551#define __builtin_altivec_vpkuhum vec_vpkuhum
5552
Daniel Jasperbe508362016-03-11 22:13:28 +00005553static __inline__ vector signed char __ATTRS_o_ai
5554vec_vpkuhum(vector signed short __a, vector signed short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005555#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005556 return (vector signed char)vec_perm(
5557 __a, __b,
5558 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
5559 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005560#else
Bill Seurer703e8482015-06-09 14:39:47 +00005561 return (vector signed char)vec_perm(
5562 __a, __b,
5563 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
5564 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005565#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005566}
5567
Daniel Jasperbe508362016-03-11 22:13:28 +00005568static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005569vec_vpkuhum(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005570#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005571 return (vector unsigned char)vec_perm(
5572 __a, __b,
5573 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
5574 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005575#else
Bill Seurer703e8482015-06-09 14:39:47 +00005576 return (vector unsigned char)vec_perm(
5577 __a, __b,
5578 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
5579 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005580#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005581}
5582
Daniel Jasperbe508362016-03-11 22:13:28 +00005583static __inline__ vector bool char __ATTRS_o_ai
5584vec_vpkuhum(vector bool short __a, vector bool short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005585#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005586 return (vector bool char)vec_perm(
5587 __a, __b,
5588 (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E,
5589 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005590#else
Bill Seurer703e8482015-06-09 14:39:47 +00005591 return (vector bool char)vec_perm(
5592 __a, __b,
5593 (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F,
5594 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005595#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00005596}
5597
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005598/* vec_vpkuwum */
5599
5600#define __builtin_altivec_vpkuwum vec_vpkuwum
5601
Daniel Jasperbe508362016-03-11 22:13:28 +00005602static __inline__ vector short __ATTRS_o_ai vec_vpkuwum(vector int __a,
5603 vector int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005604#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005605 return (vector short)vec_perm(
5606 __a, __b,
5607 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
5608 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005609#else
Bill Seurer703e8482015-06-09 14:39:47 +00005610 return (vector short)vec_perm(
5611 __a, __b,
5612 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
5613 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005614#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005615}
5616
Daniel Jasperbe508362016-03-11 22:13:28 +00005617static __inline__ vector unsigned short __ATTRS_o_ai
5618vec_vpkuwum(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005619#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005620 return (vector unsigned short)vec_perm(
5621 __a, __b,
5622 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
5623 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005624#else
Bill Seurer703e8482015-06-09 14:39:47 +00005625 return (vector unsigned short)vec_perm(
5626 __a, __b,
5627 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
5628 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005629#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005630}
5631
Daniel Jasperbe508362016-03-11 22:13:28 +00005632static __inline__ vector bool short __ATTRS_o_ai
5633vec_vpkuwum(vector bool int __a, vector bool int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005634#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005635 return (vector bool short)vec_perm(
5636 __a, __b,
5637 (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D,
5638 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005639#else
Bill Seurer703e8482015-06-09 14:39:47 +00005640 return (vector bool short)vec_perm(
5641 __a, __b,
5642 (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F,
5643 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F));
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005644#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00005645}
5646
Bill Schmidt41e14c42015-05-16 01:02:25 +00005647/* vec_vpkudum */
5648
5649#ifdef __POWER8_VECTOR__
5650#define __builtin_altivec_vpkudum vec_vpkudum
5651
Daniel Jasperbe508362016-03-11 22:13:28 +00005652static __inline__ vector int __ATTRS_o_ai vec_vpkudum(vector long long __a,
5653 vector long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005654#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005655 return (vector int)vec_perm(
5656 __a, __b,
5657 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
5658 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
Bill Schmidt41e14c42015-05-16 01:02:25 +00005659#else
Bill Seurer703e8482015-06-09 14:39:47 +00005660 return (vector int)vec_perm(
5661 __a, __b,
5662 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
5663 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
Bill Schmidt41e14c42015-05-16 01:02:25 +00005664#endif
5665}
5666
Daniel Jasperbe508362016-03-11 22:13:28 +00005667static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005668vec_vpkudum(vector unsigned long long __a, vector unsigned long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005669#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005670 return (vector unsigned int)vec_perm(
5671 __a, __b,
5672 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
5673 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
Bill Schmidt41e14c42015-05-16 01:02:25 +00005674#else
Bill Seurer703e8482015-06-09 14:39:47 +00005675 return (vector unsigned int)vec_perm(
5676 __a, __b,
5677 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
5678 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
Bill Schmidt41e14c42015-05-16 01:02:25 +00005679#endif
5680}
5681
Daniel Jasperbe508362016-03-11 22:13:28 +00005682static __inline__ vector bool int __ATTRS_o_ai
5683vec_vpkudum(vector bool long long __a, vector bool long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005684#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005685 return (vector bool int)vec_perm(
5686 (vector long long)__a, (vector long long)__b,
5687 (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B,
5688 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B));
Bill Schmidt41e14c42015-05-16 01:02:25 +00005689#else
Bill Seurer703e8482015-06-09 14:39:47 +00005690 return (vector bool int)vec_perm(
5691 (vector long long)__a, (vector long long)__b,
5692 (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F,
5693 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F));
Bill Schmidt41e14c42015-05-16 01:02:25 +00005694#endif
5695}
5696#endif
5697
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005698/* vec_packpx */
5699
Daniel Jasperbe508362016-03-11 22:13:28 +00005700static __inline__ vector pixel __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005701vec_packpx(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005702#ifdef __LITTLE_ENDIAN__
5703 return (vector pixel)__builtin_altivec_vpkpx(__b, __a);
5704#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005705 return (vector pixel)__builtin_altivec_vpkpx(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005706#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005707}
5708
5709/* vec_vpkpx */
5710
Daniel Jasperbe508362016-03-11 22:13:28 +00005711static __inline__ vector pixel __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005712vec_vpkpx(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005713#ifdef __LITTLE_ENDIAN__
5714 return (vector pixel)__builtin_altivec_vpkpx(__b, __a);
5715#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005716 return (vector pixel)__builtin_altivec_vpkpx(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005717#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005718}
5719
5720/* vec_packs */
5721
Daniel Jasperbe508362016-03-11 22:13:28 +00005722static __inline__ vector signed char __ATTRS_o_ai vec_packs(vector short __a,
5723 vector short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005724#ifdef __LITTLE_ENDIAN__
5725 return __builtin_altivec_vpkshss(__b, __a);
5726#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005727 return __builtin_altivec_vpkshss(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005728#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005729}
5730
Daniel Jasperbe508362016-03-11 22:13:28 +00005731static __inline__ vector unsigned char __ATTRS_o_ai
5732vec_packs(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005733#ifdef __LITTLE_ENDIAN__
5734 return __builtin_altivec_vpkuhus(__b, __a);
5735#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005736 return __builtin_altivec_vpkuhus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005737#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005738}
5739
Daniel Jasperbe508362016-03-11 22:13:28 +00005740static __inline__ vector signed short __ATTRS_o_ai vec_packs(vector int __a,
5741 vector int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005742#ifdef __LITTLE_ENDIAN__
5743 return __builtin_altivec_vpkswss(__b, __a);
5744#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005745 return __builtin_altivec_vpkswss(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005746#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005747}
5748
Daniel Jasperbe508362016-03-11 22:13:28 +00005749static __inline__ vector unsigned short __ATTRS_o_ai
5750vec_packs(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005751#ifdef __LITTLE_ENDIAN__
5752 return __builtin_altivec_vpkuwus(__b, __a);
5753#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005754 return __builtin_altivec_vpkuwus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005755#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005756}
5757
Bill Schmidt41e14c42015-05-16 01:02:25 +00005758#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00005759static __inline__ vector int __ATTRS_o_ai vec_packs(vector long long __a,
5760 vector long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005761#ifdef __LITTLE_ENDIAN__
5762 return __builtin_altivec_vpksdss(__b, __a);
5763#else
5764 return __builtin_altivec_vpksdss(__a, __b);
5765#endif
5766}
5767
Daniel Jasperbe508362016-03-11 22:13:28 +00005768static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005769vec_packs(vector unsigned long long __a, vector unsigned long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005770#ifdef __LITTLE_ENDIAN__
5771 return __builtin_altivec_vpkudus(__b, __a);
5772#else
5773 return __builtin_altivec_vpkudus(__a, __b);
5774#endif
5775}
5776#endif
5777
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005778/* vec_vpkshss */
5779
Daniel Jasperbe508362016-03-11 22:13:28 +00005780static __inline__ vector signed char __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005781vec_vpkshss(vector short __a, vector short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005782#ifdef __LITTLE_ENDIAN__
5783 return __builtin_altivec_vpkshss(__b, __a);
5784#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005785 return __builtin_altivec_vpkshss(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005786#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005787}
5788
Bill Schmidt41e14c42015-05-16 01:02:25 +00005789/* vec_vpksdss */
5790
5791#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00005792static __inline__ vector int __ATTRS_o_ai vec_vpksdss(vector long long __a,
5793 vector long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005794#ifdef __LITTLE_ENDIAN__
5795 return __builtin_altivec_vpksdss(__b, __a);
5796#else
5797 return __builtin_altivec_vpksdss(__a, __b);
5798#endif
5799}
5800#endif
5801
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005802/* vec_vpkuhus */
5803
Daniel Jasperbe508362016-03-11 22:13:28 +00005804static __inline__ vector unsigned char __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005805vec_vpkuhus(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005806#ifdef __LITTLE_ENDIAN__
5807 return __builtin_altivec_vpkuhus(__b, __a);
5808#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005809 return __builtin_altivec_vpkuhus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005810#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005811}
5812
Bill Schmidt41e14c42015-05-16 01:02:25 +00005813/* vec_vpkudus */
5814
5815#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00005816static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005817vec_vpkudus(vector unsigned long long __a, vector unsigned long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005818#ifdef __LITTLE_ENDIAN__
5819 return __builtin_altivec_vpkudus(__b, __a);
5820#else
5821 return __builtin_altivec_vpkudus(__a, __b);
5822#endif
5823}
5824#endif
5825
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005826/* vec_vpkswss */
5827
Daniel Jasperbe508362016-03-11 22:13:28 +00005828static __inline__ vector signed short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005829vec_vpkswss(vector int __a, vector int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005830#ifdef __LITTLE_ENDIAN__
5831 return __builtin_altivec_vpkswss(__b, __a);
5832#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005833 return __builtin_altivec_vpkswss(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005834#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005835}
5836
5837/* vec_vpkuwus */
5838
Daniel Jasperbe508362016-03-11 22:13:28 +00005839static __inline__ vector unsigned short __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00005840vec_vpkuwus(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005841#ifdef __LITTLE_ENDIAN__
5842 return __builtin_altivec_vpkuwus(__b, __a);
5843#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005844 return __builtin_altivec_vpkuwus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005845#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005846}
5847
5848/* vec_packsu */
5849
Daniel Jasperbe508362016-03-11 22:13:28 +00005850static __inline__ vector unsigned char __ATTRS_o_ai
5851vec_packsu(vector short __a, vector short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005852#ifdef __LITTLE_ENDIAN__
5853 return __builtin_altivec_vpkshus(__b, __a);
5854#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005855 return __builtin_altivec_vpkshus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005856#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005857}
5858
Daniel Jasperbe508362016-03-11 22:13:28 +00005859static __inline__ vector unsigned char __ATTRS_o_ai
5860vec_packsu(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005861#ifdef __LITTLE_ENDIAN__
5862 return __builtin_altivec_vpkuhus(__b, __a);
5863#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005864 return __builtin_altivec_vpkuhus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005865#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005866}
5867
Daniel Jasperbe508362016-03-11 22:13:28 +00005868static __inline__ vector unsigned short __ATTRS_o_ai
5869vec_packsu(vector int __a, vector int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005870#ifdef __LITTLE_ENDIAN__
5871 return __builtin_altivec_vpkswus(__b, __a);
5872#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005873 return __builtin_altivec_vpkswus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005874#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005875}
5876
Daniel Jasperbe508362016-03-11 22:13:28 +00005877static __inline__ vector unsigned short __ATTRS_o_ai
5878vec_packsu(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005879#ifdef __LITTLE_ENDIAN__
5880 return __builtin_altivec_vpkuwus(__b, __a);
5881#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005882 return __builtin_altivec_vpkuwus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005883#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005884}
5885
Bill Schmidt41e14c42015-05-16 01:02:25 +00005886#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00005887static __inline__ vector unsigned int __ATTRS_o_ai
5888vec_packsu(vector long long __a, vector long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005889#ifdef __LITTLE_ENDIAN__
5890 return __builtin_altivec_vpksdus(__b, __a);
5891#else
5892 return __builtin_altivec_vpksdus(__a, __b);
5893#endif
5894}
5895
Daniel Jasperbe508362016-03-11 22:13:28 +00005896static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005897vec_packsu(vector unsigned long long __a, vector unsigned long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005898#ifdef __LITTLE_ENDIAN__
5899 return __builtin_altivec_vpkudus(__b, __a);
5900#else
5901 return __builtin_altivec_vpkudus(__a, __b);
5902#endif
5903}
5904#endif
5905
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005906/* vec_vpkshus */
5907
Daniel Jasperbe508362016-03-11 22:13:28 +00005908static __inline__ vector unsigned char __ATTRS_o_ai
5909vec_vpkshus(vector short __a, vector short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005910#ifdef __LITTLE_ENDIAN__
5911 return __builtin_altivec_vpkshus(__b, __a);
5912#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005913 return __builtin_altivec_vpkshus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005914#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005915}
5916
Daniel Jasperbe508362016-03-11 22:13:28 +00005917static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00005918vec_vpkshus(vector unsigned short __a, vector unsigned short __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005919#ifdef __LITTLE_ENDIAN__
5920 return __builtin_altivec_vpkuhus(__b, __a);
5921#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005922 return __builtin_altivec_vpkuhus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005923#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005924}
5925
5926/* vec_vpkswus */
5927
Daniel Jasperbe508362016-03-11 22:13:28 +00005928static __inline__ vector unsigned short __ATTRS_o_ai
5929vec_vpkswus(vector int __a, vector int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005930#ifdef __LITTLE_ENDIAN__
5931 return __builtin_altivec_vpkswus(__b, __a);
5932#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005933 return __builtin_altivec_vpkswus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005934#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005935}
5936
Daniel Jasperbe508362016-03-11 22:13:28 +00005937static __inline__ vector unsigned short __ATTRS_o_ai
5938vec_vpkswus(vector unsigned int __a, vector unsigned int __b) {
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005939#ifdef __LITTLE_ENDIAN__
5940 return __builtin_altivec_vpkuwus(__b, __a);
5941#else
David Blaikie3302f2b2013-01-16 23:08:36 +00005942 return __builtin_altivec_vpkuwus(__a, __b);
Bill Schmidt8a7b4f12014-06-06 15:10:47 +00005943#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005944}
5945
Bill Schmidt41e14c42015-05-16 01:02:25 +00005946/* vec_vpksdus */
5947
5948#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00005949static __inline__ vector unsigned int __ATTRS_o_ai
5950vec_vpksdus(vector long long __a, vector long long __b) {
Bill Schmidt41e14c42015-05-16 01:02:25 +00005951#ifdef __LITTLE_ENDIAN__
5952 return __builtin_altivec_vpksdus(__b, __a);
5953#else
5954 return __builtin_altivec_vpksdus(__a, __b);
5955#endif
5956}
5957#endif
5958
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005959/* vec_perm */
5960
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005961// The vperm instruction is defined architecturally with a big-endian bias.
5962// For little endian, we swap the input operands and invert the permute
5963// control vector. Only the rightmost 5 bits matter, so we could use
5964// a vector of all 31s instead of all 255s to perform the inversion.
5965// However, when the PCV is not a constant, using 255 has an advantage
5966// in that the vec_xor can be recognized as a vec_nor (and for P8 and
5967// later, possibly a vec_nand).
5968
Daniel Jasperbe508362016-03-11 22:13:28 +00005969static __inline__ vector signed char __ATTRS_o_ai vec_perm(
5970 vector signed char __a, vector signed char __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005971#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005972 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
5973 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005974 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00005975 return (vector signed char)__builtin_altivec_vperm_4si((vector int)__b,
5976 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005977#else
Bill Seurer703e8482015-06-09 14:39:47 +00005978 return (vector signed char)__builtin_altivec_vperm_4si((vector int)__a,
5979 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005980#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005981}
5982
Daniel Jasperbe508362016-03-11 22:13:28 +00005983static __inline__ vector unsigned char __ATTRS_o_ai
5984vec_perm(vector unsigned char __a, vector unsigned char __b,
5985 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005986#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00005987 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
5988 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005989 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00005990 return (vector unsigned char)__builtin_altivec_vperm_4si(
5991 (vector int)__b, (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005992#else
Bill Seurer703e8482015-06-09 14:39:47 +00005993 return (vector unsigned char)__builtin_altivec_vperm_4si(
5994 (vector int)__a, (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00005995#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00005996}
5997
Daniel Jasperbe508362016-03-11 22:13:28 +00005998static __inline__ vector bool char __ATTRS_o_ai
5999vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006000#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006001 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6002 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006003 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006004 return (vector bool char)__builtin_altivec_vperm_4si((vector int)__b,
6005 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006006#else
Bill Seurer703e8482015-06-09 14:39:47 +00006007 return (vector bool char)__builtin_altivec_vperm_4si((vector int)__a,
6008 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006009#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00006010}
6011
Daniel Jasperbe508362016-03-11 22:13:28 +00006012static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a,
6013 vector signed short __b,
6014 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006015#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006016 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6017 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006018 __d = vec_xor(__c, __d);
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006019 return (vector signed short)__builtin_altivec_vperm_4si((vector int)__b,
6020 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006021#else
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006022 return (vector signed short)__builtin_altivec_vperm_4si((vector int)__a,
6023 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006024#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006025}
6026
Daniel Jasperbe508362016-03-11 22:13:28 +00006027static __inline__ vector unsigned short __ATTRS_o_ai
6028vec_perm(vector unsigned short __a, vector unsigned short __b,
6029 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006030#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006031 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6032 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006033 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006034 return (vector unsigned short)__builtin_altivec_vperm_4si(
6035 (vector int)__b, (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006036#else
Bill Seurer703e8482015-06-09 14:39:47 +00006037 return (vector unsigned short)__builtin_altivec_vperm_4si(
6038 (vector int)__a, (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006039#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006040}
6041
Daniel Jasperbe508362016-03-11 22:13:28 +00006042static __inline__ vector bool short __ATTRS_o_ai vec_perm(
6043 vector bool short __a, vector bool short __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006044#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006045 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6046 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006047 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006048 return (vector bool short)__builtin_altivec_vperm_4si((vector int)__b,
6049 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006050#else
Bill Seurer703e8482015-06-09 14:39:47 +00006051 return (vector bool short)__builtin_altivec_vperm_4si((vector int)__a,
6052 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006053#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00006054}
6055
Daniel Jasperbe508362016-03-11 22:13:28 +00006056static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a,
6057 vector pixel __b,
6058 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006059#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006060 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6061 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006062 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006063 return (vector pixel)__builtin_altivec_vperm_4si((vector int)__b,
6064 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006065#else
Bill Seurer703e8482015-06-09 14:39:47 +00006066 return (vector pixel)__builtin_altivec_vperm_4si((vector int)__a,
6067 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006068#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00006069}
6070
Daniel Jasperbe508362016-03-11 22:13:28 +00006071static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a,
6072 vector signed int __b,
6073 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006074#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006075 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6076 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006077 __d = vec_xor(__c, __d);
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006078 return (vector signed int)__builtin_altivec_vperm_4si(__b, __a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006079#else
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006080 return (vector signed int)__builtin_altivec_vperm_4si(__a, __b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006081#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006082}
6083
Daniel Jasperbe508362016-03-11 22:13:28 +00006084static __inline__ vector unsigned int __ATTRS_o_ai
6085vec_perm(vector unsigned int __a, vector unsigned int __b,
6086 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006087#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006088 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6089 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006090 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006091 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__b,
6092 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006093#else
Bill Seurer703e8482015-06-09 14:39:47 +00006094 return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__a,
6095 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006096#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006097}
6098
Daniel Jasperbe508362016-03-11 22:13:28 +00006099static __inline__ vector bool int __ATTRS_o_ai
6100vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006101#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006102 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6103 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006104 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006105 return (vector bool int)__builtin_altivec_vperm_4si((vector int)__b,
6106 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006107#else
Bill Seurer703e8482015-06-09 14:39:47 +00006108 return (vector bool int)__builtin_altivec_vperm_4si((vector int)__a,
6109 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006110#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00006111}
6112
Daniel Jasperbe508362016-03-11 22:13:28 +00006113static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a,
6114 vector float __b,
6115 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006116#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006117 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6118 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006119 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006120 return (vector float)__builtin_altivec_vperm_4si((vector int)__b,
6121 (vector int)__a, __d);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006122#else
Bill Seurer703e8482015-06-09 14:39:47 +00006123 return (vector float)__builtin_altivec_vperm_4si((vector int)__a,
6124 (vector int)__b, __c);
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006125#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006126}
6127
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006128#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006129static __inline__ vector long long __ATTRS_o_ai
6130vec_perm(vector signed long long __a, vector signed long long __b,
6131 vector unsigned char __c) {
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006132#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006133 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6134 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006135 __d = vec_xor(__c, __d);
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006136 return (vector signed long long)__builtin_altivec_vperm_4si(
6137 (vector int)__b, (vector int)__a, __d);
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006138#else
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006139 return (vector signed long long)__builtin_altivec_vperm_4si(
6140 (vector int)__a, (vector int)__b, __c);
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006141#endif
6142}
6143
Daniel Jasperbe508362016-03-11 22:13:28 +00006144static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006145vec_perm(vector unsigned long long __a, vector unsigned long long __b,
Bill Seurer703e8482015-06-09 14:39:47 +00006146 vector unsigned char __c) {
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006147#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006148 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6149 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006150 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006151 return (vector unsigned long long)__builtin_altivec_vperm_4si(
6152 (vector int)__b, (vector int)__a, __d);
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006153#else
Bill Seurer703e8482015-06-09 14:39:47 +00006154 return (vector unsigned long long)__builtin_altivec_vperm_4si(
6155 (vector int)__a, (vector int)__b, __c);
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006156#endif
6157}
6158
Daniel Jasperbe508362016-03-11 22:13:28 +00006159static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006160vec_perm(vector bool long long __a, vector bool long long __b,
6161 vector unsigned char __c) {
6162#ifdef __LITTLE_ENDIAN__
6163 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6164 255, 255, 255, 255, 255, 255, 255, 255};
6165 __d = vec_xor(__c, __d);
6166 return (vector bool long long)__builtin_altivec_vperm_4si(
6167 (vector int)__b, (vector int)__a, __d);
6168#else
6169 return (vector bool long long)__builtin_altivec_vperm_4si(
6170 (vector int)__a, (vector int)__b, __c);
6171#endif
6172}
6173
Daniel Jasperbe508362016-03-11 22:13:28 +00006174static __inline__ vector double __ATTRS_o_ai
6175vec_perm(vector double __a, vector double __b, vector unsigned char __c) {
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006176#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00006177 vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255,
6178 255, 255, 255, 255, 255, 255, 255, 255};
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006179 __d = vec_xor(__c, __d);
Bill Seurer703e8482015-06-09 14:39:47 +00006180 return (vector double)__builtin_altivec_vperm_4si((vector int)__b,
6181 (vector int)__a, __d);
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006182#else
Bill Seurer703e8482015-06-09 14:39:47 +00006183 return (vector double)__builtin_altivec_vperm_4si((vector int)__a,
6184 (vector int)__b, __c);
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006185#endif
6186}
6187#endif
6188
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006189/* vec_vperm */
6190
Daniel Jasperbe508362016-03-11 22:13:28 +00006191static __inline__ vector signed char __ATTRS_o_ai vec_vperm(
6192 vector signed char __a, vector signed char __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006193 return vec_perm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006194}
6195
Daniel Jasperbe508362016-03-11 22:13:28 +00006196static __inline__ vector unsigned char __ATTRS_o_ai
6197vec_vperm(vector unsigned char __a, vector unsigned char __b,
6198 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006199 return vec_perm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006200}
6201
Daniel Jasperbe508362016-03-11 22:13:28 +00006202static __inline__ vector bool char __ATTRS_o_ai vec_vperm(
6203 vector bool char __a, vector bool char __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006204 return vec_perm(__a, __b, __c);
Anton Yartsev9e968982010-08-19 03:00:09 +00006205}
6206
Daniel Jasperbe508362016-03-11 22:13:28 +00006207static __inline__ vector short __ATTRS_o_ai
6208vec_vperm(vector short __a, vector short __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006209 return vec_perm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006210}
6211
Daniel Jasperbe508362016-03-11 22:13:28 +00006212static __inline__ vector unsigned short __ATTRS_o_ai
6213vec_vperm(vector unsigned short __a, vector unsigned short __b,
6214 vector unsigned char __c) {
6215 return vec_perm(__a, __b, __c);
6216}
6217
6218static __inline__ vector bool short __ATTRS_o_ai vec_vperm(
6219 vector bool short __a, vector bool short __b, vector unsigned char __c) {
6220 return vec_perm(__a, __b, __c);
6221}
6222
6223static __inline__ vector pixel __ATTRS_o_ai
6224vec_vperm(vector pixel __a, vector pixel __b, vector unsigned char __c) {
6225 return vec_perm(__a, __b, __c);
6226}
6227
6228static __inline__ vector int __ATTRS_o_ai vec_vperm(vector int __a,
6229 vector int __b,
Bill Seurer703e8482015-06-09 14:39:47 +00006230 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006231 return vec_perm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006232}
6233
Daniel Jasperbe508362016-03-11 22:13:28 +00006234static __inline__ vector unsigned int __ATTRS_o_ai
6235vec_vperm(vector unsigned int __a, vector unsigned int __b,
6236 vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006237 return vec_perm(__a, __b, __c);
Anton Yartsev9e968982010-08-19 03:00:09 +00006238}
6239
Daniel Jasperbe508362016-03-11 22:13:28 +00006240static __inline__ vector bool int __ATTRS_o_ai
6241vec_vperm(vector bool int __a, vector bool int __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006242 return vec_perm(__a, __b, __c);
Anton Yartsev9e968982010-08-19 03:00:09 +00006243}
6244
Daniel Jasperbe508362016-03-11 22:13:28 +00006245static __inline__ vector float __ATTRS_o_ai
6246vec_vperm(vector float __a, vector float __b, vector unsigned char __c) {
Bill Schmidtf7e289c2014-06-05 19:07:40 +00006247 return vec_perm(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006248}
6249
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006250#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006251static __inline__ vector long long __ATTRS_o_ai vec_vperm(
6252 vector long long __a, vector long long __b, vector unsigned char __c) {
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006253 return vec_perm(__a, __b, __c);
6254}
6255
Daniel Jasperbe508362016-03-11 22:13:28 +00006256static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006257vec_vperm(vector unsigned long long __a, vector unsigned long long __b,
Bill Seurer703e8482015-06-09 14:39:47 +00006258 vector unsigned char __c) {
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006259 return vec_perm(__a, __b, __c);
6260}
6261
Daniel Jasperbe508362016-03-11 22:13:28 +00006262static __inline__ vector double __ATTRS_o_ai
6263vec_vperm(vector double __a, vector double __b, vector unsigned char __c) {
Bill Schmidt8ff672d2014-11-14 13:10:13 +00006264 return vec_perm(__a, __b, __c);
6265}
6266#endif
6267
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006268/* vec_re */
6269
Daniel Jasperbe508362016-03-11 22:13:28 +00006270static __inline__ vector float __ATTRS_o_ai vec_re(vector float __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006271#ifdef __VSX__
6272 return __builtin_vsx_xvresp(__a);
6273#else
David Blaikie3302f2b2013-01-16 23:08:36 +00006274 return __builtin_altivec_vrefp(__a);
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006275#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006276}
6277
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006278#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006279static __inline__ vector double __ATTRS_o_ai vec_re(vector double __a) {
Nemanja Ivanovic6c363ed2015-07-14 17:50:27 +00006280 return __builtin_vsx_xvredp(__a);
6281}
6282#endif
6283
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006284/* vec_vrefp */
6285
Daniel Jasperbe508362016-03-11 22:13:28 +00006286static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00006287vec_vrefp(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006288 return __builtin_altivec_vrefp(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006289}
6290
6291/* vec_rl */
6292
Daniel Jasperbe508362016-03-11 22:13:28 +00006293static __inline__ vector signed char __ATTRS_o_ai
6294vec_rl(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006295 return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006296}
6297
Daniel Jasperbe508362016-03-11 22:13:28 +00006298static __inline__ vector unsigned char __ATTRS_o_ai
6299vec_rl(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006300 return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006301}
6302
Daniel Jasperbe508362016-03-11 22:13:28 +00006303static __inline__ vector short __ATTRS_o_ai vec_rl(vector short __a,
6304 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006305 return __builtin_altivec_vrlh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006306}
6307
Daniel Jasperbe508362016-03-11 22:13:28 +00006308static __inline__ vector unsigned short __ATTRS_o_ai
6309vec_rl(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006310 return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006311}
6312
Daniel Jasperbe508362016-03-11 22:13:28 +00006313static __inline__ vector int __ATTRS_o_ai vec_rl(vector int __a,
6314 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006315 return __builtin_altivec_vrlw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006316}
6317
Daniel Jasperbe508362016-03-11 22:13:28 +00006318static __inline__ vector unsigned int __ATTRS_o_ai
6319vec_rl(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006320 return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006321}
6322
Kit Barton8553bec2015-03-11 15:57:19 +00006323#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00006324static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00006325vec_rl(vector signed long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00006326 return __builtin_altivec_vrld(__a, __b);
6327}
6328
Daniel Jasperbe508362016-03-11 22:13:28 +00006329static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00006330vec_rl(vector unsigned long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00006331 return __builtin_altivec_vrld(__a, __b);
6332}
6333#endif
6334
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006335/* vec_vrlb */
6336
Daniel Jasperbe508362016-03-11 22:13:28 +00006337static __inline__ vector signed char __ATTRS_o_ai
6338vec_vrlb(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006339 return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006340}
6341
Daniel Jasperbe508362016-03-11 22:13:28 +00006342static __inline__ vector unsigned char __ATTRS_o_ai
6343vec_vrlb(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006344 return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006345}
6346
6347/* vec_vrlh */
6348
Daniel Jasperbe508362016-03-11 22:13:28 +00006349static __inline__ vector short __ATTRS_o_ai
6350vec_vrlh(vector short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006351 return __builtin_altivec_vrlh(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006352}
6353
Daniel Jasperbe508362016-03-11 22:13:28 +00006354static __inline__ vector unsigned short __ATTRS_o_ai
6355vec_vrlh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006356 return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006357}
6358
6359/* vec_vrlw */
6360
Daniel Jasperbe508362016-03-11 22:13:28 +00006361static __inline__ vector int __ATTRS_o_ai vec_vrlw(vector int __a,
6362 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006363 return __builtin_altivec_vrlw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006364}
6365
Daniel Jasperbe508362016-03-11 22:13:28 +00006366static __inline__ vector unsigned int __ATTRS_o_ai
6367vec_vrlw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006368 return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006369}
6370
6371/* vec_round */
6372
Daniel Jasperbe508362016-03-11 22:13:28 +00006373static __inline__ vector float __ATTRS_o_ai vec_round(vector float __a) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006374#ifdef __VSX__
6375 return __builtin_vsx_xvrspi(__a);
6376#else
David Blaikie3302f2b2013-01-16 23:08:36 +00006377 return __builtin_altivec_vrfin(__a);
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006378#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006379}
6380
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006381#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006382static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006383 return __builtin_vsx_xvrdpi(__a);
6384}
6385
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006386/* vec_rint */
6387
Daniel Jasperbe508362016-03-11 22:13:28 +00006388static __inline__ vector float __ATTRS_o_ai vec_rint(vector float __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006389 return __builtin_vsx_xvrspic(__a);
6390}
6391
Daniel Jasperbe508362016-03-11 22:13:28 +00006392static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006393 return __builtin_vsx_xvrdpic(__a);
6394}
6395
6396/* vec_nearbyint */
6397
Daniel Jasperbe508362016-03-11 22:13:28 +00006398static __inline__ vector float __ATTRS_o_ai vec_nearbyint(vector float __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006399 return __builtin_vsx_xvrspi(__a);
6400}
6401
Daniel Jasperbe508362016-03-11 22:13:28 +00006402static __inline__ vector double __ATTRS_o_ai vec_nearbyint(vector double __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006403 return __builtin_vsx_xvrdpi(__a);
6404}
6405#endif
6406
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006407/* vec_vrfin */
6408
Daniel Jasperbe508362016-03-11 22:13:28 +00006409static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00006410vec_vrfin(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006411 return __builtin_altivec_vrfin(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006412}
6413
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006414/* vec_sqrt */
6415
6416#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006417static __inline__ vector float __ATTRS_o_ai vec_sqrt(vector float __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006418 return __builtin_vsx_xvsqrtsp(__a);
6419}
6420
Daniel Jasperbe508362016-03-11 22:13:28 +00006421static __inline__ vector double __ATTRS_o_ai vec_sqrt(vector double __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006422 return __builtin_vsx_xvsqrtdp(__a);
6423}
6424#endif
6425
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006426/* vec_rsqrte */
6427
Daniel Jasperbe508362016-03-11 22:13:28 +00006428static __inline__ vector float __ATTRS_o_ai vec_rsqrte(vector float __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006429#ifdef __VSX__
6430 return __builtin_vsx_xvrsqrtesp(__a);
6431#else
David Blaikie3302f2b2013-01-16 23:08:36 +00006432 return __builtin_altivec_vrsqrtefp(__a);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006433#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006434}
6435
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006436#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006437static __inline__ vector double __ATTRS_o_ai vec_rsqrte(vector double __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006438 return __builtin_vsx_xvrsqrtedp(__a);
6439}
6440#endif
6441
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006442/* vec_vrsqrtefp */
6443
Daniel Jasperbe508362016-03-11 22:13:28 +00006444static __inline__ __vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00006445vec_vrsqrtefp(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006446 return __builtin_altivec_vrsqrtefp(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006447}
6448
6449/* vec_sel */
6450
6451#define __builtin_altivec_vsel_4si vec_sel
6452
Daniel Jasperbe508362016-03-11 22:13:28 +00006453static __inline__ vector signed char __ATTRS_o_ai vec_sel(
6454 vector signed char __a, vector signed char __b, vector unsigned char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006455 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006456}
6457
Daniel Jasperbe508362016-03-11 22:13:28 +00006458static __inline__ vector signed char __ATTRS_o_ai
6459vec_sel(vector signed char __a, vector signed char __b, vector bool char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006460 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006461}
6462
Daniel Jasperbe508362016-03-11 22:13:28 +00006463static __inline__ vector unsigned char __ATTRS_o_ai
6464vec_sel(vector unsigned char __a, vector unsigned char __b,
6465 vector unsigned char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006466 return (__a & ~__c) | (__b & __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006467}
6468
Daniel Jasperbe508362016-03-11 22:13:28 +00006469static __inline__ vector unsigned char __ATTRS_o_ai vec_sel(
6470 vector unsigned char __a, vector unsigned char __b, vector bool char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006471 return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006472}
6473
Daniel Jasperbe508362016-03-11 22:13:28 +00006474static __inline__ vector bool char __ATTRS_o_ai
6475vec_sel(vector bool char __a, vector bool char __b, vector unsigned char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006476 return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006477}
6478
Daniel Jasperbe508362016-03-11 22:13:28 +00006479static __inline__ vector bool char __ATTRS_o_ai vec_sel(vector bool char __a,
6480 vector bool char __b,
6481 vector bool char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006482 return (__a & ~__c) | (__b & __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006483}
6484
Daniel Jasperbe508362016-03-11 22:13:28 +00006485static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a,
6486 vector short __b,
6487 vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006488 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006489}
6490
Daniel Jasperbe508362016-03-11 22:13:28 +00006491static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a,
6492 vector short __b,
6493 vector bool short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006494 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006495}
6496
Daniel Jasperbe508362016-03-11 22:13:28 +00006497static __inline__ vector unsigned short __ATTRS_o_ai
6498vec_sel(vector unsigned short __a, vector unsigned short __b,
6499 vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006500 return (__a & ~__c) | (__b & __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006501}
6502
Daniel Jasperbe508362016-03-11 22:13:28 +00006503static __inline__ vector unsigned short __ATTRS_o_ai
6504vec_sel(vector unsigned short __a, vector unsigned short __b,
6505 vector bool short __c) {
Bill Seurer703e8482015-06-09 14:39:47 +00006506 return (__a & ~(vector unsigned short)__c) |
6507 (__b & (vector unsigned short)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006508}
6509
Daniel Jasperbe508362016-03-11 22:13:28 +00006510static __inline__ vector bool short __ATTRS_o_ai vec_sel(
6511 vector bool short __a, vector bool short __b, vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006512 return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006513}
6514
Daniel Jasperbe508362016-03-11 22:13:28 +00006515static __inline__ vector bool short __ATTRS_o_ai
6516vec_sel(vector bool short __a, vector bool short __b, vector bool short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006517 return (__a & ~__c) | (__b & __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006518}
6519
Daniel Jasperbe508362016-03-11 22:13:28 +00006520static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a,
6521 vector int __b,
6522 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006523 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006524}
6525
Daniel Jasperbe508362016-03-11 22:13:28 +00006526static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a,
6527 vector int __b,
6528 vector bool int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006529 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006530}
6531
Daniel Jasperbe508362016-03-11 22:13:28 +00006532static __inline__ vector unsigned int __ATTRS_o_ai vec_sel(
6533 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006534 return (__a & ~__c) | (__b & __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006535}
6536
Daniel Jasperbe508362016-03-11 22:13:28 +00006537static __inline__ vector unsigned int __ATTRS_o_ai
6538vec_sel(vector unsigned int __a, vector unsigned int __b, vector bool int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006539 return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006540}
6541
Daniel Jasperbe508362016-03-11 22:13:28 +00006542static __inline__ vector bool int __ATTRS_o_ai
6543vec_sel(vector bool int __a, vector bool int __b, vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006544 return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006545}
6546
Daniel Jasperbe508362016-03-11 22:13:28 +00006547static __inline__ vector bool int __ATTRS_o_ai vec_sel(vector bool int __a,
6548 vector bool int __b,
6549 vector bool int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006550 return (__a & ~__c) | (__b & __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006551}
6552
Daniel Jasperbe508362016-03-11 22:13:28 +00006553static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a,
6554 vector float __b,
6555 vector unsigned int __c) {
Bill Seurer703e8482015-06-09 14:39:47 +00006556 vector int __res = ((vector int)__a & ~(vector int)__c) |
6557 ((vector int)__b & (vector int)__c);
David Blaikie3302f2b2013-01-16 23:08:36 +00006558 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006559}
6560
Daniel Jasperbe508362016-03-11 22:13:28 +00006561static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a,
6562 vector float __b,
6563 vector bool int __c) {
Bill Seurer703e8482015-06-09 14:39:47 +00006564 vector int __res = ((vector int)__a & ~(vector int)__c) |
6565 ((vector int)__b & (vector int)__c);
David Blaikie3302f2b2013-01-16 23:08:36 +00006566 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +00006567}
6568
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006569#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00006570static __inline__ vector double __ATTRS_o_ai
6571vec_sel(vector double __a, vector double __b, vector bool long long __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006572 vector long long __res = ((vector long long)__a & ~(vector long long)__c) |
Daniel Jasperbe508362016-03-11 22:13:28 +00006573 ((vector long long)__b & (vector long long)__c);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006574 return (vector double)__res;
6575}
6576
Daniel Jasperbe508362016-03-11 22:13:28 +00006577static __inline__ vector double __ATTRS_o_ai
6578vec_sel(vector double __a, vector double __b, vector unsigned long long __c) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006579 vector long long __res = ((vector long long)__a & ~(vector long long)__c) |
Daniel Jasperbe508362016-03-11 22:13:28 +00006580 ((vector long long)__b & (vector long long)__c);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00006581 return (vector double)__res;
6582}
6583#endif
6584
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006585/* vec_vsel */
6586
Daniel Jasperbe508362016-03-11 22:13:28 +00006587static __inline__ vector signed char __ATTRS_o_ai vec_vsel(
6588 vector signed char __a, vector signed char __b, vector unsigned char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006589 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006590}
6591
Daniel Jasperbe508362016-03-11 22:13:28 +00006592static __inline__ vector signed char __ATTRS_o_ai
6593vec_vsel(vector signed char __a, vector signed char __b, vector bool char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006594 return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006595}
6596
Daniel Jasperbe508362016-03-11 22:13:28 +00006597static __inline__ vector unsigned char __ATTRS_o_ai
6598vec_vsel(vector unsigned char __a, vector unsigned char __b,
6599 vector unsigned char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006600 return (__a & ~__c) | (__b & __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006601}
6602
Daniel Jasperbe508362016-03-11 22:13:28 +00006603static __inline__ vector unsigned char __ATTRS_o_ai vec_vsel(
6604 vector unsigned char __a, vector unsigned char __b, vector bool char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006605 return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006606}
6607
Daniel Jasperbe508362016-03-11 22:13:28 +00006608static __inline__ vector bool char __ATTRS_o_ai
6609vec_vsel(vector bool char __a, vector bool char __b, vector unsigned char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006610 return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006611}
6612
Daniel Jasperbe508362016-03-11 22:13:28 +00006613static __inline__ vector bool char __ATTRS_o_ai vec_vsel(vector bool char __a,
6614 vector bool char __b,
6615 vector bool char __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006616 return (__a & ~__c) | (__b & __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006617}
6618
Daniel Jasperbe508362016-03-11 22:13:28 +00006619static __inline__ vector short __ATTRS_o_ai
6620vec_vsel(vector short __a, vector short __b, vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006621 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006622}
6623
Daniel Jasperbe508362016-03-11 22:13:28 +00006624static __inline__ vector short __ATTRS_o_ai vec_vsel(vector short __a,
6625 vector short __b,
6626 vector bool short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006627 return (__a & ~(vector short)__c) | (__b & (vector short)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006628}
6629
Daniel Jasperbe508362016-03-11 22:13:28 +00006630static __inline__ vector unsigned short __ATTRS_o_ai
6631vec_vsel(vector unsigned short __a, vector unsigned short __b,
6632 vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006633 return (__a & ~__c) | (__b & __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006634}
6635
Daniel Jasperbe508362016-03-11 22:13:28 +00006636static __inline__ vector unsigned short __ATTRS_o_ai
6637vec_vsel(vector unsigned short __a, vector unsigned short __b,
6638 vector bool short __c) {
Bill Seurer703e8482015-06-09 14:39:47 +00006639 return (__a & ~(vector unsigned short)__c) |
6640 (__b & (vector unsigned short)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006641}
6642
Daniel Jasperbe508362016-03-11 22:13:28 +00006643static __inline__ vector bool short __ATTRS_o_ai vec_vsel(
6644 vector bool short __a, vector bool short __b, vector unsigned short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006645 return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006646}
6647
Daniel Jasperbe508362016-03-11 22:13:28 +00006648static __inline__ vector bool short __ATTRS_o_ai
6649vec_vsel(vector bool short __a, vector bool short __b, vector bool short __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006650 return (__a & ~__c) | (__b & __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006651}
6652
Daniel Jasperbe508362016-03-11 22:13:28 +00006653static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a,
6654 vector int __b,
6655 vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006656 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006657}
6658
Daniel Jasperbe508362016-03-11 22:13:28 +00006659static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a,
6660 vector int __b,
6661 vector bool int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006662 return (__a & ~(vector int)__c) | (__b & (vector int)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006663}
6664
Daniel Jasperbe508362016-03-11 22:13:28 +00006665static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel(
6666 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006667 return (__a & ~__c) | (__b & __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006668}
6669
Daniel Jasperbe508362016-03-11 22:13:28 +00006670static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel(
6671 vector unsigned int __a, vector unsigned int __b, vector bool int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006672 return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006673}
6674
Daniel Jasperbe508362016-03-11 22:13:28 +00006675static __inline__ vector bool int __ATTRS_o_ai
6676vec_vsel(vector bool int __a, vector bool int __b, vector unsigned int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006677 return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006678}
6679
Daniel Jasperbe508362016-03-11 22:13:28 +00006680static __inline__ vector bool int __ATTRS_o_ai vec_vsel(vector bool int __a,
6681 vector bool int __b,
6682 vector bool int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006683 return (__a & ~__c) | (__b & __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00006684}
6685
Daniel Jasperbe508362016-03-11 22:13:28 +00006686static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a,
6687 vector float __b,
6688 vector unsigned int __c) {
Bill Seurer703e8482015-06-09 14:39:47 +00006689 vector int __res = ((vector int)__a & ~(vector int)__c) |
6690 ((vector int)__b & (vector int)__c);
David Blaikie3302f2b2013-01-16 23:08:36 +00006691 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006692}
6693
Daniel Jasperbe508362016-03-11 22:13:28 +00006694static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a,
6695 vector float __b,
6696 vector bool int __c) {
Bill Seurer703e8482015-06-09 14:39:47 +00006697 vector int __res = ((vector int)__a & ~(vector int)__c) |
6698 ((vector int)__b & (vector int)__c);
David Blaikie3302f2b2013-01-16 23:08:36 +00006699 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +00006700}
6701
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006702/* vec_sl */
6703
Daniel Jasperbe508362016-03-11 22:13:28 +00006704static __inline__ vector signed char __ATTRS_o_ai
6705vec_sl(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006706 return __a << (vector signed char)__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006707}
6708
Daniel Jasperbe508362016-03-11 22:13:28 +00006709static __inline__ vector unsigned char __ATTRS_o_ai
6710vec_sl(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006711 return __a << __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006712}
6713
Daniel Jasperbe508362016-03-11 22:13:28 +00006714static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
6715 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006716 return __a << (vector short)__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006717}
6718
Daniel Jasperbe508362016-03-11 22:13:28 +00006719static __inline__ vector unsigned short __ATTRS_o_ai
6720vec_sl(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006721 return __a << __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006722}
6723
Daniel Jasperbe508362016-03-11 22:13:28 +00006724static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
6725 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006726 return __a << (vector int)__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006727}
6728
Daniel Jasperbe508362016-03-11 22:13:28 +00006729static __inline__ vector unsigned int __ATTRS_o_ai
6730vec_sl(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006731 return __a << __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006732}
6733
Kit Barton8553bec2015-03-11 15:57:19 +00006734#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00006735static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00006736vec_sl(vector signed long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00006737 return __a << (vector long long)__b;
6738}
6739
Daniel Jasperbe508362016-03-11 22:13:28 +00006740static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00006741vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00006742 return __a << __b;
6743}
6744#endif
6745
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006746/* vec_vslb */
6747
6748#define __builtin_altivec_vslb vec_vslb
6749
Daniel Jasperbe508362016-03-11 22:13:28 +00006750static __inline__ vector signed char __ATTRS_o_ai
6751vec_vslb(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006752 return vec_sl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006753}
6754
Daniel Jasperbe508362016-03-11 22:13:28 +00006755static __inline__ vector unsigned char __ATTRS_o_ai
6756vec_vslb(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006757 return vec_sl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006758}
6759
6760/* vec_vslh */
6761
6762#define __builtin_altivec_vslh vec_vslh
6763
Daniel Jasperbe508362016-03-11 22:13:28 +00006764static __inline__ vector short __ATTRS_o_ai
6765vec_vslh(vector short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006766 return vec_sl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006767}
6768
Daniel Jasperbe508362016-03-11 22:13:28 +00006769static __inline__ vector unsigned short __ATTRS_o_ai
6770vec_vslh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006771 return vec_sl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006772}
6773
6774/* vec_vslw */
6775
6776#define __builtin_altivec_vslw vec_vslw
6777
Daniel Jasperbe508362016-03-11 22:13:28 +00006778static __inline__ vector int __ATTRS_o_ai vec_vslw(vector int __a,
6779 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006780 return vec_sl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006781}
6782
Daniel Jasperbe508362016-03-11 22:13:28 +00006783static __inline__ vector unsigned int __ATTRS_o_ai
6784vec_vslw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00006785 return vec_sl(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006786}
6787
6788/* vec_sld */
6789
6790#define __builtin_altivec_vsldoi_4si vec_sld
6791
Daniel Jasperbe508362016-03-11 22:13:28 +00006792static __inline__ vector signed char __ATTRS_o_ai vec_sld(
6793 vector signed char __a, vector signed char __b, unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006794 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006795#ifdef __LITTLE_ENDIAN__
6796 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006797 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6798 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6799 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6800 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006801#else
Bill Seurer703e8482015-06-09 14:39:47 +00006802 return vec_perm(
6803 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006804 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6805 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6806 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006807#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006808}
6809
Daniel Jasperbe508362016-03-11 22:13:28 +00006810static __inline__ vector unsigned char __ATTRS_o_ai
6811vec_sld(vector unsigned char __a, vector unsigned char __b,
6812 unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006813 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006814#ifdef __LITTLE_ENDIAN__
6815 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006816 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6817 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6818 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6819 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006820#else
Bill Seurer703e8482015-06-09 14:39:47 +00006821 return vec_perm(
6822 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006823 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6824 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6825 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006826#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006827}
6828
Daniel Jasperbe508362016-03-11 22:13:28 +00006829static __inline__ vector bool char __ATTRS_o_ai
6830vec_sld(vector bool char __a, vector bool char __b, unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006831 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006832#ifdef __LITTLE_ENDIAN__
6833 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006834 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6835 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6836 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6837 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006838#else
Bill Seurer703e8482015-06-09 14:39:47 +00006839 return vec_perm(
6840 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006841 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6842 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6843 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006844#endif
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006845}
6846
Daniel Jasperbe508362016-03-11 22:13:28 +00006847static __inline__ vector signed short __ATTRS_o_ai vec_sld(
6848 vector signed short __a, vector signed short __b, unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006849 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006850#ifdef __LITTLE_ENDIAN__
6851 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006852 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6853 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6854 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6855 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006856#else
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006857 return vec_perm(
6858 __a, __b,
6859 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6860 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6861 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006862#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006863}
6864
Daniel Jasperbe508362016-03-11 22:13:28 +00006865static __inline__ vector unsigned short __ATTRS_o_ai
6866vec_sld(vector unsigned short __a, vector unsigned short __b,
6867 unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006868 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006869#ifdef __LITTLE_ENDIAN__
6870 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006871 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6872 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6873 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6874 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006875#else
Bill Seurer703e8482015-06-09 14:39:47 +00006876 return vec_perm(
6877 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006878 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6879 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6880 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006881#endif
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006882}
6883
Daniel Jasperbe508362016-03-11 22:13:28 +00006884static __inline__ vector bool short __ATTRS_o_ai
6885vec_sld(vector bool short __a, vector bool short __b, unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006886 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006887#ifdef __LITTLE_ENDIAN__
6888 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006889 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6890 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6891 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6892 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006893#else
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006894 return vec_perm(
6895 __a, __b,
6896 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6897 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6898 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006899#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00006900}
6901
Daniel Jasperbe508362016-03-11 22:13:28 +00006902static __inline__ vector pixel __ATTRS_o_ai vec_sld(vector pixel __a,
6903 vector pixel __b,
6904 unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006905 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006906#ifdef __LITTLE_ENDIAN__
6907 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006908 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6909 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6910 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6911 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006912#else
Bill Seurer703e8482015-06-09 14:39:47 +00006913 return vec_perm(
6914 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006915 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6916 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6917 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006918#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006919}
6920
Daniel Jasperbe508362016-03-11 22:13:28 +00006921static __inline__ vector signed int __ATTRS_o_ai
6922vec_sld(vector signed int __a, vector signed int __b, unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006923 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006924#ifdef __LITTLE_ENDIAN__
6925 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006926 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6927 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6928 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6929 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006930#else
Bill Seurer703e8482015-06-09 14:39:47 +00006931 return vec_perm(
6932 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006933 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6934 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6935 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006936#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006937}
6938
Daniel Jasperbe508362016-03-11 22:13:28 +00006939static __inline__ vector unsigned int __ATTRS_o_ai vec_sld(
6940 vector unsigned int __a, vector unsigned int __b, unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006941 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006942#ifdef __LITTLE_ENDIAN__
6943 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006944 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6945 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6946 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6947 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006948#else
Bill Seurer703e8482015-06-09 14:39:47 +00006949 return vec_perm(
6950 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006951 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6952 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6953 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006954#endif
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006955}
6956
Daniel Jasperbe508362016-03-11 22:13:28 +00006957static __inline__ vector bool int __ATTRS_o_ai vec_sld(vector bool int __a,
6958 vector bool int __b,
6959 unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006960 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006961#ifdef __LITTLE_ENDIAN__
6962 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006963 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6964 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6965 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6966 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006967#else
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006968 return vec_perm(
6969 __a, __b,
6970 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6971 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6972 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006973#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006974}
6975
Daniel Jasperbe508362016-03-11 22:13:28 +00006976static __inline__ vector float __ATTRS_o_ai vec_sld(vector float __a,
6977 vector float __b,
6978 unsigned const int __c) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006979 unsigned char __d = __c & 0x0F;
Bill Schmidt8da737a2015-07-15 15:45:53 +00006980#ifdef __LITTLE_ENDIAN__
6981 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00006982 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
6983 20 - __d, 21 - __d, 22 - __d, 23 - __d,
6984 24 - __d, 25 - __d, 26 - __d, 27 - __d,
6985 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006986#else
Bill Seurer703e8482015-06-09 14:39:47 +00006987 return vec_perm(
6988 __a, __b,
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00006989 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
6990 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
6991 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
Bill Schmidt8da737a2015-07-15 15:45:53 +00006992#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00006993}
6994
6995/* vec_vsldoi */
6996
Daniel Jasperbe508362016-03-11 22:13:28 +00006997static __inline__ vector signed char __ATTRS_o_ai
6998vec_vsldoi(vector signed char __a, vector signed char __b, unsigned char __c) {
Bill Schmidt8da737a2015-07-15 15:45:53 +00006999 unsigned char __d = __c & 0x0F;
7000#ifdef __LITTLE_ENDIAN__
7001 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00007002 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7003 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7004 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7005 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00007006#else
Bill Seurer703e8482015-06-09 14:39:47 +00007007 return vec_perm(
7008 __a, __b,
Bill Schmidt8da737a2015-07-15 15:45:53 +00007009 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7010 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7011 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7012#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007013}
7014
Daniel Jasperbe508362016-03-11 22:13:28 +00007015static __inline__ vector unsigned char __ATTRS_o_ai vec_vsldoi(
7016 vector unsigned char __a, vector unsigned char __b, unsigned char __c) {
Bill Schmidt8da737a2015-07-15 15:45:53 +00007017 unsigned char __d = __c & 0x0F;
7018#ifdef __LITTLE_ENDIAN__
7019 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00007020 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7021 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7022 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7023 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00007024#else
Bill Seurer703e8482015-06-09 14:39:47 +00007025 return vec_perm(
7026 __a, __b,
Bill Schmidt8da737a2015-07-15 15:45:53 +00007027 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7028 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7029 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7030#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007031}
7032
Daniel Jasperbe508362016-03-11 22:13:28 +00007033static __inline__ vector short __ATTRS_o_ai vec_vsldoi(vector short __a,
7034 vector short __b,
7035 unsigned char __c) {
Bill Schmidt8da737a2015-07-15 15:45:53 +00007036 unsigned char __d = __c & 0x0F;
7037#ifdef __LITTLE_ENDIAN__
7038 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00007039 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7040 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7041 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7042 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00007043#else
Bill Seurer703e8482015-06-09 14:39:47 +00007044 return vec_perm(
7045 __a, __b,
Bill Schmidt8da737a2015-07-15 15:45:53 +00007046 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7047 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7048 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7049#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007050}
7051
Daniel Jasperbe508362016-03-11 22:13:28 +00007052static __inline__ vector unsigned short __ATTRS_o_ai vec_vsldoi(
7053 vector unsigned short __a, vector unsigned short __b, unsigned char __c) {
7054 unsigned char __d = __c & 0x0F;
7055#ifdef __LITTLE_ENDIAN__
7056 return vec_perm(
7057 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7058 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7059 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7060 28 - __d, 29 - __d, 30 - __d, 31 - __d));
7061#else
7062 return vec_perm(
7063 __a, __b,
7064 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7065 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7066 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7067#endif
7068}
7069
7070static __inline__ vector pixel __ATTRS_o_ai vec_vsldoi(vector pixel __a,
7071 vector pixel __b,
7072 unsigned char __c) {
7073 unsigned char __d = __c & 0x0F;
7074#ifdef __LITTLE_ENDIAN__
7075 return vec_perm(
7076 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7077 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7078 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7079 28 - __d, 29 - __d, 30 - __d, 31 - __d));
7080#else
7081 return vec_perm(
7082 __a, __b,
7083 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7084 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7085 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7086#endif
7087}
7088
7089static __inline__ vector int __ATTRS_o_ai vec_vsldoi(vector int __a,
7090 vector int __b,
Bill Seurer703e8482015-06-09 14:39:47 +00007091 unsigned char __c) {
Bill Schmidt8da737a2015-07-15 15:45:53 +00007092 unsigned char __d = __c & 0x0F;
7093#ifdef __LITTLE_ENDIAN__
7094 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00007095 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7096 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7097 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7098 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00007099#else
Bill Seurer703e8482015-06-09 14:39:47 +00007100 return vec_perm(
7101 __a, __b,
Bill Schmidt8da737a2015-07-15 15:45:53 +00007102 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7103 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7104 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7105#endif
Anton Yartsev9e968982010-08-19 03:00:09 +00007106}
7107
Daniel Jasperbe508362016-03-11 22:13:28 +00007108static __inline__ vector unsigned int __ATTRS_o_ai vec_vsldoi(
7109 vector unsigned int __a, vector unsigned int __b, unsigned char __c) {
Bill Schmidt8da737a2015-07-15 15:45:53 +00007110 unsigned char __d = __c & 0x0F;
7111#ifdef __LITTLE_ENDIAN__
7112 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00007113 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7114 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7115 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7116 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00007117#else
Bill Seurer703e8482015-06-09 14:39:47 +00007118 return vec_perm(
7119 __a, __b,
Bill Schmidt8da737a2015-07-15 15:45:53 +00007120 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7121 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7122 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7123#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007124}
7125
Daniel Jasperbe508362016-03-11 22:13:28 +00007126static __inline__ vector float __ATTRS_o_ai vec_vsldoi(vector float __a,
7127 vector float __b,
7128 unsigned char __c) {
Bill Schmidt8da737a2015-07-15 15:45:53 +00007129 unsigned char __d = __c & 0x0F;
7130#ifdef __LITTLE_ENDIAN__
7131 return vec_perm(
Daniel Jasperbe508362016-03-11 22:13:28 +00007132 __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d,
7133 20 - __d, 21 - __d, 22 - __d, 23 - __d,
7134 24 - __d, 25 - __d, 26 - __d, 27 - __d,
7135 28 - __d, 29 - __d, 30 - __d, 31 - __d));
Bill Schmidt8da737a2015-07-15 15:45:53 +00007136#else
Bill Seurer703e8482015-06-09 14:39:47 +00007137 return vec_perm(
7138 __a, __b,
Bill Schmidt8da737a2015-07-15 15:45:53 +00007139 (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5,
7140 __d + 6, __d + 7, __d + 8, __d + 9, __d + 10,
7141 __d + 11, __d + 12, __d + 13, __d + 14, __d + 15));
7142#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007143}
7144
7145/* vec_sll */
7146
Daniel Jasperbe508362016-03-11 22:13:28 +00007147static __inline__ vector signed char __ATTRS_o_ai
7148vec_sll(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007149 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
7150 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007151}
7152
Daniel Jasperbe508362016-03-11 22:13:28 +00007153static __inline__ vector signed char __ATTRS_o_ai
7154vec_sll(vector signed char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007155 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
7156 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007157}
7158
Daniel Jasperbe508362016-03-11 22:13:28 +00007159static __inline__ vector signed char __ATTRS_o_ai
7160vec_sll(vector signed char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007161 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
7162 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007163}
7164
Daniel Jasperbe508362016-03-11 22:13:28 +00007165static __inline__ vector unsigned char __ATTRS_o_ai
7166vec_sll(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007167 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
7168 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007169}
7170
Daniel Jasperbe508362016-03-11 22:13:28 +00007171static __inline__ vector unsigned char __ATTRS_o_ai
7172vec_sll(vector unsigned char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007173 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
7174 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007175}
7176
Daniel Jasperbe508362016-03-11 22:13:28 +00007177static __inline__ vector unsigned char __ATTRS_o_ai
7178vec_sll(vector unsigned char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007179 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
7180 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007181}
7182
Daniel Jasperbe508362016-03-11 22:13:28 +00007183static __inline__ vector bool char __ATTRS_o_ai
7184vec_sll(vector bool char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007185 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
7186 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007187}
7188
Daniel Jasperbe508362016-03-11 22:13:28 +00007189static __inline__ vector bool char __ATTRS_o_ai
7190vec_sll(vector bool char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007191 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
7192 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007193}
7194
Daniel Jasperbe508362016-03-11 22:13:28 +00007195static __inline__ vector bool char __ATTRS_o_ai
7196vec_sll(vector bool char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007197 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
7198 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007199}
7200
Daniel Jasperbe508362016-03-11 22:13:28 +00007201static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
7202 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007203 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007204}
7205
Daniel Jasperbe508362016-03-11 22:13:28 +00007206static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
7207 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007208 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007209}
7210
Daniel Jasperbe508362016-03-11 22:13:28 +00007211static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a,
7212 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007213 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007214}
7215
Daniel Jasperbe508362016-03-11 22:13:28 +00007216static __inline__ vector unsigned short __ATTRS_o_ai
7217vec_sll(vector unsigned short __a, vector unsigned char __b) {
7218 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
7219 (vector int)__b);
7220}
7221
7222static __inline__ vector unsigned short __ATTRS_o_ai
7223vec_sll(vector unsigned short __a, vector unsigned short __b) {
7224 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
7225 (vector int)__b);
7226}
7227
7228static __inline__ vector unsigned short __ATTRS_o_ai
7229vec_sll(vector unsigned short __a, vector unsigned int __b) {
7230 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
7231 (vector int)__b);
7232}
7233
7234static __inline__ vector bool short __ATTRS_o_ai
7235vec_sll(vector bool short __a, vector unsigned char __b) {
7236 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
7237 (vector int)__b);
7238}
7239
7240static __inline__ vector bool short __ATTRS_o_ai
7241vec_sll(vector bool short __a, vector unsigned short __b) {
7242 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
7243 (vector int)__b);
7244}
7245
7246static __inline__ vector bool short __ATTRS_o_ai
7247vec_sll(vector bool short __a, vector unsigned int __b) {
7248 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
7249 (vector int)__b);
7250}
7251
7252static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
7253 vector unsigned char __b) {
7254 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
7255}
7256
7257static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
7258 vector unsigned short __b) {
7259 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
7260}
7261
7262static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a,
7263 vector unsigned int __b) {
7264 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
7265}
7266
7267static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007268 vector unsigned char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00007269 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007270}
7271
Daniel Jasperbe508362016-03-11 22:13:28 +00007272static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007273 vector unsigned short __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00007274 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007275}
7276
Daniel Jasperbe508362016-03-11 22:13:28 +00007277static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007278 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007279 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007280}
7281
Daniel Jasperbe508362016-03-11 22:13:28 +00007282static __inline__ vector unsigned int __ATTRS_o_ai
7283vec_sll(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007284 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
7285 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007286}
7287
Daniel Jasperbe508362016-03-11 22:13:28 +00007288static __inline__ vector unsigned int __ATTRS_o_ai
7289vec_sll(vector unsigned int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007290 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
7291 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007292}
7293
Daniel Jasperbe508362016-03-11 22:13:28 +00007294static __inline__ vector unsigned int __ATTRS_o_ai
7295vec_sll(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007296 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
7297 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007298}
7299
Daniel Jasperbe508362016-03-11 22:13:28 +00007300static __inline__ vector bool int __ATTRS_o_ai
7301vec_sll(vector bool int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007302 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
7303 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007304}
7305
Daniel Jasperbe508362016-03-11 22:13:28 +00007306static __inline__ vector bool int __ATTRS_o_ai
7307vec_sll(vector bool int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007308 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
7309 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007310}
7311
Daniel Jasperbe508362016-03-11 22:13:28 +00007312static __inline__ vector bool int __ATTRS_o_ai
7313vec_sll(vector bool int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007314 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
7315 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007316}
7317
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007318/* vec_vsl */
7319
Daniel Jasperbe508362016-03-11 22:13:28 +00007320static __inline__ vector signed char __ATTRS_o_ai
7321vec_vsl(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007322 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
7323 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007324}
7325
Daniel Jasperbe508362016-03-11 22:13:28 +00007326static __inline__ vector signed char __ATTRS_o_ai
7327vec_vsl(vector signed char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007328 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
7329 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007330}
7331
Daniel Jasperbe508362016-03-11 22:13:28 +00007332static __inline__ vector signed char __ATTRS_o_ai
7333vec_vsl(vector signed char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007334 return (vector signed char)__builtin_altivec_vsl((vector int)__a,
7335 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007336}
7337
Daniel Jasperbe508362016-03-11 22:13:28 +00007338static __inline__ vector unsigned char __ATTRS_o_ai
7339vec_vsl(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007340 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
7341 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007342}
7343
Daniel Jasperbe508362016-03-11 22:13:28 +00007344static __inline__ vector unsigned char __ATTRS_o_ai
7345vec_vsl(vector unsigned char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007346 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
7347 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007348}
7349
Daniel Jasperbe508362016-03-11 22:13:28 +00007350static __inline__ vector unsigned char __ATTRS_o_ai
7351vec_vsl(vector unsigned char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007352 return (vector unsigned char)__builtin_altivec_vsl((vector int)__a,
7353 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007354}
7355
Daniel Jasperbe508362016-03-11 22:13:28 +00007356static __inline__ vector bool char __ATTRS_o_ai
7357vec_vsl(vector bool char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007358 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
7359 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007360}
7361
Daniel Jasperbe508362016-03-11 22:13:28 +00007362static __inline__ vector bool char __ATTRS_o_ai
7363vec_vsl(vector bool char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007364 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
7365 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007366}
7367
Daniel Jasperbe508362016-03-11 22:13:28 +00007368static __inline__ vector bool char __ATTRS_o_ai
7369vec_vsl(vector bool char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007370 return (vector bool char)__builtin_altivec_vsl((vector int)__a,
7371 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007372}
7373
Daniel Jasperbe508362016-03-11 22:13:28 +00007374static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
7375 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007376 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007377}
7378
Daniel Jasperbe508362016-03-11 22:13:28 +00007379static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
7380 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007381 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007382}
7383
Daniel Jasperbe508362016-03-11 22:13:28 +00007384static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a,
7385 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007386 return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007387}
7388
Daniel Jasperbe508362016-03-11 22:13:28 +00007389static __inline__ vector unsigned short __ATTRS_o_ai
7390vec_vsl(vector unsigned short __a, vector unsigned char __b) {
7391 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
7392 (vector int)__b);
7393}
7394
7395static __inline__ vector unsigned short __ATTRS_o_ai
7396vec_vsl(vector unsigned short __a, vector unsigned short __b) {
7397 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
7398 (vector int)__b);
7399}
7400
7401static __inline__ vector unsigned short __ATTRS_o_ai
7402vec_vsl(vector unsigned short __a, vector unsigned int __b) {
7403 return (vector unsigned short)__builtin_altivec_vsl((vector int)__a,
7404 (vector int)__b);
7405}
7406
7407static __inline__ vector bool short __ATTRS_o_ai
7408vec_vsl(vector bool short __a, vector unsigned char __b) {
7409 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
7410 (vector int)__b);
7411}
7412
7413static __inline__ vector bool short __ATTRS_o_ai
7414vec_vsl(vector bool short __a, vector unsigned short __b) {
7415 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
7416 (vector int)__b);
7417}
7418
7419static __inline__ vector bool short __ATTRS_o_ai
7420vec_vsl(vector bool short __a, vector unsigned int __b) {
7421 return (vector bool short)__builtin_altivec_vsl((vector int)__a,
7422 (vector int)__b);
7423}
7424
7425static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
7426 vector unsigned char __b) {
7427 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
7428}
7429
7430static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
7431 vector unsigned short __b) {
7432 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
7433}
7434
7435static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a,
7436 vector unsigned int __b) {
7437 return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b);
7438}
7439
7440static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007441 vector unsigned char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00007442 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007443}
7444
Daniel Jasperbe508362016-03-11 22:13:28 +00007445static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007446 vector unsigned short __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00007447 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007448}
7449
Daniel Jasperbe508362016-03-11 22:13:28 +00007450static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007451 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007452 return (vector int)__builtin_altivec_vsl(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007453}
7454
Daniel Jasperbe508362016-03-11 22:13:28 +00007455static __inline__ vector unsigned int __ATTRS_o_ai
7456vec_vsl(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007457 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
7458 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007459}
7460
Daniel Jasperbe508362016-03-11 22:13:28 +00007461static __inline__ vector unsigned int __ATTRS_o_ai
7462vec_vsl(vector unsigned int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007463 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
7464 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007465}
7466
Daniel Jasperbe508362016-03-11 22:13:28 +00007467static __inline__ vector unsigned int __ATTRS_o_ai
7468vec_vsl(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007469 return (vector unsigned int)__builtin_altivec_vsl((vector int)__a,
7470 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007471}
7472
Daniel Jasperbe508362016-03-11 22:13:28 +00007473static __inline__ vector bool int __ATTRS_o_ai
7474vec_vsl(vector bool int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007475 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
7476 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007477}
7478
Daniel Jasperbe508362016-03-11 22:13:28 +00007479static __inline__ vector bool int __ATTRS_o_ai
7480vec_vsl(vector bool int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007481 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
7482 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007483}
7484
Daniel Jasperbe508362016-03-11 22:13:28 +00007485static __inline__ vector bool int __ATTRS_o_ai
7486vec_vsl(vector bool int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007487 return (vector bool int)__builtin_altivec_vsl((vector int)__a,
7488 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00007489}
7490
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007491/* vec_slo */
7492
Daniel Jasperbe508362016-03-11 22:13:28 +00007493static __inline__ vector signed char __ATTRS_o_ai
7494vec_slo(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007495 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
7496 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007497}
7498
Daniel Jasperbe508362016-03-11 22:13:28 +00007499static __inline__ vector signed char __ATTRS_o_ai
7500vec_slo(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007501 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
7502 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007503}
7504
Daniel Jasperbe508362016-03-11 22:13:28 +00007505static __inline__ vector unsigned char __ATTRS_o_ai
7506vec_slo(vector unsigned char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007507 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
7508 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007509}
7510
Daniel Jasperbe508362016-03-11 22:13:28 +00007511static __inline__ vector unsigned char __ATTRS_o_ai
7512vec_slo(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007513 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
7514 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007515}
7516
Daniel Jasperbe508362016-03-11 22:13:28 +00007517static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a,
7518 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007519 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007520}
7521
Daniel Jasperbe508362016-03-11 22:13:28 +00007522static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a,
7523 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007524 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007525}
7526
Daniel Jasperbe508362016-03-11 22:13:28 +00007527static __inline__ vector unsigned short __ATTRS_o_ai
7528vec_slo(vector unsigned short __a, vector signed char __b) {
7529 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
7530 (vector int)__b);
7531}
7532
7533static __inline__ vector unsigned short __ATTRS_o_ai
7534vec_slo(vector unsigned short __a, vector unsigned char __b) {
7535 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
7536 (vector int)__b);
7537}
7538
7539static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a,
7540 vector signed char __b) {
7541 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
7542}
7543
7544static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a,
7545 vector unsigned char __b) {
7546 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
7547}
7548
7549static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007550 vector signed char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00007551 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007552}
7553
Daniel Jasperbe508362016-03-11 22:13:28 +00007554static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007555 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007556 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007557}
7558
Daniel Jasperbe508362016-03-11 22:13:28 +00007559static __inline__ vector unsigned int __ATTRS_o_ai
7560vec_slo(vector unsigned int __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007561 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
7562 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007563}
7564
Daniel Jasperbe508362016-03-11 22:13:28 +00007565static __inline__ vector unsigned int __ATTRS_o_ai
7566vec_slo(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007567 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
7568 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007569}
7570
Daniel Jasperbe508362016-03-11 22:13:28 +00007571static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a,
7572 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007573 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007574}
7575
Daniel Jasperbe508362016-03-11 22:13:28 +00007576static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a,
7577 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007578 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007579}
7580
7581/* vec_vslo */
7582
Daniel Jasperbe508362016-03-11 22:13:28 +00007583static __inline__ vector signed char __ATTRS_o_ai
7584vec_vslo(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007585 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
7586 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007587}
7588
Daniel Jasperbe508362016-03-11 22:13:28 +00007589static __inline__ vector signed char __ATTRS_o_ai
7590vec_vslo(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007591 return (vector signed char)__builtin_altivec_vslo((vector int)__a,
7592 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007593}
7594
Daniel Jasperbe508362016-03-11 22:13:28 +00007595static __inline__ vector unsigned char __ATTRS_o_ai
7596vec_vslo(vector unsigned char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007597 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
7598 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007599}
7600
Daniel Jasperbe508362016-03-11 22:13:28 +00007601static __inline__ vector unsigned char __ATTRS_o_ai
7602vec_vslo(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007603 return (vector unsigned char)__builtin_altivec_vslo((vector int)__a,
7604 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007605}
7606
Daniel Jasperbe508362016-03-11 22:13:28 +00007607static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a,
7608 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007609 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007610}
7611
Daniel Jasperbe508362016-03-11 22:13:28 +00007612static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a,
7613 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007614 return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007615}
7616
Daniel Jasperbe508362016-03-11 22:13:28 +00007617static __inline__ vector unsigned short __ATTRS_o_ai
7618vec_vslo(vector unsigned short __a, vector signed char __b) {
7619 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
7620 (vector int)__b);
7621}
7622
7623static __inline__ vector unsigned short __ATTRS_o_ai
7624vec_vslo(vector unsigned short __a, vector unsigned char __b) {
7625 return (vector unsigned short)__builtin_altivec_vslo((vector int)__a,
7626 (vector int)__b);
7627}
7628
7629static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a,
7630 vector signed char __b) {
7631 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
7632}
7633
7634static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a,
7635 vector unsigned char __b) {
7636 return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
7637}
7638
7639static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007640 vector signed char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00007641 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007642}
7643
Daniel Jasperbe508362016-03-11 22:13:28 +00007644static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00007645 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007646 return (vector int)__builtin_altivec_vslo(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007647}
7648
Daniel Jasperbe508362016-03-11 22:13:28 +00007649static __inline__ vector unsigned int __ATTRS_o_ai
7650vec_vslo(vector unsigned int __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007651 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
7652 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007653}
7654
Daniel Jasperbe508362016-03-11 22:13:28 +00007655static __inline__ vector unsigned int __ATTRS_o_ai
7656vec_vslo(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00007657 return (vector unsigned int)__builtin_altivec_vslo((vector int)__a,
7658 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007659}
7660
Daniel Jasperbe508362016-03-11 22:13:28 +00007661static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a,
7662 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007663 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007664}
7665
Daniel Jasperbe508362016-03-11 22:13:28 +00007666static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a,
7667 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007668 return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007669}
7670
7671/* vec_splat */
7672
Daniel Jasperbe508362016-03-11 22:13:28 +00007673static __inline__ vector signed char __ATTRS_o_ai
7674vec_splat(vector signed char __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007675 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007676}
7677
Daniel Jasperbe508362016-03-11 22:13:28 +00007678static __inline__ vector unsigned char __ATTRS_o_ai
7679vec_splat(vector unsigned char __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007680 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
Anton Yartsev9e968982010-08-19 03:00:09 +00007681}
7682
Daniel Jasperbe508362016-03-11 22:13:28 +00007683static __inline__ vector bool char __ATTRS_o_ai
7684vec_splat(vector bool char __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007685 return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007686}
7687
Daniel Jasperbe508362016-03-11 22:13:28 +00007688static __inline__ vector signed short __ATTRS_o_ai
7689vec_splat(vector signed short __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007690 unsigned char b0 = (__b & 0x07) * 2;
7691 unsigned char b1 = b0 + 1;
Bill Seurer703e8482015-06-09 14:39:47 +00007692 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007693 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
7694 b0, b1, b0, b1, b0, b1));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007695}
7696
Daniel Jasperbe508362016-03-11 22:13:28 +00007697static __inline__ vector unsigned short __ATTRS_o_ai
7698vec_splat(vector unsigned short __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007699 unsigned char b0 = (__b & 0x07) * 2;
7700 unsigned char b1 = b0 + 1;
Bill Seurer703e8482015-06-09 14:39:47 +00007701 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007702 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
7703 b0, b1, b0, b1, b0, b1));
Anton Yartsev9e968982010-08-19 03:00:09 +00007704}
7705
Daniel Jasperbe508362016-03-11 22:13:28 +00007706static __inline__ vector bool short __ATTRS_o_ai
7707vec_splat(vector bool short __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007708 unsigned char b0 = (__b & 0x07) * 2;
7709 unsigned char b1 = b0 + 1;
Bill Seurer703e8482015-06-09 14:39:47 +00007710 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007711 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
7712 b0, b1, b0, b1, b0, b1));
Anton Yartsev9e968982010-08-19 03:00:09 +00007713}
7714
Daniel Jasperbe508362016-03-11 22:13:28 +00007715static __inline__ vector pixel __ATTRS_o_ai vec_splat(vector pixel __a,
7716 unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007717 unsigned char b0 = (__b & 0x07) * 2;
7718 unsigned char b1 = b0 + 1;
Bill Seurer703e8482015-06-09 14:39:47 +00007719 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007720 (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1,
7721 b0, b1, b0, b1, b0, b1));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007722}
7723
Daniel Jasperbe508362016-03-11 22:13:28 +00007724static __inline__ vector signed int __ATTRS_o_ai
7725vec_splat(vector signed int __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007726 unsigned char b0 = (__b & 0x03) * 4;
7727 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
Bill Seurer703e8482015-06-09 14:39:47 +00007728 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007729 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
7730 b2, b3, b0, b1, b2, b3));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007731}
7732
Daniel Jasperbe508362016-03-11 22:13:28 +00007733static __inline__ vector unsigned int __ATTRS_o_ai
7734vec_splat(vector unsigned int __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007735 unsigned char b0 = (__b & 0x03) * 4;
7736 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
Bill Seurer703e8482015-06-09 14:39:47 +00007737 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007738 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
7739 b2, b3, b0, b1, b2, b3));
Anton Yartsev9e968982010-08-19 03:00:09 +00007740}
7741
Daniel Jasperbe508362016-03-11 22:13:28 +00007742static __inline__ vector bool int __ATTRS_o_ai
7743vec_splat(vector bool int __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007744 unsigned char b0 = (__b & 0x03) * 4;
7745 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
Bill Seurer703e8482015-06-09 14:39:47 +00007746 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007747 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
7748 b2, b3, b0, b1, b2, b3));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007749}
7750
Daniel Jasperbe508362016-03-11 22:13:28 +00007751static __inline__ vector float __ATTRS_o_ai vec_splat(vector float __a,
7752 unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007753 unsigned char b0 = (__b & 0x03) * 4;
7754 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3;
Bill Seurer703e8482015-06-09 14:39:47 +00007755 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007756 (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1,
7757 b2, b3, b0, b1, b2, b3));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007758}
7759
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007760#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00007761static __inline__ vector double __ATTRS_o_ai vec_splat(vector double __a,
7762 unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007763 unsigned char b0 = (__b & 0x01) * 8;
Daniel Jasperbe508362016-03-11 22:13:28 +00007764 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
7765 b6 = b0 + 6, b7 = b0 + 7;
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007766 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007767 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
7768 b2, b3, b4, b5, b6, b7));
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007769}
Daniel Jasperbe508362016-03-11 22:13:28 +00007770static __inline__ vector bool long long __ATTRS_o_ai
7771vec_splat(vector bool long long __a, unsigned const int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007772 unsigned char b0 = (__b & 0x01) * 8;
Daniel Jasperbe508362016-03-11 22:13:28 +00007773 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
7774 b6 = b0 + 6, b7 = b0 + 7;
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007775 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007776 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
7777 b2, b3, b4, b5, b6, b7));
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007778}
Daniel Jasperbe508362016-03-11 22:13:28 +00007779static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007780vec_splat(vector signed long long __a, unsigned const int __b) {
7781 unsigned char b0 = (__b & 0x01) * 8;
Daniel Jasperbe508362016-03-11 22:13:28 +00007782 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
7783 b6 = b0 + 6, b7 = b0 + 7;
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007784 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007785 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
7786 b2, b3, b4, b5, b6, b7));
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007787}
Daniel Jasperbe508362016-03-11 22:13:28 +00007788static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007789vec_splat(vector unsigned long long __a, unsigned const int __b) {
7790 unsigned char b0 = (__b & 0x01) * 8;
Daniel Jasperbe508362016-03-11 22:13:28 +00007791 unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5,
7792 b6 = b0 + 6, b7 = b0 + 7;
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007793 return vec_perm(__a, __a,
Daniel Jasperbe508362016-03-11 22:13:28 +00007794 (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1,
7795 b2, b3, b4, b5, b6, b7));
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007796}
7797#endif
7798
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007799/* vec_vspltb */
7800
7801#define __builtin_altivec_vspltb vec_vspltb
7802
Daniel Jasperbe508362016-03-11 22:13:28 +00007803static __inline__ vector signed char __ATTRS_o_ai
7804vec_vspltb(vector signed char __a, unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007805 return vec_perm(__a, __a, (vector unsigned char)(__b));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007806}
7807
Daniel Jasperbe508362016-03-11 22:13:28 +00007808static __inline__ vector unsigned char __ATTRS_o_ai
7809vec_vspltb(vector unsigned char __a, unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007810 return vec_perm(__a, __a, (vector unsigned char)(__b));
Anton Yartsev9e968982010-08-19 03:00:09 +00007811}
7812
Daniel Jasperbe508362016-03-11 22:13:28 +00007813static __inline__ vector bool char __ATTRS_o_ai vec_vspltb(vector bool char __a,
7814 unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007815 return vec_perm(__a, __a, (vector unsigned char)(__b));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007816}
7817
7818/* vec_vsplth */
7819
7820#define __builtin_altivec_vsplth vec_vsplth
7821
Daniel Jasperbe508362016-03-11 22:13:28 +00007822static __inline__ vector short __ATTRS_o_ai vec_vsplth(vector short __a,
7823 unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007824 __b *= 2;
Bill Seurer703e8482015-06-09 14:39:47 +00007825 unsigned char b1 = __b + 1;
7826 return vec_perm(__a, __a,
7827 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
7828 __b, b1, __b, b1, __b, b1, __b, b1));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007829}
7830
Daniel Jasperbe508362016-03-11 22:13:28 +00007831static __inline__ vector unsigned short __ATTRS_o_ai
7832vec_vsplth(vector unsigned short __a, unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007833 __b *= 2;
Bill Seurer703e8482015-06-09 14:39:47 +00007834 unsigned char b1 = __b + 1;
7835 return vec_perm(__a, __a,
7836 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
7837 __b, b1, __b, b1, __b, b1, __b, b1));
Anton Yartsev9e968982010-08-19 03:00:09 +00007838}
7839
Daniel Jasperbe508362016-03-11 22:13:28 +00007840static __inline__ vector bool short __ATTRS_o_ai
7841vec_vsplth(vector bool short __a, unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007842 __b *= 2;
Bill Seurer703e8482015-06-09 14:39:47 +00007843 unsigned char b1 = __b + 1;
7844 return vec_perm(__a, __a,
7845 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
7846 __b, b1, __b, b1, __b, b1, __b, b1));
Anton Yartsev9e968982010-08-19 03:00:09 +00007847}
7848
Daniel Jasperbe508362016-03-11 22:13:28 +00007849static __inline__ vector pixel __ATTRS_o_ai vec_vsplth(vector pixel __a,
7850 unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007851 __b *= 2;
Bill Seurer703e8482015-06-09 14:39:47 +00007852 unsigned char b1 = __b + 1;
7853 return vec_perm(__a, __a,
7854 (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1,
7855 __b, b1, __b, b1, __b, b1, __b, b1));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007856}
7857
7858/* vec_vspltw */
7859
7860#define __builtin_altivec_vspltw vec_vspltw
7861
Daniel Jasperbe508362016-03-11 22:13:28 +00007862static __inline__ vector int __ATTRS_o_ai vec_vspltw(vector int __a,
7863 unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007864 __b *= 4;
Bill Seurer703e8482015-06-09 14:39:47 +00007865 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
7866 return vec_perm(__a, __a,
7867 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
7868 b1, b2, b3, __b, b1, b2, b3));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007869}
7870
Daniel Jasperbe508362016-03-11 22:13:28 +00007871static __inline__ vector unsigned int __ATTRS_o_ai
7872vec_vspltw(vector unsigned int __a, unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007873 __b *= 4;
Bill Seurer703e8482015-06-09 14:39:47 +00007874 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
7875 return vec_perm(__a, __a,
7876 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
7877 b1, b2, b3, __b, b1, b2, b3));
Anton Yartsev9e968982010-08-19 03:00:09 +00007878}
7879
Daniel Jasperbe508362016-03-11 22:13:28 +00007880static __inline__ vector bool int __ATTRS_o_ai vec_vspltw(vector bool int __a,
7881 unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007882 __b *= 4;
Bill Seurer703e8482015-06-09 14:39:47 +00007883 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
7884 return vec_perm(__a, __a,
7885 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
7886 b1, b2, b3, __b, b1, b2, b3));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007887}
7888
Daniel Jasperbe508362016-03-11 22:13:28 +00007889static __inline__ vector float __ATTRS_o_ai vec_vspltw(vector float __a,
7890 unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007891 __b *= 4;
Bill Seurer703e8482015-06-09 14:39:47 +00007892 unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3;
7893 return vec_perm(__a, __a,
7894 (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b,
7895 b1, b2, b3, __b, b1, b2, b3));
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007896}
7897
7898/* vec_splat_s8 */
7899
7900#define __builtin_altivec_vspltisb vec_splat_s8
7901
7902// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007903static __inline__ vector signed char __ATTRS_o_ai
7904vec_splat_s8(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007905 return (vector signed char)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007906}
7907
7908/* vec_vspltisb */
7909
7910// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007911static __inline__ vector signed char __ATTRS_o_ai
7912vec_vspltisb(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007913 return (vector signed char)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007914}
7915
7916/* vec_splat_s16 */
7917
7918#define __builtin_altivec_vspltish vec_splat_s16
7919
7920// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007921static __inline__ vector short __ATTRS_o_ai vec_splat_s16(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007922 return (vector short)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007923}
7924
7925/* vec_vspltish */
7926
7927// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007928static __inline__ vector short __ATTRS_o_ai vec_vspltish(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007929 return (vector short)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007930}
7931
7932/* vec_splat_s32 */
7933
7934#define __builtin_altivec_vspltisw vec_splat_s32
7935
7936// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007937static __inline__ vector int __ATTRS_o_ai vec_splat_s32(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007938 return (vector int)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007939}
7940
7941/* vec_vspltisw */
7942
7943// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007944static __inline__ vector int __ATTRS_o_ai vec_vspltisw(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007945 return (vector int)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007946}
7947
7948/* vec_splat_u8 */
7949
7950// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007951static __inline__ vector unsigned char __ATTRS_o_ai
7952vec_splat_u8(unsigned char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007953 return (vector unsigned char)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007954}
7955
7956/* vec_splat_u16 */
7957
7958// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007959static __inline__ vector unsigned short __ATTRS_o_ai
7960vec_splat_u16(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007961 return (vector unsigned short)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007962}
7963
7964/* vec_splat_u32 */
7965
7966// FIXME: parameter should be treated as 5-bit signed literal
Daniel Jasperbe508362016-03-11 22:13:28 +00007967static __inline__ vector unsigned int __ATTRS_o_ai
7968vec_splat_u32(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007969 return (vector unsigned int)(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007970}
7971
7972/* vec_sr */
7973
Daniel Jasperbe508362016-03-11 22:13:28 +00007974static __inline__ vector signed char __ATTRS_o_ai
7975vec_sr(vector signed char __a, vector unsigned char __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007976 vector unsigned char __res = (vector unsigned char)__a >> __b;
7977 return (vector signed char)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007978}
7979
Daniel Jasperbe508362016-03-11 22:13:28 +00007980static __inline__ vector unsigned char __ATTRS_o_ai
7981vec_sr(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007982 return __a >> __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007983}
7984
Daniel Jasperbe508362016-03-11 22:13:28 +00007985static __inline__ vector signed short __ATTRS_o_ai
7986vec_sr(vector signed short __a, vector unsigned short __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007987 vector unsigned short __res = (vector unsigned short)__a >> __b;
7988 return (vector signed short)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007989}
7990
Daniel Jasperbe508362016-03-11 22:13:28 +00007991static __inline__ vector unsigned short __ATTRS_o_ai
7992vec_sr(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00007993 return __a >> __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00007994}
7995
Daniel Jasperbe508362016-03-11 22:13:28 +00007996static __inline__ vector signed int __ATTRS_o_ai
7997vec_sr(vector signed int __a, vector unsigned int __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00007998 vector unsigned int __res = (vector unsigned int)__a >> __b;
7999 return (vector signed int)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008000}
8001
Daniel Jasperbe508362016-03-11 22:13:28 +00008002static __inline__ vector unsigned int __ATTRS_o_ai
8003vec_sr(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008004 return __a >> __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008005}
8006
Kit Barton8553bec2015-03-11 15:57:19 +00008007#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00008008static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00008009vec_sr(vector signed long long __a, vector unsigned long long __b) {
Nemanja Ivanovic26c35342015-07-10 13:11:34 +00008010 vector unsigned long long __res = (vector unsigned long long)__a >> __b;
8011 return (vector signed long long)__res;
Kit Barton8553bec2015-03-11 15:57:19 +00008012}
8013
Daniel Jasperbe508362016-03-11 22:13:28 +00008014static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00008015vec_sr(vector unsigned long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00008016 return __a >> __b;
8017}
8018#endif
8019
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008020/* vec_vsrb */
8021
8022#define __builtin_altivec_vsrb vec_vsrb
8023
Daniel Jasperbe508362016-03-11 22:13:28 +00008024static __inline__ vector signed char __ATTRS_o_ai
8025vec_vsrb(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008026 return __a >> (vector signed char)__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008027}
8028
Daniel Jasperbe508362016-03-11 22:13:28 +00008029static __inline__ vector unsigned char __ATTRS_o_ai
8030vec_vsrb(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008031 return __a >> __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008032}
8033
8034/* vec_vsrh */
8035
8036#define __builtin_altivec_vsrh vec_vsrh
8037
Daniel Jasperbe508362016-03-11 22:13:28 +00008038static __inline__ vector short __ATTRS_o_ai
8039vec_vsrh(vector short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008040 return __a >> (vector short)__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008041}
8042
Daniel Jasperbe508362016-03-11 22:13:28 +00008043static __inline__ vector unsigned short __ATTRS_o_ai
8044vec_vsrh(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008045 return __a >> __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008046}
8047
8048/* vec_vsrw */
8049
8050#define __builtin_altivec_vsrw vec_vsrw
8051
Daniel Jasperbe508362016-03-11 22:13:28 +00008052static __inline__ vector int __ATTRS_o_ai vec_vsrw(vector int __a,
8053 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008054 return __a >> (vector int)__b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008055}
8056
Daniel Jasperbe508362016-03-11 22:13:28 +00008057static __inline__ vector unsigned int __ATTRS_o_ai
8058vec_vsrw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008059 return __a >> __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008060}
8061
8062/* vec_sra */
8063
Daniel Jasperbe508362016-03-11 22:13:28 +00008064static __inline__ vector signed char __ATTRS_o_ai
8065vec_sra(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008066 return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008067}
8068
Daniel Jasperbe508362016-03-11 22:13:28 +00008069static __inline__ vector unsigned char __ATTRS_o_ai
8070vec_sra(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008071 return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008072}
8073
Daniel Jasperbe508362016-03-11 22:13:28 +00008074static __inline__ vector short __ATTRS_o_ai vec_sra(vector short __a,
8075 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008076 return __builtin_altivec_vsrah(__a, (vector unsigned short)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008077}
8078
Daniel Jasperbe508362016-03-11 22:13:28 +00008079static __inline__ vector unsigned short __ATTRS_o_ai
8080vec_sra(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008081 return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008082}
8083
Daniel Jasperbe508362016-03-11 22:13:28 +00008084static __inline__ vector int __ATTRS_o_ai vec_sra(vector int __a,
8085 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008086 return __builtin_altivec_vsraw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008087}
8088
Daniel Jasperbe508362016-03-11 22:13:28 +00008089static __inline__ vector unsigned int __ATTRS_o_ai
8090vec_sra(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008091 return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008092}
8093
Kit Barton8553bec2015-03-11 15:57:19 +00008094#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +00008095static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00008096vec_sra(vector signed long long __a, vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +00008097 return __a >> __b;
8098}
8099
Daniel Jasperbe508362016-03-11 22:13:28 +00008100static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00008101vec_sra(vector unsigned long long __a, vector unsigned long long __b) {
8102 return (vector unsigned long long)((vector signed long long)__a >> __b);
Kit Barton8553bec2015-03-11 15:57:19 +00008103}
8104#endif
8105
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008106/* vec_vsrab */
8107
Daniel Jasperbe508362016-03-11 22:13:28 +00008108static __inline__ vector signed char __ATTRS_o_ai
8109vec_vsrab(vector signed char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008110 return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008111}
8112
Daniel Jasperbe508362016-03-11 22:13:28 +00008113static __inline__ vector unsigned char __ATTRS_o_ai
8114vec_vsrab(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008115 return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008116}
8117
8118/* vec_vsrah */
8119
Daniel Jasperbe508362016-03-11 22:13:28 +00008120static __inline__ vector short __ATTRS_o_ai
8121vec_vsrah(vector short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008122 return __builtin_altivec_vsrah(__a, (vector unsigned short)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008123}
8124
Daniel Jasperbe508362016-03-11 22:13:28 +00008125static __inline__ vector unsigned short __ATTRS_o_ai
8126vec_vsrah(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008127 return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008128}
8129
8130/* vec_vsraw */
8131
Daniel Jasperbe508362016-03-11 22:13:28 +00008132static __inline__ vector int __ATTRS_o_ai vec_vsraw(vector int __a,
8133 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008134 return __builtin_altivec_vsraw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008135}
8136
Daniel Jasperbe508362016-03-11 22:13:28 +00008137static __inline__ vector unsigned int __ATTRS_o_ai
8138vec_vsraw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008139 return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008140}
8141
8142/* vec_srl */
8143
Daniel Jasperbe508362016-03-11 22:13:28 +00008144static __inline__ vector signed char __ATTRS_o_ai
8145vec_srl(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008146 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
8147 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008148}
8149
Daniel Jasperbe508362016-03-11 22:13:28 +00008150static __inline__ vector signed char __ATTRS_o_ai
8151vec_srl(vector signed char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008152 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
8153 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008154}
8155
Daniel Jasperbe508362016-03-11 22:13:28 +00008156static __inline__ vector signed char __ATTRS_o_ai
8157vec_srl(vector signed char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008158 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
8159 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008160}
8161
Daniel Jasperbe508362016-03-11 22:13:28 +00008162static __inline__ vector unsigned char __ATTRS_o_ai
8163vec_srl(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008164 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
8165 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008166}
8167
Daniel Jasperbe508362016-03-11 22:13:28 +00008168static __inline__ vector unsigned char __ATTRS_o_ai
8169vec_srl(vector unsigned char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008170 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
8171 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008172}
8173
Daniel Jasperbe508362016-03-11 22:13:28 +00008174static __inline__ vector unsigned char __ATTRS_o_ai
8175vec_srl(vector unsigned char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008176 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
8177 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008178}
8179
Daniel Jasperbe508362016-03-11 22:13:28 +00008180static __inline__ vector bool char __ATTRS_o_ai
8181vec_srl(vector bool char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008182 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
8183 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008184}
8185
Daniel Jasperbe508362016-03-11 22:13:28 +00008186static __inline__ vector bool char __ATTRS_o_ai
8187vec_srl(vector bool char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008188 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
8189 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008190}
8191
Daniel Jasperbe508362016-03-11 22:13:28 +00008192static __inline__ vector bool char __ATTRS_o_ai
8193vec_srl(vector bool char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008194 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
8195 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008196}
8197
Daniel Jasperbe508362016-03-11 22:13:28 +00008198static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
8199 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008200 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008201}
8202
Daniel Jasperbe508362016-03-11 22:13:28 +00008203static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
8204 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008205 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008206}
8207
Daniel Jasperbe508362016-03-11 22:13:28 +00008208static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a,
8209 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008210 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008211}
8212
Daniel Jasperbe508362016-03-11 22:13:28 +00008213static __inline__ vector unsigned short __ATTRS_o_ai
8214vec_srl(vector unsigned short __a, vector unsigned char __b) {
8215 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
8216 (vector int)__b);
8217}
8218
8219static __inline__ vector unsigned short __ATTRS_o_ai
8220vec_srl(vector unsigned short __a, vector unsigned short __b) {
8221 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
8222 (vector int)__b);
8223}
8224
8225static __inline__ vector unsigned short __ATTRS_o_ai
8226vec_srl(vector unsigned short __a, vector unsigned int __b) {
8227 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
8228 (vector int)__b);
8229}
8230
8231static __inline__ vector bool short __ATTRS_o_ai
8232vec_srl(vector bool short __a, vector unsigned char __b) {
8233 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
8234 (vector int)__b);
8235}
8236
8237static __inline__ vector bool short __ATTRS_o_ai
8238vec_srl(vector bool short __a, vector unsigned short __b) {
8239 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
8240 (vector int)__b);
8241}
8242
8243static __inline__ vector bool short __ATTRS_o_ai
8244vec_srl(vector bool short __a, vector unsigned int __b) {
8245 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
8246 (vector int)__b);
8247}
8248
8249static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
8250 vector unsigned char __b) {
8251 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
8252}
8253
8254static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
8255 vector unsigned short __b) {
8256 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
8257}
8258
8259static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a,
8260 vector unsigned int __b) {
8261 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
8262}
8263
8264static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008265 vector unsigned char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00008266 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008267}
8268
Daniel Jasperbe508362016-03-11 22:13:28 +00008269static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008270 vector unsigned short __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00008271 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008272}
8273
Daniel Jasperbe508362016-03-11 22:13:28 +00008274static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008275 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008276 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008277}
8278
Daniel Jasperbe508362016-03-11 22:13:28 +00008279static __inline__ vector unsigned int __ATTRS_o_ai
8280vec_srl(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008281 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
8282 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008283}
8284
Daniel Jasperbe508362016-03-11 22:13:28 +00008285static __inline__ vector unsigned int __ATTRS_o_ai
8286vec_srl(vector unsigned int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008287 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
8288 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008289}
8290
Daniel Jasperbe508362016-03-11 22:13:28 +00008291static __inline__ vector unsigned int __ATTRS_o_ai
8292vec_srl(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008293 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
8294 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008295}
8296
Daniel Jasperbe508362016-03-11 22:13:28 +00008297static __inline__ vector bool int __ATTRS_o_ai
8298vec_srl(vector bool int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008299 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
8300 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008301}
8302
Daniel Jasperbe508362016-03-11 22:13:28 +00008303static __inline__ vector bool int __ATTRS_o_ai
8304vec_srl(vector bool int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008305 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
8306 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008307}
8308
Daniel Jasperbe508362016-03-11 22:13:28 +00008309static __inline__ vector bool int __ATTRS_o_ai
8310vec_srl(vector bool int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008311 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
8312 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008313}
8314
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008315/* vec_vsr */
8316
Daniel Jasperbe508362016-03-11 22:13:28 +00008317static __inline__ vector signed char __ATTRS_o_ai
8318vec_vsr(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008319 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
8320 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008321}
8322
Daniel Jasperbe508362016-03-11 22:13:28 +00008323static __inline__ vector signed char __ATTRS_o_ai
8324vec_vsr(vector signed char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008325 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
8326 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008327}
8328
Daniel Jasperbe508362016-03-11 22:13:28 +00008329static __inline__ vector signed char __ATTRS_o_ai
8330vec_vsr(vector signed char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008331 return (vector signed char)__builtin_altivec_vsr((vector int)__a,
8332 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008333}
8334
Daniel Jasperbe508362016-03-11 22:13:28 +00008335static __inline__ vector unsigned char __ATTRS_o_ai
8336vec_vsr(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008337 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
8338 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008339}
8340
Daniel Jasperbe508362016-03-11 22:13:28 +00008341static __inline__ vector unsigned char __ATTRS_o_ai
8342vec_vsr(vector unsigned char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008343 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
8344 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008345}
8346
Daniel Jasperbe508362016-03-11 22:13:28 +00008347static __inline__ vector unsigned char __ATTRS_o_ai
8348vec_vsr(vector unsigned char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008349 return (vector unsigned char)__builtin_altivec_vsr((vector int)__a,
8350 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008351}
8352
Daniel Jasperbe508362016-03-11 22:13:28 +00008353static __inline__ vector bool char __ATTRS_o_ai
8354vec_vsr(vector bool char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008355 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
8356 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008357}
8358
Daniel Jasperbe508362016-03-11 22:13:28 +00008359static __inline__ vector bool char __ATTRS_o_ai
8360vec_vsr(vector bool char __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008361 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
8362 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008363}
8364
Daniel Jasperbe508362016-03-11 22:13:28 +00008365static __inline__ vector bool char __ATTRS_o_ai
8366vec_vsr(vector bool char __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008367 return (vector bool char)__builtin_altivec_vsr((vector int)__a,
8368 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008369}
8370
Daniel Jasperbe508362016-03-11 22:13:28 +00008371static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
8372 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008373 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008374}
8375
Daniel Jasperbe508362016-03-11 22:13:28 +00008376static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
8377 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008378 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008379}
8380
Daniel Jasperbe508362016-03-11 22:13:28 +00008381static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a,
8382 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008383 return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008384}
8385
Daniel Jasperbe508362016-03-11 22:13:28 +00008386static __inline__ vector unsigned short __ATTRS_o_ai
8387vec_vsr(vector unsigned short __a, vector unsigned char __b) {
8388 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
8389 (vector int)__b);
8390}
8391
8392static __inline__ vector unsigned short __ATTRS_o_ai
8393vec_vsr(vector unsigned short __a, vector unsigned short __b) {
8394 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
8395 (vector int)__b);
8396}
8397
8398static __inline__ vector unsigned short __ATTRS_o_ai
8399vec_vsr(vector unsigned short __a, vector unsigned int __b) {
8400 return (vector unsigned short)__builtin_altivec_vsr((vector int)__a,
8401 (vector int)__b);
8402}
8403
8404static __inline__ vector bool short __ATTRS_o_ai
8405vec_vsr(vector bool short __a, vector unsigned char __b) {
8406 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
8407 (vector int)__b);
8408}
8409
8410static __inline__ vector bool short __ATTRS_o_ai
8411vec_vsr(vector bool short __a, vector unsigned short __b) {
8412 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
8413 (vector int)__b);
8414}
8415
8416static __inline__ vector bool short __ATTRS_o_ai
8417vec_vsr(vector bool short __a, vector unsigned int __b) {
8418 return (vector bool short)__builtin_altivec_vsr((vector int)__a,
8419 (vector int)__b);
8420}
8421
8422static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
8423 vector unsigned char __b) {
8424 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
8425}
8426
8427static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
8428 vector unsigned short __b) {
8429 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
8430}
8431
8432static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a,
8433 vector unsigned int __b) {
8434 return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b);
8435}
8436
8437static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008438 vector unsigned char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00008439 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008440}
8441
Daniel Jasperbe508362016-03-11 22:13:28 +00008442static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008443 vector unsigned short __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00008444 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008445}
8446
Daniel Jasperbe508362016-03-11 22:13:28 +00008447static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008448 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008449 return (vector int)__builtin_altivec_vsr(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008450}
8451
Daniel Jasperbe508362016-03-11 22:13:28 +00008452static __inline__ vector unsigned int __ATTRS_o_ai
8453vec_vsr(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008454 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
8455 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008456}
8457
Daniel Jasperbe508362016-03-11 22:13:28 +00008458static __inline__ vector unsigned int __ATTRS_o_ai
8459vec_vsr(vector unsigned int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008460 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
8461 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008462}
8463
Daniel Jasperbe508362016-03-11 22:13:28 +00008464static __inline__ vector unsigned int __ATTRS_o_ai
8465vec_vsr(vector unsigned int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008466 return (vector unsigned int)__builtin_altivec_vsr((vector int)__a,
8467 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008468}
8469
Daniel Jasperbe508362016-03-11 22:13:28 +00008470static __inline__ vector bool int __ATTRS_o_ai
8471vec_vsr(vector bool int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008472 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
8473 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008474}
8475
Daniel Jasperbe508362016-03-11 22:13:28 +00008476static __inline__ vector bool int __ATTRS_o_ai
8477vec_vsr(vector bool int __a, vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008478 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
8479 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008480}
8481
Daniel Jasperbe508362016-03-11 22:13:28 +00008482static __inline__ vector bool int __ATTRS_o_ai
8483vec_vsr(vector bool int __a, vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008484 return (vector bool int)__builtin_altivec_vsr((vector int)__a,
8485 (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008486}
8487
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008488/* vec_sro */
8489
Daniel Jasperbe508362016-03-11 22:13:28 +00008490static __inline__ vector signed char __ATTRS_o_ai
8491vec_sro(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008492 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
8493 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008494}
8495
Daniel Jasperbe508362016-03-11 22:13:28 +00008496static __inline__ vector signed char __ATTRS_o_ai
8497vec_sro(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008498 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
8499 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008500}
8501
Daniel Jasperbe508362016-03-11 22:13:28 +00008502static __inline__ vector unsigned char __ATTRS_o_ai
8503vec_sro(vector unsigned char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008504 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
8505 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008506}
8507
Daniel Jasperbe508362016-03-11 22:13:28 +00008508static __inline__ vector unsigned char __ATTRS_o_ai
8509vec_sro(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008510 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
8511 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008512}
8513
Daniel Jasperbe508362016-03-11 22:13:28 +00008514static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a,
8515 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008516 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008517}
8518
Daniel Jasperbe508362016-03-11 22:13:28 +00008519static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a,
8520 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008521 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008522}
8523
Daniel Jasperbe508362016-03-11 22:13:28 +00008524static __inline__ vector unsigned short __ATTRS_o_ai
8525vec_sro(vector unsigned short __a, vector signed char __b) {
8526 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
8527 (vector int)__b);
8528}
8529
8530static __inline__ vector unsigned short __ATTRS_o_ai
8531vec_sro(vector unsigned short __a, vector unsigned char __b) {
8532 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
8533 (vector int)__b);
8534}
8535
8536static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a,
8537 vector signed char __b) {
8538 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
8539}
8540
8541static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a,
8542 vector unsigned char __b) {
8543 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
8544}
8545
8546static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008547 vector signed char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00008548 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008549}
8550
Daniel Jasperbe508362016-03-11 22:13:28 +00008551static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008552 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008553 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008554}
8555
Daniel Jasperbe508362016-03-11 22:13:28 +00008556static __inline__ vector unsigned int __ATTRS_o_ai
8557vec_sro(vector unsigned int __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008558 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
8559 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008560}
8561
Daniel Jasperbe508362016-03-11 22:13:28 +00008562static __inline__ vector unsigned int __ATTRS_o_ai
8563vec_sro(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008564 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
8565 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008566}
8567
Daniel Jasperbe508362016-03-11 22:13:28 +00008568static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a,
8569 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008570 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008571}
8572
Daniel Jasperbe508362016-03-11 22:13:28 +00008573static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a,
8574 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008575 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008576}
8577
8578/* vec_vsro */
8579
Daniel Jasperbe508362016-03-11 22:13:28 +00008580static __inline__ vector signed char __ATTRS_o_ai
8581vec_vsro(vector signed char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008582 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
8583 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008584}
8585
Daniel Jasperbe508362016-03-11 22:13:28 +00008586static __inline__ vector signed char __ATTRS_o_ai
8587vec_vsro(vector signed char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008588 return (vector signed char)__builtin_altivec_vsro((vector int)__a,
8589 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008590}
8591
Daniel Jasperbe508362016-03-11 22:13:28 +00008592static __inline__ vector unsigned char __ATTRS_o_ai
8593vec_vsro(vector unsigned char __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008594 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
8595 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008596}
8597
Daniel Jasperbe508362016-03-11 22:13:28 +00008598static __inline__ vector unsigned char __ATTRS_o_ai
8599vec_vsro(vector unsigned char __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008600 return (vector unsigned char)__builtin_altivec_vsro((vector int)__a,
8601 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008602}
8603
Daniel Jasperbe508362016-03-11 22:13:28 +00008604static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a,
8605 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008606 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008607}
8608
Daniel Jasperbe508362016-03-11 22:13:28 +00008609static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a,
8610 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008611 return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008612}
8613
Daniel Jasperbe508362016-03-11 22:13:28 +00008614static __inline__ vector unsigned short __ATTRS_o_ai
8615vec_vsro(vector unsigned short __a, vector signed char __b) {
8616 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
8617 (vector int)__b);
8618}
8619
8620static __inline__ vector unsigned short __ATTRS_o_ai
8621vec_vsro(vector unsigned short __a, vector unsigned char __b) {
8622 return (vector unsigned short)__builtin_altivec_vsro((vector int)__a,
8623 (vector int)__b);
8624}
8625
8626static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a,
8627 vector signed char __b) {
8628 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
8629}
8630
8631static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a,
8632 vector unsigned char __b) {
8633 return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
8634}
8635
8636static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008637 vector signed char __b) {
Daniel Jasperbe508362016-03-11 22:13:28 +00008638 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008639}
8640
Daniel Jasperbe508362016-03-11 22:13:28 +00008641static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a,
Bill Seurer703e8482015-06-09 14:39:47 +00008642 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008643 return (vector int)__builtin_altivec_vsro(__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008644}
8645
Daniel Jasperbe508362016-03-11 22:13:28 +00008646static __inline__ vector unsigned int __ATTRS_o_ai
8647vec_vsro(vector unsigned int __a, vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008648 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
8649 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008650}
8651
Daniel Jasperbe508362016-03-11 22:13:28 +00008652static __inline__ vector unsigned int __ATTRS_o_ai
8653vec_vsro(vector unsigned int __a, vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +00008654 return (vector unsigned int)__builtin_altivec_vsro((vector int)__a,
8655 (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008656}
8657
Daniel Jasperbe508362016-03-11 22:13:28 +00008658static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a,
8659 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008660 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008661}
8662
Daniel Jasperbe508362016-03-11 22:13:28 +00008663static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a,
8664 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008665 return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008666}
8667
8668/* vec_st */
8669
Daniel Jasperbe508362016-03-11 22:13:28 +00008670static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, int __b,
8671 vector signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008672 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008673}
8674
Daniel Jasperbe508362016-03-11 22:13:28 +00008675static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, int __b,
8676 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008677 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008678}
8679
Daniel Jasperbe508362016-03-11 22:13:28 +00008680static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, int __b,
8681 vector unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008682 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008683}
8684
Daniel Jasperbe508362016-03-11 22:13:28 +00008685static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, int __b,
8686 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008687 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008688}
8689
Daniel Jasperbe508362016-03-11 22:13:28 +00008690static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, int __b,
8691 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008692 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008693}
8694
Daniel Jasperbe508362016-03-11 22:13:28 +00008695static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, int __b,
8696 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008697 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008698}
8699
Daniel Jasperbe508362016-03-11 22:13:28 +00008700static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, int __b,
8701 vector bool char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008702 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008703}
8704
Daniel Jasperbe508362016-03-11 22:13:28 +00008705static __inline__ void __ATTRS_o_ai vec_st(vector short __a, int __b,
8706 vector short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008707 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008708}
8709
Daniel Jasperbe508362016-03-11 22:13:28 +00008710static __inline__ void __ATTRS_o_ai vec_st(vector short __a, int __b,
8711 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008712 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008713}
8714
Daniel Jasperbe508362016-03-11 22:13:28 +00008715static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, int __b,
8716 vector unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008717 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008718}
8719
Daniel Jasperbe508362016-03-11 22:13:28 +00008720static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, int __b,
8721 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008722 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008723}
8724
Daniel Jasperbe508362016-03-11 22:13:28 +00008725static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, int __b,
8726 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008727 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008728}
8729
Daniel Jasperbe508362016-03-11 22:13:28 +00008730static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, int __b,
8731 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008732 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008733}
8734
Daniel Jasperbe508362016-03-11 22:13:28 +00008735static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, int __b,
8736 vector bool short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008737 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008738}
8739
Daniel Jasperbe508362016-03-11 22:13:28 +00008740static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, int __b,
8741 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008742 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008743}
8744
Daniel Jasperbe508362016-03-11 22:13:28 +00008745static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, int __b,
8746 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008747 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008748}
8749
Daniel Jasperbe508362016-03-11 22:13:28 +00008750static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, int __b,
8751 vector pixel *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008752 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008753}
8754
Daniel Jasperbe508362016-03-11 22:13:28 +00008755static __inline__ void __ATTRS_o_ai vec_st(vector int __a, int __b,
8756 vector int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008757 __builtin_altivec_stvx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008758}
8759
Daniel Jasperbe508362016-03-11 22:13:28 +00008760static __inline__ void __ATTRS_o_ai vec_st(vector int __a, int __b, int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008761 __builtin_altivec_stvx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008762}
8763
Daniel Jasperbe508362016-03-11 22:13:28 +00008764static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, int __b,
8765 vector unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008766 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008767}
8768
Daniel Jasperbe508362016-03-11 22:13:28 +00008769static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, int __b,
8770 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008771 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008772}
8773
Daniel Jasperbe508362016-03-11 22:13:28 +00008774static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, int __b,
8775 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008776 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008777}
8778
Daniel Jasperbe508362016-03-11 22:13:28 +00008779static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, int __b,
8780 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008781 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008782}
8783
Daniel Jasperbe508362016-03-11 22:13:28 +00008784static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, int __b,
8785 vector bool int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008786 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008787}
8788
Daniel Jasperbe508362016-03-11 22:13:28 +00008789static __inline__ void __ATTRS_o_ai vec_st(vector float __a, int __b,
8790 vector float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008791 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008792}
8793
Daniel Jasperbe508362016-03-11 22:13:28 +00008794static __inline__ void __ATTRS_o_ai vec_st(vector float __a, int __b,
8795 float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008796 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008797}
8798
8799/* vec_stvx */
8800
Daniel Jasperbe508362016-03-11 22:13:28 +00008801static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, int __b,
8802 vector signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008803 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008804}
8805
Daniel Jasperbe508362016-03-11 22:13:28 +00008806static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, int __b,
8807 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008808 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008809}
8810
Daniel Jasperbe508362016-03-11 22:13:28 +00008811static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, int __b,
8812 vector unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008813 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008814}
8815
Daniel Jasperbe508362016-03-11 22:13:28 +00008816static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, int __b,
8817 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008818 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008819}
8820
Daniel Jasperbe508362016-03-11 22:13:28 +00008821static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, int __b,
8822 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008823 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008824}
8825
Daniel Jasperbe508362016-03-11 22:13:28 +00008826static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, int __b,
8827 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008828 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008829}
8830
Daniel Jasperbe508362016-03-11 22:13:28 +00008831static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, int __b,
8832 vector bool char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008833 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008834}
8835
Daniel Jasperbe508362016-03-11 22:13:28 +00008836static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, int __b,
8837 vector short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008838 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008839}
8840
Daniel Jasperbe508362016-03-11 22:13:28 +00008841static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, int __b,
8842 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008843 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008844}
8845
Daniel Jasperbe508362016-03-11 22:13:28 +00008846static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, int __b,
8847 vector unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008848 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008849}
8850
Daniel Jasperbe508362016-03-11 22:13:28 +00008851static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, int __b,
8852 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008853 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008854}
8855
Daniel Jasperbe508362016-03-11 22:13:28 +00008856static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, int __b,
8857 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008858 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008859}
8860
Daniel Jasperbe508362016-03-11 22:13:28 +00008861static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, int __b,
8862 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008863 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008864}
8865
Daniel Jasperbe508362016-03-11 22:13:28 +00008866static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, int __b,
8867 vector bool short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008868 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008869}
8870
Daniel Jasperbe508362016-03-11 22:13:28 +00008871static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, int __b,
8872 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008873 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008874}
8875
Daniel Jasperbe508362016-03-11 22:13:28 +00008876static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, int __b,
8877 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008878 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008879}
8880
Daniel Jasperbe508362016-03-11 22:13:28 +00008881static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, int __b,
8882 vector pixel *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008883 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008884}
8885
Daniel Jasperbe508362016-03-11 22:13:28 +00008886static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, int __b,
8887 vector int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008888 __builtin_altivec_stvx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008889}
8890
Daniel Jasperbe508362016-03-11 22:13:28 +00008891static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, int __b,
8892 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008893 __builtin_altivec_stvx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008894}
8895
Daniel Jasperbe508362016-03-11 22:13:28 +00008896static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, int __b,
8897 vector unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008898 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008899}
8900
Daniel Jasperbe508362016-03-11 22:13:28 +00008901static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, int __b,
8902 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008903 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008904}
8905
Daniel Jasperbe508362016-03-11 22:13:28 +00008906static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, int __b,
8907 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008908 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008909}
8910
Daniel Jasperbe508362016-03-11 22:13:28 +00008911static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, int __b,
8912 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008913 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008914}
8915
Daniel Jasperbe508362016-03-11 22:13:28 +00008916static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, int __b,
8917 vector bool int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008918 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008919}
8920
Daniel Jasperbe508362016-03-11 22:13:28 +00008921static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, int __b,
8922 vector float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008923 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008924}
8925
Daniel Jasperbe508362016-03-11 22:13:28 +00008926static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, int __b,
8927 float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008928 __builtin_altivec_stvx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008929}
8930
8931/* vec_ste */
8932
Daniel Jasperbe508362016-03-11 22:13:28 +00008933static __inline__ void __ATTRS_o_ai vec_ste(vector signed char __a, int __b,
8934 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008935 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008936}
8937
Daniel Jasperbe508362016-03-11 22:13:28 +00008938static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned char __a, int __b,
8939 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008940 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008941}
8942
Daniel Jasperbe508362016-03-11 22:13:28 +00008943static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, int __b,
8944 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008945 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008946}
8947
Daniel Jasperbe508362016-03-11 22:13:28 +00008948static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, int __b,
8949 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008950 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008951}
8952
Daniel Jasperbe508362016-03-11 22:13:28 +00008953static __inline__ void __ATTRS_o_ai vec_ste(vector short __a, int __b,
8954 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008955 __builtin_altivec_stvehx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008956}
8957
Daniel Jasperbe508362016-03-11 22:13:28 +00008958static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned short __a, int __b,
8959 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008960 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008961}
8962
Daniel Jasperbe508362016-03-11 22:13:28 +00008963static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, int __b,
8964 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008965 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008966}
8967
Daniel Jasperbe508362016-03-11 22:13:28 +00008968static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, int __b,
8969 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008970 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008971}
8972
Daniel Jasperbe508362016-03-11 22:13:28 +00008973static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, int __b,
8974 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008975 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008976}
8977
Daniel Jasperbe508362016-03-11 22:13:28 +00008978static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, int __b,
8979 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008980 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008981}
8982
Daniel Jasperbe508362016-03-11 22:13:28 +00008983static __inline__ void __ATTRS_o_ai vec_ste(vector int __a, int __b, int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008984 __builtin_altivec_stvewx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008985}
8986
Daniel Jasperbe508362016-03-11 22:13:28 +00008987static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned int __a, int __b,
8988 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008989 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00008990}
8991
Daniel Jasperbe508362016-03-11 22:13:28 +00008992static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, int __b,
8993 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008994 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00008995}
8996
Daniel Jasperbe508362016-03-11 22:13:28 +00008997static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, int __b,
8998 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00008999 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009000}
9001
Daniel Jasperbe508362016-03-11 22:13:28 +00009002static __inline__ void __ATTRS_o_ai vec_ste(vector float __a, int __b,
9003 float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009004 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009005}
9006
9007/* vec_stvebx */
9008
Daniel Jasperbe508362016-03-11 22:13:28 +00009009static __inline__ void __ATTRS_o_ai vec_stvebx(vector signed char __a, int __b,
9010 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009011 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009012}
9013
Daniel Jasperbe508362016-03-11 22:13:28 +00009014static __inline__ void __ATTRS_o_ai vec_stvebx(vector unsigned char __a,
9015 int __b, unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009016 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009017}
9018
Daniel Jasperbe508362016-03-11 22:13:28 +00009019static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, int __b,
9020 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009021 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009022}
9023
Daniel Jasperbe508362016-03-11 22:13:28 +00009024static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, int __b,
9025 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009026 __builtin_altivec_stvebx((vector char)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009027}
9028
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009029/* vec_stvehx */
9030
Daniel Jasperbe508362016-03-11 22:13:28 +00009031static __inline__ void __ATTRS_o_ai vec_stvehx(vector short __a, int __b,
9032 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009033 __builtin_altivec_stvehx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009034}
9035
Daniel Jasperbe508362016-03-11 22:13:28 +00009036static __inline__ void __ATTRS_o_ai vec_stvehx(vector unsigned short __a,
9037 int __b, unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009038 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009039}
9040
Daniel Jasperbe508362016-03-11 22:13:28 +00009041static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, int __b,
9042 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009043 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009044}
9045
Daniel Jasperbe508362016-03-11 22:13:28 +00009046static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, int __b,
9047 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009048 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009049}
9050
Daniel Jasperbe508362016-03-11 22:13:28 +00009051static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, int __b,
9052 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009053 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009054}
9055
Daniel Jasperbe508362016-03-11 22:13:28 +00009056static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, int __b,
9057 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009058 __builtin_altivec_stvehx((vector short)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009059}
9060
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009061/* vec_stvewx */
9062
Daniel Jasperbe508362016-03-11 22:13:28 +00009063static __inline__ void __ATTRS_o_ai vec_stvewx(vector int __a, int __b,
9064 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009065 __builtin_altivec_stvewx(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009066}
9067
Daniel Jasperbe508362016-03-11 22:13:28 +00009068static __inline__ void __ATTRS_o_ai vec_stvewx(vector unsigned int __a, int __b,
9069 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009070 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009071}
9072
Daniel Jasperbe508362016-03-11 22:13:28 +00009073static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, int __b,
9074 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009075 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009076}
9077
Daniel Jasperbe508362016-03-11 22:13:28 +00009078static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, int __b,
9079 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009080 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009081}
9082
Daniel Jasperbe508362016-03-11 22:13:28 +00009083static __inline__ void __ATTRS_o_ai vec_stvewx(vector float __a, int __b,
9084 float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009085 __builtin_altivec_stvewx((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009086}
9087
9088/* vec_stl */
9089
Daniel Jasperbe508362016-03-11 22:13:28 +00009090static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b,
9091 vector signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009092 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009093}
9094
Daniel Jasperbe508362016-03-11 22:13:28 +00009095static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b,
9096 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009097 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009098}
9099
Daniel Jasperbe508362016-03-11 22:13:28 +00009100static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b,
9101 vector unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009102 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009103}
9104
Daniel Jasperbe508362016-03-11 22:13:28 +00009105static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b,
9106 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009107 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009108}
9109
Daniel Jasperbe508362016-03-11 22:13:28 +00009110static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
9111 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009112 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009113}
9114
Daniel Jasperbe508362016-03-11 22:13:28 +00009115static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
9116 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009117 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009118}
9119
Daniel Jasperbe508362016-03-11 22:13:28 +00009120static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b,
9121 vector bool char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009122 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009123}
9124
Daniel Jasperbe508362016-03-11 22:13:28 +00009125static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b,
9126 vector short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009127 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009128}
9129
Daniel Jasperbe508362016-03-11 22:13:28 +00009130static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b,
9131 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009132 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009133}
9134
Daniel Jasperbe508362016-03-11 22:13:28 +00009135static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b,
9136 vector unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009137 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009138}
9139
Daniel Jasperbe508362016-03-11 22:13:28 +00009140static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b,
9141 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009142 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009143}
9144
Daniel Jasperbe508362016-03-11 22:13:28 +00009145static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
9146 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009147 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009148}
9149
Daniel Jasperbe508362016-03-11 22:13:28 +00009150static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
9151 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009152 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009153}
9154
Daniel Jasperbe508362016-03-11 22:13:28 +00009155static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b,
9156 vector bool short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009157 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009158}
9159
Daniel Jasperbe508362016-03-11 22:13:28 +00009160static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
9161 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009162 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009163}
9164
Daniel Jasperbe508362016-03-11 22:13:28 +00009165static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
9166 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009167 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009168}
9169
Daniel Jasperbe508362016-03-11 22:13:28 +00009170static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b,
9171 vector pixel *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009172 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009173}
9174
Daniel Jasperbe508362016-03-11 22:13:28 +00009175static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b,
9176 vector int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009177 __builtin_altivec_stvxl(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009178}
9179
Daniel Jasperbe508362016-03-11 22:13:28 +00009180static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b, int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009181 __builtin_altivec_stvxl(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009182}
9183
Daniel Jasperbe508362016-03-11 22:13:28 +00009184static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b,
9185 vector unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009186 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009187}
9188
Daniel Jasperbe508362016-03-11 22:13:28 +00009189static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b,
9190 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009191 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009192}
9193
Daniel Jasperbe508362016-03-11 22:13:28 +00009194static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
9195 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009196 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009197}
9198
Daniel Jasperbe508362016-03-11 22:13:28 +00009199static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
9200 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009201 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009202}
9203
Daniel Jasperbe508362016-03-11 22:13:28 +00009204static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b,
9205 vector bool int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009206 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009207}
9208
Daniel Jasperbe508362016-03-11 22:13:28 +00009209static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b,
9210 vector float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009211 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009212}
9213
Daniel Jasperbe508362016-03-11 22:13:28 +00009214static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b,
9215 float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009216 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009217}
9218
9219/* vec_stvxl */
9220
Daniel Jasperbe508362016-03-11 22:13:28 +00009221static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b,
9222 vector signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009223 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009224}
9225
Daniel Jasperbe508362016-03-11 22:13:28 +00009226static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b,
9227 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009228 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009229}
9230
Daniel Jasperbe508362016-03-11 22:13:28 +00009231static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b,
9232 vector unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009233 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009234}
9235
Daniel Jasperbe508362016-03-11 22:13:28 +00009236static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b,
9237 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009238 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009239}
9240
Daniel Jasperbe508362016-03-11 22:13:28 +00009241static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
9242 signed char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009243 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009244}
9245
Daniel Jasperbe508362016-03-11 22:13:28 +00009246static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
9247 unsigned char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009248 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009249}
9250
Daniel Jasperbe508362016-03-11 22:13:28 +00009251static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b,
9252 vector bool char *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009253 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009254}
9255
Daniel Jasperbe508362016-03-11 22:13:28 +00009256static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b,
9257 vector short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009258 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009259}
9260
Daniel Jasperbe508362016-03-11 22:13:28 +00009261static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b,
9262 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009263 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009264}
9265
Daniel Jasperbe508362016-03-11 22:13:28 +00009266static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a,
9267 int __b,
9268 vector unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009269 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009270}
9271
Daniel Jasperbe508362016-03-11 22:13:28 +00009272static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a,
9273 int __b, unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009274 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009275}
9276
Daniel Jasperbe508362016-03-11 22:13:28 +00009277static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
9278 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009279 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009280}
9281
Daniel Jasperbe508362016-03-11 22:13:28 +00009282static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
9283 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009284 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009285}
9286
Daniel Jasperbe508362016-03-11 22:13:28 +00009287static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b,
9288 vector bool short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009289 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009290}
9291
Daniel Jasperbe508362016-03-11 22:13:28 +00009292static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
9293 short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009294 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009295}
9296
Daniel Jasperbe508362016-03-11 22:13:28 +00009297static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
9298 unsigned short *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009299 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009300}
9301
Daniel Jasperbe508362016-03-11 22:13:28 +00009302static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b,
9303 vector pixel *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009304 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009305}
9306
Daniel Jasperbe508362016-03-11 22:13:28 +00009307static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b,
9308 vector int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009309 __builtin_altivec_stvxl(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009310}
9311
Daniel Jasperbe508362016-03-11 22:13:28 +00009312static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b,
9313 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009314 __builtin_altivec_stvxl(__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009315}
9316
Daniel Jasperbe508362016-03-11 22:13:28 +00009317static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b,
9318 vector unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009319 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009320}
9321
Daniel Jasperbe508362016-03-11 22:13:28 +00009322static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b,
9323 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009324 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009325}
9326
Daniel Jasperbe508362016-03-11 22:13:28 +00009327static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
9328 int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009329 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009330}
9331
Daniel Jasperbe508362016-03-11 22:13:28 +00009332static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
9333 unsigned int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009334 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009335}
9336
Daniel Jasperbe508362016-03-11 22:13:28 +00009337static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b,
9338 vector bool int *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009339 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009340}
9341
Daniel Jasperbe508362016-03-11 22:13:28 +00009342static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b,
9343 vector float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009344 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009345}
9346
Daniel Jasperbe508362016-03-11 22:13:28 +00009347static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b,
9348 float *__c) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009349 __builtin_altivec_stvxl((vector int)__a, __b, __c);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009350}
9351
9352/* vec_sub */
9353
Daniel Jasperbe508362016-03-11 22:13:28 +00009354static __inline__ vector signed char __ATTRS_o_ai
9355vec_sub(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009356 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009357}
9358
Daniel Jasperbe508362016-03-11 22:13:28 +00009359static __inline__ vector signed char __ATTRS_o_ai
9360vec_sub(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009361 return (vector signed char)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009362}
9363
Daniel Jasperbe508362016-03-11 22:13:28 +00009364static __inline__ vector signed char __ATTRS_o_ai
9365vec_sub(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009366 return __a - (vector signed char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009367}
9368
Daniel Jasperbe508362016-03-11 22:13:28 +00009369static __inline__ vector unsigned char __ATTRS_o_ai
9370vec_sub(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009371 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009372}
9373
Daniel Jasperbe508362016-03-11 22:13:28 +00009374static __inline__ vector unsigned char __ATTRS_o_ai
9375vec_sub(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009376 return (vector unsigned char)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009377}
9378
Daniel Jasperbe508362016-03-11 22:13:28 +00009379static __inline__ vector unsigned char __ATTRS_o_ai
9380vec_sub(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009381 return __a - (vector unsigned char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009382}
9383
Daniel Jasperbe508362016-03-11 22:13:28 +00009384static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a,
9385 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009386 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009387}
9388
Daniel Jasperbe508362016-03-11 22:13:28 +00009389static __inline__ vector short __ATTRS_o_ai vec_sub(vector bool short __a,
9390 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009391 return (vector short)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009392}
9393
Daniel Jasperbe508362016-03-11 22:13:28 +00009394static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a,
9395 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009396 return __a - (vector short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009397}
9398
Daniel Jasperbe508362016-03-11 22:13:28 +00009399static __inline__ vector unsigned short __ATTRS_o_ai
9400vec_sub(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009401 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009402}
9403
Daniel Jasperbe508362016-03-11 22:13:28 +00009404static __inline__ vector unsigned short __ATTRS_o_ai
9405vec_sub(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009406 return (vector unsigned short)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009407}
9408
Daniel Jasperbe508362016-03-11 22:13:28 +00009409static __inline__ vector unsigned short __ATTRS_o_ai
9410vec_sub(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009411 return __a - (vector unsigned short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009412}
9413
Daniel Jasperbe508362016-03-11 22:13:28 +00009414static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a,
9415 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009416 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009417}
9418
Daniel Jasperbe508362016-03-11 22:13:28 +00009419static __inline__ vector int __ATTRS_o_ai vec_sub(vector bool int __a,
9420 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009421 return (vector int)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009422}
9423
Daniel Jasperbe508362016-03-11 22:13:28 +00009424static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a,
9425 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009426 return __a - (vector int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009427}
9428
Daniel Jasperbe508362016-03-11 22:13:28 +00009429static __inline__ vector unsigned int __ATTRS_o_ai
9430vec_sub(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009431 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009432}
9433
Daniel Jasperbe508362016-03-11 22:13:28 +00009434static __inline__ vector unsigned int __ATTRS_o_ai
9435vec_sub(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009436 return (vector unsigned int)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009437}
9438
Daniel Jasperbe508362016-03-11 22:13:28 +00009439static __inline__ vector unsigned int __ATTRS_o_ai
9440vec_sub(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009441 return __a - (vector unsigned int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009442}
9443
Kit Barton5944ee212015-05-25 15:52:45 +00009444#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +00009445static __inline__ vector signed __int128 __ATTRS_o_ai
9446vec_sub(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009447 return __a - __b;
9448}
9449
Daniel Jasperbe508362016-03-11 22:13:28 +00009450static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009451vec_sub(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009452 return __a - __b;
9453}
9454#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
9455
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00009456#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00009457static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00009458vec_sub(vector signed long long __a, vector signed long long __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009459 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009460}
9461
Daniel Jasperbe508362016-03-11 22:13:28 +00009462static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00009463vec_sub(vector unsigned long long __a, vector unsigned long long __b) {
9464 return __a - __b;
9465}
9466
Daniel Jasperbe508362016-03-11 22:13:28 +00009467static __inline__ vector double __ATTRS_o_ai vec_sub(vector double __a,
9468 vector double __b) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00009469 return __a - __b;
9470}
9471#endif
9472
Daniel Jasperbe508362016-03-11 22:13:28 +00009473static __inline__ vector float __ATTRS_o_ai vec_sub(vector float __a,
9474 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +00009475 return __a - __b;
9476}
9477
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009478/* vec_vsububm */
9479
9480#define __builtin_altivec_vsububm vec_vsububm
9481
Daniel Jasperbe508362016-03-11 22:13:28 +00009482static __inline__ vector signed char __ATTRS_o_ai
9483vec_vsububm(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009484 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009485}
9486
Daniel Jasperbe508362016-03-11 22:13:28 +00009487static __inline__ vector signed char __ATTRS_o_ai
9488vec_vsububm(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009489 return (vector signed char)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009490}
9491
Daniel Jasperbe508362016-03-11 22:13:28 +00009492static __inline__ vector signed char __ATTRS_o_ai
9493vec_vsububm(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009494 return __a - (vector signed char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009495}
9496
Daniel Jasperbe508362016-03-11 22:13:28 +00009497static __inline__ vector unsigned char __ATTRS_o_ai
9498vec_vsububm(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009499 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009500}
9501
Daniel Jasperbe508362016-03-11 22:13:28 +00009502static __inline__ vector unsigned char __ATTRS_o_ai
9503vec_vsububm(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009504 return (vector unsigned char)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009505}
9506
Daniel Jasperbe508362016-03-11 22:13:28 +00009507static __inline__ vector unsigned char __ATTRS_o_ai
9508vec_vsububm(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009509 return __a - (vector unsigned char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009510}
9511
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009512/* vec_vsubuhm */
9513
9514#define __builtin_altivec_vsubuhm vec_vsubuhm
9515
Daniel Jasperbe508362016-03-11 22:13:28 +00009516static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a,
9517 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009518 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009519}
9520
Daniel Jasperbe508362016-03-11 22:13:28 +00009521static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector bool short __a,
9522 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009523 return (vector short)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009524}
9525
Daniel Jasperbe508362016-03-11 22:13:28 +00009526static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a,
9527 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009528 return __a - (vector short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009529}
9530
Daniel Jasperbe508362016-03-11 22:13:28 +00009531static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009532vec_vsubuhm(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009533 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009534}
9535
Daniel Jasperbe508362016-03-11 22:13:28 +00009536static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009537vec_vsubuhm(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009538 return (vector unsigned short)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009539}
9540
Daniel Jasperbe508362016-03-11 22:13:28 +00009541static __inline__ vector unsigned short __ATTRS_o_ai
9542vec_vsubuhm(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009543 return __a - (vector unsigned short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009544}
9545
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009546/* vec_vsubuwm */
9547
9548#define __builtin_altivec_vsubuwm vec_vsubuwm
9549
Daniel Jasperbe508362016-03-11 22:13:28 +00009550static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a,
9551 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009552 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009553}
9554
Daniel Jasperbe508362016-03-11 22:13:28 +00009555static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector bool int __a,
9556 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009557 return (vector int)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009558}
9559
Daniel Jasperbe508362016-03-11 22:13:28 +00009560static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a,
9561 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009562 return __a - (vector int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009563}
9564
Daniel Jasperbe508362016-03-11 22:13:28 +00009565static __inline__ vector unsigned int __ATTRS_o_ai
9566vec_vsubuwm(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009567 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009568}
9569
Daniel Jasperbe508362016-03-11 22:13:28 +00009570static __inline__ vector unsigned int __ATTRS_o_ai
9571vec_vsubuwm(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009572 return (vector unsigned int)__a - __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009573}
9574
Daniel Jasperbe508362016-03-11 22:13:28 +00009575static __inline__ vector unsigned int __ATTRS_o_ai
9576vec_vsubuwm(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009577 return __a - (vector unsigned int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +00009578}
9579
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009580/* vec_vsubfp */
9581
9582#define __builtin_altivec_vsubfp vec_vsubfp
9583
Daniel Jasperbe508362016-03-11 22:13:28 +00009584static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009585vec_vsubfp(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009586 return __a - __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009587}
9588
9589/* vec_subc */
9590
Daniel Jasperbe508362016-03-11 22:13:28 +00009591static __inline__ vector unsigned int __ATTRS_o_ai
9592vec_subc(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009593 return __builtin_altivec_vsubcuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009594}
9595
Kit Barton5944ee212015-05-25 15:52:45 +00009596#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +00009597static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009598vec_subc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009599 return __builtin_altivec_vsubcuq(__a, __b);
9600}
9601
Daniel Jasperbe508362016-03-11 22:13:28 +00009602static __inline__ vector signed __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009603vec_subc(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009604 return __builtin_altivec_vsubcuq(__a, __b);
9605}
9606#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
9607
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009608/* vec_vsubcuw */
9609
Daniel Jasperbe508362016-03-11 22:13:28 +00009610static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009611vec_vsubcuw(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009612 return __builtin_altivec_vsubcuw(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009613}
9614
9615/* vec_subs */
9616
Daniel Jasperbe508362016-03-11 22:13:28 +00009617static __inline__ vector signed char __ATTRS_o_ai
9618vec_subs(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009619 return __builtin_altivec_vsubsbs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009620}
9621
Daniel Jasperbe508362016-03-11 22:13:28 +00009622static __inline__ vector signed char __ATTRS_o_ai
9623vec_subs(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009624 return __builtin_altivec_vsubsbs((vector signed char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009625}
9626
Daniel Jasperbe508362016-03-11 22:13:28 +00009627static __inline__ vector signed char __ATTRS_o_ai
9628vec_subs(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009629 return __builtin_altivec_vsubsbs(__a, (vector signed char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009630}
9631
Daniel Jasperbe508362016-03-11 22:13:28 +00009632static __inline__ vector unsigned char __ATTRS_o_ai
9633vec_subs(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009634 return __builtin_altivec_vsububs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009635}
9636
Daniel Jasperbe508362016-03-11 22:13:28 +00009637static __inline__ vector unsigned char __ATTRS_o_ai
9638vec_subs(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009639 return __builtin_altivec_vsububs((vector unsigned char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009640}
9641
Daniel Jasperbe508362016-03-11 22:13:28 +00009642static __inline__ vector unsigned char __ATTRS_o_ai
9643vec_subs(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009644 return __builtin_altivec_vsububs(__a, (vector unsigned char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009645}
9646
Daniel Jasperbe508362016-03-11 22:13:28 +00009647static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a,
9648 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009649 return __builtin_altivec_vsubshs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009650}
9651
Daniel Jasperbe508362016-03-11 22:13:28 +00009652static __inline__ vector short __ATTRS_o_ai vec_subs(vector bool short __a,
9653 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009654 return __builtin_altivec_vsubshs((vector short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009655}
9656
Daniel Jasperbe508362016-03-11 22:13:28 +00009657static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a,
9658 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009659 return __builtin_altivec_vsubshs(__a, (vector short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009660}
9661
Daniel Jasperbe508362016-03-11 22:13:28 +00009662static __inline__ vector unsigned short __ATTRS_o_ai
9663vec_subs(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009664 return __builtin_altivec_vsubuhs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009665}
9666
Daniel Jasperbe508362016-03-11 22:13:28 +00009667static __inline__ vector unsigned short __ATTRS_o_ai
9668vec_subs(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009669 return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009670}
9671
Daniel Jasperbe508362016-03-11 22:13:28 +00009672static __inline__ vector unsigned short __ATTRS_o_ai
9673vec_subs(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009674 return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009675}
9676
Daniel Jasperbe508362016-03-11 22:13:28 +00009677static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a,
9678 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009679 return __builtin_altivec_vsubsws(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009680}
9681
Daniel Jasperbe508362016-03-11 22:13:28 +00009682static __inline__ vector int __ATTRS_o_ai vec_subs(vector bool int __a,
9683 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009684 return __builtin_altivec_vsubsws((vector int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009685}
9686
Daniel Jasperbe508362016-03-11 22:13:28 +00009687static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a,
9688 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009689 return __builtin_altivec_vsubsws(__a, (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009690}
9691
Daniel Jasperbe508362016-03-11 22:13:28 +00009692static __inline__ vector unsigned int __ATTRS_o_ai
9693vec_subs(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009694 return __builtin_altivec_vsubuws(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009695}
9696
Daniel Jasperbe508362016-03-11 22:13:28 +00009697static __inline__ vector unsigned int __ATTRS_o_ai
9698vec_subs(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009699 return __builtin_altivec_vsubuws((vector unsigned int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009700}
9701
Daniel Jasperbe508362016-03-11 22:13:28 +00009702static __inline__ vector unsigned int __ATTRS_o_ai
9703vec_subs(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009704 return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009705}
9706
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009707/* vec_vsubsbs */
9708
Daniel Jasperbe508362016-03-11 22:13:28 +00009709static __inline__ vector signed char __ATTRS_o_ai
9710vec_vsubsbs(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009711 return __builtin_altivec_vsubsbs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009712}
9713
Daniel Jasperbe508362016-03-11 22:13:28 +00009714static __inline__ vector signed char __ATTRS_o_ai
9715vec_vsubsbs(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009716 return __builtin_altivec_vsubsbs((vector signed char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009717}
9718
Daniel Jasperbe508362016-03-11 22:13:28 +00009719static __inline__ vector signed char __ATTRS_o_ai
9720vec_vsubsbs(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009721 return __builtin_altivec_vsubsbs(__a, (vector signed char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009722}
9723
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009724/* vec_vsububs */
9725
Daniel Jasperbe508362016-03-11 22:13:28 +00009726static __inline__ vector unsigned char __ATTRS_o_ai
9727vec_vsububs(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009728 return __builtin_altivec_vsububs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009729}
9730
Daniel Jasperbe508362016-03-11 22:13:28 +00009731static __inline__ vector unsigned char __ATTRS_o_ai
9732vec_vsububs(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009733 return __builtin_altivec_vsububs((vector unsigned char)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009734}
9735
Daniel Jasperbe508362016-03-11 22:13:28 +00009736static __inline__ vector unsigned char __ATTRS_o_ai
9737vec_vsububs(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009738 return __builtin_altivec_vsububs(__a, (vector unsigned char)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009739}
9740
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009741/* vec_vsubshs */
9742
Daniel Jasperbe508362016-03-11 22:13:28 +00009743static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a,
9744 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009745 return __builtin_altivec_vsubshs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009746}
9747
Daniel Jasperbe508362016-03-11 22:13:28 +00009748static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector bool short __a,
9749 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009750 return __builtin_altivec_vsubshs((vector short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009751}
9752
Daniel Jasperbe508362016-03-11 22:13:28 +00009753static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a,
9754 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009755 return __builtin_altivec_vsubshs(__a, (vector short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009756}
9757
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009758/* vec_vsubuhs */
9759
Daniel Jasperbe508362016-03-11 22:13:28 +00009760static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009761vec_vsubuhs(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009762 return __builtin_altivec_vsubuhs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009763}
9764
Daniel Jasperbe508362016-03-11 22:13:28 +00009765static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009766vec_vsubuhs(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009767 return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009768}
9769
Daniel Jasperbe508362016-03-11 22:13:28 +00009770static __inline__ vector unsigned short __ATTRS_o_ai
9771vec_vsubuhs(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009772 return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009773}
9774
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009775/* vec_vsubsws */
9776
Daniel Jasperbe508362016-03-11 22:13:28 +00009777static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a,
9778 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009779 return __builtin_altivec_vsubsws(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009780}
9781
Daniel Jasperbe508362016-03-11 22:13:28 +00009782static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector bool int __a,
9783 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009784 return __builtin_altivec_vsubsws((vector int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009785}
9786
Daniel Jasperbe508362016-03-11 22:13:28 +00009787static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a,
9788 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009789 return __builtin_altivec_vsubsws(__a, (vector int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009790}
9791
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009792/* vec_vsubuws */
9793
Daniel Jasperbe508362016-03-11 22:13:28 +00009794static __inline__ vector unsigned int __ATTRS_o_ai
9795vec_vsubuws(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009796 return __builtin_altivec_vsubuws(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009797}
9798
Daniel Jasperbe508362016-03-11 22:13:28 +00009799static __inline__ vector unsigned int __ATTRS_o_ai
9800vec_vsubuws(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009801 return __builtin_altivec_vsubuws((vector unsigned int)__a, __b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009802}
9803
Daniel Jasperbe508362016-03-11 22:13:28 +00009804static __inline__ vector unsigned int __ATTRS_o_ai
9805vec_vsubuws(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009806 return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b);
Anton Yartsevfc83c602010-08-19 03:21:36 +00009807}
9808
Kit Barton5944ee212015-05-25 15:52:45 +00009809#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
9810/* vec_vsubuqm */
9811
Daniel Jasperbe508362016-03-11 22:13:28 +00009812static __inline__ vector signed __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009813vec_vsubuqm(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009814 return __a - __b;
9815}
9816
Daniel Jasperbe508362016-03-11 22:13:28 +00009817static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009818vec_vsubuqm(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009819 return __a - __b;
9820}
9821
9822/* vec_vsubeuqm */
9823
Daniel Jasperbe508362016-03-11 22:13:28 +00009824static __inline__ vector signed __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +00009825vec_vsubeuqm(vector signed __int128 __a, vector signed __int128 __b,
Bill Seurer703e8482015-06-09 14:39:47 +00009826 vector signed __int128 __c) {
Kit Barton5944ee212015-05-25 15:52:45 +00009827 return __builtin_altivec_vsubeuqm(__a, __b, __c);
9828}
9829
Daniel Jasperbe508362016-03-11 22:13:28 +00009830static __inline__ vector unsigned __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +00009831vec_vsubeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b,
Bill Seurer703e8482015-06-09 14:39:47 +00009832 vector unsigned __int128 __c) {
Kit Barton5944ee212015-05-25 15:52:45 +00009833 return __builtin_altivec_vsubeuqm(__a, __b, __c);
9834}
9835
9836/* vec_vsubcuq */
9837
Daniel Jasperbe508362016-03-11 22:13:28 +00009838static __inline__ vector signed __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009839vec_vsubcuq(vector signed __int128 __a, vector signed __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009840 return __builtin_altivec_vsubcuq(__a, __b);
9841}
9842
Daniel Jasperbe508362016-03-11 22:13:28 +00009843static __inline__ vector unsigned __int128 __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +00009844vec_vsubcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
Kit Barton5944ee212015-05-25 15:52:45 +00009845 return __builtin_altivec_vsubcuq(__a, __b);
9846}
9847
9848/* vec_vsubecuq */
9849
Daniel Jasperbe508362016-03-11 22:13:28 +00009850static __inline__ vector signed __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +00009851vec_vsubecuq(vector signed __int128 __a, vector signed __int128 __b,
Bill Seurer703e8482015-06-09 14:39:47 +00009852 vector signed __int128 __c) {
Kit Barton5944ee212015-05-25 15:52:45 +00009853 return __builtin_altivec_vsubecuq(__a, __b, __c);
9854}
9855
Daniel Jasperbe508362016-03-11 22:13:28 +00009856static __inline__ vector unsigned __int128 __ATTRS_o_ai
Kit Barton5944ee212015-05-25 15:52:45 +00009857vec_vsubecuq(vector unsigned __int128 __a, vector unsigned __int128 __b,
Bill Seurer703e8482015-06-09 14:39:47 +00009858 vector unsigned __int128 __c) {
Kit Barton5944ee212015-05-25 15:52:45 +00009859 return __builtin_altivec_vsubecuq(__a, __b, __c);
9860}
9861#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
9862
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009863/* vec_sum4s */
9864
Daniel Jasperbe508362016-03-11 22:13:28 +00009865static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed char __a,
9866 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009867 return __builtin_altivec_vsum4sbs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009868}
9869
Daniel Jasperbe508362016-03-11 22:13:28 +00009870static __inline__ vector unsigned int __ATTRS_o_ai
9871vec_sum4s(vector unsigned char __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009872 return __builtin_altivec_vsum4ubs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009873}
9874
Daniel Jasperbe508362016-03-11 22:13:28 +00009875static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed short __a,
9876 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009877 return __builtin_altivec_vsum4shs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009878}
9879
9880/* vec_vsum4sbs */
9881
Daniel Jasperbe508362016-03-11 22:13:28 +00009882static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009883vec_vsum4sbs(vector signed char __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009884 return __builtin_altivec_vsum4sbs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009885}
9886
9887/* vec_vsum4ubs */
9888
Daniel Jasperbe508362016-03-11 22:13:28 +00009889static __inline__ vector unsigned int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009890vec_vsum4ubs(vector unsigned char __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009891 return __builtin_altivec_vsum4ubs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009892}
9893
9894/* vec_vsum4shs */
9895
Daniel Jasperbe508362016-03-11 22:13:28 +00009896static __inline__ vector int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009897vec_vsum4shs(vector signed short __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009898 return __builtin_altivec_vsum4shs(__a, __b);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009899}
9900
9901/* vec_sum2s */
9902
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009903/* The vsum2sws instruction has a big-endian bias, so that the second
9904 input vector and the result always reference big-endian elements
9905 1 and 3 (little-endian element 0 and 2). For ease of porting the
9906 programmer wants elements 1 and 3 in both cases, so for little
9907 endian we must perform some permutes. */
9908
Daniel Jasperbe508362016-03-11 22:13:28 +00009909static __inline__ vector signed int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009910vec_sum2s(vector int __a, vector int __b) {
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009911#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00009912 vector int __c = (vector signed int)vec_perm(
9913 __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
9914 8, 9, 10, 11));
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009915 __c = __builtin_altivec_vsum2sws(__a, __c);
Bill Seurer703e8482015-06-09 14:39:47 +00009916 return (vector signed int)vec_perm(
9917 __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
9918 8, 9, 10, 11));
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009919#else
David Blaikie3302f2b2013-01-16 23:08:36 +00009920 return __builtin_altivec_vsum2sws(__a, __b);
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009921#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009922}
9923
9924/* vec_vsum2sws */
9925
Daniel Jasperbe508362016-03-11 22:13:28 +00009926static __inline__ vector signed int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009927vec_vsum2sws(vector int __a, vector int __b) {
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009928#ifdef __LITTLE_ENDIAN__
Bill Seurer703e8482015-06-09 14:39:47 +00009929 vector int __c = (vector signed int)vec_perm(
9930 __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
9931 8, 9, 10, 11));
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009932 __c = __builtin_altivec_vsum2sws(__a, __c);
Bill Seurer703e8482015-06-09 14:39:47 +00009933 return (vector signed int)vec_perm(
9934 __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15,
9935 8, 9, 10, 11));
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009936#else
David Blaikie3302f2b2013-01-16 23:08:36 +00009937 return __builtin_altivec_vsum2sws(__a, __b);
Bill Schmidt7f0a5c52014-06-06 23:12:00 +00009938#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009939}
9940
9941/* vec_sums */
9942
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009943/* The vsumsws instruction has a big-endian bias, so that the second
9944 input vector and the result always reference big-endian element 3
9945 (little-endian element 0). For ease of porting the programmer
9946 wants element 3 in both cases, so for little endian we must perform
9947 some permutes. */
9948
Daniel Jasperbe508362016-03-11 22:13:28 +00009949static __inline__ vector signed int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009950vec_sums(vector signed int __a, vector signed int __b) {
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009951#ifdef __LITTLE_ENDIAN__
Bill Schmidtccbe0a82014-08-04 23:21:26 +00009952 __b = (vector signed int)vec_splat(__b, 3);
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009953 __b = __builtin_altivec_vsumsws(__a, __b);
Bill Schmidtccbe0a82014-08-04 23:21:26 +00009954 return (vector signed int)(0, 0, 0, __b[0]);
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009955#else
David Blaikie3302f2b2013-01-16 23:08:36 +00009956 return __builtin_altivec_vsumsws(__a, __b);
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009957#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009958}
9959
9960/* vec_vsumsws */
9961
Daniel Jasperbe508362016-03-11 22:13:28 +00009962static __inline__ vector signed int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009963vec_vsumsws(vector signed int __a, vector signed int __b) {
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009964#ifdef __LITTLE_ENDIAN__
Bill Schmidtccbe0a82014-08-04 23:21:26 +00009965 __b = (vector signed int)vec_splat(__b, 3);
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009966 __b = __builtin_altivec_vsumsws(__a, __b);
Bill Schmidtccbe0a82014-08-04 23:21:26 +00009967 return (vector signed int)(0, 0, 0, __b[0]);
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009968#else
David Blaikie3302f2b2013-01-16 23:08:36 +00009969 return __builtin_altivec_vsumsws(__a, __b);
Bill Schmidt7f6596bb2014-06-09 03:31:47 +00009970#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009971}
9972
9973/* vec_trunc */
9974
Daniel Jasperbe508362016-03-11 22:13:28 +00009975static __inline__ vector float __ATTRS_o_ai vec_trunc(vector float __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00009976#ifdef __VSX__
9977 return __builtin_vsx_xvrspiz(__a);
9978#else
David Blaikie3302f2b2013-01-16 23:08:36 +00009979 return __builtin_altivec_vrfiz(__a);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00009980#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009981}
9982
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00009983#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +00009984static __inline__ vector double __ATTRS_o_ai vec_trunc(vector double __a) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +00009985 return __builtin_vsx_xvrdpiz(__a);
9986}
9987#endif
9988
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009989/* vec_vrfiz */
9990
Daniel Jasperbe508362016-03-11 22:13:28 +00009991static __inline__ vector float __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +00009992vec_vrfiz(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +00009993 return __builtin_altivec_vrfiz(__a);
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +00009994}
9995
9996/* vec_unpackh */
9997
Bill Schmidtd7c53a92014-06-07 02:20:52 +00009998/* The vector unpack instructions all have a big-endian bias, so for
9999 little endian we must reverse the meanings of "high" and "low." */
10000
Daniel Jasperbe508362016-03-11 22:13:28 +000010001static __inline__ vector short __ATTRS_o_ai
10002vec_unpackh(vector signed char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010003#ifdef __LITTLE_ENDIAN__
10004 return __builtin_altivec_vupklsb((vector char)__a);
10005#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010006 return __builtin_altivec_vupkhsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010007#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010008}
10009
Daniel Jasperbe508362016-03-11 22:13:28 +000010010static __inline__ vector bool short __ATTRS_o_ai
10011vec_unpackh(vector bool char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010012#ifdef __LITTLE_ENDIAN__
10013 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
10014#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010015 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010016#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010017}
10018
Daniel Jasperbe508362016-03-11 22:13:28 +000010019static __inline__ vector int __ATTRS_o_ai vec_unpackh(vector short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010020#ifdef __LITTLE_ENDIAN__
10021 return __builtin_altivec_vupklsh(__a);
10022#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010023 return __builtin_altivec_vupkhsh(__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010024#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010025}
10026
Daniel Jasperbe508362016-03-11 22:13:28 +000010027static __inline__ vector bool int __ATTRS_o_ai
10028vec_unpackh(vector bool short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010029#ifdef __LITTLE_ENDIAN__
10030 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
10031#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010032 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010033#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010034}
10035
Daniel Jasperbe508362016-03-11 22:13:28 +000010036static __inline__ vector unsigned int __ATTRS_o_ai
10037vec_unpackh(vector pixel __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010038#ifdef __LITTLE_ENDIAN__
10039 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
10040#else
10041 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
10042#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010043}
10044
Bill Schmidt41e14c42015-05-16 01:02:25 +000010045#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000010046static __inline__ vector long long __ATTRS_o_ai vec_unpackh(vector int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010047#ifdef __LITTLE_ENDIAN__
10048 return __builtin_altivec_vupklsw(__a);
10049#else
10050 return __builtin_altivec_vupkhsw(__a);
10051#endif
10052}
10053
Daniel Jasperbe508362016-03-11 22:13:28 +000010054static __inline__ vector bool long long __ATTRS_o_ai
10055vec_unpackh(vector bool int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010056#ifdef __LITTLE_ENDIAN__
10057 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
10058#else
10059 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
10060#endif
10061}
10062#endif
10063
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010064/* vec_vupkhsb */
10065
Daniel Jasperbe508362016-03-11 22:13:28 +000010066static __inline__ vector short __ATTRS_o_ai
10067vec_vupkhsb(vector signed char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010068#ifdef __LITTLE_ENDIAN__
10069 return __builtin_altivec_vupklsb((vector char)__a);
10070#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010071 return __builtin_altivec_vupkhsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010072#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010073}
10074
Daniel Jasperbe508362016-03-11 22:13:28 +000010075static __inline__ vector bool short __ATTRS_o_ai
10076vec_vupkhsb(vector bool char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010077#ifdef __LITTLE_ENDIAN__
10078 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
10079#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010080 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010081#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010082}
10083
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010084/* vec_vupkhsh */
10085
Daniel Jasperbe508362016-03-11 22:13:28 +000010086static __inline__ vector int __ATTRS_o_ai vec_vupkhsh(vector short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010087#ifdef __LITTLE_ENDIAN__
10088 return __builtin_altivec_vupklsh(__a);
10089#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010090 return __builtin_altivec_vupkhsh(__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010091#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010092}
10093
Daniel Jasperbe508362016-03-11 22:13:28 +000010094static __inline__ vector bool int __ATTRS_o_ai
10095vec_vupkhsh(vector bool short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010096#ifdef __LITTLE_ENDIAN__
10097 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
10098#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010099 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010100#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010101}
10102
Daniel Jasperbe508362016-03-11 22:13:28 +000010103static __inline__ vector unsigned int __ATTRS_o_ai
10104vec_vupkhsh(vector pixel __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010105#ifdef __LITTLE_ENDIAN__
10106 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
10107#else
10108 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
10109#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010110}
10111
Bill Schmidt41e14c42015-05-16 01:02:25 +000010112/* vec_vupkhsw */
10113
10114#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000010115static __inline__ vector long long __ATTRS_o_ai vec_vupkhsw(vector int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010116#ifdef __LITTLE_ENDIAN__
10117 return __builtin_altivec_vupklsw(__a);
10118#else
10119 return __builtin_altivec_vupkhsw(__a);
10120#endif
10121}
10122
Daniel Jasperbe508362016-03-11 22:13:28 +000010123static __inline__ vector bool long long __ATTRS_o_ai
10124vec_vupkhsw(vector bool int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010125#ifdef __LITTLE_ENDIAN__
10126 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
10127#else
10128 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
10129#endif
10130}
10131#endif
10132
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010133/* vec_unpackl */
10134
Daniel Jasperbe508362016-03-11 22:13:28 +000010135static __inline__ vector short __ATTRS_o_ai
10136vec_unpackl(vector signed char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010137#ifdef __LITTLE_ENDIAN__
10138 return __builtin_altivec_vupkhsb((vector char)__a);
10139#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010140 return __builtin_altivec_vupklsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010141#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010142}
10143
Daniel Jasperbe508362016-03-11 22:13:28 +000010144static __inline__ vector bool short __ATTRS_o_ai
10145vec_unpackl(vector bool char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010146#ifdef __LITTLE_ENDIAN__
10147 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
10148#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010149 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010150#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010151}
10152
Daniel Jasperbe508362016-03-11 22:13:28 +000010153static __inline__ vector int __ATTRS_o_ai vec_unpackl(vector short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010154#ifdef __LITTLE_ENDIAN__
10155 return __builtin_altivec_vupkhsh(__a);
10156#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010157 return __builtin_altivec_vupklsh(__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010158#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010159}
10160
Daniel Jasperbe508362016-03-11 22:13:28 +000010161static __inline__ vector bool int __ATTRS_o_ai
10162vec_unpackl(vector bool short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010163#ifdef __LITTLE_ENDIAN__
10164 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
10165#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010166 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010167#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010168}
10169
Daniel Jasperbe508362016-03-11 22:13:28 +000010170static __inline__ vector unsigned int __ATTRS_o_ai
10171vec_unpackl(vector pixel __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010172#ifdef __LITTLE_ENDIAN__
10173 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
10174#else
10175 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
10176#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010177}
10178
Bill Schmidt41e14c42015-05-16 01:02:25 +000010179#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000010180static __inline__ vector long long __ATTRS_o_ai vec_unpackl(vector int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010181#ifdef __LITTLE_ENDIAN__
10182 return __builtin_altivec_vupkhsw(__a);
10183#else
10184 return __builtin_altivec_vupklsw(__a);
10185#endif
10186}
10187
Daniel Jasperbe508362016-03-11 22:13:28 +000010188static __inline__ vector bool long long __ATTRS_o_ai
10189vec_unpackl(vector bool int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010190#ifdef __LITTLE_ENDIAN__
10191 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
10192#else
10193 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
10194#endif
10195}
10196#endif
10197
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010198/* vec_vupklsb */
10199
Daniel Jasperbe508362016-03-11 22:13:28 +000010200static __inline__ vector short __ATTRS_o_ai
10201vec_vupklsb(vector signed char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010202#ifdef __LITTLE_ENDIAN__
10203 return __builtin_altivec_vupkhsb((vector char)__a);
10204#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010205 return __builtin_altivec_vupklsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010206#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010207}
10208
Daniel Jasperbe508362016-03-11 22:13:28 +000010209static __inline__ vector bool short __ATTRS_o_ai
10210vec_vupklsb(vector bool char __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010211#ifdef __LITTLE_ENDIAN__
10212 return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a);
10213#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010214 return (vector bool short)__builtin_altivec_vupklsb((vector char)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010215#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010216}
10217
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010218/* vec_vupklsh */
10219
Daniel Jasperbe508362016-03-11 22:13:28 +000010220static __inline__ vector int __ATTRS_o_ai vec_vupklsh(vector short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010221#ifdef __LITTLE_ENDIAN__
10222 return __builtin_altivec_vupkhsh(__a);
10223#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010224 return __builtin_altivec_vupklsh(__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010225#endif
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010226}
10227
Daniel Jasperbe508362016-03-11 22:13:28 +000010228static __inline__ vector bool int __ATTRS_o_ai
10229vec_vupklsh(vector bool short __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010230#ifdef __LITTLE_ENDIAN__
10231 return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a);
10232#else
David Blaikie3302f2b2013-01-16 23:08:36 +000010233 return (vector bool int)__builtin_altivec_vupklsh((vector short)__a);
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010234#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010235}
10236
Daniel Jasperbe508362016-03-11 22:13:28 +000010237static __inline__ vector unsigned int __ATTRS_o_ai
10238vec_vupklsh(vector pixel __a) {
Bill Schmidtd7c53a92014-06-07 02:20:52 +000010239#ifdef __LITTLE_ENDIAN__
10240 return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a);
10241#else
10242 return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a);
10243#endif
Anton Yartsevfc83c602010-08-19 03:21:36 +000010244}
10245
Bill Schmidt41e14c42015-05-16 01:02:25 +000010246/* vec_vupklsw */
10247
10248#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000010249static __inline__ vector long long __ATTRS_o_ai vec_vupklsw(vector int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010250#ifdef __LITTLE_ENDIAN__
10251 return __builtin_altivec_vupkhsw(__a);
10252#else
10253 return __builtin_altivec_vupklsw(__a);
10254#endif
10255}
10256
Daniel Jasperbe508362016-03-11 22:13:28 +000010257static __inline__ vector bool long long __ATTRS_o_ai
10258vec_vupklsw(vector bool int __a) {
Bill Schmidt41e14c42015-05-16 01:02:25 +000010259#ifdef __LITTLE_ENDIAN__
10260 return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a);
10261#else
10262 return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a);
10263#endif
10264}
10265#endif
10266
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010267/* vec_vsx_ld */
10268
10269#ifdef __VSX__
10270
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010271static __inline__ vector bool int __ATTRS_o_ai
10272vec_vsx_ld(int __a, const vector bool int *__b) {
10273 return (vector bool int)__builtin_vsx_lxvw4x(__a, __b);
10274}
10275
Daniel Jasperbe508362016-03-11 22:13:28 +000010276static __inline__ vector signed int __ATTRS_o_ai
10277vec_vsx_ld(int __a, const vector signed int *__b) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010278 return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
10279}
10280
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010281static __inline__ vector signed int __ATTRS_o_ai
10282vec_vsx_ld(int __a, const signed int *__b) {
10283 return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
10284}
10285
Daniel Jasperbe508362016-03-11 22:13:28 +000010286static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010287vec_vsx_ld(int __a, const vector unsigned int *__b) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010288 return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
10289}
10290
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010291static __inline__ vector unsigned int __ATTRS_o_ai
10292vec_vsx_ld(int __a, const unsigned int *__b) {
10293 return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
10294}
10295
Daniel Jasperbe508362016-03-11 22:13:28 +000010296static __inline__ vector float __ATTRS_o_ai
10297vec_vsx_ld(int __a, const vector float *__b) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010298 return (vector float)__builtin_vsx_lxvw4x(__a, __b);
10299}
10300
Eric Christopherd5c75ee2016-04-12 21:08:54 +000010301static __inline__ vector float __ATTRS_o_ai vec_vsx_ld(int __a,
10302 const float *__b) {
10303 return (vector float)__builtin_vsx_lxvw4x(__a, __b);
10304}
10305
Daniel Jasperbe508362016-03-11 22:13:28 +000010306static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010307vec_vsx_ld(int __a, const vector signed long long *__b) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010308 return (vector signed long long)__builtin_vsx_lxvd2x(__a, __b);
10309}
10310
Daniel Jasperbe508362016-03-11 22:13:28 +000010311static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010312vec_vsx_ld(int __a, const vector unsigned long long *__b) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010313 return (vector unsigned long long)__builtin_vsx_lxvd2x(__a, __b);
10314}
10315
Daniel Jasperbe508362016-03-11 22:13:28 +000010316static __inline__ vector double __ATTRS_o_ai
10317vec_vsx_ld(int __a, const vector double *__b) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010318 return (vector double)__builtin_vsx_lxvd2x(__a, __b);
10319}
10320
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010321static __inline__ vector double __ATTRS_o_ai
10322vec_vsx_ld(int __a, const double *__b) {
10323 return (vector double)__builtin_vsx_lxvd2x(__a, __b);
10324}
10325
10326static __inline__ vector bool short __ATTRS_o_ai
10327vec_vsx_ld(int __a, const vector bool short *__b) {
10328 return (vector bool short)__builtin_vsx_lxvw4x(__a, __b);
10329}
10330
Daniel Jasperbe508362016-03-11 22:13:28 +000010331static __inline__ vector signed short __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010332vec_vsx_ld(int __a, const vector signed short *__b) {
10333 return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
10334}
10335
Daniel Jasperbe508362016-03-11 22:13:28 +000010336static __inline__ vector signed short __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010337vec_vsx_ld(int __a, const signed short *__b) {
10338 return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
10339}
10340
Daniel Jasperbe508362016-03-11 22:13:28 +000010341static __inline__ vector unsigned short __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010342vec_vsx_ld(int __a, const vector unsigned short *__b) {
10343 return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
10344}
10345
Daniel Jasperbe508362016-03-11 22:13:28 +000010346static __inline__ vector unsigned short __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010347vec_vsx_ld(int __a, const unsigned short *__b) {
10348 return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
10349}
10350
Daniel Jasperbe508362016-03-11 22:13:28 +000010351static __inline__ vector bool char __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010352vec_vsx_ld(int __a, const vector bool char *__b) {
10353 return (vector bool char)__builtin_vsx_lxvw4x(__a, __b);
10354}
10355
Daniel Jasperbe508362016-03-11 22:13:28 +000010356static __inline__ vector signed char __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010357vec_vsx_ld(int __a, const vector signed char *__b) {
10358 return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
10359}
10360
Daniel Jasperbe508362016-03-11 22:13:28 +000010361static __inline__ vector signed char __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010362vec_vsx_ld(int __a, const signed char *__b) {
10363 return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
10364}
10365
Daniel Jasperbe508362016-03-11 22:13:28 +000010366static __inline__ vector unsigned char __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010367vec_vsx_ld(int __a, const vector unsigned char *__b) {
10368 return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
10369}
10370
Daniel Jasperbe508362016-03-11 22:13:28 +000010371static __inline__ vector unsigned char __ATTRS_o_ai
Kit Barton2b36b152016-03-01 18:11:28 +000010372vec_vsx_ld(int __a, const unsigned char *__b) {
10373 return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
10374}
10375
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010376#endif
10377
10378/* vec_vsx_st */
10379
10380#ifdef __VSX__
10381
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010382static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
10383 vector bool int *__c) {
10384 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10385}
10386
10387static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
10388 signed int *__c) {
10389 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10390}
10391
10392static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
10393 unsigned int *__c) {
10394 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10395}
10396
Daniel Jasperbe508362016-03-11 22:13:28 +000010397static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
10398 vector signed int *__c) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010399 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10400}
10401
Daniel Jasperbe508362016-03-11 22:13:28 +000010402static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
10403 signed int *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010404 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10405}
10406
Daniel Jasperbe508362016-03-11 22:13:28 +000010407static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
10408 vector unsigned int *__c) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010409 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10410}
10411
Daniel Jasperbe508362016-03-11 22:13:28 +000010412static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
10413 unsigned int *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010414 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10415}
10416
Daniel Jasperbe508362016-03-11 22:13:28 +000010417static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
10418 vector float *__c) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010419 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10420}
10421
Eric Christopherd5c75ee2016-04-12 21:08:54 +000010422static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
10423 float *__c) {
10424 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10425}
10426
Daniel Jasperbe508362016-03-11 22:13:28 +000010427static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed long long __a,
10428 int __b,
10429 vector signed long long *__c) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010430 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
10431}
10432
Daniel Jasperbe508362016-03-11 22:13:28 +000010433static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned long long __a,
10434 int __b,
10435 vector unsigned long long *__c) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010436 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
10437}
10438
Daniel Jasperbe508362016-03-11 22:13:28 +000010439static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
10440 vector double *__c) {
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010441 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
10442}
10443
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010444static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
10445 double *__c) {
10446 __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
10447}
10448
10449static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
10450 vector bool short *__c) {
10451 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10452}
10453
10454static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
10455 signed short *__c) {
10456 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10457}
10458
10459static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
10460 unsigned short *__c) {
10461 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10462}
Daniel Jasperbe508362016-03-11 22:13:28 +000010463static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
10464 vector signed short *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010465 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10466}
10467
Daniel Jasperbe508362016-03-11 22:13:28 +000010468static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
10469 signed short *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010470 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10471}
10472
Daniel Jasperbe508362016-03-11 22:13:28 +000010473static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a,
10474 int __b,
10475 vector unsigned short *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010476 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10477}
10478
Daniel Jasperbe508362016-03-11 22:13:28 +000010479static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a,
10480 int __b, unsigned short *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010481 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10482}
10483
Chuang-Yu Cheng8eac7ae2016-04-13 05:16:31 +000010484static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
10485 vector bool char *__c) {
10486 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10487}
10488
10489static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
10490 signed char *__c) {
10491 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10492}
10493
10494static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b,
10495 unsigned char *__c) {
10496 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10497}
10498
Daniel Jasperbe508362016-03-11 22:13:28 +000010499static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
10500 vector signed char *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010501 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10502}
10503
Daniel Jasperbe508362016-03-11 22:13:28 +000010504static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
10505 signed char *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010506 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10507}
10508
Daniel Jasperbe508362016-03-11 22:13:28 +000010509static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a,
10510 int __b,
10511 vector unsigned char *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010512 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10513}
10514
Daniel Jasperbe508362016-03-11 22:13:28 +000010515static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a,
10516 int __b, unsigned char *__c) {
Kit Barton2b36b152016-03-01 18:11:28 +000010517 __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
10518}
10519
Bill Schmidt9ec8cea2014-11-12 04:19:56 +000010520#endif
10521
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010522/* vec_xor */
10523
10524#define __builtin_altivec_vxor vec_xor
10525
Daniel Jasperbe508362016-03-11 22:13:28 +000010526static __inline__ vector signed char __ATTRS_o_ai
10527vec_xor(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010528 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010529}
10530
Daniel Jasperbe508362016-03-11 22:13:28 +000010531static __inline__ vector signed char __ATTRS_o_ai
10532vec_xor(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010533 return (vector signed char)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010534}
10535
Daniel Jasperbe508362016-03-11 22:13:28 +000010536static __inline__ vector signed char __ATTRS_o_ai
10537vec_xor(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010538 return __a ^ (vector signed char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010539}
10540
Daniel Jasperbe508362016-03-11 22:13:28 +000010541static __inline__ vector unsigned char __ATTRS_o_ai
10542vec_xor(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010543 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010544}
10545
Daniel Jasperbe508362016-03-11 22:13:28 +000010546static __inline__ vector unsigned char __ATTRS_o_ai
10547vec_xor(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010548 return (vector unsigned char)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010549}
10550
Daniel Jasperbe508362016-03-11 22:13:28 +000010551static __inline__ vector unsigned char __ATTRS_o_ai
10552vec_xor(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010553 return __a ^ (vector unsigned char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010554}
10555
Daniel Jasperbe508362016-03-11 22:13:28 +000010556static __inline__ vector bool char __ATTRS_o_ai vec_xor(vector bool char __a,
10557 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010558 return __a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010559}
10560
Daniel Jasperbe508362016-03-11 22:13:28 +000010561static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a,
10562 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010563 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010564}
10565
Daniel Jasperbe508362016-03-11 22:13:28 +000010566static __inline__ vector short __ATTRS_o_ai vec_xor(vector bool short __a,
10567 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010568 return (vector short)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010569}
10570
Daniel Jasperbe508362016-03-11 22:13:28 +000010571static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a,
10572 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010573 return __a ^ (vector short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010574}
10575
Daniel Jasperbe508362016-03-11 22:13:28 +000010576static __inline__ vector unsigned short __ATTRS_o_ai
10577vec_xor(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010578 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010579}
10580
Daniel Jasperbe508362016-03-11 22:13:28 +000010581static __inline__ vector unsigned short __ATTRS_o_ai
10582vec_xor(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010583 return (vector unsigned short)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010584}
10585
Daniel Jasperbe508362016-03-11 22:13:28 +000010586static __inline__ vector unsigned short __ATTRS_o_ai
10587vec_xor(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010588 return __a ^ (vector unsigned short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010589}
10590
Daniel Jasperbe508362016-03-11 22:13:28 +000010591static __inline__ vector bool short __ATTRS_o_ai
10592vec_xor(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010593 return __a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010594}
10595
Daniel Jasperbe508362016-03-11 22:13:28 +000010596static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a,
10597 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010598 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010599}
10600
Daniel Jasperbe508362016-03-11 22:13:28 +000010601static __inline__ vector int __ATTRS_o_ai vec_xor(vector bool int __a,
10602 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010603 return (vector int)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010604}
10605
Daniel Jasperbe508362016-03-11 22:13:28 +000010606static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a,
10607 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010608 return __a ^ (vector int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010609}
10610
Daniel Jasperbe508362016-03-11 22:13:28 +000010611static __inline__ vector unsigned int __ATTRS_o_ai
10612vec_xor(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010613 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010614}
10615
Daniel Jasperbe508362016-03-11 22:13:28 +000010616static __inline__ vector unsigned int __ATTRS_o_ai
10617vec_xor(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010618 return (vector unsigned int)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010619}
10620
Daniel Jasperbe508362016-03-11 22:13:28 +000010621static __inline__ vector unsigned int __ATTRS_o_ai
10622vec_xor(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010623 return __a ^ (vector unsigned int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010624}
10625
Daniel Jasperbe508362016-03-11 22:13:28 +000010626static __inline__ vector bool int __ATTRS_o_ai vec_xor(vector bool int __a,
10627 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010628 return __a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010629}
10630
Daniel Jasperbe508362016-03-11 22:13:28 +000010631static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a,
10632 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000010633 vector unsigned int __res =
10634 (vector unsigned int)__a ^ (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +000010635 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010636}
10637
Daniel Jasperbe508362016-03-11 22:13:28 +000010638static __inline__ vector float __ATTRS_o_ai vec_xor(vector bool int __a,
10639 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000010640 vector unsigned int __res =
10641 (vector unsigned int)__a ^ (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +000010642 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010643}
10644
Daniel Jasperbe508362016-03-11 22:13:28 +000010645static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a,
10646 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000010647 vector unsigned int __res =
10648 (vector unsigned int)__a ^ (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +000010649 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010650}
10651
Bill Seurer8be14f12015-06-04 18:45:44 +000010652#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000010653static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010654vec_xor(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010655 return __a ^ __b;
10656}
10657
Daniel Jasperbe508362016-03-11 22:13:28 +000010658static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010659vec_xor(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010660 return (vector signed long long)__a ^ __b;
10661}
10662
Daniel Jasperbe508362016-03-11 22:13:28 +000010663static __inline__ vector signed long long __ATTRS_o_ai
10664vec_xor(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010665 return __a ^ (vector signed long long)__b;
10666}
10667
Daniel Jasperbe508362016-03-11 22:13:28 +000010668static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010669vec_xor(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010670 return __a ^ __b;
10671}
10672
Daniel Jasperbe508362016-03-11 22:13:28 +000010673static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010674vec_xor(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010675 return (vector unsigned long long)__a ^ __b;
10676}
10677
Daniel Jasperbe508362016-03-11 22:13:28 +000010678static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010679vec_xor(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010680 return __a ^ (vector unsigned long long)__b;
10681}
10682
Daniel Jasperbe508362016-03-11 22:13:28 +000010683static __inline__ vector bool long long __ATTRS_o_ai
10684vec_xor(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010685 return __a ^ __b;
10686}
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +000010687
Daniel Jasperbe508362016-03-11 22:13:28 +000010688static __inline__ vector double __ATTRS_o_ai vec_xor(vector double __a,
10689 vector double __b) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +000010690 return (vector double)((vector unsigned long long)__a ^
Daniel Jasperbe508362016-03-11 22:13:28 +000010691 (vector unsigned long long)__b);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +000010692}
10693
Daniel Jasperbe508362016-03-11 22:13:28 +000010694static __inline__ vector double __ATTRS_o_ai
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +000010695vec_xor(vector double __a, vector bool long long __b) {
10696 return (vector double)((vector unsigned long long)__a ^
Daniel Jasperbe508362016-03-11 22:13:28 +000010697 (vector unsigned long long)__b);
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +000010698}
10699
Daniel Jasperbe508362016-03-11 22:13:28 +000010700static __inline__ vector double __ATTRS_o_ai vec_xor(vector bool long long __a,
10701 vector double __b) {
Nemanja Ivanovic1c7ad712015-07-05 06:40:52 +000010702 return (vector double)((vector unsigned long long)__a ^
10703 (vector unsigned long long)__b);
10704}
Bill Seurer8be14f12015-06-04 18:45:44 +000010705#endif
10706
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010707/* vec_vxor */
10708
Daniel Jasperbe508362016-03-11 22:13:28 +000010709static __inline__ vector signed char __ATTRS_o_ai
10710vec_vxor(vector signed char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010711 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010712}
10713
Daniel Jasperbe508362016-03-11 22:13:28 +000010714static __inline__ vector signed char __ATTRS_o_ai
10715vec_vxor(vector bool char __a, vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010716 return (vector signed char)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010717}
10718
Daniel Jasperbe508362016-03-11 22:13:28 +000010719static __inline__ vector signed char __ATTRS_o_ai
10720vec_vxor(vector signed char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010721 return __a ^ (vector signed char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010722}
10723
Daniel Jasperbe508362016-03-11 22:13:28 +000010724static __inline__ vector unsigned char __ATTRS_o_ai
10725vec_vxor(vector unsigned char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010726 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010727}
10728
Daniel Jasperbe508362016-03-11 22:13:28 +000010729static __inline__ vector unsigned char __ATTRS_o_ai
10730vec_vxor(vector bool char __a, vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010731 return (vector unsigned char)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010732}
10733
Daniel Jasperbe508362016-03-11 22:13:28 +000010734static __inline__ vector unsigned char __ATTRS_o_ai
10735vec_vxor(vector unsigned char __a, vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010736 return __a ^ (vector unsigned char)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010737}
10738
Daniel Jasperbe508362016-03-11 22:13:28 +000010739static __inline__ vector bool char __ATTRS_o_ai vec_vxor(vector bool char __a,
10740 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010741 return __a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010742}
10743
Daniel Jasperbe508362016-03-11 22:13:28 +000010744static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a,
10745 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010746 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010747}
10748
Daniel Jasperbe508362016-03-11 22:13:28 +000010749static __inline__ vector short __ATTRS_o_ai vec_vxor(vector bool short __a,
10750 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010751 return (vector short)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010752}
10753
Daniel Jasperbe508362016-03-11 22:13:28 +000010754static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a,
10755 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010756 return __a ^ (vector short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010757}
10758
Daniel Jasperbe508362016-03-11 22:13:28 +000010759static __inline__ vector unsigned short __ATTRS_o_ai
10760vec_vxor(vector unsigned short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010761 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010762}
10763
Daniel Jasperbe508362016-03-11 22:13:28 +000010764static __inline__ vector unsigned short __ATTRS_o_ai
10765vec_vxor(vector bool short __a, vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010766 return (vector unsigned short)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010767}
10768
Daniel Jasperbe508362016-03-11 22:13:28 +000010769static __inline__ vector unsigned short __ATTRS_o_ai
10770vec_vxor(vector unsigned short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010771 return __a ^ (vector unsigned short)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010772}
10773
Daniel Jasperbe508362016-03-11 22:13:28 +000010774static __inline__ vector bool short __ATTRS_o_ai
10775vec_vxor(vector bool short __a, vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010776 return __a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010777}
10778
Daniel Jasperbe508362016-03-11 22:13:28 +000010779static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a,
10780 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010781 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010782}
10783
Daniel Jasperbe508362016-03-11 22:13:28 +000010784static __inline__ vector int __ATTRS_o_ai vec_vxor(vector bool int __a,
10785 vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010786 return (vector int)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010787}
10788
Daniel Jasperbe508362016-03-11 22:13:28 +000010789static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a,
10790 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010791 return __a ^ (vector int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010792}
10793
Daniel Jasperbe508362016-03-11 22:13:28 +000010794static __inline__ vector unsigned int __ATTRS_o_ai
10795vec_vxor(vector unsigned int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010796 return __a ^ __b;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010797}
10798
Daniel Jasperbe508362016-03-11 22:13:28 +000010799static __inline__ vector unsigned int __ATTRS_o_ai
10800vec_vxor(vector bool int __a, vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010801 return (vector unsigned int)__a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010802}
10803
Daniel Jasperbe508362016-03-11 22:13:28 +000010804static __inline__ vector unsigned int __ATTRS_o_ai
10805vec_vxor(vector unsigned int __a, vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010806 return __a ^ (vector unsigned int)__b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010807}
10808
Daniel Jasperbe508362016-03-11 22:13:28 +000010809static __inline__ vector bool int __ATTRS_o_ai vec_vxor(vector bool int __a,
10810 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010811 return __a ^ __b;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010812}
10813
Daniel Jasperbe508362016-03-11 22:13:28 +000010814static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a,
10815 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000010816 vector unsigned int __res =
10817 (vector unsigned int)__a ^ (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +000010818 return (vector float)__res;
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000010819}
Chris Lattnerdad40622010-04-14 03:54:58 +000010820
Daniel Jasperbe508362016-03-11 22:13:28 +000010821static __inline__ vector float __ATTRS_o_ai vec_vxor(vector bool int __a,
10822 vector float __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000010823 vector unsigned int __res =
10824 (vector unsigned int)__a ^ (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +000010825 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010826}
10827
Daniel Jasperbe508362016-03-11 22:13:28 +000010828static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a,
10829 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000010830 vector unsigned int __res =
10831 (vector unsigned int)__a ^ (vector unsigned int)__b;
David Blaikie3302f2b2013-01-16 23:08:36 +000010832 return (vector float)__res;
Anton Yartsevfc83c602010-08-19 03:21:36 +000010833}
10834
Bill Seurer8be14f12015-06-04 18:45:44 +000010835#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000010836static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010837vec_vxor(vector signed long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010838 return __a ^ __b;
10839}
10840
Daniel Jasperbe508362016-03-11 22:13:28 +000010841static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010842vec_vxor(vector bool long long __a, vector signed long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010843 return (vector signed long long)__a ^ __b;
10844}
10845
Daniel Jasperbe508362016-03-11 22:13:28 +000010846static __inline__ vector signed long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010847vec_vxor(vector signed long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010848 return __a ^ (vector signed long long)__b;
10849}
10850
Daniel Jasperbe508362016-03-11 22:13:28 +000010851static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010852vec_vxor(vector unsigned long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010853 return __a ^ __b;
10854}
10855
Daniel Jasperbe508362016-03-11 22:13:28 +000010856static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010857vec_vxor(vector bool long long __a, vector unsigned long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010858 return (vector unsigned long long)__a ^ __b;
10859}
10860
Daniel Jasperbe508362016-03-11 22:13:28 +000010861static __inline__ vector unsigned long long __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000010862vec_vxor(vector unsigned long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010863 return __a ^ (vector unsigned long long)__b;
10864}
10865
Daniel Jasperbe508362016-03-11 22:13:28 +000010866static __inline__ vector bool long long __ATTRS_o_ai
10867vec_vxor(vector bool long long __a, vector bool long long __b) {
Bill Seurer8be14f12015-06-04 18:45:44 +000010868 return __a ^ __b;
10869}
10870#endif
10871
Anton Yartsev79d6af32010-09-18 00:39:16 +000010872/* ------------------------ extensions for CBEA ----------------------------- */
Anton Yartsev73d40232010-10-14 14:37:46 +000010873
10874/* vec_extract */
10875
Daniel Jasperbe508362016-03-11 22:13:28 +000010876static __inline__ signed char __ATTRS_o_ai vec_extract(vector signed char __a,
10877 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010878 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010879}
10880
Daniel Jasperbe508362016-03-11 22:13:28 +000010881static __inline__ unsigned char __ATTRS_o_ai
10882vec_extract(vector unsigned char __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010883 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010884}
10885
Daniel Jasperbe508362016-03-11 22:13:28 +000010886static __inline__ unsigned char __ATTRS_o_ai vec_extract(vector bool char __a,
10887 int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010888 return __a[__b];
10889}
10890
Daniel Jasperbe508362016-03-11 22:13:28 +000010891static __inline__ signed short __ATTRS_o_ai vec_extract(vector signed short __a,
10892 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010893 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010894}
10895
Daniel Jasperbe508362016-03-11 22:13:28 +000010896static __inline__ unsigned short __ATTRS_o_ai
10897vec_extract(vector unsigned short __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010898 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010899}
10900
Daniel Jasperbe508362016-03-11 22:13:28 +000010901static __inline__ unsigned short __ATTRS_o_ai vec_extract(vector bool short __a,
10902 int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010903 return __a[__b];
10904}
10905
Daniel Jasperbe508362016-03-11 22:13:28 +000010906static __inline__ signed int __ATTRS_o_ai vec_extract(vector signed int __a,
10907 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010908 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010909}
10910
Daniel Jasperbe508362016-03-11 22:13:28 +000010911static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector unsigned int __a,
10912 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010913 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010914}
10915
Daniel Jasperbe508362016-03-11 22:13:28 +000010916static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector bool int __a,
10917 int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010918 return __a[__b];
10919}
10920
10921#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000010922static __inline__ signed long long __ATTRS_o_ai
10923vec_extract(vector signed long long __a, int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010924 return __a[__b];
10925}
10926
Daniel Jasperbe508362016-03-11 22:13:28 +000010927static __inline__ unsigned long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010928vec_extract(vector unsigned long long __a, int __b) {
10929 return __a[__b];
10930}
10931
Daniel Jasperbe508362016-03-11 22:13:28 +000010932static __inline__ unsigned long long __ATTRS_o_ai
10933vec_extract(vector bool long long __a, int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010934 return __a[__b];
10935}
10936
Daniel Jasperbe508362016-03-11 22:13:28 +000010937static __inline__ double __ATTRS_o_ai vec_extract(vector double __a, int __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010938 return __a[__b];
10939}
10940#endif
10941
Daniel Jasperbe508362016-03-11 22:13:28 +000010942static __inline__ float __ATTRS_o_ai vec_extract(vector float __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010943 return __a[__b];
Anton Yartsev73d40232010-10-14 14:37:46 +000010944}
10945
10946/* vec_insert */
10947
Daniel Jasperbe508362016-03-11 22:13:28 +000010948static __inline__ vector signed char __ATTRS_o_ai
10949vec_insert(signed char __a, vector signed char __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010950 __b[__c] = __a;
10951 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000010952}
10953
Daniel Jasperbe508362016-03-11 22:13:28 +000010954static __inline__ vector unsigned char __ATTRS_o_ai
10955vec_insert(unsigned char __a, vector unsigned char __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010956 __b[__c] = __a;
10957 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000010958}
10959
Daniel Jasperbe508362016-03-11 22:13:28 +000010960static __inline__ vector bool char __ATTRS_o_ai vec_insert(unsigned char __a,
10961 vector bool char __b,
10962 int __c) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010963 __b[__c] = __a;
10964 return __b;
10965}
10966
Daniel Jasperbe508362016-03-11 22:13:28 +000010967static __inline__ vector signed short __ATTRS_o_ai
10968vec_insert(signed short __a, vector signed short __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010969 __b[__c] = __a;
10970 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000010971}
10972
Daniel Jasperbe508362016-03-11 22:13:28 +000010973static __inline__ vector unsigned short __ATTRS_o_ai
10974vec_insert(unsigned short __a, vector unsigned short __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010975 __b[__c] = __a;
10976 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000010977}
10978
Daniel Jasperbe508362016-03-11 22:13:28 +000010979static __inline__ vector bool short __ATTRS_o_ai
10980vec_insert(unsigned short __a, vector bool short __b, int __c) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000010981 __b[__c] = __a;
10982 return __b;
10983}
10984
Daniel Jasperbe508362016-03-11 22:13:28 +000010985static __inline__ vector signed int __ATTRS_o_ai
10986vec_insert(signed int __a, vector signed int __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010987 __b[__c] = __a;
10988 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000010989}
10990
Daniel Jasperbe508362016-03-11 22:13:28 +000010991static __inline__ vector unsigned int __ATTRS_o_ai
10992vec_insert(unsigned int __a, vector unsigned int __b, int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000010993 __b[__c] = __a;
10994 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000010995}
10996
Daniel Jasperbe508362016-03-11 22:13:28 +000010997static __inline__ vector bool int __ATTRS_o_ai vec_insert(unsigned int __a,
10998 vector bool int __b,
10999 int __c) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000011000 __b[__c] = __a;
11001 return __b;
11002}
11003
11004#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000011005static __inline__ vector signed long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000011006vec_insert(signed long long __a, vector signed long long __b, int __c) {
11007 __b[__c] = __a;
11008 return __b;
11009}
11010
Daniel Jasperbe508362016-03-11 22:13:28 +000011011static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000011012vec_insert(unsigned long long __a, vector unsigned long long __b, int __c) {
11013 __b[__c] = __a;
11014 return __b;
11015}
11016
Daniel Jasperbe508362016-03-11 22:13:28 +000011017static __inline__ vector bool long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000011018vec_insert(unsigned long long __a, vector bool long long __b, int __c) {
11019 __b[__c] = __a;
11020 return __b;
11021}
Daniel Jasperbe508362016-03-11 22:13:28 +000011022static __inline__ vector double __ATTRS_o_ai vec_insert(double __a,
11023 vector double __b,
11024 int __c) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000011025 __b[__c] = __a;
11026 return __b;
11027}
11028#endif
11029
Daniel Jasperbe508362016-03-11 22:13:28 +000011030static __inline__ vector float __ATTRS_o_ai vec_insert(float __a,
11031 vector float __b,
11032 int __c) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011033 __b[__c] = __a;
11034 return __b;
Anton Yartsev73d40232010-10-14 14:37:46 +000011035}
11036
11037/* vec_lvlx */
11038
Daniel Jasperbe508362016-03-11 22:13:28 +000011039static __inline__ vector signed char __ATTRS_o_ai
11040vec_lvlx(int __a, const signed char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011041 return vec_perm(vec_ld(__a, __b), (vector signed char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011042 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011043}
11044
Daniel Jasperbe508362016-03-11 22:13:28 +000011045static __inline__ vector signed char __ATTRS_o_ai
11046vec_lvlx(int __a, const vector signed char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011047 return vec_perm(vec_ld(__a, __b), (vector signed char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011048 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011049}
11050
Daniel Jasperbe508362016-03-11 22:13:28 +000011051static __inline__ vector unsigned char __ATTRS_o_ai
11052vec_lvlx(int __a, const unsigned char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011053 return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011054 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011055}
11056
Daniel Jasperbe508362016-03-11 22:13:28 +000011057static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011058vec_lvlx(int __a, const vector unsigned char *__b) {
11059 return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011060 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011061}
11062
Daniel Jasperbe508362016-03-11 22:13:28 +000011063static __inline__ vector bool char __ATTRS_o_ai
11064vec_lvlx(int __a, const vector bool char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011065 return vec_perm(vec_ld(__a, __b), (vector bool char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011066 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011067}
11068
Daniel Jasperbe508362016-03-11 22:13:28 +000011069static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a,
11070 const short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011071 return vec_perm(vec_ld(__a, __b), (vector short)(0), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011072}
11073
Daniel Jasperbe508362016-03-11 22:13:28 +000011074static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a,
11075 const vector short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011076 return vec_perm(vec_ld(__a, __b), (vector short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011077 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011078}
11079
Daniel Jasperbe508362016-03-11 22:13:28 +000011080static __inline__ vector unsigned short __ATTRS_o_ai
11081vec_lvlx(int __a, const unsigned short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011082 return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011083 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011084}
11085
Daniel Jasperbe508362016-03-11 22:13:28 +000011086static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011087vec_lvlx(int __a, const vector unsigned short *__b) {
11088 return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011089 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011090}
11091
Daniel Jasperbe508362016-03-11 22:13:28 +000011092static __inline__ vector bool short __ATTRS_o_ai
11093vec_lvlx(int __a, const vector bool short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011094 return vec_perm(vec_ld(__a, __b), (vector bool short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011095 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011096}
11097
Daniel Jasperbe508362016-03-11 22:13:28 +000011098static __inline__ vector pixel __ATTRS_o_ai vec_lvlx(int __a,
11099 const vector pixel *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011100 return vec_perm(vec_ld(__a, __b), (vector pixel)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011101 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011102}
11103
Daniel Jasperbe508362016-03-11 22:13:28 +000011104static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a, const int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011105 return vec_perm(vec_ld(__a, __b), (vector int)(0), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011106}
11107
Daniel Jasperbe508362016-03-11 22:13:28 +000011108static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a,
11109 const vector int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011110 return vec_perm(vec_ld(__a, __b), (vector int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011111 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011112}
11113
Daniel Jasperbe508362016-03-11 22:13:28 +000011114static __inline__ vector unsigned int __ATTRS_o_ai
11115vec_lvlx(int __a, const unsigned int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011116 return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011117 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011118}
11119
Daniel Jasperbe508362016-03-11 22:13:28 +000011120static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011121vec_lvlx(int __a, const vector unsigned int *__b) {
11122 return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011123 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011124}
11125
Daniel Jasperbe508362016-03-11 22:13:28 +000011126static __inline__ vector bool int __ATTRS_o_ai
11127vec_lvlx(int __a, const vector bool int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011128 return vec_perm(vec_ld(__a, __b), (vector bool int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011129 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011130}
11131
Daniel Jasperbe508362016-03-11 22:13:28 +000011132static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a,
11133 const float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011134 return vec_perm(vec_ld(__a, __b), (vector float)(0), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011135}
11136
Daniel Jasperbe508362016-03-11 22:13:28 +000011137static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a,
11138 const vector float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011139 return vec_perm(vec_ld(__a, __b), (vector float)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011140 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011141}
11142
11143/* vec_lvlxl */
11144
Daniel Jasperbe508362016-03-11 22:13:28 +000011145static __inline__ vector signed char __ATTRS_o_ai
11146vec_lvlxl(int __a, const signed char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011147 return vec_perm(vec_ldl(__a, __b), (vector signed char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011148 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011149}
11150
Daniel Jasperbe508362016-03-11 22:13:28 +000011151static __inline__ vector signed char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011152vec_lvlxl(int __a, const vector signed char *__b) {
11153 return vec_perm(vec_ldl(__a, __b), (vector signed char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011154 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011155}
11156
Daniel Jasperbe508362016-03-11 22:13:28 +000011157static __inline__ vector unsigned char __ATTRS_o_ai
11158vec_lvlxl(int __a, const unsigned char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011159 return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011160 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011161}
11162
Daniel Jasperbe508362016-03-11 22:13:28 +000011163static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011164vec_lvlxl(int __a, const vector unsigned char *__b) {
11165 return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011166 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011167}
11168
Daniel Jasperbe508362016-03-11 22:13:28 +000011169static __inline__ vector bool char __ATTRS_o_ai
11170vec_lvlxl(int __a, const vector bool char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011171 return vec_perm(vec_ldl(__a, __b), (vector bool char)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011172 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011173}
11174
Daniel Jasperbe508362016-03-11 22:13:28 +000011175static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a,
11176 const short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011177 return vec_perm(vec_ldl(__a, __b), (vector short)(0), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011178}
11179
Daniel Jasperbe508362016-03-11 22:13:28 +000011180static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a,
11181 const vector short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011182 return vec_perm(vec_ldl(__a, __b), (vector short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011183 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011184}
11185
Daniel Jasperbe508362016-03-11 22:13:28 +000011186static __inline__ vector unsigned short __ATTRS_o_ai
11187vec_lvlxl(int __a, const unsigned short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011188 return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011189 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011190}
11191
Daniel Jasperbe508362016-03-11 22:13:28 +000011192static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011193vec_lvlxl(int __a, const vector unsigned short *__b) {
11194 return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011195 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011196}
11197
Daniel Jasperbe508362016-03-11 22:13:28 +000011198static __inline__ vector bool short __ATTRS_o_ai
11199vec_lvlxl(int __a, const vector bool short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011200 return vec_perm(vec_ldl(__a, __b), (vector bool short)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011201 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011202}
11203
Daniel Jasperbe508362016-03-11 22:13:28 +000011204static __inline__ vector pixel __ATTRS_o_ai vec_lvlxl(int __a,
11205 const vector pixel *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011206 return vec_perm(vec_ldl(__a, __b), (vector pixel)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011207 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011208}
11209
Daniel Jasperbe508362016-03-11 22:13:28 +000011210static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a, const int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011211 return vec_perm(vec_ldl(__a, __b), (vector int)(0), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011212}
11213
Daniel Jasperbe508362016-03-11 22:13:28 +000011214static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a,
11215 const vector int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011216 return vec_perm(vec_ldl(__a, __b), (vector int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011217 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011218}
11219
Daniel Jasperbe508362016-03-11 22:13:28 +000011220static __inline__ vector unsigned int __ATTRS_o_ai
11221vec_lvlxl(int __a, const unsigned int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011222 return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011223 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011224}
11225
Daniel Jasperbe508362016-03-11 22:13:28 +000011226static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011227vec_lvlxl(int __a, const vector unsigned int *__b) {
11228 return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011229 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011230}
11231
Daniel Jasperbe508362016-03-11 22:13:28 +000011232static __inline__ vector bool int __ATTRS_o_ai
11233vec_lvlxl(int __a, const vector bool int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011234 return vec_perm(vec_ldl(__a, __b), (vector bool int)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011235 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011236}
11237
Daniel Jasperbe508362016-03-11 22:13:28 +000011238static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a,
11239 const float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011240 return vec_perm(vec_ldl(__a, __b), (vector float)(0), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011241}
11242
Daniel Jasperbe508362016-03-11 22:13:28 +000011243static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a,
11244 vector float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011245 return vec_perm(vec_ldl(__a, __b), (vector float)(0),
David Blaikie3302f2b2013-01-16 23:08:36 +000011246 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011247}
11248
11249/* vec_lvrx */
11250
Daniel Jasperbe508362016-03-11 22:13:28 +000011251static __inline__ vector signed char __ATTRS_o_ai
11252vec_lvrx(int __a, const signed char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011253 return vec_perm((vector signed char)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011254 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011255}
11256
Daniel Jasperbe508362016-03-11 22:13:28 +000011257static __inline__ vector signed char __ATTRS_o_ai
11258vec_lvrx(int __a, const vector signed char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011259 return vec_perm((vector signed char)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011260 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011261}
11262
Daniel Jasperbe508362016-03-11 22:13:28 +000011263static __inline__ vector unsigned char __ATTRS_o_ai
11264vec_lvrx(int __a, const unsigned char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011265 return vec_perm((vector unsigned char)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011266 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011267}
11268
Daniel Jasperbe508362016-03-11 22:13:28 +000011269static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011270vec_lvrx(int __a, const vector unsigned char *__b) {
11271 return vec_perm((vector unsigned char)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011272 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011273}
11274
Daniel Jasperbe508362016-03-11 22:13:28 +000011275static __inline__ vector bool char __ATTRS_o_ai
11276vec_lvrx(int __a, const vector bool char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011277 return vec_perm((vector bool char)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011278 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011279}
11280
Daniel Jasperbe508362016-03-11 22:13:28 +000011281static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a,
11282 const short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011283 return vec_perm((vector short)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011284}
11285
Daniel Jasperbe508362016-03-11 22:13:28 +000011286static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a,
11287 const vector short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011288 return vec_perm((vector short)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011289 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011290}
11291
Daniel Jasperbe508362016-03-11 22:13:28 +000011292static __inline__ vector unsigned short __ATTRS_o_ai
11293vec_lvrx(int __a, const unsigned short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011294 return vec_perm((vector unsigned short)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011295 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011296}
11297
Daniel Jasperbe508362016-03-11 22:13:28 +000011298static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011299vec_lvrx(int __a, const vector unsigned short *__b) {
11300 return vec_perm((vector unsigned short)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011301 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011302}
11303
Daniel Jasperbe508362016-03-11 22:13:28 +000011304static __inline__ vector bool short __ATTRS_o_ai
11305vec_lvrx(int __a, const vector bool short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011306 return vec_perm((vector bool short)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011307 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011308}
11309
Daniel Jasperbe508362016-03-11 22:13:28 +000011310static __inline__ vector pixel __ATTRS_o_ai vec_lvrx(int __a,
11311 const vector pixel *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011312 return vec_perm((vector pixel)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011313 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011314}
11315
Daniel Jasperbe508362016-03-11 22:13:28 +000011316static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a, const int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011317 return vec_perm((vector int)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011318}
11319
Daniel Jasperbe508362016-03-11 22:13:28 +000011320static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a,
11321 const vector int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011322 return vec_perm((vector int)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011323 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011324}
11325
Daniel Jasperbe508362016-03-11 22:13:28 +000011326static __inline__ vector unsigned int __ATTRS_o_ai
11327vec_lvrx(int __a, const unsigned int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011328 return vec_perm((vector unsigned int)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011329 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011330}
11331
Daniel Jasperbe508362016-03-11 22:13:28 +000011332static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011333vec_lvrx(int __a, const vector unsigned int *__b) {
11334 return vec_perm((vector unsigned int)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011335 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011336}
11337
Daniel Jasperbe508362016-03-11 22:13:28 +000011338static __inline__ vector bool int __ATTRS_o_ai
11339vec_lvrx(int __a, const vector bool int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011340 return vec_perm((vector bool int)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011341 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011342}
11343
Daniel Jasperbe508362016-03-11 22:13:28 +000011344static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a,
11345 const float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011346 return vec_perm((vector float)(0), vec_ld(__a, __b), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011347}
11348
Daniel Jasperbe508362016-03-11 22:13:28 +000011349static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a,
11350 const vector float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011351 return vec_perm((vector float)(0), vec_ld(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011352 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011353}
11354
11355/* vec_lvrxl */
11356
Daniel Jasperbe508362016-03-11 22:13:28 +000011357static __inline__ vector signed char __ATTRS_o_ai
11358vec_lvrxl(int __a, const signed char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011359 return vec_perm((vector signed char)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011360 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011361}
11362
Daniel Jasperbe508362016-03-11 22:13:28 +000011363static __inline__ vector signed char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011364vec_lvrxl(int __a, const vector signed char *__b) {
11365 return vec_perm((vector signed char)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011366 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011367}
11368
Daniel Jasperbe508362016-03-11 22:13:28 +000011369static __inline__ vector unsigned char __ATTRS_o_ai
11370vec_lvrxl(int __a, const unsigned char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011371 return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011372 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011373}
11374
Daniel Jasperbe508362016-03-11 22:13:28 +000011375static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011376vec_lvrxl(int __a, const vector unsigned char *__b) {
11377 return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011378 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011379}
11380
Daniel Jasperbe508362016-03-11 22:13:28 +000011381static __inline__ vector bool char __ATTRS_o_ai
11382vec_lvrxl(int __a, const vector bool char *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011383 return vec_perm((vector bool char)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011384 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011385}
11386
Daniel Jasperbe508362016-03-11 22:13:28 +000011387static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a,
11388 const short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011389 return vec_perm((vector short)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011390}
11391
Daniel Jasperbe508362016-03-11 22:13:28 +000011392static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a,
11393 const vector short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011394 return vec_perm((vector short)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011395 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011396}
11397
Daniel Jasperbe508362016-03-11 22:13:28 +000011398static __inline__ vector unsigned short __ATTRS_o_ai
11399vec_lvrxl(int __a, const unsigned short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011400 return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011401 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011402}
11403
Daniel Jasperbe508362016-03-11 22:13:28 +000011404static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011405vec_lvrxl(int __a, const vector unsigned short *__b) {
11406 return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011407 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011408}
11409
Daniel Jasperbe508362016-03-11 22:13:28 +000011410static __inline__ vector bool short __ATTRS_o_ai
11411vec_lvrxl(int __a, const vector bool short *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011412 return vec_perm((vector bool short)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011413 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011414}
11415
Daniel Jasperbe508362016-03-11 22:13:28 +000011416static __inline__ vector pixel __ATTRS_o_ai vec_lvrxl(int __a,
11417 const vector pixel *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011418 return vec_perm((vector pixel)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011419 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011420}
11421
Daniel Jasperbe508362016-03-11 22:13:28 +000011422static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a, const int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011423 return vec_perm((vector int)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011424}
11425
Daniel Jasperbe508362016-03-11 22:13:28 +000011426static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a,
11427 const vector int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011428 return vec_perm((vector int)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011429 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011430}
11431
Daniel Jasperbe508362016-03-11 22:13:28 +000011432static __inline__ vector unsigned int __ATTRS_o_ai
11433vec_lvrxl(int __a, const unsigned int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011434 return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011435 vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011436}
11437
Daniel Jasperbe508362016-03-11 22:13:28 +000011438static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000011439vec_lvrxl(int __a, const vector unsigned int *__b) {
11440 return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011441 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011442}
11443
Daniel Jasperbe508362016-03-11 22:13:28 +000011444static __inline__ vector bool int __ATTRS_o_ai
11445vec_lvrxl(int __a, const vector bool int *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011446 return vec_perm((vector bool int)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011447 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011448}
11449
Daniel Jasperbe508362016-03-11 22:13:28 +000011450static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a,
11451 const float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011452 return vec_perm((vector float)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011453}
11454
Daniel Jasperbe508362016-03-11 22:13:28 +000011455static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a,
11456 const vector float *__b) {
Bill Seurer703e8482015-06-09 14:39:47 +000011457 return vec_perm((vector float)(0), vec_ldl(__a, __b),
David Blaikie3302f2b2013-01-16 23:08:36 +000011458 vec_lvsl(__a, (unsigned char *)__b));
Anton Yartsev73d40232010-10-14 14:37:46 +000011459}
11460
11461/* vec_stvlx */
11462
Daniel Jasperbe508362016-03-11 22:13:28 +000011463static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b,
11464 signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011465 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11466 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011467}
11468
Daniel Jasperbe508362016-03-11 22:13:28 +000011469static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b,
11470 vector signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011471 return vec_st(
11472 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11473 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011474}
11475
Daniel Jasperbe508362016-03-11 22:13:28 +000011476static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b,
11477 unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011478 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11479 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011480}
11481
Daniel Jasperbe508362016-03-11 22:13:28 +000011482static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b,
11483 vector unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011484 return vec_st(
11485 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11486 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011487}
11488
Daniel Jasperbe508362016-03-11 22:13:28 +000011489static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool char __a, int __b,
11490 vector bool char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011491 return vec_st(
11492 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11493 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011494}
11495
Daniel Jasperbe508362016-03-11 22:13:28 +000011496static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b,
11497 short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011498 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11499 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011500}
11501
Daniel Jasperbe508362016-03-11 22:13:28 +000011502static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b,
11503 vector short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011504 return vec_st(
11505 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11506 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011507}
11508
Daniel Jasperbe508362016-03-11 22:13:28 +000011509static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a,
11510 int __b, unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011511 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11512 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011513}
11514
Daniel Jasperbe508362016-03-11 22:13:28 +000011515static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a,
11516 int __b,
11517 vector unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011518 return vec_st(
11519 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11520 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011521}
11522
Daniel Jasperbe508362016-03-11 22:13:28 +000011523static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool short __a, int __b,
11524 vector bool short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011525 return vec_st(
11526 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11527 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011528}
11529
Daniel Jasperbe508362016-03-11 22:13:28 +000011530static __inline__ void __ATTRS_o_ai vec_stvlx(vector pixel __a, int __b,
11531 vector pixel *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011532 return vec_st(
11533 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11534 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011535}
11536
Daniel Jasperbe508362016-03-11 22:13:28 +000011537static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b,
11538 int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011539 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11540 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011541}
11542
Daniel Jasperbe508362016-03-11 22:13:28 +000011543static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b,
11544 vector int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011545 return vec_st(
11546 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11547 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011548}
11549
Daniel Jasperbe508362016-03-11 22:13:28 +000011550static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b,
11551 unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011552 return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11553 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011554}
11555
Daniel Jasperbe508362016-03-11 22:13:28 +000011556static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b,
11557 vector unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011558 return vec_st(
11559 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11560 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011561}
11562
Daniel Jasperbe508362016-03-11 22:13:28 +000011563static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool int __a, int __b,
11564 vector bool int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011565 return vec_st(
11566 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11567 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011568}
11569
Daniel Jasperbe508362016-03-11 22:13:28 +000011570static __inline__ void __ATTRS_o_ai vec_stvlx(vector float __a, int __b,
11571 vector float *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011572 return vec_st(
11573 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11574 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011575}
11576
11577/* vec_stvlxl */
11578
Daniel Jasperbe508362016-03-11 22:13:28 +000011579static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b,
11580 signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011581 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11582 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011583}
11584
Daniel Jasperbe508362016-03-11 22:13:28 +000011585static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b,
11586 vector signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011587 return vec_stl(
11588 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11589 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011590}
11591
Daniel Jasperbe508362016-03-11 22:13:28 +000011592static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a,
11593 int __b, unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011594 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11595 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011596}
11597
Daniel Jasperbe508362016-03-11 22:13:28 +000011598static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a,
11599 int __b,
11600 vector unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011601 return vec_stl(
11602 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11603 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011604}
11605
Daniel Jasperbe508362016-03-11 22:13:28 +000011606static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool char __a, int __b,
11607 vector bool char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011608 return vec_stl(
11609 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11610 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011611}
11612
Daniel Jasperbe508362016-03-11 22:13:28 +000011613static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b,
11614 short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011615 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11616 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011617}
11618
Daniel Jasperbe508362016-03-11 22:13:28 +000011619static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b,
11620 vector short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011621 return vec_stl(
11622 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11623 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011624}
11625
Daniel Jasperbe508362016-03-11 22:13:28 +000011626static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a,
11627 int __b, unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011628 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11629 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011630}
11631
Daniel Jasperbe508362016-03-11 22:13:28 +000011632static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a,
11633 int __b,
11634 vector unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011635 return vec_stl(
11636 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11637 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011638}
11639
Daniel Jasperbe508362016-03-11 22:13:28 +000011640static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool short __a, int __b,
11641 vector bool short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011642 return vec_stl(
11643 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11644 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011645}
11646
Daniel Jasperbe508362016-03-11 22:13:28 +000011647static __inline__ void __ATTRS_o_ai vec_stvlxl(vector pixel __a, int __b,
11648 vector pixel *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011649 return vec_stl(
11650 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11651 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011652}
11653
Daniel Jasperbe508362016-03-11 22:13:28 +000011654static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b,
11655 int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011656 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11657 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011658}
11659
Daniel Jasperbe508362016-03-11 22:13:28 +000011660static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b,
11661 vector int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011662 return vec_stl(
11663 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11664 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011665}
11666
Daniel Jasperbe508362016-03-11 22:13:28 +000011667static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b,
11668 unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011669 return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b,
11670 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011671}
11672
Daniel Jasperbe508362016-03-11 22:13:28 +000011673static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b,
11674 vector unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011675 return vec_stl(
11676 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11677 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011678}
11679
Daniel Jasperbe508362016-03-11 22:13:28 +000011680static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool int __a, int __b,
11681 vector bool int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011682 return vec_stl(
11683 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11684 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011685}
11686
Daniel Jasperbe508362016-03-11 22:13:28 +000011687static __inline__ void __ATTRS_o_ai vec_stvlxl(vector float __a, int __b,
11688 vector float *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011689 return vec_stl(
11690 vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)),
11691 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011692}
11693
11694/* vec_stvrx */
11695
Daniel Jasperbe508362016-03-11 22:13:28 +000011696static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b,
11697 signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011698 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11699 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011700}
11701
Daniel Jasperbe508362016-03-11 22:13:28 +000011702static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b,
11703 vector signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011704 return vec_st(
11705 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11706 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011707}
11708
Daniel Jasperbe508362016-03-11 22:13:28 +000011709static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b,
11710 unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011711 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11712 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011713}
11714
Daniel Jasperbe508362016-03-11 22:13:28 +000011715static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b,
11716 vector unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011717 return vec_st(
11718 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11719 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011720}
11721
Daniel Jasperbe508362016-03-11 22:13:28 +000011722static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool char __a, int __b,
11723 vector bool char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011724 return vec_st(
11725 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11726 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011727}
11728
Daniel Jasperbe508362016-03-11 22:13:28 +000011729static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b,
11730 short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011731 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11732 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011733}
11734
Daniel Jasperbe508362016-03-11 22:13:28 +000011735static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b,
11736 vector short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011737 return vec_st(
11738 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11739 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011740}
11741
Daniel Jasperbe508362016-03-11 22:13:28 +000011742static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a,
11743 int __b, unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011744 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11745 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011746}
11747
Daniel Jasperbe508362016-03-11 22:13:28 +000011748static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a,
11749 int __b,
11750 vector unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011751 return vec_st(
11752 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11753 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011754}
11755
Daniel Jasperbe508362016-03-11 22:13:28 +000011756static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool short __a, int __b,
11757 vector bool short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011758 return vec_st(
11759 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11760 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011761}
11762
Daniel Jasperbe508362016-03-11 22:13:28 +000011763static __inline__ void __ATTRS_o_ai vec_stvrx(vector pixel __a, int __b,
11764 vector pixel *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011765 return vec_st(
11766 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11767 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011768}
11769
Daniel Jasperbe508362016-03-11 22:13:28 +000011770static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b,
11771 int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011772 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11773 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011774}
11775
Daniel Jasperbe508362016-03-11 22:13:28 +000011776static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b,
11777 vector int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011778 return vec_st(
11779 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11780 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011781}
11782
Daniel Jasperbe508362016-03-11 22:13:28 +000011783static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b,
11784 unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011785 return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11786 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011787}
11788
Daniel Jasperbe508362016-03-11 22:13:28 +000011789static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b,
11790 vector unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011791 return vec_st(
11792 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11793 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011794}
11795
Daniel Jasperbe508362016-03-11 22:13:28 +000011796static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool int __a, int __b,
11797 vector bool int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011798 return vec_st(
11799 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11800 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011801}
11802
Daniel Jasperbe508362016-03-11 22:13:28 +000011803static __inline__ void __ATTRS_o_ai vec_stvrx(vector float __a, int __b,
11804 vector float *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011805 return vec_st(
11806 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11807 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011808}
11809
11810/* vec_stvrxl */
11811
Daniel Jasperbe508362016-03-11 22:13:28 +000011812static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b,
11813 signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011814 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11815 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011816}
11817
Daniel Jasperbe508362016-03-11 22:13:28 +000011818static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b,
11819 vector signed char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011820 return vec_stl(
11821 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11822 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011823}
11824
Daniel Jasperbe508362016-03-11 22:13:28 +000011825static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a,
11826 int __b, unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011827 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11828 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011829}
11830
Daniel Jasperbe508362016-03-11 22:13:28 +000011831static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a,
11832 int __b,
11833 vector unsigned char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011834 return vec_stl(
11835 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11836 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011837}
11838
Daniel Jasperbe508362016-03-11 22:13:28 +000011839static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool char __a, int __b,
11840 vector bool char *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011841 return vec_stl(
11842 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11843 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011844}
11845
Daniel Jasperbe508362016-03-11 22:13:28 +000011846static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b,
11847 short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011848 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11849 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011850}
11851
Daniel Jasperbe508362016-03-11 22:13:28 +000011852static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b,
11853 vector short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011854 return vec_stl(
11855 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11856 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011857}
11858
Daniel Jasperbe508362016-03-11 22:13:28 +000011859static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a,
11860 int __b, unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011861 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11862 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011863}
11864
Daniel Jasperbe508362016-03-11 22:13:28 +000011865static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a,
11866 int __b,
11867 vector unsigned short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011868 return vec_stl(
11869 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11870 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011871}
11872
Daniel Jasperbe508362016-03-11 22:13:28 +000011873static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool short __a, int __b,
11874 vector bool short *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011875 return vec_stl(
11876 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11877 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011878}
11879
Daniel Jasperbe508362016-03-11 22:13:28 +000011880static __inline__ void __ATTRS_o_ai vec_stvrxl(vector pixel __a, int __b,
11881 vector pixel *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011882 return vec_stl(
11883 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11884 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011885}
11886
Daniel Jasperbe508362016-03-11 22:13:28 +000011887static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b,
11888 int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011889 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11890 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011891}
11892
Daniel Jasperbe508362016-03-11 22:13:28 +000011893static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b,
11894 vector int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011895 return vec_stl(
11896 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11897 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011898}
11899
Daniel Jasperbe508362016-03-11 22:13:28 +000011900static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b,
11901 unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011902 return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b,
11903 __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011904}
11905
Daniel Jasperbe508362016-03-11 22:13:28 +000011906static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b,
11907 vector unsigned int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011908 return vec_stl(
11909 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11910 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011911}
11912
Daniel Jasperbe508362016-03-11 22:13:28 +000011913static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool int __a, int __b,
11914 vector bool int *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011915 return vec_stl(
11916 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11917 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011918}
11919
Daniel Jasperbe508362016-03-11 22:13:28 +000011920static __inline__ void __ATTRS_o_ai vec_stvrxl(vector float __a, int __b,
11921 vector float *__c) {
Bill Seurer703e8482015-06-09 14:39:47 +000011922 return vec_stl(
11923 vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)),
11924 __b, __c);
Anton Yartsev73d40232010-10-14 14:37:46 +000011925}
11926
11927/* vec_promote */
11928
Daniel Jasperbe508362016-03-11 22:13:28 +000011929static __inline__ vector signed char __ATTRS_o_ai vec_promote(signed char __a,
11930 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011931 vector signed char __res = (vector signed char)(0);
11932 __res[__b] = __a;
11933 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011934}
11935
Daniel Jasperbe508362016-03-11 22:13:28 +000011936static __inline__ vector unsigned char __ATTRS_o_ai
11937vec_promote(unsigned char __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011938 vector unsigned char __res = (vector unsigned char)(0);
11939 __res[__b] = __a;
11940 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011941}
11942
Daniel Jasperbe508362016-03-11 22:13:28 +000011943static __inline__ vector short __ATTRS_o_ai vec_promote(short __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011944 vector short __res = (vector short)(0);
11945 __res[__b] = __a;
11946 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011947}
11948
Daniel Jasperbe508362016-03-11 22:13:28 +000011949static __inline__ vector unsigned short __ATTRS_o_ai
11950vec_promote(unsigned short __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011951 vector unsigned short __res = (vector unsigned short)(0);
11952 __res[__b] = __a;
11953 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011954}
11955
Daniel Jasperbe508362016-03-11 22:13:28 +000011956static __inline__ vector int __ATTRS_o_ai vec_promote(int __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011957 vector int __res = (vector int)(0);
11958 __res[__b] = __a;
11959 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011960}
11961
Daniel Jasperbe508362016-03-11 22:13:28 +000011962static __inline__ vector unsigned int __ATTRS_o_ai vec_promote(unsigned int __a,
11963 int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011964 vector unsigned int __res = (vector unsigned int)(0);
11965 __res[__b] = __a;
11966 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011967}
11968
Daniel Jasperbe508362016-03-11 22:13:28 +000011969static __inline__ vector float __ATTRS_o_ai vec_promote(float __a, int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011970 vector float __res = (vector float)(0);
11971 __res[__b] = __a;
11972 return __res;
Anton Yartsev73d40232010-10-14 14:37:46 +000011973}
11974
11975/* vec_splats */
11976
Daniel Jasperbe508362016-03-11 22:13:28 +000011977static __inline__ vector signed char __ATTRS_o_ai vec_splats(signed char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011978 return (vector signed char)(__a);
Anton Yartsev73d40232010-10-14 14:37:46 +000011979}
11980
Daniel Jasperbe508362016-03-11 22:13:28 +000011981static __inline__ vector unsigned char __ATTRS_o_ai
11982vec_splats(unsigned char __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011983 return (vector unsigned char)(__a);
Anton Yartsev73d40232010-10-14 14:37:46 +000011984}
11985
Daniel Jasperbe508362016-03-11 22:13:28 +000011986static __inline__ vector short __ATTRS_o_ai vec_splats(short __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011987 return (vector short)(__a);
Anton Yartsev73d40232010-10-14 14:37:46 +000011988}
11989
Daniel Jasperbe508362016-03-11 22:13:28 +000011990static __inline__ vector unsigned short __ATTRS_o_ai
11991vec_splats(unsigned short __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000011992 return (vector unsigned short)(__a);
Anton Yartsev73d40232010-10-14 14:37:46 +000011993}
11994
Daniel Jasperbe508362016-03-11 22:13:28 +000011995static __inline__ vector int __ATTRS_o_ai vec_splats(int __a) {
11996 return (vector int)(__a);
11997}
Anton Yartsev73d40232010-10-14 14:37:46 +000011998
Daniel Jasperbe508362016-03-11 22:13:28 +000011999static __inline__ vector unsigned int __ATTRS_o_ai
12000vec_splats(unsigned int __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012001 return (vector unsigned int)(__a);
Anton Yartsev73d40232010-10-14 14:37:46 +000012002}
12003
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012004#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012005static __inline__ vector signed long long __ATTRS_o_ai
12006vec_splats(signed long long __a) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012007 return (vector signed long long)(__a);
12008}
12009
Daniel Jasperbe508362016-03-11 22:13:28 +000012010static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012011vec_splats(unsigned long long __a) {
12012 return (vector unsigned long long)(__a);
12013}
12014
12015#if defined(__POWER8_VECTOR__) && defined(__powerpc64__)
Daniel Jasperbe508362016-03-11 22:13:28 +000012016static __inline__ vector signed __int128 __ATTRS_o_ai
12017vec_splats(signed __int128 __a) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012018 return (vector signed __int128)(__a);
12019}
12020
Daniel Jasperbe508362016-03-11 22:13:28 +000012021static __inline__ vector unsigned __int128 __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012022vec_splats(unsigned __int128 __a) {
12023 return (vector unsigned __int128)(__a);
12024}
12025
12026#endif
12027
Daniel Jasperbe508362016-03-11 22:13:28 +000012028static __inline__ vector double __ATTRS_o_ai vec_splats(double __a) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012029 return (vector double)(__a);
12030}
12031#endif
12032
Daniel Jasperbe508362016-03-11 22:13:28 +000012033static __inline__ vector float __ATTRS_o_ai vec_splats(float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012034 return (vector float)(__a);
Anton Yartsev73d40232010-10-14 14:37:46 +000012035}
12036
Anton Yartsev79d6af32010-09-18 00:39:16 +000012037/* ----------------------------- predicates --------------------------------- */
Chris Lattnerdad40622010-04-14 03:54:58 +000012038
Chris Lattnerdad40622010-04-14 03:54:58 +000012039/* vec_all_eq */
12040
Daniel Jasperbe508362016-03-11 22:13:28 +000012041static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a,
12042 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012043 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12044 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012045}
12046
Daniel Jasperbe508362016-03-11 22:13:28 +000012047static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a,
12048 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012049 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12050 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012051}
12052
Daniel Jasperbe508362016-03-11 22:13:28 +000012053static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a,
12054 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012055 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12056 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012057}
12058
Daniel Jasperbe508362016-03-11 22:13:28 +000012059static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a,
12060 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012061 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12062 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012063}
12064
Daniel Jasperbe508362016-03-11 22:13:28 +000012065static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
12066 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012067 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12068 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012069}
12070
Daniel Jasperbe508362016-03-11 22:13:28 +000012071static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
12072 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012073 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12074 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012075}
12076
Daniel Jasperbe508362016-03-11 22:13:28 +000012077static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a,
12078 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012079 return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a,
12080 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012081}
12082
Daniel Jasperbe508362016-03-11 22:13:28 +000012083static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a,
12084 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012085 return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012086}
12087
Daniel Jasperbe508362016-03-11 22:13:28 +000012088static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a,
12089 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012090 return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012091}
12092
Daniel Jasperbe508362016-03-11 22:13:28 +000012093static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a,
12094 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012095 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
12096 (vector short)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012097}
12098
Daniel Jasperbe508362016-03-11 22:13:28 +000012099static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a,
12100 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012101 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
12102 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012103}
12104
Daniel Jasperbe508362016-03-11 22:13:28 +000012105static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
12106 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012107 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
12108 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012109}
12110
Daniel Jasperbe508362016-03-11 22:13:28 +000012111static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
12112 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012113 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
12114 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012115}
12116
Daniel Jasperbe508362016-03-11 22:13:28 +000012117static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a,
12118 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012119 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
12120 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012121}
12122
Daniel Jasperbe508362016-03-11 22:13:28 +000012123static __inline__ int __ATTRS_o_ai vec_all_eq(vector pixel __a,
12124 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012125 return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a,
12126 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012127}
12128
Daniel Jasperbe508362016-03-11 22:13:28 +000012129static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012130 return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012131}
12132
Daniel Jasperbe508362016-03-11 22:13:28 +000012133static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a,
12134 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012135 return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012136}
12137
Daniel Jasperbe508362016-03-11 22:13:28 +000012138static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a,
12139 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012140 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
12141 (vector int)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012142}
12143
Daniel Jasperbe508362016-03-11 22:13:28 +000012144static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a,
12145 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012146 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
12147 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012148}
12149
Daniel Jasperbe508362016-03-11 22:13:28 +000012150static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
12151 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012152 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
12153 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012154}
12155
Daniel Jasperbe508362016-03-11 22:13:28 +000012156static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
12157 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012158 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
12159 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012160}
12161
Daniel Jasperbe508362016-03-11 22:13:28 +000012162static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a,
12163 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012164 return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a,
12165 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012166}
12167
Kit Barton8553bec2015-03-11 15:57:19 +000012168#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000012169static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed long long __a,
12170 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012171 return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, __b);
12172}
12173
Daniel Jasperbe508362016-03-11 22:13:28 +000012174static __inline__ int __ATTRS_o_ai vec_all_eq(vector long long __a,
12175 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012176 return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, (vector long long)__b);
12177}
12178
Daniel Jasperbe508362016-03-11 22:13:28 +000012179static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a,
12180 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012181 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012182 (vector long long)__b);
12183}
12184
Daniel Jasperbe508362016-03-11 22:13:28 +000012185static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a,
12186 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012187 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012188 (vector long long)__b);
12189}
12190
Daniel Jasperbe508362016-03-11 22:13:28 +000012191static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
12192 vector long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012193 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012194 (vector long long)__b);
12195}
12196
Daniel Jasperbe508362016-03-11 22:13:28 +000012197static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
12198 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012199 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012200 (vector long long)__b);
12201}
12202
Daniel Jasperbe508362016-03-11 22:13:28 +000012203static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a,
12204 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012205 return __builtin_altivec_vcmpequd_p(__CR6_LT, (vector long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012206 (vector long long)__b);
12207}
12208#endif
12209
Daniel Jasperbe508362016-03-11 22:13:28 +000012210static __inline__ int __ATTRS_o_ai vec_all_eq(vector float __a,
12211 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012212#ifdef __VSX__
12213 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __b);
12214#else
David Blaikie3302f2b2013-01-16 23:08:36 +000012215 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012216#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000012217}
12218
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012219#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012220static __inline__ int __ATTRS_o_ai vec_all_eq(vector double __a,
12221 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012222 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __b);
12223}
12224#endif
12225
Chris Lattnerdad40622010-04-14 03:54:58 +000012226/* vec_all_ge */
12227
Daniel Jasperbe508362016-03-11 22:13:28 +000012228static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a,
12229 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012230 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012231}
12232
Daniel Jasperbe508362016-03-11 22:13:28 +000012233static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a,
12234 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012235 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012236}
12237
Daniel Jasperbe508362016-03-11 22:13:28 +000012238static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a,
12239 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012240 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012241}
12242
Daniel Jasperbe508362016-03-11 22:13:28 +000012243static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a,
12244 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012245 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012246}
12247
Daniel Jasperbe508362016-03-11 22:13:28 +000012248static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
12249 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012250 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012251 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012252}
12253
Daniel Jasperbe508362016-03-11 22:13:28 +000012254static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
12255 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012256 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012257}
12258
Daniel Jasperbe508362016-03-11 22:13:28 +000012259static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a,
12260 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012261 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012262 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012263}
12264
Daniel Jasperbe508362016-03-11 22:13:28 +000012265static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a,
12266 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012267 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012268}
12269
Daniel Jasperbe508362016-03-11 22:13:28 +000012270static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a,
12271 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012272 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector short)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012273}
12274
Daniel Jasperbe508362016-03-11 22:13:28 +000012275static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a,
12276 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012277 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012278}
12279
Daniel Jasperbe508362016-03-11 22:13:28 +000012280static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a,
12281 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012282 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
12283 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012284}
12285
Daniel Jasperbe508362016-03-11 22:13:28 +000012286static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
12287 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012288 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012289 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012290}
12291
Daniel Jasperbe508362016-03-11 22:13:28 +000012292static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
12293 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012294 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012295 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012296}
12297
Daniel Jasperbe508362016-03-11 22:13:28 +000012298static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
12299 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012300 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b,
12301 (vector unsigned short)__a);
12302}
12303
Daniel Jasperbe508362016-03-11 22:13:28 +000012304static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012305 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012306}
12307
Daniel Jasperbe508362016-03-11 22:13:28 +000012308static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a,
12309 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012310 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector int)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012311}
12312
Daniel Jasperbe508362016-03-11 22:13:28 +000012313static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a,
12314 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012315 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012316}
12317
Daniel Jasperbe508362016-03-11 22:13:28 +000012318static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a,
12319 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012320 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012321}
12322
Daniel Jasperbe508362016-03-11 22:13:28 +000012323static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
12324 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012325 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012326 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012327}
12328
Daniel Jasperbe508362016-03-11 22:13:28 +000012329static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
12330 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012331 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012332}
12333
Daniel Jasperbe508362016-03-11 22:13:28 +000012334static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
12335 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012336 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012337 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012338}
12339
Kit Barton8553bec2015-03-11 15:57:19 +000012340#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000012341static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
12342 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012343 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, __a);
12344}
Daniel Jasperbe508362016-03-11 22:13:28 +000012345static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a,
12346 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012347 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b,
12348 __a);
12349}
12350
Daniel Jasperbe508362016-03-11 22:13:28 +000012351static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a,
12352 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012353 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b, __a);
12354}
12355
Daniel Jasperbe508362016-03-11 22:13:28 +000012356static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a,
12357 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012358 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
12359 __a);
12360}
12361
Daniel Jasperbe508362016-03-11 22:13:28 +000012362static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
12363 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012364 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
Kit Barton8553bec2015-03-11 15:57:19 +000012365 (vector unsigned long long)__a);
12366}
12367
Daniel Jasperbe508362016-03-11 22:13:28 +000012368static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
12369 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012370 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b,
12371 (vector unsigned long long)__a);
12372}
12373
Daniel Jasperbe508362016-03-11 22:13:28 +000012374static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a,
12375 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012376 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
Kit Barton8553bec2015-03-11 15:57:19 +000012377 (vector unsigned long long)__a);
12378}
12379#endif
12380
Daniel Jasperbe508362016-03-11 22:13:28 +000012381static __inline__ int __ATTRS_o_ai vec_all_ge(vector float __a,
12382 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012383#ifdef __VSX__
12384 return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __a, __b);
12385#else
David Blaikie3302f2b2013-01-16 23:08:36 +000012386 return __builtin_altivec_vcmpgefp_p(__CR6_LT, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012387#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000012388}
12389
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012390#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012391static __inline__ int __ATTRS_o_ai vec_all_ge(vector double __a,
12392 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012393 return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __a, __b);
12394}
12395#endif
12396
Chris Lattnerdad40622010-04-14 03:54:58 +000012397/* vec_all_gt */
12398
Daniel Jasperbe508362016-03-11 22:13:28 +000012399static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a,
12400 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012401 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012402}
12403
Daniel Jasperbe508362016-03-11 22:13:28 +000012404static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a,
12405 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012406 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, (vector signed char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012407}
12408
Daniel Jasperbe508362016-03-11 22:13:28 +000012409static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a,
12410 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012411 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012412}
12413
Daniel Jasperbe508362016-03-11 22:13:28 +000012414static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a,
12415 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012416 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012417}
12418
Daniel Jasperbe508362016-03-11 22:13:28 +000012419static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
12420 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012421 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012422 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012423}
12424
Daniel Jasperbe508362016-03-11 22:13:28 +000012425static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
12426 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012427 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a, __b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012428}
12429
Daniel Jasperbe508362016-03-11 22:13:28 +000012430static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a,
12431 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012432 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012433 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012434}
12435
Daniel Jasperbe508362016-03-11 22:13:28 +000012436static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a,
12437 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012438 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012439}
12440
Daniel Jasperbe508362016-03-11 22:13:28 +000012441static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a,
12442 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012443 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012444}
12445
Daniel Jasperbe508362016-03-11 22:13:28 +000012446static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a,
12447 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012448 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012449}
12450
Daniel Jasperbe508362016-03-11 22:13:28 +000012451static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a,
12452 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012453 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012454 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012455}
12456
Daniel Jasperbe508362016-03-11 22:13:28 +000012457static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
12458 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012459 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012460 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012461}
12462
Daniel Jasperbe508362016-03-11 22:13:28 +000012463static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
12464 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012465 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
12466 __b);
12467}
12468
Daniel Jasperbe508362016-03-11 22:13:28 +000012469static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
12470 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012471 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a,
12472 (vector unsigned short)__b);
12473}
12474
Daniel Jasperbe508362016-03-11 22:13:28 +000012475static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012476 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012477}
12478
Daniel Jasperbe508362016-03-11 22:13:28 +000012479static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a,
12480 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012481 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012482}
12483
Daniel Jasperbe508362016-03-11 22:13:28 +000012484static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a,
12485 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012486 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012487}
12488
Daniel Jasperbe508362016-03-11 22:13:28 +000012489static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a,
12490 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012491 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012492}
12493
Daniel Jasperbe508362016-03-11 22:13:28 +000012494static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
12495 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012496 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012497 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012498}
12499
Daniel Jasperbe508362016-03-11 22:13:28 +000012500static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
12501 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012502 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a, __b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012503}
12504
Daniel Jasperbe508362016-03-11 22:13:28 +000012505static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a,
12506 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012507 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012508 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012509}
12510
Kit Barton8553bec2015-03-11 15:57:19 +000012511#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000012512static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
12513 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012514 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a, __b);
12515}
Daniel Jasperbe508362016-03-11 22:13:28 +000012516static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a,
12517 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012518 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a,
12519 (vector signed long long)__b);
12520}
12521
Daniel Jasperbe508362016-03-11 22:13:28 +000012522static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a,
12523 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012524 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a, __b);
12525}
12526
Daniel Jasperbe508362016-03-11 22:13:28 +000012527static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a,
12528 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012529 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a,
Kit Barton8553bec2015-03-11 15:57:19 +000012530 (vector unsigned long long)__b);
12531}
12532
Daniel Jasperbe508362016-03-11 22:13:28 +000012533static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
12534 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012535 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012536 (vector unsigned long long)__b);
12537}
12538
Daniel Jasperbe508362016-03-11 22:13:28 +000012539static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
12540 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012541 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
12542 __b);
12543}
12544
Daniel Jasperbe508362016-03-11 22:13:28 +000012545static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a,
12546 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012547 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012548 (vector unsigned long long)__b);
12549}
12550#endif
12551
Daniel Jasperbe508362016-03-11 22:13:28 +000012552static __inline__ int __ATTRS_o_ai vec_all_gt(vector float __a,
12553 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012554#ifdef __VSX__
12555 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __a, __b);
12556#else
David Blaikie3302f2b2013-01-16 23:08:36 +000012557 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012558#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000012559}
12560
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012561#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012562static __inline__ int __ATTRS_o_ai vec_all_gt(vector double __a,
12563 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012564 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __a, __b);
12565}
12566#endif
12567
Chris Lattnerdad40622010-04-14 03:54:58 +000012568/* vec_all_in */
12569
Daniel Jasperbe508362016-03-11 22:13:28 +000012570static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000012571vec_all_in(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012572 return __builtin_altivec_vcmpbfp_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012573}
12574
12575/* vec_all_le */
12576
Daniel Jasperbe508362016-03-11 22:13:28 +000012577static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a,
12578 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012579 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012580}
12581
Daniel Jasperbe508362016-03-11 22:13:28 +000012582static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a,
12583 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012584 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, (vector signed char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012585}
12586
Daniel Jasperbe508362016-03-11 22:13:28 +000012587static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a,
12588 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012589 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012590}
12591
Daniel Jasperbe508362016-03-11 22:13:28 +000012592static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a,
12593 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012594 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012595}
12596
Daniel Jasperbe508362016-03-11 22:13:28 +000012597static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
12598 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012599 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012600 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012601}
12602
Daniel Jasperbe508362016-03-11 22:13:28 +000012603static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
12604 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012605 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a, __b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012606}
12607
Daniel Jasperbe508362016-03-11 22:13:28 +000012608static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a,
12609 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012610 return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012611 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012612}
12613
Daniel Jasperbe508362016-03-11 22:13:28 +000012614static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a,
12615 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012616 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012617}
12618
Daniel Jasperbe508362016-03-11 22:13:28 +000012619static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a,
12620 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012621 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012622}
12623
Daniel Jasperbe508362016-03-11 22:13:28 +000012624static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a,
12625 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012626 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012627}
12628
Daniel Jasperbe508362016-03-11 22:13:28 +000012629static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a,
12630 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012631 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012632 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012633}
12634
Daniel Jasperbe508362016-03-11 22:13:28 +000012635static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
12636 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012637 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012638 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012639}
12640
Daniel Jasperbe508362016-03-11 22:13:28 +000012641static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
12642 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012643 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
12644 __b);
12645}
12646
Daniel Jasperbe508362016-03-11 22:13:28 +000012647static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a,
12648 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012649 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a,
12650 (vector unsigned short)__b);
12651}
12652
Daniel Jasperbe508362016-03-11 22:13:28 +000012653static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012654 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012655}
12656
Daniel Jasperbe508362016-03-11 22:13:28 +000012657static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a,
12658 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012659 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012660}
12661
Daniel Jasperbe508362016-03-11 22:13:28 +000012662static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a,
12663 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012664 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012665}
12666
Daniel Jasperbe508362016-03-11 22:13:28 +000012667static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a,
12668 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012669 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012670}
12671
Daniel Jasperbe508362016-03-11 22:13:28 +000012672static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
12673 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012674 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012675 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012676}
12677
Daniel Jasperbe508362016-03-11 22:13:28 +000012678static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
12679 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012680 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a, __b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012681}
12682
Daniel Jasperbe508362016-03-11 22:13:28 +000012683static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a,
12684 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012685 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000012686 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012687}
12688
Kit Barton8553bec2015-03-11 15:57:19 +000012689#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000012690static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
12691 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012692 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a, __b);
12693}
12694
Daniel Jasperbe508362016-03-11 22:13:28 +000012695static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a,
12696 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012697 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a, __b);
12698}
12699
Daniel Jasperbe508362016-03-11 22:13:28 +000012700static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a,
12701 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012702 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a,
12703 (vector signed long long)__b);
12704}
12705
Daniel Jasperbe508362016-03-11 22:13:28 +000012706static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a,
12707 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012708 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a,
Kit Barton8553bec2015-03-11 15:57:19 +000012709 (vector unsigned long long)__b);
12710}
12711
Daniel Jasperbe508362016-03-11 22:13:28 +000012712static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
12713 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012714 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012715 (vector unsigned long long)__b);
12716}
12717
Daniel Jasperbe508362016-03-11 22:13:28 +000012718static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
12719 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012720 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
12721 __b);
12722}
12723
Daniel Jasperbe508362016-03-11 22:13:28 +000012724static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a,
12725 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012726 return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000012727 (vector unsigned long long)__b);
12728}
12729#endif
12730
Daniel Jasperbe508362016-03-11 22:13:28 +000012731static __inline__ int __ATTRS_o_ai vec_all_le(vector float __a,
12732 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012733#ifdef __VSX__
12734 return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __b, __a);
12735#else
David Blaikie3302f2b2013-01-16 23:08:36 +000012736 return __builtin_altivec_vcmpgefp_p(__CR6_LT, __b, __a);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012737#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000012738}
12739
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012740#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012741static __inline__ int __ATTRS_o_ai vec_all_le(vector double __a,
12742 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012743 return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __b, __a);
12744}
12745#endif
12746
Chris Lattnerdad40622010-04-14 03:54:58 +000012747/* vec_all_lt */
12748
Daniel Jasperbe508362016-03-11 22:13:28 +000012749static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a,
12750 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012751 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012752}
12753
Daniel Jasperbe508362016-03-11 22:13:28 +000012754static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a,
12755 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012756 return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012757}
12758
Daniel Jasperbe508362016-03-11 22:13:28 +000012759static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a,
12760 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012761 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012762}
12763
Daniel Jasperbe508362016-03-11 22:13:28 +000012764static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a,
12765 vector bool char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012766 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012767}
12768
Daniel Jasperbe508362016-03-11 22:13:28 +000012769static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
12770 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012771 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012772 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012773}
12774
Daniel Jasperbe508362016-03-11 22:13:28 +000012775static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
12776 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012777 return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012778}
12779
Daniel Jasperbe508362016-03-11 22:13:28 +000012780static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a,
12781 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012782 return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012783 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012784}
12785
Daniel Jasperbe508362016-03-11 22:13:28 +000012786static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a,
12787 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012788 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012789}
12790
Daniel Jasperbe508362016-03-11 22:13:28 +000012791static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a,
12792 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012793 return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector short)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012794}
12795
Daniel Jasperbe508362016-03-11 22:13:28 +000012796static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a,
12797 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012798 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012799}
12800
Daniel Jasperbe508362016-03-11 22:13:28 +000012801static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a,
12802 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012803 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
12804 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012805}
12806
Daniel Jasperbe508362016-03-11 22:13:28 +000012807static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
12808 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012809 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012810 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012811}
12812
Daniel Jasperbe508362016-03-11 22:13:28 +000012813static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
12814 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012815 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012816 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012817}
12818
Daniel Jasperbe508362016-03-11 22:13:28 +000012819static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a,
12820 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012821 return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b,
12822 (vector unsigned short)__a);
12823}
12824
Daniel Jasperbe508362016-03-11 22:13:28 +000012825static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012826 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012827}
12828
Daniel Jasperbe508362016-03-11 22:13:28 +000012829static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a,
12830 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012831 return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector int)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012832}
12833
Daniel Jasperbe508362016-03-11 22:13:28 +000012834static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a,
12835 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012836 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000012837}
12838
Daniel Jasperbe508362016-03-11 22:13:28 +000012839static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a,
12840 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012841 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012842}
12843
Daniel Jasperbe508362016-03-11 22:13:28 +000012844static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
12845 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012846 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012847 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012848}
12849
Daniel Jasperbe508362016-03-11 22:13:28 +000012850static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
12851 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012852 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012853}
12854
Daniel Jasperbe508362016-03-11 22:13:28 +000012855static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a,
12856 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012857 return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000012858 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012859}
12860
Kit Barton8553bec2015-03-11 15:57:19 +000012861#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000012862static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
12863 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012864 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, __a);
12865}
12866
Daniel Jasperbe508362016-03-11 22:13:28 +000012867static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a,
12868 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012869 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b, __a);
12870}
12871
Daniel Jasperbe508362016-03-11 22:13:28 +000012872static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a,
12873 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012874 return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__b,
12875 __a);
12876}
12877
Daniel Jasperbe508362016-03-11 22:13:28 +000012878static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a,
12879 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012880 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
12881 __a);
12882}
12883
Daniel Jasperbe508362016-03-11 22:13:28 +000012884static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
12885 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012886 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
Kit Barton8553bec2015-03-11 15:57:19 +000012887 (vector unsigned long long)__a);
12888}
12889
Daniel Jasperbe508362016-03-11 22:13:28 +000012890static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
12891 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000012892 return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b,
12893 (vector unsigned long long)__a);
12894}
12895
Daniel Jasperbe508362016-03-11 22:13:28 +000012896static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a,
12897 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012898 return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b,
Kit Barton8553bec2015-03-11 15:57:19 +000012899 (vector unsigned long long)__a);
12900}
12901#endif
12902
Daniel Jasperbe508362016-03-11 22:13:28 +000012903static __inline__ int __ATTRS_o_ai vec_all_lt(vector float __a,
12904 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012905#ifdef __VSX__
12906 return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __b, __a);
12907#else
David Blaikie3302f2b2013-01-16 23:08:36 +000012908 return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __b, __a);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012909#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000012910}
12911
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012912#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012913static __inline__ int __ATTRS_o_ai vec_all_lt(vector double __a,
12914 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012915 return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __b, __a);
12916}
12917#endif
12918
Chris Lattnerdad40622010-04-14 03:54:58 +000012919/* vec_all_nan */
12920
Daniel Jasperbe508362016-03-11 22:13:28 +000012921static __inline__ int __ATTRS_o_ai vec_all_nan(vector float __a) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012922#ifdef __VSX__
12923 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __a);
12924#else
David Blaikie3302f2b2013-01-16 23:08:36 +000012925 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __a);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012926#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000012927}
12928
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012929#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000012930static __inline__ int __ATTRS_o_ai vec_all_nan(vector double __a) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000012931 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __a);
12932}
12933#endif
12934
Chris Lattnerdad40622010-04-14 03:54:58 +000012935/* vec_all_ne */
12936
Daniel Jasperbe508362016-03-11 22:13:28 +000012937static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a,
12938 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012939 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12940 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012941}
12942
Daniel Jasperbe508362016-03-11 22:13:28 +000012943static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a,
12944 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012945 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12946 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012947}
12948
Daniel Jasperbe508362016-03-11 22:13:28 +000012949static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a,
12950 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012951 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12952 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012953}
12954
Daniel Jasperbe508362016-03-11 22:13:28 +000012955static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a,
12956 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012957 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12958 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012959}
12960
Daniel Jasperbe508362016-03-11 22:13:28 +000012961static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
12962 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012963 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12964 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012965}
12966
Daniel Jasperbe508362016-03-11 22:13:28 +000012967static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
12968 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012969 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12970 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012971}
12972
Daniel Jasperbe508362016-03-11 22:13:28 +000012973static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a,
12974 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012975 return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a,
12976 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012977}
12978
Daniel Jasperbe508362016-03-11 22:13:28 +000012979static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a,
12980 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012981 return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012982}
12983
Daniel Jasperbe508362016-03-11 22:13:28 +000012984static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a,
12985 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000012986 return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012987}
12988
Daniel Jasperbe508362016-03-11 22:13:28 +000012989static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a,
12990 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012991 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
12992 (vector short)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000012993}
12994
Daniel Jasperbe508362016-03-11 22:13:28 +000012995static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a,
12996 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000012997 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
12998 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000012999}
13000
Daniel Jasperbe508362016-03-11 22:13:28 +000013001static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
13002 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013003 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
13004 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013005}
13006
Daniel Jasperbe508362016-03-11 22:13:28 +000013007static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
13008 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013009 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
13010 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013011}
13012
Daniel Jasperbe508362016-03-11 22:13:28 +000013013static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a,
13014 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013015 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
13016 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013017}
13018
Daniel Jasperbe508362016-03-11 22:13:28 +000013019static __inline__ int __ATTRS_o_ai vec_all_ne(vector pixel __a,
13020 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013021 return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a,
13022 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013023}
13024
Daniel Jasperbe508362016-03-11 22:13:28 +000013025static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013026 return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013027}
13028
Daniel Jasperbe508362016-03-11 22:13:28 +000013029static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a,
13030 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013031 return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013032}
13033
Daniel Jasperbe508362016-03-11 22:13:28 +000013034static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a,
13035 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013036 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
13037 (vector int)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013038}
13039
Daniel Jasperbe508362016-03-11 22:13:28 +000013040static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a,
13041 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013042 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
13043 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013044}
13045
Daniel Jasperbe508362016-03-11 22:13:28 +000013046static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
13047 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013048 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
13049 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013050}
13051
Daniel Jasperbe508362016-03-11 22:13:28 +000013052static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
13053 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013054 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
13055 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013056}
13057
Daniel Jasperbe508362016-03-11 22:13:28 +000013058static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a,
13059 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013060 return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a,
13061 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013062}
13063
Kit Barton8553bec2015-03-11 15:57:19 +000013064#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000013065static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
13066 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013067 return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a, __b);
13068}
13069
Daniel Jasperbe508362016-03-11 22:13:28 +000013070static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a,
13071 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013072 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000013073 (vector long long)__b);
13074}
13075
Daniel Jasperbe508362016-03-11 22:13:28 +000013076static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a,
13077 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013078 return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a,
13079 (vector signed long long)__b);
13080}
13081
Daniel Jasperbe508362016-03-11 22:13:28 +000013082static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a,
13083 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013084 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
13085 (vector signed long long)__b);
13086}
13087
Daniel Jasperbe508362016-03-11 22:13:28 +000013088static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
13089 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013090 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000013091 (vector signed long long)__b);
13092}
13093
Daniel Jasperbe508362016-03-11 22:13:28 +000013094static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
13095 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013096 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
13097 (vector signed long long)__b);
13098}
13099
Daniel Jasperbe508362016-03-11 22:13:28 +000013100static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a,
13101 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013102 return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a,
Kit Barton8553bec2015-03-11 15:57:19 +000013103 (vector signed long long)__b);
13104}
13105#endif
13106
Daniel Jasperbe508362016-03-11 22:13:28 +000013107static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a,
13108 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013109#ifdef __VSX__
13110 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __b);
13111#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013112 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013113#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013114}
13115
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013116#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013117static __inline__ int __ATTRS_o_ai vec_all_ne(vector double __a,
13118 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013119 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __b);
13120}
13121#endif
13122
Chris Lattnerdad40622010-04-14 03:54:58 +000013123/* vec_all_nge */
13124
Daniel Jasperbe508362016-03-11 22:13:28 +000013125static __inline__ int __ATTRS_o_ai vec_all_nge(vector float __a,
13126 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013127#ifdef __VSX__
13128 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __a, __b);
13129#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013130 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013131#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013132}
13133
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013134#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013135static __inline__ int __ATTRS_o_ai vec_all_nge(vector double __a,
13136 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013137 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __a, __b);
13138}
13139#endif
13140
Chris Lattnerdad40622010-04-14 03:54:58 +000013141/* vec_all_ngt */
13142
Daniel Jasperbe508362016-03-11 22:13:28 +000013143static __inline__ int __ATTRS_o_ai vec_all_ngt(vector float __a,
13144 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013145#ifdef __VSX__
13146 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __a, __b);
13147#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013148 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013149#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013150}
13151
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013152#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013153static __inline__ int __ATTRS_o_ai vec_all_ngt(vector double __a,
13154 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013155 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __a, __b);
13156}
13157#endif
13158
Chris Lattnerdad40622010-04-14 03:54:58 +000013159/* vec_all_nle */
13160
Daniel Jasperbe508362016-03-11 22:13:28 +000013161static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000013162vec_all_nle(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013163 return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013164}
13165
13166/* vec_all_nlt */
13167
Daniel Jasperbe508362016-03-11 22:13:28 +000013168static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000013169vec_all_nlt(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013170 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013171}
13172
13173/* vec_all_numeric */
13174
Daniel Jasperbe508362016-03-11 22:13:28 +000013175static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000013176vec_all_numeric(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013177 return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013178}
13179
13180/* vec_any_eq */
13181
Daniel Jasperbe508362016-03-11 22:13:28 +000013182static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a,
13183 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013184 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13185 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013186}
13187
Daniel Jasperbe508362016-03-11 22:13:28 +000013188static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a,
13189 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013190 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13191 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013192}
13193
Daniel Jasperbe508362016-03-11 22:13:28 +000013194static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a,
13195 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013196 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13197 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013198}
13199
Daniel Jasperbe508362016-03-11 22:13:28 +000013200static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a,
13201 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013202 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13203 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013204}
13205
Daniel Jasperbe508362016-03-11 22:13:28 +000013206static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
13207 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013208 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13209 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013210}
13211
Daniel Jasperbe508362016-03-11 22:13:28 +000013212static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
13213 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013214 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13215 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013216}
13217
Daniel Jasperbe508362016-03-11 22:13:28 +000013218static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a,
13219 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013220 return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a,
13221 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013222}
13223
Daniel Jasperbe508362016-03-11 22:13:28 +000013224static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a,
13225 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013226 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013227}
13228
Daniel Jasperbe508362016-03-11 22:13:28 +000013229static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a,
13230 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013231 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013232}
13233
Daniel Jasperbe508362016-03-11 22:13:28 +000013234static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a,
13235 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013236 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013237 (vector short)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013238}
13239
Daniel Jasperbe508362016-03-11 22:13:28 +000013240static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a,
13241 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013242 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013243 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013244}
13245
Daniel Jasperbe508362016-03-11 22:13:28 +000013246static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
13247 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013248 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013249 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013250}
13251
Daniel Jasperbe508362016-03-11 22:13:28 +000013252static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
13253 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013254 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013255 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013256}
13257
Daniel Jasperbe508362016-03-11 22:13:28 +000013258static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a,
13259 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013260 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013261 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013262}
13263
Daniel Jasperbe508362016-03-11 22:13:28 +000013264static __inline__ int __ATTRS_o_ai vec_any_eq(vector pixel __a,
13265 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013266 return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013267 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013268}
13269
Daniel Jasperbe508362016-03-11 22:13:28 +000013270static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013271 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013272}
13273
Daniel Jasperbe508362016-03-11 22:13:28 +000013274static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a,
13275 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013276 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013277}
13278
Daniel Jasperbe508362016-03-11 22:13:28 +000013279static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a,
13280 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013281 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
13282 (vector int)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013283}
13284
Daniel Jasperbe508362016-03-11 22:13:28 +000013285static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a,
13286 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013287 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
13288 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013289}
13290
Daniel Jasperbe508362016-03-11 22:13:28 +000013291static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
13292 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013293 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
13294 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013295}
13296
Daniel Jasperbe508362016-03-11 22:13:28 +000013297static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
13298 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013299 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
13300 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013301}
13302
Daniel Jasperbe508362016-03-11 22:13:28 +000013303static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a,
13304 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013305 return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a,
13306 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013307}
13308
Kit Barton8553bec2015-03-11 15:57:19 +000013309#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000013310static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
13311 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013312 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a, __b);
13313}
13314
Daniel Jasperbe508362016-03-11 22:13:28 +000013315static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a,
13316 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013317 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, (vector long long)__a,
13318 (vector long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000013319}
13320
Daniel Jasperbe508362016-03-11 22:13:28 +000013321static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a,
13322 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013323 return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a,
13324 (vector signed long long)__b);
13325}
13326
Daniel Jasperbe508362016-03-11 22:13:28 +000013327static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a,
13328 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013329 return __builtin_altivec_vcmpequd_p(
13330 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000013331}
13332
Daniel Jasperbe508362016-03-11 22:13:28 +000013333static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
13334 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013335 return __builtin_altivec_vcmpequd_p(
13336 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000013337}
13338
Daniel Jasperbe508362016-03-11 22:13:28 +000013339static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
13340 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013341 return __builtin_altivec_vcmpequd_p(
13342 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000013343}
13344
Daniel Jasperbe508362016-03-11 22:13:28 +000013345static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a,
13346 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013347 return __builtin_altivec_vcmpequd_p(
13348 __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000013349}
13350#endif
13351
Daniel Jasperbe508362016-03-11 22:13:28 +000013352static __inline__ int __ATTRS_o_ai vec_any_eq(vector float __a,
13353 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013354#ifdef __VSX__
13355 return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __b);
13356#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013357 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013358#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013359}
13360
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013361#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013362static __inline__ int __ATTRS_o_ai vec_any_eq(vector double __a,
13363 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013364 return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __b);
13365}
13366#endif
13367
Chris Lattnerdad40622010-04-14 03:54:58 +000013368/* vec_any_ge */
13369
Daniel Jasperbe508362016-03-11 22:13:28 +000013370static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a,
13371 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013372 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013373}
13374
Daniel Jasperbe508362016-03-11 22:13:28 +000013375static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a,
13376 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013377 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__b,
13378 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013379}
13380
Daniel Jasperbe508362016-03-11 22:13:28 +000013381static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a,
13382 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013383 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013384}
13385
Daniel Jasperbe508362016-03-11 22:13:28 +000013386static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a,
13387 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013388 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
13389 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013390}
13391
Daniel Jasperbe508362016-03-11 22:13:28 +000013392static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
13393 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013394 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013395 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013396}
13397
Daniel Jasperbe508362016-03-11 22:13:28 +000013398static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
13399 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013400 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013401 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013402}
13403
Daniel Jasperbe508362016-03-11 22:13:28 +000013404static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a,
13405 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013406 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b,
13407 (vector unsigned char)__a);
13408}
13409
Daniel Jasperbe508362016-03-11 22:13:28 +000013410static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a,
13411 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013412 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013413}
13414
Daniel Jasperbe508362016-03-11 22:13:28 +000013415static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a,
13416 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013417 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector short)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013418}
13419
Daniel Jasperbe508362016-03-11 22:13:28 +000013420static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a,
13421 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013422 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013423}
13424
Daniel Jasperbe508362016-03-11 22:13:28 +000013425static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a,
13426 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013427 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
13428 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013429}
13430
Daniel Jasperbe508362016-03-11 22:13:28 +000013431static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
13432 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013433 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013434 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013435}
13436
Daniel Jasperbe508362016-03-11 22:13:28 +000013437static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
13438 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013439 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013440 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013441}
13442
Daniel Jasperbe508362016-03-11 22:13:28 +000013443static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a,
13444 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013445 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b,
13446 (vector unsigned short)__a);
13447}
13448
Daniel Jasperbe508362016-03-11 22:13:28 +000013449static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013450 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013451}
13452
Daniel Jasperbe508362016-03-11 22:13:28 +000013453static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a,
13454 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013455 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector int)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013456}
13457
Daniel Jasperbe508362016-03-11 22:13:28 +000013458static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a,
13459 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013460 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013461}
13462
Daniel Jasperbe508362016-03-11 22:13:28 +000013463static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a,
13464 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013465 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
13466 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013467}
13468
Daniel Jasperbe508362016-03-11 22:13:28 +000013469static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
13470 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013471 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013472 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013473}
13474
Daniel Jasperbe508362016-03-11 22:13:28 +000013475static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
13476 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013477 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b,
13478 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013479}
13480
Daniel Jasperbe508362016-03-11 22:13:28 +000013481static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a,
13482 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013483 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013484 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013485}
13486
Kit Barton8553bec2015-03-11 15:57:19 +000013487#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000013488static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
13489 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013490 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b, __a);
13491}
13492
Daniel Jasperbe508362016-03-11 22:13:28 +000013493static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a,
13494 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013495 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b, __a);
13496}
13497
Daniel Jasperbe508362016-03-11 22:13:28 +000013498static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a,
13499 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013500 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV,
13501 (vector signed long long)__b, __a);
13502}
13503
Daniel Jasperbe508362016-03-11 22:13:28 +000013504static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a,
13505 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013506 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
Kit Barton8553bec2015-03-11 15:57:19 +000013507 (vector unsigned long long)__b, __a);
13508}
13509
Daniel Jasperbe508362016-03-11 22:13:28 +000013510static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
13511 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013512 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
13513 (vector unsigned long long)__b,
13514 (vector unsigned long long)__a);
13515}
13516
Daniel Jasperbe508362016-03-11 22:13:28 +000013517static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
13518 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013519 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b,
13520 (vector unsigned long long)__a);
13521}
13522
Daniel Jasperbe508362016-03-11 22:13:28 +000013523static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a,
13524 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013525 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
13526 (vector unsigned long long)__b,
13527 (vector unsigned long long)__a);
13528}
13529#endif
13530
Daniel Jasperbe508362016-03-11 22:13:28 +000013531static __inline__ int __ATTRS_o_ai vec_any_ge(vector float __a,
13532 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013533#ifdef __VSX__
13534 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __a, __b);
13535#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013536 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013537#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013538}
13539
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013540#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013541static __inline__ int __ATTRS_o_ai vec_any_ge(vector double __a,
13542 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013543 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __a, __b);
13544}
13545#endif
13546
Chris Lattnerdad40622010-04-14 03:54:58 +000013547/* vec_any_gt */
13548
Daniel Jasperbe508362016-03-11 22:13:28 +000013549static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a,
13550 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013551 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013552}
13553
Daniel Jasperbe508362016-03-11 22:13:28 +000013554static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a,
13555 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013556 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a,
13557 (vector signed char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013558}
13559
Daniel Jasperbe508362016-03-11 22:13:28 +000013560static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a,
13561 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013562 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013563}
13564
Daniel Jasperbe508362016-03-11 22:13:28 +000013565static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a,
13566 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013567 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013568 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013569}
13570
Daniel Jasperbe508362016-03-11 22:13:28 +000013571static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
13572 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013573 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013574 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013575}
13576
Daniel Jasperbe508362016-03-11 22:13:28 +000013577static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
13578 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013579 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
13580 __b);
13581}
13582
Daniel Jasperbe508362016-03-11 22:13:28 +000013583static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a,
13584 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013585 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a,
13586 (vector unsigned char)__b);
13587}
13588
Daniel Jasperbe508362016-03-11 22:13:28 +000013589static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a,
13590 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013591 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013592}
13593
Daniel Jasperbe508362016-03-11 22:13:28 +000013594static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a,
13595 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013596 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013597}
13598
Daniel Jasperbe508362016-03-11 22:13:28 +000013599static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a,
13600 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013601 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013602}
13603
Daniel Jasperbe508362016-03-11 22:13:28 +000013604static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a,
13605 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013606 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013607 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013608}
13609
Daniel Jasperbe508362016-03-11 22:13:28 +000013610static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
13611 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013612 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013613 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013614}
13615
Daniel Jasperbe508362016-03-11 22:13:28 +000013616static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
13617 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013618 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
13619 __b);
13620}
13621
Daniel Jasperbe508362016-03-11 22:13:28 +000013622static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a,
13623 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013624 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a,
13625 (vector unsigned short)__b);
13626}
13627
Daniel Jasperbe508362016-03-11 22:13:28 +000013628static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013629 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013630}
13631
Daniel Jasperbe508362016-03-11 22:13:28 +000013632static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a,
13633 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013634 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013635}
13636
Daniel Jasperbe508362016-03-11 22:13:28 +000013637static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a,
13638 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013639 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013640}
13641
Daniel Jasperbe508362016-03-11 22:13:28 +000013642static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a,
13643 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013644 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013645 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013646}
13647
Daniel Jasperbe508362016-03-11 22:13:28 +000013648static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
13649 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013650 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
13651 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013652}
13653
Daniel Jasperbe508362016-03-11 22:13:28 +000013654static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
13655 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013656 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
13657 __b);
13658}
13659
Daniel Jasperbe508362016-03-11 22:13:28 +000013660static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a,
13661 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013662 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013663 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013664}
13665
Kit Barton8553bec2015-03-11 15:57:19 +000013666#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000013667static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a,
13668 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013669 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a, __b);
13670}
13671
Daniel Jasperbe508362016-03-11 22:13:28 +000013672static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a,
13673 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013674 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a, __b);
13675}
13676
Daniel Jasperbe508362016-03-11 22:13:28 +000013677static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a,
13678 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013679 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a,
13680 (vector signed long long)__b);
13681}
13682
Daniel Jasperbe508362016-03-11 22:13:28 +000013683static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a,
13684 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013685 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a,
Kit Barton8553bec2015-03-11 15:57:19 +000013686 (vector unsigned long long)__b);
13687}
13688
Daniel Jasperbe508362016-03-11 22:13:28 +000013689static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
13690 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013691 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
13692 (vector unsigned long long)__a,
13693 (vector unsigned long long)__b);
13694}
13695
Daniel Jasperbe508362016-03-11 22:13:28 +000013696static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
13697 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013698 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
Kit Barton8553bec2015-03-11 15:57:19 +000013699 (vector unsigned long long)__a, __b);
13700}
13701
Daniel Jasperbe508362016-03-11 22:13:28 +000013702static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a,
13703 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013704 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
13705 (vector unsigned long long)__a,
13706 (vector unsigned long long)__b);
13707}
13708#endif
13709
Daniel Jasperbe508362016-03-11 22:13:28 +000013710static __inline__ int __ATTRS_o_ai vec_any_gt(vector float __a,
13711 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013712#ifdef __VSX__
13713 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __a, __b);
13714#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013715 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013716#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013717}
13718
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013719#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013720static __inline__ int __ATTRS_o_ai vec_any_gt(vector double __a,
13721 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013722 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __a, __b);
13723}
13724#endif
13725
Chris Lattnerdad40622010-04-14 03:54:58 +000013726/* vec_any_le */
13727
Daniel Jasperbe508362016-03-11 22:13:28 +000013728static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a,
13729 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013730 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013731}
13732
Daniel Jasperbe508362016-03-11 22:13:28 +000013733static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a,
13734 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013735 return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a,
13736 (vector signed char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013737}
13738
Daniel Jasperbe508362016-03-11 22:13:28 +000013739static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a,
13740 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013741 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013742}
13743
Daniel Jasperbe508362016-03-11 22:13:28 +000013744static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a,
13745 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013746 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013747 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013748}
13749
Daniel Jasperbe508362016-03-11 22:13:28 +000013750static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
13751 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013752 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013753 (vector unsigned char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013754}
13755
Daniel Jasperbe508362016-03-11 22:13:28 +000013756static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
13757 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013758 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
13759 __b);
13760}
13761
Daniel Jasperbe508362016-03-11 22:13:28 +000013762static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a,
13763 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013764 return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a,
13765 (vector unsigned char)__b);
13766}
13767
Daniel Jasperbe508362016-03-11 22:13:28 +000013768static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a,
13769 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013770 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013771}
13772
Daniel Jasperbe508362016-03-11 22:13:28 +000013773static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a,
13774 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013775 return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013776}
13777
Daniel Jasperbe508362016-03-11 22:13:28 +000013778static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a,
13779 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013780 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013781}
13782
Daniel Jasperbe508362016-03-11 22:13:28 +000013783static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a,
13784 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013785 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013786 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013787}
13788
Daniel Jasperbe508362016-03-11 22:13:28 +000013789static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
13790 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013791 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013792 (vector unsigned short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013793}
13794
Daniel Jasperbe508362016-03-11 22:13:28 +000013795static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
13796 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013797 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
13798 __b);
13799}
13800
Daniel Jasperbe508362016-03-11 22:13:28 +000013801static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a,
13802 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013803 return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a,
13804 (vector unsigned short)__b);
13805}
13806
Daniel Jasperbe508362016-03-11 22:13:28 +000013807static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013808 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013809}
13810
Daniel Jasperbe508362016-03-11 22:13:28 +000013811static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a,
13812 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013813 return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013814}
13815
Daniel Jasperbe508362016-03-11 22:13:28 +000013816static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a,
13817 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013818 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000013819}
13820
Daniel Jasperbe508362016-03-11 22:13:28 +000013821static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a,
13822 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013823 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013824 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013825}
13826
Daniel Jasperbe508362016-03-11 22:13:28 +000013827static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
13828 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013829 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
13830 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013831}
13832
Daniel Jasperbe508362016-03-11 22:13:28 +000013833static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
13834 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013835 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
13836 __b);
13837}
13838
Daniel Jasperbe508362016-03-11 22:13:28 +000013839static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a,
13840 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013841 return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000013842 (vector unsigned int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013843}
13844
Kit Barton8553bec2015-03-11 15:57:19 +000013845#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000013846static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a,
13847 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013848 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a, __b);
13849}
13850
Daniel Jasperbe508362016-03-11 22:13:28 +000013851static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a,
13852 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013853 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a, __b);
13854}
13855
Daniel Jasperbe508362016-03-11 22:13:28 +000013856static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a,
13857 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013858 return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a,
13859 (vector signed long long)__b);
13860}
13861
Daniel Jasperbe508362016-03-11 22:13:28 +000013862static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a,
13863 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013864 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a,
Kit Barton8553bec2015-03-11 15:57:19 +000013865 (vector unsigned long long)__b);
13866}
13867
Daniel Jasperbe508362016-03-11 22:13:28 +000013868static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
13869 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013870 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
13871 (vector unsigned long long)__a,
13872 (vector unsigned long long)__b);
13873}
13874
Daniel Jasperbe508362016-03-11 22:13:28 +000013875static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
13876 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013877 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
Kit Barton8553bec2015-03-11 15:57:19 +000013878 (vector unsigned long long)__a, __b);
13879}
13880
Daniel Jasperbe508362016-03-11 22:13:28 +000013881static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a,
13882 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000013883 return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV,
13884 (vector unsigned long long)__a,
13885 (vector unsigned long long)__b);
13886}
13887#endif
13888
Daniel Jasperbe508362016-03-11 22:13:28 +000013889static __inline__ int __ATTRS_o_ai vec_any_le(vector float __a,
13890 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013891#ifdef __VSX__
13892 return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __b, __a);
13893#else
David Blaikie3302f2b2013-01-16 23:08:36 +000013894 return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __b, __a);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013895#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000013896}
13897
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013898#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000013899static __inline__ int __ATTRS_o_ai vec_any_le(vector double __a,
13900 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000013901 return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __b, __a);
13902}
13903#endif
13904
Chris Lattnerdad40622010-04-14 03:54:58 +000013905/* vec_any_lt */
13906
Daniel Jasperbe508362016-03-11 22:13:28 +000013907static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a,
13908 vector signed char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013909 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013910}
13911
Daniel Jasperbe508362016-03-11 22:13:28 +000013912static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a,
13913 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013914 return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__b,
13915 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013916}
13917
Daniel Jasperbe508362016-03-11 22:13:28 +000013918static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a,
13919 vector unsigned char __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013920 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013921}
13922
Daniel Jasperbe508362016-03-11 22:13:28 +000013923static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a,
13924 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013925 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
13926 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013927}
13928
Daniel Jasperbe508362016-03-11 22:13:28 +000013929static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
13930 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013931 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013932 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013933}
13934
Daniel Jasperbe508362016-03-11 22:13:28 +000013935static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
13936 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013937 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013938 (vector unsigned char)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013939}
13940
Daniel Jasperbe508362016-03-11 22:13:28 +000013941static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a,
13942 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013943 return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b,
13944 (vector unsigned char)__a);
13945}
13946
Daniel Jasperbe508362016-03-11 22:13:28 +000013947static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a,
13948 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013949 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013950}
13951
Daniel Jasperbe508362016-03-11 22:13:28 +000013952static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a,
13953 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013954 return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector short)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013955}
13956
Daniel Jasperbe508362016-03-11 22:13:28 +000013957static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a,
13958 vector unsigned short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013959 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013960}
13961
Daniel Jasperbe508362016-03-11 22:13:28 +000013962static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a,
13963 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013964 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
13965 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013966}
13967
Daniel Jasperbe508362016-03-11 22:13:28 +000013968static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
13969 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013970 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013971 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013972}
13973
Daniel Jasperbe508362016-03-11 22:13:28 +000013974static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
13975 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013976 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b,
David Blaikie3302f2b2013-01-16 23:08:36 +000013977 (vector unsigned short)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013978}
13979
Daniel Jasperbe508362016-03-11 22:13:28 +000013980static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a,
13981 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000013982 return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b,
13983 (vector unsigned short)__a);
13984}
13985
Daniel Jasperbe508362016-03-11 22:13:28 +000013986static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013987 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013988}
13989
Daniel Jasperbe508362016-03-11 22:13:28 +000013990static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a,
13991 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013992 return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector int)__b, __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000013993}
13994
Daniel Jasperbe508362016-03-11 22:13:28 +000013995static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a,
13996 vector unsigned int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000013997 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000013998}
13999
Daniel Jasperbe508362016-03-11 22:13:28 +000014000static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a,
14001 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014002 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
14003 __a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014004}
14005
Daniel Jasperbe508362016-03-11 22:13:28 +000014006static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
14007 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014008 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000014009 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014010}
14011
Daniel Jasperbe508362016-03-11 22:13:28 +000014012static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
14013 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014014 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b,
14015 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014016}
14017
Daniel Jasperbe508362016-03-11 22:13:28 +000014018static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a,
14019 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014020 return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b,
David Blaikie3302f2b2013-01-16 23:08:36 +000014021 (vector unsigned int)__a);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014022}
14023
Kit Barton8553bec2015-03-11 15:57:19 +000014024#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000014025static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a,
14026 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014027 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b, __a);
14028}
14029
Daniel Jasperbe508362016-03-11 22:13:28 +000014030static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a,
14031 vector unsigned long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014032 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b, __a);
14033}
14034
Daniel Jasperbe508362016-03-11 22:13:28 +000014035static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a,
14036 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014037 return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV,
14038 (vector signed long long)__b, __a);
14039}
14040
Daniel Jasperbe508362016-03-11 22:13:28 +000014041static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a,
14042 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014043 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
Kit Barton8553bec2015-03-11 15:57:19 +000014044 (vector unsigned long long)__b, __a);
14045}
14046
Daniel Jasperbe508362016-03-11 22:13:28 +000014047static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
14048 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014049 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
14050 (vector unsigned long long)__b,
14051 (vector unsigned long long)__a);
14052}
14053
Daniel Jasperbe508362016-03-11 22:13:28 +000014054static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
14055 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014056 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b,
Kit Barton8553bec2015-03-11 15:57:19 +000014057 (vector unsigned long long)__a);
14058}
14059
Daniel Jasperbe508362016-03-11 22:13:28 +000014060static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a,
14061 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014062 return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV,
14063 (vector unsigned long long)__b,
14064 (vector unsigned long long)__a);
14065}
14066#endif
14067
Daniel Jasperbe508362016-03-11 22:13:28 +000014068static __inline__ int __ATTRS_o_ai vec_any_lt(vector float __a,
14069 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014070#ifdef __VSX__
14071 return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __b, __a);
14072#else
David Blaikie3302f2b2013-01-16 23:08:36 +000014073 return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __b, __a);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014074#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000014075}
14076
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014077#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000014078static __inline__ int __ATTRS_o_ai vec_any_lt(vector double __a,
14079 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014080 return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __b, __a);
14081}
14082#endif
14083
Chris Lattnerdad40622010-04-14 03:54:58 +000014084/* vec_any_nan */
14085
Daniel Jasperbe508362016-03-11 22:13:28 +000014086static __inline__ int __attribute__((__always_inline__))
14087vec_any_nan(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014088 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000014089}
14090
14091/* vec_any_ne */
14092
Daniel Jasperbe508362016-03-11 22:13:28 +000014093static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a,
14094 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014095 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14096 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014097}
14098
Daniel Jasperbe508362016-03-11 22:13:28 +000014099static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a,
14100 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014101 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14102 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014103}
14104
Daniel Jasperbe508362016-03-11 22:13:28 +000014105static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a,
14106 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014107 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14108 (vector char)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014109}
14110
Daniel Jasperbe508362016-03-11 22:13:28 +000014111static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a,
14112 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014113 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14114 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014115}
14116
Daniel Jasperbe508362016-03-11 22:13:28 +000014117static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
14118 vector signed char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014119 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14120 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014121}
14122
Daniel Jasperbe508362016-03-11 22:13:28 +000014123static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
14124 vector unsigned char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014125 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14126 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014127}
14128
Daniel Jasperbe508362016-03-11 22:13:28 +000014129static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a,
14130 vector bool char __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014131 return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a,
14132 (vector char)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014133}
14134
Daniel Jasperbe508362016-03-11 22:13:28 +000014135static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a,
14136 vector short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014137 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014138}
14139
Daniel Jasperbe508362016-03-11 22:13:28 +000014140static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a,
14141 vector bool short __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014142 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014143}
14144
Daniel Jasperbe508362016-03-11 22:13:28 +000014145static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a,
14146 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014147 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000014148 (vector short)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014149}
14150
Daniel Jasperbe508362016-03-11 22:13:28 +000014151static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a,
14152 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014153 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000014154 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014155}
14156
Daniel Jasperbe508362016-03-11 22:13:28 +000014157static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
14158 vector short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014159 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000014160 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014161}
14162
Daniel Jasperbe508362016-03-11 22:13:28 +000014163static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
14164 vector unsigned short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014165 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000014166 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014167}
14168
Daniel Jasperbe508362016-03-11 22:13:28 +000014169static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a,
14170 vector bool short __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014171 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000014172 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014173}
14174
Daniel Jasperbe508362016-03-11 22:13:28 +000014175static __inline__ int __ATTRS_o_ai vec_any_ne(vector pixel __a,
14176 vector pixel __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014177 return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a,
David Blaikie3302f2b2013-01-16 23:08:36 +000014178 (vector short)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014179}
14180
Daniel Jasperbe508362016-03-11 22:13:28 +000014181static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a, vector int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014182 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014183}
14184
Daniel Jasperbe508362016-03-11 22:13:28 +000014185static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a,
14186 vector bool int __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014187 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014188}
14189
Daniel Jasperbe508362016-03-11 22:13:28 +000014190static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a,
14191 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014192 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
14193 (vector int)__b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014194}
14195
Daniel Jasperbe508362016-03-11 22:13:28 +000014196static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a,
14197 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014198 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
14199 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014200}
14201
Daniel Jasperbe508362016-03-11 22:13:28 +000014202static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
14203 vector int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014204 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
14205 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014206}
14207
Daniel Jasperbe508362016-03-11 22:13:28 +000014208static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
14209 vector unsigned int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014210 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
14211 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014212}
14213
Daniel Jasperbe508362016-03-11 22:13:28 +000014214static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a,
14215 vector bool int __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014216 return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a,
14217 (vector int)__b);
Anton Yartsev583a1cf2010-08-19 11:57:49 +000014218}
14219
Kit Barton8553bec2015-03-11 15:57:19 +000014220#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000014221static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a,
14222 vector signed long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014223 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, __a, __b);
14224}
14225
Daniel Jasperbe508362016-03-11 22:13:28 +000014226static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a,
14227 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014228 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, (vector long long)__a,
14229 (vector long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000014230}
14231
Daniel Jasperbe508362016-03-11 22:13:28 +000014232static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a,
14233 vector bool long long __b) {
Kit Barton8553bec2015-03-11 15:57:19 +000014234 return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, __a,
14235 (vector signed long long)__b);
14236}
14237
Daniel Jasperbe508362016-03-11 22:13:28 +000014238static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a,
14239 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014240 return __builtin_altivec_vcmpequd_p(
14241 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000014242}
14243
Daniel Jasperbe508362016-03-11 22:13:28 +000014244static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
14245 vector signed long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014246 return __builtin_altivec_vcmpequd_p(
14247 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000014248}
14249
Daniel Jasperbe508362016-03-11 22:13:28 +000014250static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
14251 vector unsigned long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014252 return __builtin_altivec_vcmpequd_p(
14253 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000014254}
14255
Daniel Jasperbe508362016-03-11 22:13:28 +000014256static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a,
14257 vector bool long long __b) {
Bill Seurer703e8482015-06-09 14:39:47 +000014258 return __builtin_altivec_vcmpequd_p(
14259 __CR6_LT_REV, (vector signed long long)__a, (vector signed long long)__b);
Kit Barton8553bec2015-03-11 15:57:19 +000014260}
14261#endif
14262
Daniel Jasperbe508362016-03-11 22:13:28 +000014263static __inline__ int __ATTRS_o_ai vec_any_ne(vector float __a,
14264 vector float __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014265#ifdef __VSX__
14266 return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __b);
14267#else
David Blaikie3302f2b2013-01-16 23:08:36 +000014268 return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014269#endif
Chris Lattnerdad40622010-04-14 03:54:58 +000014270}
14271
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014272#ifdef __VSX__
Daniel Jasperbe508362016-03-11 22:13:28 +000014273static __inline__ int __ATTRS_o_ai vec_any_ne(vector double __a,
14274 vector double __b) {
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014275 return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __b);
14276}
14277#endif
14278
Chris Lattnerdad40622010-04-14 03:54:58 +000014279/* vec_any_nge */
14280
Daniel Jasperbe508362016-03-11 22:13:28 +000014281static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014282vec_any_nge(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014283 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014284}
14285
14286/* vec_any_ngt */
14287
Daniel Jasperbe508362016-03-11 22:13:28 +000014288static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014289vec_any_ngt(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014290 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014291}
14292
14293/* vec_any_nle */
14294
Daniel Jasperbe508362016-03-11 22:13:28 +000014295static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014296vec_any_nle(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014297 return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000014298}
14299
14300/* vec_any_nlt */
14301
Daniel Jasperbe508362016-03-11 22:13:28 +000014302static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014303vec_any_nlt(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014304 return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __b, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000014305}
14306
14307/* vec_any_numeric */
14308
Daniel Jasperbe508362016-03-11 22:13:28 +000014309static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014310vec_any_numeric(vector float __a) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014311 return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __a);
Chris Lattnerdad40622010-04-14 03:54:58 +000014312}
14313
14314/* vec_any_out */
14315
Daniel Jasperbe508362016-03-11 22:13:28 +000014316static __inline__ int __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014317vec_any_out(vector float __a, vector float __b) {
David Blaikie3302f2b2013-01-16 23:08:36 +000014318 return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, __a, __b);
Chris Lattnerdad40622010-04-14 03:54:58 +000014319}
14320
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014321/* Power 8 Crypto functions
14322Note: We diverge from the current GCC implementation with regard
14323to cryptography and related functions as follows:
14324- Only the SHA and AES instructions and builtins are disabled by -mno-crypto
14325- The remaining ones are only available on Power8 and up so
14326 require -mpower8-vector
14327The justification for this is that export requirements require that
14328Category:Vector.Crypto is optional (i.e. compliant hardware may not provide
14329support). As a result, we need to be able to turn off support for those.
14330The remaining ones (currently controlled by -mcrypto for GCC) still
14331need to be provided on compliant hardware even if Vector.Crypto is not
14332provided.
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014333*/
14334#ifdef __CRYPTO__
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014335#define vec_sbox_be __builtin_altivec_crypto_vsbox
14336#define vec_cipher_be __builtin_altivec_crypto_vcipher
14337#define vec_cipherlast_be __builtin_altivec_crypto_vcipherlast
14338#define vec_ncipher_be __builtin_altivec_crypto_vncipher
14339#define vec_ncipherlast_be __builtin_altivec_crypto_vncipherlast
14340
Daniel Jasperbe508362016-03-11 22:13:28 +000014341static __inline__ vector unsigned long long __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014342__builtin_crypto_vsbox(vector unsigned long long __a) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014343 return __builtin_altivec_crypto_vsbox(__a);
14344}
14345
Daniel Jasperbe508362016-03-11 22:13:28 +000014346static __inline__ vector unsigned long long __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014347__builtin_crypto_vcipher(vector unsigned long long __a,
14348 vector unsigned long long __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014349 return __builtin_altivec_crypto_vcipher(__a, __b);
14350}
14351
Daniel Jasperbe508362016-03-11 22:13:28 +000014352static __inline__ vector unsigned long long __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014353__builtin_crypto_vcipherlast(vector unsigned long long __a,
14354 vector unsigned long long __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014355 return __builtin_altivec_crypto_vcipherlast(__a, __b);
14356}
14357
Daniel Jasperbe508362016-03-11 22:13:28 +000014358static __inline__ vector unsigned long long __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014359__builtin_crypto_vncipher(vector unsigned long long __a,
14360 vector unsigned long long __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014361 return __builtin_altivec_crypto_vncipher(__a, __b);
14362}
14363
Daniel Jasperbe508362016-03-11 22:13:28 +000014364static __inline__ vector unsigned long long __attribute__((__always_inline__))
Bill Seurer703e8482015-06-09 14:39:47 +000014365__builtin_crypto_vncipherlast(vector unsigned long long __a,
14366 vector unsigned long long __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014367 return __builtin_altivec_crypto_vncipherlast(__a, __b);
14368}
14369
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014370#define __builtin_crypto_vshasigmad __builtin_altivec_crypto_vshasigmad
14371#define __builtin_crypto_vshasigmaw __builtin_altivec_crypto_vshasigmaw
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014372
Daniel Jasperbe508362016-03-11 22:13:28 +000014373#define vec_shasigma_be(X, Y, Z) \
14374 _Generic((X), vector unsigned int \
14375 : __builtin_crypto_vshasigmaw, vector unsigned long long \
14376 : __builtin_crypto_vshasigmad)((X), (Y), (Z))
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014377#endif
14378
14379#ifdef __POWER8_VECTOR__
Daniel Jasperbe508362016-03-11 22:13:28 +000014380static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000014381__builtin_crypto_vpermxor(vector unsigned char __a, vector unsigned char __b,
14382 vector unsigned char __c) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014383 return __builtin_altivec_crypto_vpermxor(__a, __b, __c);
14384}
14385
Daniel Jasperbe508362016-03-11 22:13:28 +000014386static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000014387__builtin_crypto_vpermxor(vector unsigned short __a, vector unsigned short __b,
14388 vector unsigned short __c) {
14389 return (vector unsigned short)__builtin_altivec_crypto_vpermxor(
14390 (vector unsigned char)__a, (vector unsigned char)__b,
14391 (vector unsigned char)__c);
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014392}
14393
Daniel Jasperbe508362016-03-11 22:13:28 +000014394static __inline__ vector unsigned int __ATTRS_o_ai __builtin_crypto_vpermxor(
Bill Seurer703e8482015-06-09 14:39:47 +000014395 vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) {
14396 return (vector unsigned int)__builtin_altivec_crypto_vpermxor(
14397 (vector unsigned char)__a, (vector unsigned char)__b,
14398 (vector unsigned char)__c);
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014399}
14400
Daniel Jasperbe508362016-03-11 22:13:28 +000014401static __inline__ vector unsigned long long __ATTRS_o_ai
14402__builtin_crypto_vpermxor(vector unsigned long long __a,
14403 vector unsigned long long __b,
14404 vector unsigned long long __c) {
Bill Seurer703e8482015-06-09 14:39:47 +000014405 return (vector unsigned long long)__builtin_altivec_crypto_vpermxor(
14406 (vector unsigned char)__a, (vector unsigned char)__b,
14407 (vector unsigned char)__c);
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014408}
14409
Daniel Jasperbe508362016-03-11 22:13:28 +000014410static __inline__ vector unsigned char __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000014411__builtin_crypto_vpmsumb(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014412 return __builtin_altivec_crypto_vpmsumb(__a, __b);
14413}
14414
Daniel Jasperbe508362016-03-11 22:13:28 +000014415static __inline__ vector unsigned short __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000014416__builtin_crypto_vpmsumb(vector unsigned short __a, vector unsigned short __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014417 return __builtin_altivec_crypto_vpmsumh(__a, __b);
14418}
14419
Daniel Jasperbe508362016-03-11 22:13:28 +000014420static __inline__ vector unsigned int __ATTRS_o_ai
Bill Seurer703e8482015-06-09 14:39:47 +000014421__builtin_crypto_vpmsumb(vector unsigned int __a, vector unsigned int __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014422 return __builtin_altivec_crypto_vpmsumw(__a, __b);
14423}
14424
Daniel Jasperbe508362016-03-11 22:13:28 +000014425static __inline__ vector unsigned long long __ATTRS_o_ai
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014426__builtin_crypto_vpmsumb(vector unsigned long long __a,
14427 vector unsigned long long __b) {
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014428 return __builtin_altivec_crypto_vpmsumd(__a, __b);
14429}
Nemanja Ivanovicb17f1122015-06-11 06:25:36 +000014430
Daniel Jasperbe508362016-03-11 22:13:28 +000014431static __inline__ vector signed char __ATTRS_o_ai
14432vec_vgbbd(vector signed char __a) {
14433 return __builtin_altivec_vgbbd((vector unsigned char)__a);
Nemanja Ivanovicb17f1122015-06-11 06:25:36 +000014434}
14435
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014436#define vec_pmsum_be __builtin_crypto_vpmsumb
14437#define vec_gb __builtin_altivec_vgbbd
14438
Daniel Jasperbe508362016-03-11 22:13:28 +000014439static __inline__ vector unsigned char __ATTRS_o_ai
14440vec_vgbbd(vector unsigned char __a) {
Nemanja Ivanovicb17f1122015-06-11 06:25:36 +000014441 return __builtin_altivec_vgbbd(__a);
14442}
14443
Daniel Jasperbe508362016-03-11 22:13:28 +000014444static __inline__ vector long long __ATTRS_o_ai
14445vec_vbpermq(vector signed char __a, vector signed char __b) {
14446 return __builtin_altivec_vbpermq((vector unsigned char)__a,
14447 (vector unsigned char)__b);
Nemanja Ivanovicb17f1122015-06-11 06:25:36 +000014448}
14449
Daniel Jasperbe508362016-03-11 22:13:28 +000014450static __inline__ vector long long __ATTRS_o_ai
14451vec_vbpermq(vector unsigned char __a, vector unsigned char __b) {
Nemanja Ivanovicb17f1122015-06-11 06:25:36 +000014452 return __builtin_altivec_vbpermq(__a, __b);
14453}
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014454
14455#ifdef __powerpc64__
Daniel Jasperbe508362016-03-11 22:13:28 +000014456static __inline__ vector unsigned long long __attribute__((__always_inline__))
14457vec_bperm(vector unsigned __int128 __a, vector unsigned char __b) {
14458 return __builtin_altivec_vbpermq((vector unsigned char)__a,
14459 (vector unsigned char)__b);
Nemanja Ivanovic236904e2015-09-29 18:13:34 +000014460}
14461#endif
Nemanja Ivanovic55e757d2015-03-04 21:48:22 +000014462#endif
14463
Anton Korobeynikovcc50b7d2010-06-19 09:47:18 +000014464#undef __ATTRS_o_ai
Chris Lattnerdad40622010-04-14 03:54:58 +000014465
14466#endif /* __ALTIVEC_H */