blob: 9263392ccc8029aa78c799c065c6042dd2c653e7 [file] [log] [blame]
Craig Topperdec792e2011-12-19 05:04:33 +00001/*===---- avx2intrin.h - AVX2 intrinsics -----------------------------------===
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
24#ifndef __IMMINTRIN_H
25#error "Never use <avx2intrin.h> directly; include <immintrin.h> instead."
26#endif
27
Richard Smith49e56442013-07-14 05:41:45 +000028#ifndef __AVX2INTRIN_H
29#define __AVX2INTRIN_H
30
Eric Christopher4d1851682015-06-17 07:09:20 +000031/* Define the default attributes for the functions in this file. */
Michael Kupersteine45af542015-06-30 13:36:19 +000032#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx2")))
Eric Christopher4d1851682015-06-17 07:09:20 +000033
Craig Topperdec792e2011-12-19 05:04:33 +000034/* SSE4 Multiple Packed Sums of Absolute Difference. */
Craig Toppercd45b1a2016-05-17 03:42:31 +000035#define _mm256_mpsadbw_epu8(X, Y, M) \
36 (__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \
37 (__v32qi)(__m256i)(Y), (int)(M))
Craig Topperdec792e2011-12-19 05:04:33 +000038
Michael Kupersteine45af542015-06-30 13:36:19 +000039static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000040_mm256_abs_epi8(__m256i __a)
Craig Topperdec792e2011-12-19 05:04:33 +000041{
David Blaikie3302f2b2013-01-16 23:08:36 +000042 return (__m256i)__builtin_ia32_pabsb256((__v32qi)__a);
Craig Topperdec792e2011-12-19 05:04:33 +000043}
44
Michael Kupersteine45af542015-06-30 13:36:19 +000045static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000046_mm256_abs_epi16(__m256i __a)
Craig Topperdec792e2011-12-19 05:04:33 +000047{
David Blaikie3302f2b2013-01-16 23:08:36 +000048 return (__m256i)__builtin_ia32_pabsw256((__v16hi)__a);
Craig Topperdec792e2011-12-19 05:04:33 +000049}
50
Michael Kupersteine45af542015-06-30 13:36:19 +000051static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000052_mm256_abs_epi32(__m256i __a)
Craig Topperdec792e2011-12-19 05:04:33 +000053{
David Blaikie3302f2b2013-01-16 23:08:36 +000054 return (__m256i)__builtin_ia32_pabsd256((__v8si)__a);
Craig Topperdec792e2011-12-19 05:04:33 +000055}
56
Michael Kupersteine45af542015-06-30 13:36:19 +000057static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000058_mm256_packs_epi16(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +000059{
David Blaikie3302f2b2013-01-16 23:08:36 +000060 return (__m256i)__builtin_ia32_packsswb256((__v16hi)__a, (__v16hi)__b);
Craig Topperdec792e2011-12-19 05:04:33 +000061}
62
Michael Kupersteine45af542015-06-30 13:36:19 +000063static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000064_mm256_packs_epi32(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +000065{
David Blaikie3302f2b2013-01-16 23:08:36 +000066 return (__m256i)__builtin_ia32_packssdw256((__v8si)__a, (__v8si)__b);
Craig Topperdec792e2011-12-19 05:04:33 +000067}
68
Michael Kupersteine45af542015-06-30 13:36:19 +000069static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000070_mm256_packus_epi16(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +000071{
David Blaikie3302f2b2013-01-16 23:08:36 +000072 return (__m256i)__builtin_ia32_packuswb256((__v16hi)__a, (__v16hi)__b);
Craig Topperdec792e2011-12-19 05:04:33 +000073}
74
Michael Kupersteine45af542015-06-30 13:36:19 +000075static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topperdec792e2011-12-19 05:04:33 +000076_mm256_packus_epi32(__m256i __V1, __m256i __V2)
77{
78 return (__m256i) __builtin_ia32_packusdw256((__v8si)__V1, (__v8si)__V2);
79}
80
Michael Kupersteine45af542015-06-30 13:36:19 +000081static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000082_mm256_add_epi8(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +000083{
David Blaikie3302f2b2013-01-16 23:08:36 +000084 return (__m256i)((__v32qi)__a + (__v32qi)__b);
Craig Topperdec792e2011-12-19 05:04:33 +000085}
86
Michael Kupersteine45af542015-06-30 13:36:19 +000087static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000088_mm256_add_epi16(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +000089{
David Blaikie3302f2b2013-01-16 23:08:36 +000090 return (__m256i)((__v16hi)__a + (__v16hi)__b);
Craig Topperdec792e2011-12-19 05:04:33 +000091}
92
Michael Kupersteine45af542015-06-30 13:36:19 +000093static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000094_mm256_add_epi32(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +000095{
David Blaikie3302f2b2013-01-16 23:08:36 +000096 return (__m256i)((__v8si)__a + (__v8si)__b);
Craig Topperdec792e2011-12-19 05:04:33 +000097}
98
Michael Kupersteine45af542015-06-30 13:36:19 +000099static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000100_mm256_add_epi64(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +0000101{
Craig Topper1aa231e2016-05-16 06:38:42 +0000102 return (__m256i)((__v4di)__a + (__v4di)__b);
Craig Topperdec792e2011-12-19 05:04:33 +0000103}
104
Michael Kupersteine45af542015-06-30 13:36:19 +0000105static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000106_mm256_adds_epi8(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000107{
David Blaikie3302f2b2013-01-16 23:08:36 +0000108 return (__m256i)__builtin_ia32_paddsb256((__v32qi)__a, (__v32qi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000109}
110
Michael Kupersteine45af542015-06-30 13:36:19 +0000111static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000112_mm256_adds_epi16(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000113{
David Blaikie3302f2b2013-01-16 23:08:36 +0000114 return (__m256i)__builtin_ia32_paddsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000115}
116
Michael Kupersteine45af542015-06-30 13:36:19 +0000117static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000118_mm256_adds_epu8(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000119{
David Blaikie3302f2b2013-01-16 23:08:36 +0000120 return (__m256i)__builtin_ia32_paddusb256((__v32qi)__a, (__v32qi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000121}
122
Michael Kupersteine45af542015-06-30 13:36:19 +0000123static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000124_mm256_adds_epu16(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000125{
David Blaikie3302f2b2013-01-16 23:08:36 +0000126 return (__m256i)__builtin_ia32_paddusw256((__v16hi)__a, (__v16hi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000127}
128
Craig Topper71481662015-11-10 05:08:05 +0000129#define _mm256_alignr_epi8(a, b, n) __extension__ ({ \
130 (__m256i)__builtin_ia32_palignr256((__v32qi)(__m256i)(a), \
131 (__v32qi)(__m256i)(b), (n)); })
Craig Topper94aba2c2011-12-19 07:03:25 +0000132
Michael Kupersteine45af542015-06-30 13:36:19 +0000133static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000134_mm256_and_si256(__m256i __a, __m256i __b)
Craig Toppera557e1c2011-12-19 09:03:48 +0000135{
Craig Topper1aa231e2016-05-16 06:38:42 +0000136 return (__m256i)((__v4di)__a & (__v4di)__b);
Craig Toppera557e1c2011-12-19 09:03:48 +0000137}
138
Michael Kupersteine45af542015-06-30 13:36:19 +0000139static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000140_mm256_andnot_si256(__m256i __a, __m256i __b)
Craig Toppera557e1c2011-12-19 09:03:48 +0000141{
Craig Topper1aa231e2016-05-16 06:38:42 +0000142 return (__m256i)(~(__v4di)__a & (__v4di)__b);
Craig Toppera557e1c2011-12-19 09:03:48 +0000143}
144
Michael Kupersteine45af542015-06-30 13:36:19 +0000145static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000146_mm256_avg_epu8(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000147{
David Blaikie3302f2b2013-01-16 23:08:36 +0000148 return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000149}
150
Michael Kupersteine45af542015-06-30 13:36:19 +0000151static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000152_mm256_avg_epu16(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000153{
David Blaikie3302f2b2013-01-16 23:08:36 +0000154 return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000155}
156
Michael Kupersteine45af542015-06-30 13:36:19 +0000157static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Toppera89747d2011-12-20 09:55:26 +0000158_mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
159{
160 return (__m256i)__builtin_ia32_pblendvb256((__v32qi)__V1, (__v32qi)__V2,
161 (__v32qi)__M);
162}
163
Craig Topper71481662015-11-10 05:08:05 +0000164#define _mm256_blend_epi16(V1, V2, M) __extension__ ({ \
165 (__m256i)__builtin_shufflevector((__v16hi)(__m256i)(V1), \
166 (__v16hi)(__m256i)(V2), \
167 (((M) & 0x01) ? 16 : 0), \
168 (((M) & 0x02) ? 17 : 1), \
169 (((M) & 0x04) ? 18 : 2), \
170 (((M) & 0x08) ? 19 : 3), \
171 (((M) & 0x10) ? 20 : 4), \
172 (((M) & 0x20) ? 21 : 5), \
173 (((M) & 0x40) ? 22 : 6), \
174 (((M) & 0x80) ? 23 : 7), \
175 (((M) & 0x01) ? 24 : 8), \
176 (((M) & 0x02) ? 25 : 9), \
Filipe Cabecinhas5d289b42014-05-13 02:37:02 +0000177 (((M) & 0x04) ? 26 : 10), \
178 (((M) & 0x08) ? 27 : 11), \
179 (((M) & 0x10) ? 28 : 12), \
180 (((M) & 0x20) ? 29 : 13), \
181 (((M) & 0x40) ? 30 : 14), \
182 (((M) & 0x80) ? 31 : 15)); })
Craig Toppera89747d2011-12-20 09:55:26 +0000183
Michael Kupersteine45af542015-06-30 13:36:19 +0000184static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000185_mm256_cmpeq_epi8(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000186{
David Blaikie3302f2b2013-01-16 23:08:36 +0000187 return (__m256i)((__v32qi)__a == (__v32qi)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000188}
189
Michael Kupersteine45af542015-06-30 13:36:19 +0000190static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000191_mm256_cmpeq_epi16(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000192{
David Blaikie3302f2b2013-01-16 23:08:36 +0000193 return (__m256i)((__v16hi)__a == (__v16hi)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000194}
195
Michael Kupersteine45af542015-06-30 13:36:19 +0000196static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000197_mm256_cmpeq_epi32(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000198{
David Blaikie3302f2b2013-01-16 23:08:36 +0000199 return (__m256i)((__v8si)__a == (__v8si)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000200}
201
Michael Kupersteine45af542015-06-30 13:36:19 +0000202static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000203_mm256_cmpeq_epi64(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000204{
Craig Topper1aa231e2016-05-16 06:38:42 +0000205 return (__m256i)((__v4di)__a == (__v4di)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000206}
207
Michael Kupersteine45af542015-06-30 13:36:19 +0000208static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000209_mm256_cmpgt_epi8(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000210{
Chandler Carruthcbe64112015-10-01 23:40:12 +0000211 /* This function always performs a signed comparison, but __v32qi is a char
212 which may be signed or unsigned, so use __v32qs. */
213 return (__m256i)((__v32qs)__a > (__v32qs)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000214}
215
Michael Kupersteine45af542015-06-30 13:36:19 +0000216static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000217_mm256_cmpgt_epi16(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000218{
David Blaikie3302f2b2013-01-16 23:08:36 +0000219 return (__m256i)((__v16hi)__a > (__v16hi)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000220}
221
Michael Kupersteine45af542015-06-30 13:36:19 +0000222static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000223_mm256_cmpgt_epi32(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000224{
David Blaikie3302f2b2013-01-16 23:08:36 +0000225 return (__m256i)((__v8si)__a > (__v8si)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000226}
227
Michael Kupersteine45af542015-06-30 13:36:19 +0000228static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000229_mm256_cmpgt_epi64(__m256i __a, __m256i __b)
Craig Toppera89747d2011-12-20 09:55:26 +0000230{
Craig Topper1aa231e2016-05-16 06:38:42 +0000231 return (__m256i)((__v4di)__a > (__v4di)__b);
Craig Toppera89747d2011-12-20 09:55:26 +0000232}
233
Michael Kupersteine45af542015-06-30 13:36:19 +0000234static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000235_mm256_hadd_epi16(__m256i __a, __m256i __b)
Craig Topper3fe5ac42011-12-21 08:17:40 +0000236{
David Blaikie3302f2b2013-01-16 23:08:36 +0000237 return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b);
Craig Topper3fe5ac42011-12-21 08:17:40 +0000238}
239
Michael Kupersteine45af542015-06-30 13:36:19 +0000240static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000241_mm256_hadd_epi32(__m256i __a, __m256i __b)
Craig Topper3fe5ac42011-12-21 08:17:40 +0000242{
David Blaikie3302f2b2013-01-16 23:08:36 +0000243 return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b);
Craig Topper3fe5ac42011-12-21 08:17:40 +0000244}
245
Michael Kupersteine45af542015-06-30 13:36:19 +0000246static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000247_mm256_hadds_epi16(__m256i __a, __m256i __b)
Craig Topper3fe5ac42011-12-21 08:17:40 +0000248{
David Blaikie3302f2b2013-01-16 23:08:36 +0000249 return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper3fe5ac42011-12-21 08:17:40 +0000250}
251
Michael Kupersteine45af542015-06-30 13:36:19 +0000252static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000253_mm256_hsub_epi16(__m256i __a, __m256i __b)
Craig Topper3fe5ac42011-12-21 08:17:40 +0000254{
David Blaikie3302f2b2013-01-16 23:08:36 +0000255 return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b);
Craig Topper3fe5ac42011-12-21 08:17:40 +0000256}
257
Michael Kupersteine45af542015-06-30 13:36:19 +0000258static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000259_mm256_hsub_epi32(__m256i __a, __m256i __b)
Craig Topper3fe5ac42011-12-21 08:17:40 +0000260{
David Blaikie3302f2b2013-01-16 23:08:36 +0000261 return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b);
Craig Topper3fe5ac42011-12-21 08:17:40 +0000262}
263
Michael Kupersteine45af542015-06-30 13:36:19 +0000264static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000265_mm256_hsubs_epi16(__m256i __a, __m256i __b)
Craig Topper3fe5ac42011-12-21 08:17:40 +0000266{
David Blaikie3302f2b2013-01-16 23:08:36 +0000267 return (__m256i)__builtin_ia32_phsubsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper3fe5ac42011-12-21 08:17:40 +0000268}
269
Michael Kupersteine45af542015-06-30 13:36:19 +0000270static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000271_mm256_maddubs_epi16(__m256i __a, __m256i __b)
Craig Toppera73baa82011-12-21 08:35:05 +0000272{
David Blaikie3302f2b2013-01-16 23:08:36 +0000273 return (__m256i)__builtin_ia32_pmaddubsw256((__v32qi)__a, (__v32qi)__b);
Craig Toppera73baa82011-12-21 08:35:05 +0000274}
275
Michael Kupersteine45af542015-06-30 13:36:19 +0000276static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000277_mm256_madd_epi16(__m256i __a, __m256i __b)
Craig Toppera73baa82011-12-21 08:35:05 +0000278{
David Blaikie3302f2b2013-01-16 23:08:36 +0000279 return (__m256i)__builtin_ia32_pmaddwd256((__v16hi)__a, (__v16hi)__b);
Craig Toppera73baa82011-12-21 08:35:05 +0000280}
281
Michael Kupersteine45af542015-06-30 13:36:19 +0000282static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000283_mm256_max_epi8(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000284{
David Blaikie3302f2b2013-01-16 23:08:36 +0000285 return (__m256i)__builtin_ia32_pmaxsb256((__v32qi)__a, (__v32qi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000286}
287
Michael Kupersteine45af542015-06-30 13:36:19 +0000288static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000289_mm256_max_epi16(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000290{
David Blaikie3302f2b2013-01-16 23:08:36 +0000291 return (__m256i)__builtin_ia32_pmaxsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000292}
293
Michael Kupersteine45af542015-06-30 13:36:19 +0000294static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000295_mm256_max_epi32(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000296{
David Blaikie3302f2b2013-01-16 23:08:36 +0000297 return (__m256i)__builtin_ia32_pmaxsd256((__v8si)__a, (__v8si)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000298}
299
Michael Kupersteine45af542015-06-30 13:36:19 +0000300static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000301_mm256_max_epu8(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000302{
David Blaikie3302f2b2013-01-16 23:08:36 +0000303 return (__m256i)__builtin_ia32_pmaxub256((__v32qi)__a, (__v32qi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000304}
305
Michael Kupersteine45af542015-06-30 13:36:19 +0000306static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000307_mm256_max_epu16(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000308{
David Blaikie3302f2b2013-01-16 23:08:36 +0000309 return (__m256i)__builtin_ia32_pmaxuw256((__v16hi)__a, (__v16hi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000310}
311
Michael Kupersteine45af542015-06-30 13:36:19 +0000312static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000313_mm256_max_epu32(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000314{
David Blaikie3302f2b2013-01-16 23:08:36 +0000315 return (__m256i)__builtin_ia32_pmaxud256((__v8si)__a, (__v8si)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000316}
317
Michael Kupersteine45af542015-06-30 13:36:19 +0000318static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000319_mm256_min_epi8(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000320{
David Blaikie3302f2b2013-01-16 23:08:36 +0000321 return (__m256i)__builtin_ia32_pminsb256((__v32qi)__a, (__v32qi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000322}
323
Michael Kupersteine45af542015-06-30 13:36:19 +0000324static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000325_mm256_min_epi16(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000326{
David Blaikie3302f2b2013-01-16 23:08:36 +0000327 return (__m256i)__builtin_ia32_pminsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000328}
329
Michael Kupersteine45af542015-06-30 13:36:19 +0000330static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000331_mm256_min_epi32(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000332{
David Blaikie3302f2b2013-01-16 23:08:36 +0000333 return (__m256i)__builtin_ia32_pminsd256((__v8si)__a, (__v8si)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000334}
335
Michael Kupersteine45af542015-06-30 13:36:19 +0000336static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000337_mm256_min_epu8(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000338{
David Blaikie3302f2b2013-01-16 23:08:36 +0000339 return (__m256i)__builtin_ia32_pminub256((__v32qi)__a, (__v32qi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000340}
341
Michael Kupersteine45af542015-06-30 13:36:19 +0000342static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000343_mm256_min_epu16(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000344{
David Blaikie3302f2b2013-01-16 23:08:36 +0000345 return (__m256i)__builtin_ia32_pminuw256 ((__v16hi)__a, (__v16hi)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000346}
347
Michael Kupersteine45af542015-06-30 13:36:19 +0000348static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000349_mm256_min_epu32(__m256i __a, __m256i __b)
Craig Topper1f2460a2011-12-22 09:18:58 +0000350{
David Blaikie3302f2b2013-01-16 23:08:36 +0000351 return (__m256i)__builtin_ia32_pminud256((__v8si)__a, (__v8si)__b);
Craig Topper1f2460a2011-12-22 09:18:58 +0000352}
353
Michael Kupersteine45af542015-06-30 13:36:19 +0000354static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000355_mm256_movemask_epi8(__m256i __a)
Craig Topper1f2460a2011-12-22 09:18:58 +0000356{
David Blaikie3302f2b2013-01-16 23:08:36 +0000357 return __builtin_ia32_pmovmskb256((__v32qi)__a);
Craig Topper1f2460a2011-12-22 09:18:58 +0000358}
359
Michael Kupersteine45af542015-06-30 13:36:19 +0000360static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000361_mm256_cvtepi8_epi16(__m128i __V)
362{
363 return (__m256i)__builtin_ia32_pmovsxbw256((__v16qi)__V);
364}
365
Michael Kupersteine45af542015-06-30 13:36:19 +0000366static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000367_mm256_cvtepi8_epi32(__m128i __V)
368{
369 return (__m256i)__builtin_ia32_pmovsxbd256((__v16qi)__V);
370}
371
Michael Kupersteine45af542015-06-30 13:36:19 +0000372static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000373_mm256_cvtepi8_epi64(__m128i __V)
374{
375 return (__m256i)__builtin_ia32_pmovsxbq256((__v16qi)__V);
376}
377
Michael Kupersteine45af542015-06-30 13:36:19 +0000378static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000379_mm256_cvtepi16_epi32(__m128i __V)
380{
381 return (__m256i)__builtin_ia32_pmovsxwd256((__v8hi)__V);
382}
383
Michael Kupersteine45af542015-06-30 13:36:19 +0000384static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000385_mm256_cvtepi16_epi64(__m128i __V)
386{
387 return (__m256i)__builtin_ia32_pmovsxwq256((__v8hi)__V);
388}
389
Michael Kupersteine45af542015-06-30 13:36:19 +0000390static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000391_mm256_cvtepi32_epi64(__m128i __V)
392{
393 return (__m256i)__builtin_ia32_pmovsxdq256((__v4si)__V);
394}
395
Michael Kupersteine45af542015-06-30 13:36:19 +0000396static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000397_mm256_cvtepu8_epi16(__m128i __V)
398{
399 return (__m256i)__builtin_ia32_pmovzxbw256((__v16qi)__V);
400}
401
Michael Kupersteine45af542015-06-30 13:36:19 +0000402static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000403_mm256_cvtepu8_epi32(__m128i __V)
404{
405 return (__m256i)__builtin_ia32_pmovzxbd256((__v16qi)__V);
406}
407
Michael Kupersteine45af542015-06-30 13:36:19 +0000408static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000409_mm256_cvtepu8_epi64(__m128i __V)
410{
411 return (__m256i)__builtin_ia32_pmovzxbq256((__v16qi)__V);
412}
413
Michael Kupersteine45af542015-06-30 13:36:19 +0000414static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000415_mm256_cvtepu16_epi32(__m128i __V)
416{
417 return (__m256i)__builtin_ia32_pmovzxwd256((__v8hi)__V);
418}
419
Michael Kupersteine45af542015-06-30 13:36:19 +0000420static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000421_mm256_cvtepu16_epi64(__m128i __V)
422{
423 return (__m256i)__builtin_ia32_pmovzxwq256((__v8hi)__V);
424}
425
Michael Kupersteine45af542015-06-30 13:36:19 +0000426static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper1f2460a2011-12-22 09:18:58 +0000427_mm256_cvtepu32_epi64(__m128i __V)
428{
429 return (__m256i)__builtin_ia32_pmovzxdq256((__v4si)__V);
430}
431
Michael Kupersteine45af542015-06-30 13:36:19 +0000432static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000433_mm256_mul_epi32(__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000434{
David Blaikie3302f2b2013-01-16 23:08:36 +0000435 return (__m256i)__builtin_ia32_pmuldq256((__v8si)__a, (__v8si)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000436}
437
Michael Kupersteine45af542015-06-30 13:36:19 +0000438static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000439_mm256_mulhrs_epi16(__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000440{
David Blaikie3302f2b2013-01-16 23:08:36 +0000441 return (__m256i)__builtin_ia32_pmulhrsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000442}
443
Michael Kupersteine45af542015-06-30 13:36:19 +0000444static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000445_mm256_mulhi_epu16(__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000446{
David Blaikie3302f2b2013-01-16 23:08:36 +0000447 return (__m256i)__builtin_ia32_pmulhuw256((__v16hi)__a, (__v16hi)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000448}
449
Michael Kupersteine45af542015-06-30 13:36:19 +0000450static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000451_mm256_mulhi_epi16(__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000452{
David Blaikie3302f2b2013-01-16 23:08:36 +0000453 return (__m256i)__builtin_ia32_pmulhw256((__v16hi)__a, (__v16hi)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000454}
455
Michael Kupersteine45af542015-06-30 13:36:19 +0000456static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000457_mm256_mullo_epi16(__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000458{
David Blaikie3302f2b2013-01-16 23:08:36 +0000459 return (__m256i)((__v16hi)__a * (__v16hi)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000460}
461
Michael Kupersteine45af542015-06-30 13:36:19 +0000462static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000463_mm256_mullo_epi32 (__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000464{
David Blaikie3302f2b2013-01-16 23:08:36 +0000465 return (__m256i)((__v8si)__a * (__v8si)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000466}
467
Michael Kupersteine45af542015-06-30 13:36:19 +0000468static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000469_mm256_mul_epu32(__m256i __a, __m256i __b)
Craig Topper235a3652011-12-23 08:31:16 +0000470{
David Blaikie3302f2b2013-01-16 23:08:36 +0000471 return __builtin_ia32_pmuludq256((__v8si)__a, (__v8si)__b);
Craig Topper235a3652011-12-23 08:31:16 +0000472}
473
Michael Kupersteine45af542015-06-30 13:36:19 +0000474static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000475_mm256_or_si256(__m256i __a, __m256i __b)
Craig Toppera557e1c2011-12-19 09:03:48 +0000476{
Craig Topper1aa231e2016-05-16 06:38:42 +0000477 return (__m256i)((__v4di)__a | (__v4di)__b);
Craig Toppera557e1c2011-12-19 09:03:48 +0000478}
479
Michael Kupersteine45af542015-06-30 13:36:19 +0000480static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000481_mm256_sad_epu8(__m256i __a, __m256i __b)
Craig Topperf4bb9522011-12-24 03:28:57 +0000482{
David Blaikie3302f2b2013-01-16 23:08:36 +0000483 return __builtin_ia32_psadbw256((__v32qi)__a, (__v32qi)__b);
Craig Topperf4bb9522011-12-24 03:28:57 +0000484}
485
Michael Kupersteine45af542015-06-30 13:36:19 +0000486static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000487_mm256_shuffle_epi8(__m256i __a, __m256i __b)
Craig Topperf4bb9522011-12-24 03:28:57 +0000488{
David Blaikie3302f2b2013-01-16 23:08:36 +0000489 return (__m256i)__builtin_ia32_pshufb256((__v32qi)__a, (__v32qi)__b);
Craig Topperf4bb9522011-12-24 03:28:57 +0000490}
491
492#define _mm256_shuffle_epi32(a, imm) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000493 (__m256i)__builtin_shufflevector((__v8si)(__m256i)(a), \
Craig Topperfd778ee2015-11-10 05:08:08 +0000494 (__v8si)_mm256_setzero_si256(), \
Craig Topperf4bb9522011-12-24 03:28:57 +0000495 (imm) & 0x3, ((imm) & 0xc) >> 2, \
496 ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \
497 4 + (((imm) & 0x03) >> 0), \
498 4 + (((imm) & 0x0c) >> 2), \
499 4 + (((imm) & 0x30) >> 4), \
500 4 + (((imm) & 0xc0) >> 6)); })
501
502#define _mm256_shufflehi_epi16(a, imm) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000503 (__m256i)__builtin_shufflevector((__v16hi)(__m256i)(a), \
Craig Topperfd778ee2015-11-10 05:08:08 +0000504 (__v16hi)_mm256_setzero_si256(), \
Craig Topperf4bb9522011-12-24 03:28:57 +0000505 0, 1, 2, 3, \
506 4 + (((imm) & 0x03) >> 0), \
507 4 + (((imm) & 0x0c) >> 2), \
508 4 + (((imm) & 0x30) >> 4), \
509 4 + (((imm) & 0xc0) >> 6), \
510 8, 9, 10, 11, \
511 12 + (((imm) & 0x03) >> 0), \
512 12 + (((imm) & 0x0c) >> 2), \
513 12 + (((imm) & 0x30) >> 4), \
514 12 + (((imm) & 0xc0) >> 6)); })
515
516#define _mm256_shufflelo_epi16(a, imm) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000517 (__m256i)__builtin_shufflevector((__v16hi)(__m256i)(a), \
Craig Topperfd778ee2015-11-10 05:08:08 +0000518 (__v16hi)_mm256_setzero_si256(), \
Craig Topperf4bb9522011-12-24 03:28:57 +0000519 (imm) & 0x3,((imm) & 0xc) >> 2, \
520 ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \
521 4, 5, 6, 7, \
522 8 + (((imm) & 0x03) >> 0), \
523 8 + (((imm) & 0x0c) >> 2), \
524 8 + (((imm) & 0x30) >> 4), \
525 8 + (((imm) & 0xc0) >> 6), \
526 12, 13, 14, 15); })
527
Michael Kupersteine45af542015-06-30 13:36:19 +0000528static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000529_mm256_sign_epi8(__m256i __a, __m256i __b)
Craig Topperf4bb9522011-12-24 03:28:57 +0000530{
David Blaikie3302f2b2013-01-16 23:08:36 +0000531 return (__m256i)__builtin_ia32_psignb256((__v32qi)__a, (__v32qi)__b);
Craig Topperf4bb9522011-12-24 03:28:57 +0000532}
533
Michael Kupersteine45af542015-06-30 13:36:19 +0000534static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000535_mm256_sign_epi16(__m256i __a, __m256i __b)
Craig Topperf4bb9522011-12-24 03:28:57 +0000536{
David Blaikie3302f2b2013-01-16 23:08:36 +0000537 return (__m256i)__builtin_ia32_psignw256((__v16hi)__a, (__v16hi)__b);
Craig Topperf4bb9522011-12-24 03:28:57 +0000538}
539
Michael Kupersteine45af542015-06-30 13:36:19 +0000540static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000541_mm256_sign_epi32(__m256i __a, __m256i __b)
Craig Topperf4bb9522011-12-24 03:28:57 +0000542{
David Blaikie3302f2b2013-01-16 23:08:36 +0000543 return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b);
Craig Topperf4bb9522011-12-24 03:28:57 +0000544}
545
546#define _mm256_slli_si256(a, count) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000547 (__m256i)__builtin_ia32_pslldqi256((__m256i)(a), (count)*8); })
Craig Topperf4bb9522011-12-24 03:28:57 +0000548
Michael Kuperstein61681832015-05-19 13:05:46 +0000549#define _mm256_bslli_epi128(a, count) _mm256_slli_si256((a), (count))
550
Michael Kupersteine45af542015-06-30 13:36:19 +0000551static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000552_mm256_slli_epi16(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000553{
David Blaikie3302f2b2013-01-16 23:08:36 +0000554 return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000555}
556
Michael Kupersteine45af542015-06-30 13:36:19 +0000557static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000558_mm256_sll_epi16(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000559{
David Blaikie3302f2b2013-01-16 23:08:36 +0000560 return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000561}
562
Michael Kupersteine45af542015-06-30 13:36:19 +0000563static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000564_mm256_slli_epi32(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000565{
David Blaikie3302f2b2013-01-16 23:08:36 +0000566 return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000567}
568
Michael Kupersteine45af542015-06-30 13:36:19 +0000569static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000570_mm256_sll_epi32(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000571{
David Blaikie3302f2b2013-01-16 23:08:36 +0000572 return (__m256i)__builtin_ia32_pslld256((__v8si)__a, (__v4si)__count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000573}
574
Michael Kupersteine45af542015-06-30 13:36:19 +0000575static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000576_mm256_slli_epi64(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000577{
Craig Topper1aa231e2016-05-16 06:38:42 +0000578 return __builtin_ia32_psllqi256((__v4di)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000579}
580
Michael Kupersteine45af542015-06-30 13:36:19 +0000581static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000582_mm256_sll_epi64(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000583{
Craig Topper1aa231e2016-05-16 06:38:42 +0000584 return __builtin_ia32_psllq256((__v4di)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000585}
586
Michael Kupersteine45af542015-06-30 13:36:19 +0000587static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000588_mm256_srai_epi16(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000589{
David Blaikie3302f2b2013-01-16 23:08:36 +0000590 return (__m256i)__builtin_ia32_psrawi256((__v16hi)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000591}
592
Michael Kupersteine45af542015-06-30 13:36:19 +0000593static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000594_mm256_sra_epi16(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000595{
David Blaikie3302f2b2013-01-16 23:08:36 +0000596 return (__m256i)__builtin_ia32_psraw256((__v16hi)__a, (__v8hi)__count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000597}
598
Michael Kupersteine45af542015-06-30 13:36:19 +0000599static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000600_mm256_srai_epi32(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000601{
David Blaikie3302f2b2013-01-16 23:08:36 +0000602 return (__m256i)__builtin_ia32_psradi256((__v8si)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000603}
604
Michael Kupersteine45af542015-06-30 13:36:19 +0000605static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000606_mm256_sra_epi32(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000607{
David Blaikie3302f2b2013-01-16 23:08:36 +0000608 return (__m256i)__builtin_ia32_psrad256((__v8si)__a, (__v4si)__count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000609}
610
611#define _mm256_srli_si256(a, count) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000612 (__m256i)__builtin_ia32_psrldqi256((__m256i)(a), (count)*8); })
Craig Topperf4bb9522011-12-24 03:28:57 +0000613
Michael Kuperstein61681832015-05-19 13:05:46 +0000614#define _mm256_bsrli_epi128(a, count) _mm256_srli_si256((a), (count))
615
Michael Kupersteine45af542015-06-30 13:36:19 +0000616static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000617_mm256_srli_epi16(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000618{
David Blaikie3302f2b2013-01-16 23:08:36 +0000619 return (__m256i)__builtin_ia32_psrlwi256((__v16hi)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000620}
621
Michael Kupersteine45af542015-06-30 13:36:19 +0000622static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000623_mm256_srl_epi16(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000624{
David Blaikie3302f2b2013-01-16 23:08:36 +0000625 return (__m256i)__builtin_ia32_psrlw256((__v16hi)__a, (__v8hi)__count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000626}
627
Michael Kupersteine45af542015-06-30 13:36:19 +0000628static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000629_mm256_srli_epi32(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000630{
David Blaikie3302f2b2013-01-16 23:08:36 +0000631 return (__m256i)__builtin_ia32_psrldi256((__v8si)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000632}
633
Michael Kupersteine45af542015-06-30 13:36:19 +0000634static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000635_mm256_srl_epi32(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000636{
David Blaikie3302f2b2013-01-16 23:08:36 +0000637 return (__m256i)__builtin_ia32_psrld256((__v8si)__a, (__v4si)__count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000638}
639
Michael Kupersteine45af542015-06-30 13:36:19 +0000640static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000641_mm256_srli_epi64(__m256i __a, int __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000642{
Craig Topper1aa231e2016-05-16 06:38:42 +0000643 return __builtin_ia32_psrlqi256((__v4di)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000644}
645
Michael Kupersteine45af542015-06-30 13:36:19 +0000646static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000647_mm256_srl_epi64(__m256i __a, __m128i __count)
Craig Topperf4bb9522011-12-24 03:28:57 +0000648{
Craig Topper1aa231e2016-05-16 06:38:42 +0000649 return __builtin_ia32_psrlq256((__v4di)__a, __count);
Craig Topperf4bb9522011-12-24 03:28:57 +0000650}
651
Michael Kupersteine45af542015-06-30 13:36:19 +0000652static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000653_mm256_sub_epi8(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +0000654{
David Blaikie3302f2b2013-01-16 23:08:36 +0000655 return (__m256i)((__v32qi)__a - (__v32qi)__b);
Craig Topperdec792e2011-12-19 05:04:33 +0000656}
657
Michael Kupersteine45af542015-06-30 13:36:19 +0000658static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000659_mm256_sub_epi16(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +0000660{
David Blaikie3302f2b2013-01-16 23:08:36 +0000661 return (__m256i)((__v16hi)__a - (__v16hi)__b);
Craig Topperdec792e2011-12-19 05:04:33 +0000662}
663
Michael Kupersteine45af542015-06-30 13:36:19 +0000664static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000665_mm256_sub_epi32(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +0000666{
David Blaikie3302f2b2013-01-16 23:08:36 +0000667 return (__m256i)((__v8si)__a - (__v8si)__b);
Craig Topperdec792e2011-12-19 05:04:33 +0000668}
669
Michael Kupersteine45af542015-06-30 13:36:19 +0000670static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000671_mm256_sub_epi64(__m256i __a, __m256i __b)
Craig Topperdec792e2011-12-19 05:04:33 +0000672{
Craig Topper1aa231e2016-05-16 06:38:42 +0000673 return (__m256i)((__v4di)__a - (__v4di)__b);
Craig Topperdec792e2011-12-19 05:04:33 +0000674}
Craig Topper94aba2c2011-12-19 07:03:25 +0000675
Michael Kupersteine45af542015-06-30 13:36:19 +0000676static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000677_mm256_subs_epi8(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000678{
David Blaikie3302f2b2013-01-16 23:08:36 +0000679 return (__m256i)__builtin_ia32_psubsb256((__v32qi)__a, (__v32qi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000680}
681
Michael Kupersteine45af542015-06-30 13:36:19 +0000682static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000683_mm256_subs_epi16(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000684{
David Blaikie3302f2b2013-01-16 23:08:36 +0000685 return (__m256i)__builtin_ia32_psubsw256((__v16hi)__a, (__v16hi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000686}
687
Michael Kupersteine45af542015-06-30 13:36:19 +0000688static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000689_mm256_subs_epu8(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000690{
David Blaikie3302f2b2013-01-16 23:08:36 +0000691 return (__m256i)__builtin_ia32_psubusb256((__v32qi)__a, (__v32qi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000692}
693
Michael Kupersteine45af542015-06-30 13:36:19 +0000694static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000695_mm256_subs_epu16(__m256i __a, __m256i __b)
Craig Topper94aba2c2011-12-19 07:03:25 +0000696{
David Blaikie3302f2b2013-01-16 23:08:36 +0000697 return (__m256i)__builtin_ia32_psubusw256((__v16hi)__a, (__v16hi)__b);
Craig Topper94aba2c2011-12-19 07:03:25 +0000698}
699
Michael Kupersteine45af542015-06-30 13:36:19 +0000700static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000701_mm256_unpackhi_epi8(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000702{
David Blaikie3302f2b2013-01-16 23:08:36 +0000703 return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 8, 32+8, 9, 32+9, 10, 32+10, 11, 32+11, 12, 32+12, 13, 32+13, 14, 32+14, 15, 32+15, 24, 32+24, 25, 32+25, 26, 32+26, 27, 32+27, 28, 32+28, 29, 32+29, 30, 32+30, 31, 32+31);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000704}
705
Michael Kupersteine45af542015-06-30 13:36:19 +0000706static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000707_mm256_unpackhi_epi16(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000708{
David Blaikie3302f2b2013-01-16 23:08:36 +0000709 return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000710}
711
Michael Kupersteine45af542015-06-30 13:36:19 +0000712static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000713_mm256_unpackhi_epi32(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000714{
David Blaikie3302f2b2013-01-16 23:08:36 +0000715 return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 2, 8+2, 3, 8+3, 6, 8+6, 7, 8+7);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000716}
717
Michael Kupersteine45af542015-06-30 13:36:19 +0000718static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000719_mm256_unpackhi_epi64(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000720{
Craig Topper1aa231e2016-05-16 06:38:42 +0000721 return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 1, 4+1, 3, 4+3);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000722}
723
Michael Kupersteine45af542015-06-30 13:36:19 +0000724static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000725_mm256_unpacklo_epi8(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000726{
David Blaikie3302f2b2013-01-16 23:08:36 +0000727 return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 0, 32+0, 1, 32+1, 2, 32+2, 3, 32+3, 4, 32+4, 5, 32+5, 6, 32+6, 7, 32+7, 16, 32+16, 17, 32+17, 18, 32+18, 19, 32+19, 20, 32+20, 21, 32+21, 22, 32+22, 23, 32+23);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000728}
729
Michael Kupersteine45af542015-06-30 13:36:19 +0000730static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000731_mm256_unpacklo_epi16(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000732{
David Blaikie3302f2b2013-01-16 23:08:36 +0000733 return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000734}
735
Michael Kupersteine45af542015-06-30 13:36:19 +0000736static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000737_mm256_unpacklo_epi32(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000738{
David Blaikie3302f2b2013-01-16 23:08:36 +0000739 return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 0, 8+0, 1, 8+1, 4, 8+4, 5, 8+5);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000740}
741
Michael Kupersteine45af542015-06-30 13:36:19 +0000742static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000743_mm256_unpacklo_epi64(__m256i __a, __m256i __b)
Craig Toppera6fdbd12011-12-24 03:58:43 +0000744{
Craig Topper1aa231e2016-05-16 06:38:42 +0000745 return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 0, 4+0, 2, 4+2);
Craig Toppera6fdbd12011-12-24 03:58:43 +0000746}
747
Michael Kupersteine45af542015-06-30 13:36:19 +0000748static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000749_mm256_xor_si256(__m256i __a, __m256i __b)
Craig Toppera557e1c2011-12-19 09:03:48 +0000750{
Craig Topper1aa231e2016-05-16 06:38:42 +0000751 return (__m256i)((__v4di)__a ^ (__v4di)__b);
Craig Toppera557e1c2011-12-19 09:03:48 +0000752}
Craig Topper94798952011-12-24 05:19:29 +0000753
Michael Kupersteine45af542015-06-30 13:36:19 +0000754static __inline__ __m256i __DEFAULT_FN_ATTRS
Ahmed Bougacha7dfaaf32015-10-02 23:29:26 +0000755_mm256_stream_load_si256(__m256i const *__V)
Craig Topper94798952011-12-24 05:19:29 +0000756{
Ahmed Bougacha7dfaaf32015-10-02 23:29:26 +0000757 return (__m256i)__builtin_ia32_movntdqa256((const __v4di *)__V);
Craig Topper94798952011-12-24 05:19:29 +0000758}
759
Michael Kupersteine45af542015-06-30 13:36:19 +0000760static __inline__ __m128 __DEFAULT_FN_ATTRS
Craig Topper94798952011-12-24 05:19:29 +0000761_mm_broadcastss_ps(__m128 __X)
762{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000763 return (__m128)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0);
Craig Topper94798952011-12-24 05:19:29 +0000764}
765
Michael Kupersteine45af542015-06-30 13:36:19 +0000766static __inline__ __m128d __DEFAULT_FN_ATTRS
Michael Kuperstein877f3cb2015-05-19 14:49:14 +0000767_mm_broadcastsd_pd(__m128d __a)
768{
Craig Topper1aa231e2016-05-16 06:38:42 +0000769 return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
Michael Kuperstein877f3cb2015-05-19 14:49:14 +0000770}
771
Michael Kupersteine45af542015-06-30 13:36:19 +0000772static __inline__ __m256 __DEFAULT_FN_ATTRS
Craig Topper94798952011-12-24 05:19:29 +0000773_mm256_broadcastss_ps(__m128 __X)
774{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000775 return (__m256)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0, 0, 0, 0, 0);
Craig Topper94798952011-12-24 05:19:29 +0000776}
777
Michael Kupersteine45af542015-06-30 13:36:19 +0000778static __inline__ __m256d __DEFAULT_FN_ATTRS
Craig Topper94798952011-12-24 05:19:29 +0000779_mm256_broadcastsd_pd(__m128d __X)
780{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000781 return (__m256d)__builtin_shufflevector((__v2df)__X, (__v2df)__X, 0, 0, 0, 0);
Craig Topper94798952011-12-24 05:19:29 +0000782}
783
Michael Kupersteine45af542015-06-30 13:36:19 +0000784static __inline__ __m256i __DEFAULT_FN_ATTRS
Juergen Ributzka2c2dbf42013-08-17 16:40:09 +0000785_mm256_broadcastsi128_si256(__m128i __X)
Craig Topper94798952011-12-24 05:19:29 +0000786{
Craig Topper1aa231e2016-05-16 06:38:42 +0000787 return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 1);
Craig Topper94798952011-12-24 05:19:29 +0000788}
789
790#define _mm_blend_epi32(V1, V2, M) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000791 (__m128i)__builtin_shufflevector((__v4si)(__m128i)(V1), \
792 (__v4si)(__m128i)(V2), \
Filipe Cabecinhas5d289b42014-05-13 02:37:02 +0000793 (((M) & 0x01) ? 4 : 0), \
794 (((M) & 0x02) ? 5 : 1), \
795 (((M) & 0x04) ? 6 : 2), \
796 (((M) & 0x08) ? 7 : 3)); })
Craig Topper94798952011-12-24 05:19:29 +0000797
798#define _mm256_blend_epi32(V1, V2, M) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000799 (__m256i)__builtin_shufflevector((__v8si)(__m256i)(V1), \
800 (__v8si)(__m256i)(V2), \
Filipe Cabecinhas5d289b42014-05-13 02:37:02 +0000801 (((M) & 0x01) ? 8 : 0), \
802 (((M) & 0x02) ? 9 : 1), \
803 (((M) & 0x04) ? 10 : 2), \
804 (((M) & 0x08) ? 11 : 3), \
805 (((M) & 0x10) ? 12 : 4), \
806 (((M) & 0x20) ? 13 : 5), \
807 (((M) & 0x40) ? 14 : 6), \
808 (((M) & 0x80) ? 15 : 7)); })
Craig Topper9f009482011-12-24 07:55:14 +0000809
Michael Kupersteine45af542015-06-30 13:36:19 +0000810static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000811_mm256_broadcastb_epi8(__m128i __X)
812{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000813 return (__m256i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000814}
815
Michael Kupersteine45af542015-06-30 13:36:19 +0000816static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000817_mm256_broadcastw_epi16(__m128i __X)
818{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000819 return (__m256i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000820}
821
Michael Kupersteine45af542015-06-30 13:36:19 +0000822static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000823_mm256_broadcastd_epi32(__m128i __X)
824{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000825 return (__m256i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000826}
827
Michael Kupersteine45af542015-06-30 13:36:19 +0000828static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000829_mm256_broadcastq_epi64(__m128i __X)
830{
Craig Topper1aa231e2016-05-16 06:38:42 +0000831 return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000832}
833
Michael Kupersteine45af542015-06-30 13:36:19 +0000834static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000835_mm_broadcastb_epi8(__m128i __X)
836{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000837 return (__m128i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000838}
839
Michael Kupersteine45af542015-06-30 13:36:19 +0000840static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000841_mm_broadcastw_epi16(__m128i __X)
842{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000843 return (__m128i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000844}
845
846
Michael Kupersteine45af542015-06-30 13:36:19 +0000847static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000848_mm_broadcastd_epi32(__m128i __X)
849{
Ahmed Bougacha5e354cb2015-08-20 20:27:21 +0000850 return (__m128i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000851}
852
Michael Kupersteine45af542015-06-30 13:36:19 +0000853static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper9f009482011-12-24 07:55:14 +0000854_mm_broadcastq_epi64(__m128i __X)
855{
Craig Topper1aa231e2016-05-16 06:38:42 +0000856 return (__m128i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0);
Craig Topper9f009482011-12-24 07:55:14 +0000857}
858
Michael Kupersteine45af542015-06-30 13:36:19 +0000859static __inline__ __m256i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000860_mm256_permutevar8x32_epi32(__m256i __a, __m256i __b)
Craig Topper9f009482011-12-24 07:55:14 +0000861{
David Blaikie3302f2b2013-01-16 23:08:36 +0000862 return (__m256i)__builtin_ia32_permvarsi256((__v8si)__a, (__v8si)__b);
Craig Topper9f009482011-12-24 07:55:14 +0000863}
864
865#define _mm256_permute4x64_pd(V, M) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000866 (__m256d)__builtin_shufflevector((__v4df)(__m256d)(V), \
867 (__v4df)_mm256_setzero_pd(), \
Craig Topper8e578552012-04-15 22:18:10 +0000868 (M) & 0x3, ((M) & 0xc) >> 2, \
869 ((M) & 0x30) >> 4, ((M) & 0xc0) >> 6); })
Craig Topper9f009482011-12-24 07:55:14 +0000870
Michael Kupersteine45af542015-06-30 13:36:19 +0000871static __inline__ __m256 __DEFAULT_FN_ATTRS
Craig Toppere20b8c62015-11-29 22:53:32 +0000872_mm256_permutevar8x32_ps(__m256 __a, __m256i __b)
Craig Topper9f009482011-12-24 07:55:14 +0000873{
Craig Toppere20b8c62015-11-29 22:53:32 +0000874 return (__m256)__builtin_ia32_permvarsf256((__v8sf)__a, (__v8si)__b);
Craig Topper9f009482011-12-24 07:55:14 +0000875}
876
877#define _mm256_permute4x64_epi64(V, M) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000878 (__m256i)__builtin_shufflevector((__v4di)(__m256i)(V), \
879 (__v4di)_mm256_setzero_si256(), \
Craig Topper8e578552012-04-15 22:18:10 +0000880 (M) & 0x3, ((M) & 0xc) >> 2, \
881 ((M) & 0x30) >> 4, ((M) & 0xc0) >> 6); })
Craig Topper9f009482011-12-24 07:55:14 +0000882
883#define _mm256_permute2x128_si256(V1, V2, M) __extension__ ({ \
Craig Topper71481662015-11-10 05:08:05 +0000884 (__m256i)__builtin_ia32_permti256((__m256i)(V1), (__m256i)(V2), (M)); })
Craig Topper175543a2011-12-24 17:20:15 +0000885
Sanjay Patel0a6da5d2015-03-12 21:54:24 +0000886#define _mm256_extracti128_si256(V, M) __extension__ ({ \
Craig Topperd619eaaa2015-11-11 03:47:10 +0000887 (__m128i)__builtin_shufflevector((__v4di)(__m256i)(V), \
888 (__v4di)_mm256_setzero_si256(), \
889 (((M) & 1) ? 2 : 0), \
890 (((M) & 1) ? 3 : 1) ); })
Craig Topper175543a2011-12-24 17:20:15 +0000891
Sanjay Patel0a6da5d2015-03-12 21:54:24 +0000892#define _mm256_inserti128_si256(V1, V2, M) __extension__ ({ \
Craig Topperd619eaaa2015-11-11 03:47:10 +0000893 (__m256i)__builtin_shufflevector((__v4di)(__m256i)(V1), \
894 (__v4di)_mm256_castsi128_si256((__m128i)(V2)), \
895 (((M) & 1) ? 0 : 4), \
896 (((M) & 1) ? 1 : 5), \
897 (((M) & 1) ? 4 : 2), \
898 (((M) & 1) ? 5 : 3) ); })
Craig Topper175543a2011-12-24 17:20:15 +0000899
Michael Kupersteine45af542015-06-30 13:36:19 +0000900static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000901_mm256_maskload_epi32(int const *__X, __m256i __M)
902{
903 return (__m256i)__builtin_ia32_maskloadd256((const __v8si *)__X, (__v8si)__M);
904}
905
Michael Kupersteine45af542015-06-30 13:36:19 +0000906static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000907_mm256_maskload_epi64(long long const *__X, __m256i __M)
908{
Craig Topper1aa231e2016-05-16 06:38:42 +0000909 return (__m256i)__builtin_ia32_maskloadq256((const __v4di *)__X, (__v4di)__M);
Craig Topper175543a2011-12-24 17:20:15 +0000910}
911
Michael Kupersteine45af542015-06-30 13:36:19 +0000912static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000913_mm_maskload_epi32(int const *__X, __m128i __M)
914{
915 return (__m128i)__builtin_ia32_maskloadd((const __v4si *)__X, (__v4si)__M);
916}
917
Michael Kupersteine45af542015-06-30 13:36:19 +0000918static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000919_mm_maskload_epi64(long long const *__X, __m128i __M)
920{
921 return (__m128i)__builtin_ia32_maskloadq((const __v2di *)__X, (__v2di)__M);
922}
923
Michael Kupersteine45af542015-06-30 13:36:19 +0000924static __inline__ void __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000925_mm256_maskstore_epi32(int *__X, __m256i __M, __m256i __Y)
926{
927 __builtin_ia32_maskstored256((__v8si *)__X, (__v8si)__M, (__v8si)__Y);
928}
929
Michael Kupersteine45af542015-06-30 13:36:19 +0000930static __inline__ void __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000931_mm256_maskstore_epi64(long long *__X, __m256i __M, __m256i __Y)
932{
Craig Topper1aa231e2016-05-16 06:38:42 +0000933 __builtin_ia32_maskstoreq256((__v4di *)__X, (__v4di)__M, (__v4di)__Y);
Craig Topper175543a2011-12-24 17:20:15 +0000934}
935
Michael Kupersteine45af542015-06-30 13:36:19 +0000936static __inline__ void __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000937_mm_maskstore_epi32(int *__X, __m128i __M, __m128i __Y)
938{
939 __builtin_ia32_maskstored((__v4si *)__X, (__v4si)__M, (__v4si)__Y);
940}
941
Michael Kupersteine45af542015-06-30 13:36:19 +0000942static __inline__ void __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000943_mm_maskstore_epi64(long long *__X, __m128i __M, __m128i __Y)
944{
Craig Topper1aa231e2016-05-16 06:38:42 +0000945 __builtin_ia32_maskstoreq(( __v2di *)__X, (__v2di)__M, (__v2di)__Y);
Craig Topper175543a2011-12-24 17:20:15 +0000946}
947
Michael Kupersteine45af542015-06-30 13:36:19 +0000948static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000949_mm256_sllv_epi32(__m256i __X, __m256i __Y)
950{
951 return (__m256i)__builtin_ia32_psllv8si((__v8si)__X, (__v8si)__Y);
952}
953
Michael Kupersteine45af542015-06-30 13:36:19 +0000954static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000955_mm_sllv_epi32(__m128i __X, __m128i __Y)
956{
957 return (__m128i)__builtin_ia32_psllv4si((__v4si)__X, (__v4si)__Y);
958}
959
Michael Kupersteine45af542015-06-30 13:36:19 +0000960static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000961_mm256_sllv_epi64(__m256i __X, __m256i __Y)
962{
Craig Topper1aa231e2016-05-16 06:38:42 +0000963 return (__m256i)__builtin_ia32_psllv4di((__v4di)__X, (__v4di)__Y);
Craig Topper175543a2011-12-24 17:20:15 +0000964}
965
Michael Kupersteine45af542015-06-30 13:36:19 +0000966static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000967_mm_sllv_epi64(__m128i __X, __m128i __Y)
968{
Craig Topper1aa231e2016-05-16 06:38:42 +0000969 return (__m128i)__builtin_ia32_psllv2di((__v2di)__X, (__v2di)__Y);
Craig Topper175543a2011-12-24 17:20:15 +0000970}
971
Michael Kupersteine45af542015-06-30 13:36:19 +0000972static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000973_mm256_srav_epi32(__m256i __X, __m256i __Y)
974{
975 return (__m256i)__builtin_ia32_psrav8si((__v8si)__X, (__v8si)__Y);
976}
977
Michael Kupersteine45af542015-06-30 13:36:19 +0000978static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000979_mm_srav_epi32(__m128i __X, __m128i __Y)
980{
981 return (__m128i)__builtin_ia32_psrav4si((__v4si)__X, (__v4si)__Y);
982}
983
Michael Kupersteine45af542015-06-30 13:36:19 +0000984static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000985_mm256_srlv_epi32(__m256i __X, __m256i __Y)
986{
987 return (__m256i)__builtin_ia32_psrlv8si((__v8si)__X, (__v8si)__Y);
988}
989
Michael Kupersteine45af542015-06-30 13:36:19 +0000990static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000991_mm_srlv_epi32(__m128i __X, __m128i __Y)
992{
993 return (__m128i)__builtin_ia32_psrlv4si((__v4si)__X, (__v4si)__Y);
994}
995
Michael Kupersteine45af542015-06-30 13:36:19 +0000996static __inline__ __m256i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +0000997_mm256_srlv_epi64(__m256i __X, __m256i __Y)
998{
Craig Topper1aa231e2016-05-16 06:38:42 +0000999 return (__m256i)__builtin_ia32_psrlv4di((__v4di)__X, (__v4di)__Y);
Craig Topper175543a2011-12-24 17:20:15 +00001000}
1001
Michael Kupersteine45af542015-06-30 13:36:19 +00001002static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper175543a2011-12-24 17:20:15 +00001003_mm_srlv_epi64(__m128i __X, __m128i __Y)
1004{
Craig Topper1aa231e2016-05-16 06:38:42 +00001005 return (__m128i)__builtin_ia32_psrlv2di((__v2di)__X, (__v2di)__Y);
Craig Topper175543a2011-12-24 17:20:15 +00001006}
Manman Renadd5e9e2012-06-26 19:55:09 +00001007
1008#define _mm_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001009 (__m128d)__builtin_ia32_gatherd_pd((__v2df)(__m128i)(a), \
1010 (double const *)(m), \
1011 (__v4si)(__m128i)(i), \
1012 (__v2df)(__m128d)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001013
1014#define _mm256_mask_i32gather_pd(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001015 (__m256d)__builtin_ia32_gatherd_pd256((__v4df)(__m256d)(a), \
1016 (double const *)(m), \
1017 (__v4si)(__m128i)(i), \
1018 (__v4df)(__m256d)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001019
1020#define _mm_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001021 (__m128d)__builtin_ia32_gatherq_pd((__v2df)(__m128d)(a), \
1022 (double const *)(m), \
1023 (__v2di)(__m128i)(i), \
1024 (__v2df)(__m128d)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001025
1026#define _mm256_mask_i64gather_pd(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001027 (__m256d)__builtin_ia32_gatherq_pd256((__v4df)(__m256d)(a), \
1028 (double const *)(m), \
1029 (__v4di)(__m256i)(i), \
1030 (__v4df)(__m256d)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001031
1032#define _mm_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001033 (__m128)__builtin_ia32_gatherd_ps((__v4sf)(__m128)(a), \
1034 (float const *)(m), \
1035 (__v4si)(__m128i)(i), \
1036 (__v4sf)(__m128)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001037
1038#define _mm256_mask_i32gather_ps(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001039 (__m256)__builtin_ia32_gatherd_ps256((__v8sf)(__m256)(a), \
1040 (float const *)(m), \
1041 (__v8si)(__m256i)(i), \
1042 (__v8sf)(__m256)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001043
1044#define _mm_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001045 (__m128)__builtin_ia32_gatherq_ps((__v4sf)(__m128)(a), \
1046 (float const *)(m), \
1047 (__v2di)(__m128i)(i), \
1048 (__v4sf)(__m128)(mask), (s)); })
Manman Renadd5e9e2012-06-26 19:55:09 +00001049
1050#define _mm256_mask_i64gather_ps(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001051 (__m128)__builtin_ia32_gatherq_ps256((__v4sf)(__m128)(a), \
1052 (float const *)(m), \
1053 (__v4di)(__m256i)(i), \
1054 (__v4sf)(__m128)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001055
1056#define _mm_mask_i32gather_epi32(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001057 (__m128i)__builtin_ia32_gatherd_d((__v4si)(__m128i)(a), \
1058 (int const *)(m), \
1059 (__v4si)(__m128i)(i), \
1060 (__v4si)(__m128i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001061
1062#define _mm256_mask_i32gather_epi32(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001063 (__m256i)__builtin_ia32_gatherd_d256((__v8si)(__m256i)(a), \
1064 (int const *)(m), \
1065 (__v8si)(__m256i)(i), \
1066 (__v8si)(__m256i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001067
1068#define _mm_mask_i64gather_epi32(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001069 (__m128i)__builtin_ia32_gatherq_d((__v4si)(__m128i)(a), \
1070 (int const *)(m), \
1071 (__v2di)(__m128i)(i), \
1072 (__v4si)(__m128i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001073
1074#define _mm256_mask_i64gather_epi32(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001075 (__m128i)__builtin_ia32_gatherq_d256((__v4si)(__m128i)(a), \
1076 (int const *)(m), \
1077 (__v4di)(__m256i)(i), \
1078 (__v4si)(__m128i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001079
1080#define _mm_mask_i32gather_epi64(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001081 (__m128i)__builtin_ia32_gatherd_q((__v2di)(__m128i)(a), \
1082 (long long const *)(m), \
1083 (__v4si)(__m128i)(i), \
1084 (__v2di)(__m128i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001085
1086#define _mm256_mask_i32gather_epi64(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001087 (__m256i)__builtin_ia32_gatherd_q256((__v4di)(__m256i)(a), \
1088 (long long const *)(m), \
1089 (__v4si)(__m128i)(i), \
1090 (__v4di)(__m256i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001091
1092#define _mm_mask_i64gather_epi64(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001093 (__m128i)__builtin_ia32_gatherq_q((__v2di)(__m128i)(a), \
1094 (long long const *)(m), \
1095 (__v2di)(__m128i)(i), \
1096 (__v2di)(__m128i)(mask), (s)); })
Manman Ren86c32502012-06-29 00:54:35 +00001097
1098#define _mm256_mask_i64gather_epi64(a, m, i, mask, s) __extension__ ({ \
Craig Topper19744ee2015-11-11 02:51:18 +00001099 (__m256i)__builtin_ia32_gatherq_q256((__v4di)(__m256i)(a), \
1100 (long long const *)(m), \
1101 (__v4di)(__m256i)(i), \
1102 (__v4di)(__m256i)(mask), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001103
1104#define _mm_i32gather_pd(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001105 (__m128d)__builtin_ia32_gatherd_pd((__v2df)_mm_undefined_pd(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001106 (double const *)(m), \
1107 (__v4si)(__m128i)(i), \
Craig Topper5ec97a72015-12-01 07:12:59 +00001108 (__v2df)_mm_cmpeq_pd(_mm_setzero_pd(), \
1109 _mm_setzero_pd()), \
Craig Topper19744ee2015-11-11 02:51:18 +00001110 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001111
1112#define _mm256_i32gather_pd(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001113 (__m256d)__builtin_ia32_gatherd_pd256((__v4df)_mm256_undefined_pd(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001114 (double const *)(m), \
1115 (__v4si)(__m128i)(i), \
Craig Topper5ec97a72015-12-01 07:12:59 +00001116 (__v4df)_mm256_cmp_pd(_mm256_setzero_pd(), \
1117 _mm256_setzero_pd(), \
1118 _CMP_EQ_OQ), \
Craig Topper19744ee2015-11-11 02:51:18 +00001119 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001120
1121#define _mm_i64gather_pd(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001122 (__m128d)__builtin_ia32_gatherq_pd((__v2df)_mm_undefined_pd(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001123 (double const *)(m), \
1124 (__v2di)(__m128i)(i), \
Craig Topper5ec97a72015-12-01 07:12:59 +00001125 (__v2df)_mm_cmpeq_pd(_mm_setzero_pd(), \
1126 _mm_setzero_pd()), \
Craig Topper19744ee2015-11-11 02:51:18 +00001127 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001128
1129#define _mm256_i64gather_pd(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001130 (__m256d)__builtin_ia32_gatherq_pd256((__v4df)_mm256_undefined_pd(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001131 (double const *)(m), \
1132 (__v4di)(__m256i)(i), \
Craig Topper5ec97a72015-12-01 07:12:59 +00001133 (__v4df)_mm256_cmp_pd(_mm256_setzero_pd(), \
1134 _mm256_setzero_pd(), \
1135 _CMP_EQ_OQ), \
Craig Topper19744ee2015-11-11 02:51:18 +00001136 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001137
1138#define _mm_i32gather_ps(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001139 (__m128)__builtin_ia32_gatherd_ps((__v4sf)_mm_undefined_ps(), \
1140 (float const *)(m), \
1141 (__v4si)(__m128i)(i), \
1142 (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \
1143 _mm_setzero_ps()), \
Craig Topper19744ee2015-11-11 02:51:18 +00001144 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001145
1146#define _mm256_i32gather_ps(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001147 (__m256)__builtin_ia32_gatherd_ps256((__v8sf)_mm256_undefined_ps(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001148 (float const *)(m), \
1149 (__v8si)(__m256i)(i), \
Craig Topper5ec97a72015-12-01 07:12:59 +00001150 (__v8sf)_mm256_cmp_ps(_mm256_setzero_ps(), \
1151 _mm256_setzero_ps(), \
1152 _CMP_EQ_OQ), \
Craig Topper19744ee2015-11-11 02:51:18 +00001153 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001154
1155#define _mm_i64gather_ps(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001156 (__m128)__builtin_ia32_gatherq_ps((__v4sf)_mm_undefined_ps(), \
1157 (float const *)(m), \
1158 (__v2di)(__m128i)(i), \
1159 (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \
1160 _mm_setzero_ps()), \
Craig Topper19744ee2015-11-11 02:51:18 +00001161 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001162
1163#define _mm256_i64gather_ps(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001164 (__m128)__builtin_ia32_gatherq_ps256((__v4sf)_mm_undefined_ps(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001165 (float const *)(m), \
1166 (__v4di)(__m256i)(i), \
Craig Topper5ec97a72015-12-01 07:12:59 +00001167 (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \
1168 _mm_setzero_ps()), \
Craig Topper19744ee2015-11-11 02:51:18 +00001169 (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001170
1171#define _mm_i32gather_epi32(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001172 (__m128i)__builtin_ia32_gatherd_d((__v4si)_mm_undefined_si128(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001173 (int const *)(m), (__v4si)(__m128i)(i), \
1174 (__v4si)_mm_set1_epi32(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001175
1176#define _mm256_i32gather_epi32(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001177 (__m256i)__builtin_ia32_gatherd_d256((__v8si)_mm256_undefined_si256(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001178 (int const *)(m), (__v8si)(__m256i)(i), \
1179 (__v8si)_mm256_set1_epi32(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001180
1181#define _mm_i64gather_epi32(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001182 (__m128i)__builtin_ia32_gatherq_d((__v4si)_mm_undefined_si128(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001183 (int const *)(m), (__v2di)(__m128i)(i), \
1184 (__v4si)_mm_set1_epi32(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001185
1186#define _mm256_i64gather_epi32(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001187 (__m128i)__builtin_ia32_gatherq_d256((__v4si)_mm_undefined_si128(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001188 (int const *)(m), (__v4di)(__m256i)(i), \
1189 (__v4si)_mm_set1_epi32(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001190
1191#define _mm_i32gather_epi64(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001192 (__m128i)__builtin_ia32_gatherd_q((__v2di)_mm_undefined_si128(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001193 (long long const *)(m), \
1194 (__v4si)(__m128i)(i), \
1195 (__v2di)_mm_set1_epi64x(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001196
1197#define _mm256_i32gather_epi64(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001198 (__m256i)__builtin_ia32_gatherd_q256((__v4di)_mm256_undefined_si256(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001199 (long long const *)(m), \
1200 (__v4si)(__m128i)(i), \
1201 (__v4di)_mm256_set1_epi64x(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001202
1203#define _mm_i64gather_epi64(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001204 (__m128i)__builtin_ia32_gatherq_q((__v2di)_mm_undefined_si128(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001205 (long long const *)(m), \
1206 (__v2di)(__m128i)(i), \
1207 (__v2di)_mm_set1_epi64x(-1), (s)); })
Manman Renf865ba02012-06-29 05:19:13 +00001208
1209#define _mm256_i64gather_epi64(m, i, s) __extension__ ({ \
Craig Topper5ec97a72015-12-01 07:12:59 +00001210 (__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_undefined_si256(), \
Craig Topper19744ee2015-11-11 02:51:18 +00001211 (long long const *)(m), \
1212 (__v4di)(__m256i)(i), \
1213 (__v4di)_mm256_set1_epi64x(-1), (s)); })
Richard Smith49e56442013-07-14 05:41:45 +00001214
Michael Kupersteine45af542015-06-30 13:36:19 +00001215#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +00001216
Richard Smith49e56442013-07-14 05:41:45 +00001217#endif /* __AVX2INTRIN_H */