blob: aba2438ca0a427306d09c652979f9a83cedebefe [file] [log] [blame]
Benjamin Kramerae8ea1f2010-08-20 16:47:17 +00001/*===---- emmintrin.h - SSE2 intrinsics ------------------------------------===
Anders Carlssonf15e71d2008-12-24 01:45:22 +00002 *
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 */
Benjamin Kramerae8ea1f2010-08-20 16:47:17 +000023
Anders Carlssonf15e71d2008-12-24 01:45:22 +000024#ifndef __EMMINTRIN_H
25#define __EMMINTRIN_H
26
Anders Carlssonf15e71d2008-12-24 01:45:22 +000027#include <xmmintrin.h>
28
29typedef double __m128d __attribute__((__vector_size__(16)));
30typedef long long __m128i __attribute__((__vector_size__(16)));
31
Eric Christopher2a9898f2010-08-26 02:09:25 +000032/* Type defines. */
33typedef double __v2df __attribute__ ((__vector_size__ (16)));
34typedef long long __v2di __attribute__ ((__vector_size__ (16)));
Anders Carlssona283f912008-12-24 02:41:00 +000035typedef short __v8hi __attribute__((__vector_size__(16)));
Anders Carlsson327c8df2009-09-18 19:18:19 +000036typedef char __v16qi __attribute__((__vector_size__(16)));
Anders Carlssonf15e71d2008-12-24 01:45:22 +000037
Chandler Carruthcbe64112015-10-01 23:40:12 +000038/* We need an explicitly signed variant for char. Note that this shouldn't
39 * appear in the interface though. */
40typedef signed char __v16qs __attribute__((__vector_size__(16)));
41
Michael Kupersteina10dff92015-09-21 13:34:47 +000042#include <f16cintrin.h>
43
Eric Christopher4d1851682015-06-17 07:09:20 +000044/* Define the default attributes for the functions in this file. */
Michael Kupersteine45af542015-06-30 13:36:19 +000045#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))
Eric Christopher4d1851682015-06-17 07:09:20 +000046
Michael Kupersteine45af542015-06-30 13:36:19 +000047static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000048_mm_add_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000049{
David Blaikie3302f2b2013-01-16 23:08:36 +000050 __a[0] += __b[0];
51 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000052}
53
Michael Kupersteine45af542015-06-30 13:36:19 +000054static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000055_mm_add_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000056{
David Blaikie3302f2b2013-01-16 23:08:36 +000057 return __a + __b;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000058}
59
Michael Kupersteine45af542015-06-30 13:36:19 +000060static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000061_mm_sub_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000062{
David Blaikie3302f2b2013-01-16 23:08:36 +000063 __a[0] -= __b[0];
64 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000065}
66
Michael Kupersteine45af542015-06-30 13:36:19 +000067static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000068_mm_sub_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000069{
David Blaikie3302f2b2013-01-16 23:08:36 +000070 return __a - __b;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000071}
72
Michael Kupersteine45af542015-06-30 13:36:19 +000073static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000074_mm_mul_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000075{
David Blaikie3302f2b2013-01-16 23:08:36 +000076 __a[0] *= __b[0];
77 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000078}
79
Michael Kupersteine45af542015-06-30 13:36:19 +000080static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000081_mm_mul_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000082{
David Blaikie3302f2b2013-01-16 23:08:36 +000083 return __a * __b;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000084}
85
Michael Kupersteine45af542015-06-30 13:36:19 +000086static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000087_mm_div_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000088{
David Blaikie3302f2b2013-01-16 23:08:36 +000089 __a[0] /= __b[0];
90 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000091}
92
Michael Kupersteine45af542015-06-30 13:36:19 +000093static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000094_mm_div_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000095{
David Blaikie3302f2b2013-01-16 23:08:36 +000096 return __a / __b;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000097}
98
Michael Kupersteine45af542015-06-30 13:36:19 +000099static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000100_mm_sqrt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000101{
David Blaikie3302f2b2013-01-16 23:08:36 +0000102 __m128d __c = __builtin_ia32_sqrtsd(__b);
103 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000104}
105
Michael Kupersteine45af542015-06-30 13:36:19 +0000106static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000107_mm_sqrt_pd(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000108{
David Blaikie3302f2b2013-01-16 23:08:36 +0000109 return __builtin_ia32_sqrtpd(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000110}
111
Michael Kupersteine45af542015-06-30 13:36:19 +0000112static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000113_mm_min_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000114{
David Blaikie3302f2b2013-01-16 23:08:36 +0000115 return __builtin_ia32_minsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000116}
117
Michael Kupersteine45af542015-06-30 13:36:19 +0000118static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000119_mm_min_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000120{
David Blaikie3302f2b2013-01-16 23:08:36 +0000121 return __builtin_ia32_minpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000122}
123
Michael Kupersteine45af542015-06-30 13:36:19 +0000124static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000125_mm_max_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000126{
David Blaikie3302f2b2013-01-16 23:08:36 +0000127 return __builtin_ia32_maxsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000128}
129
Michael Kupersteine45af542015-06-30 13:36:19 +0000130static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000131_mm_max_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000132{
David Blaikie3302f2b2013-01-16 23:08:36 +0000133 return __builtin_ia32_maxpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000134}
135
Michael Kupersteine45af542015-06-30 13:36:19 +0000136static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000137_mm_and_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000138{
David Blaikie3302f2b2013-01-16 23:08:36 +0000139 return (__m128d)((__v4si)__a & (__v4si)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000140}
141
Michael Kupersteine45af542015-06-30 13:36:19 +0000142static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000143_mm_andnot_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000144{
David Blaikie3302f2b2013-01-16 23:08:36 +0000145 return (__m128d)(~(__v4si)__a & (__v4si)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000146}
147
Michael Kupersteine45af542015-06-30 13:36:19 +0000148static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000149_mm_or_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000150{
David Blaikie3302f2b2013-01-16 23:08:36 +0000151 return (__m128d)((__v4si)__a | (__v4si)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000152}
153
Michael Kupersteine45af542015-06-30 13:36:19 +0000154static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000155_mm_xor_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000156{
David Blaikie3302f2b2013-01-16 23:08:36 +0000157 return (__m128d)((__v4si)__a ^ (__v4si)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000158}
159
Michael Kupersteine45af542015-06-30 13:36:19 +0000160static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000161_mm_cmpeq_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000162{
Craig Topper2094d8f2014-12-27 06:59:57 +0000163 return (__m128d)__builtin_ia32_cmpeqpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000164}
165
Michael Kupersteine45af542015-06-30 13:36:19 +0000166static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000167_mm_cmplt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000168{
Craig Topper2094d8f2014-12-27 06:59:57 +0000169 return (__m128d)__builtin_ia32_cmpltpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000170}
171
Michael Kupersteine45af542015-06-30 13:36:19 +0000172static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000173_mm_cmple_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000174{
Craig Topper2094d8f2014-12-27 06:59:57 +0000175 return (__m128d)__builtin_ia32_cmplepd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000176}
177
Michael Kupersteine45af542015-06-30 13:36:19 +0000178static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000179_mm_cmpgt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000180{
Craig Topper2094d8f2014-12-27 06:59:57 +0000181 return (__m128d)__builtin_ia32_cmpltpd(__b, __a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000182}
183
Michael Kupersteine45af542015-06-30 13:36:19 +0000184static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000185_mm_cmpge_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000186{
Craig Topper2094d8f2014-12-27 06:59:57 +0000187 return (__m128d)__builtin_ia32_cmplepd(__b, __a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000188}
189
Michael Kupersteine45af542015-06-30 13:36:19 +0000190static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000191_mm_cmpord_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000192{
Craig Topper2094d8f2014-12-27 06:59:57 +0000193 return (__m128d)__builtin_ia32_cmpordpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000194}
195
Michael Kupersteine45af542015-06-30 13:36:19 +0000196static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000197_mm_cmpunord_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000198{
Craig Topper2094d8f2014-12-27 06:59:57 +0000199 return (__m128d)__builtin_ia32_cmpunordpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000200}
201
Michael Kupersteine45af542015-06-30 13:36:19 +0000202static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000203_mm_cmpneq_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000204{
Craig Topper2094d8f2014-12-27 06:59:57 +0000205 return (__m128d)__builtin_ia32_cmpneqpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000206}
207
Michael Kupersteine45af542015-06-30 13:36:19 +0000208static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000209_mm_cmpnlt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000210{
Craig Topper2094d8f2014-12-27 06:59:57 +0000211 return (__m128d)__builtin_ia32_cmpnltpd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000212}
213
Michael Kupersteine45af542015-06-30 13:36:19 +0000214static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000215_mm_cmpnle_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000216{
Craig Topper2094d8f2014-12-27 06:59:57 +0000217 return (__m128d)__builtin_ia32_cmpnlepd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000218}
219
Michael Kupersteine45af542015-06-30 13:36:19 +0000220static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000221_mm_cmpngt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000222{
Craig Topper2094d8f2014-12-27 06:59:57 +0000223 return (__m128d)__builtin_ia32_cmpnltpd(__b, __a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000224}
225
Michael Kupersteine45af542015-06-30 13:36:19 +0000226static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000227_mm_cmpnge_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000228{
Craig Topper2094d8f2014-12-27 06:59:57 +0000229 return (__m128d)__builtin_ia32_cmpnlepd(__b, __a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000230}
231
Michael Kupersteine45af542015-06-30 13:36:19 +0000232static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000233_mm_cmpeq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000234{
Craig Topper2094d8f2014-12-27 06:59:57 +0000235 return (__m128d)__builtin_ia32_cmpeqsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000236}
237
Michael Kupersteine45af542015-06-30 13:36:19 +0000238static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000239_mm_cmplt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000240{
Craig Topper2094d8f2014-12-27 06:59:57 +0000241 return (__m128d)__builtin_ia32_cmpltsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000242}
243
Michael Kupersteine45af542015-06-30 13:36:19 +0000244static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000245_mm_cmple_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000246{
Craig Topper2094d8f2014-12-27 06:59:57 +0000247 return (__m128d)__builtin_ia32_cmplesd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000248}
249
Michael Kupersteine45af542015-06-30 13:36:19 +0000250static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000251_mm_cmpgt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000252{
Craig Topper2094d8f2014-12-27 06:59:57 +0000253 __m128d __c = __builtin_ia32_cmpltsd(__b, __a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000254 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000255}
256
Michael Kupersteine45af542015-06-30 13:36:19 +0000257static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000258_mm_cmpge_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000259{
Craig Topper2094d8f2014-12-27 06:59:57 +0000260 __m128d __c = __builtin_ia32_cmplesd(__b, __a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000261 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000262}
263
Michael Kupersteine45af542015-06-30 13:36:19 +0000264static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000265_mm_cmpord_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000266{
Craig Topper2094d8f2014-12-27 06:59:57 +0000267 return (__m128d)__builtin_ia32_cmpordsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000268}
269
Michael Kupersteine45af542015-06-30 13:36:19 +0000270static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000271_mm_cmpunord_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000272{
Craig Topper2094d8f2014-12-27 06:59:57 +0000273 return (__m128d)__builtin_ia32_cmpunordsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000274}
275
Michael Kupersteine45af542015-06-30 13:36:19 +0000276static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000277_mm_cmpneq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000278{
Craig Topper2094d8f2014-12-27 06:59:57 +0000279 return (__m128d)__builtin_ia32_cmpneqsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000280}
281
Michael Kupersteine45af542015-06-30 13:36:19 +0000282static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000283_mm_cmpnlt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000284{
Craig Topper2094d8f2014-12-27 06:59:57 +0000285 return (__m128d)__builtin_ia32_cmpnltsd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000286}
287
Michael Kupersteine45af542015-06-30 13:36:19 +0000288static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000289_mm_cmpnle_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000290{
Craig Topper2094d8f2014-12-27 06:59:57 +0000291 return (__m128d)__builtin_ia32_cmpnlesd(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000292}
293
Michael Kupersteine45af542015-06-30 13:36:19 +0000294static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000295_mm_cmpngt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000296{
Craig Topper2094d8f2014-12-27 06:59:57 +0000297 __m128d __c = __builtin_ia32_cmpnltsd(__b, __a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000298 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000299}
300
Michael Kupersteine45af542015-06-30 13:36:19 +0000301static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000302_mm_cmpnge_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000303{
Craig Topper2094d8f2014-12-27 06:59:57 +0000304 __m128d __c = __builtin_ia32_cmpnlesd(__b, __a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000305 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000306}
307
Michael Kupersteine45af542015-06-30 13:36:19 +0000308static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000309_mm_comieq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000310{
David Blaikie3302f2b2013-01-16 23:08:36 +0000311 return __builtin_ia32_comisdeq(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000312}
313
Michael Kupersteine45af542015-06-30 13:36:19 +0000314static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000315_mm_comilt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000316{
David Blaikie3302f2b2013-01-16 23:08:36 +0000317 return __builtin_ia32_comisdlt(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000318}
319
Michael Kupersteine45af542015-06-30 13:36:19 +0000320static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000321_mm_comile_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000322{
David Blaikie3302f2b2013-01-16 23:08:36 +0000323 return __builtin_ia32_comisdle(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000324}
325
Michael Kupersteine45af542015-06-30 13:36:19 +0000326static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000327_mm_comigt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000328{
David Blaikie3302f2b2013-01-16 23:08:36 +0000329 return __builtin_ia32_comisdgt(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000330}
331
Michael Kupersteine45af542015-06-30 13:36:19 +0000332static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000333_mm_comige_sd(__m128d __a, __m128d __b)
Eli Friedman89c11332011-10-06 20:31:50 +0000334{
David Blaikie3302f2b2013-01-16 23:08:36 +0000335 return __builtin_ia32_comisdge(__a, __b);
Eli Friedman89c11332011-10-06 20:31:50 +0000336}
337
Michael Kupersteine45af542015-06-30 13:36:19 +0000338static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000339_mm_comineq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000340{
David Blaikie3302f2b2013-01-16 23:08:36 +0000341 return __builtin_ia32_comisdneq(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000342}
343
Michael Kupersteine45af542015-06-30 13:36:19 +0000344static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000345_mm_ucomieq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000346{
David Blaikie3302f2b2013-01-16 23:08:36 +0000347 return __builtin_ia32_ucomisdeq(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000348}
349
Michael Kupersteine45af542015-06-30 13:36:19 +0000350static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000351_mm_ucomilt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000352{
David Blaikie3302f2b2013-01-16 23:08:36 +0000353 return __builtin_ia32_ucomisdlt(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000354}
355
Michael Kupersteine45af542015-06-30 13:36:19 +0000356static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000357_mm_ucomile_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000358{
David Blaikie3302f2b2013-01-16 23:08:36 +0000359 return __builtin_ia32_ucomisdle(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000360}
361
Michael Kupersteine45af542015-06-30 13:36:19 +0000362static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000363_mm_ucomigt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000364{
David Blaikie3302f2b2013-01-16 23:08:36 +0000365 return __builtin_ia32_ucomisdgt(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000366}
367
Michael Kupersteine45af542015-06-30 13:36:19 +0000368static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000369_mm_ucomige_sd(__m128d __a, __m128d __b)
Eli Friedmanf8cb4802011-08-29 21:26:24 +0000370{
David Blaikie3302f2b2013-01-16 23:08:36 +0000371 return __builtin_ia32_ucomisdge(__a, __b);
Eli Friedmanf8cb4802011-08-29 21:26:24 +0000372}
373
Michael Kupersteine45af542015-06-30 13:36:19 +0000374static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000375_mm_ucomineq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000376{
David Blaikie3302f2b2013-01-16 23:08:36 +0000377 return __builtin_ia32_ucomisdneq(__a, __b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000378}
379
Michael Kupersteine45af542015-06-30 13:36:19 +0000380static __inline__ __m128 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000381_mm_cvtpd_ps(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000382{
David Blaikie3302f2b2013-01-16 23:08:36 +0000383 return __builtin_ia32_cvtpd2ps(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000384}
385
Michael Kupersteine45af542015-06-30 13:36:19 +0000386static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000387_mm_cvtps_pd(__m128 __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000388{
David Blaikie3302f2b2013-01-16 23:08:36 +0000389 return __builtin_ia32_cvtps2pd(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000390}
391
Michael Kupersteine45af542015-06-30 13:36:19 +0000392static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000393_mm_cvtepi32_pd(__m128i __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000394{
David Blaikie3302f2b2013-01-16 23:08:36 +0000395 return __builtin_ia32_cvtdq2pd((__v4si)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000396}
397
Michael Kupersteine45af542015-06-30 13:36:19 +0000398static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000399_mm_cvtpd_epi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000400{
David Blaikie3302f2b2013-01-16 23:08:36 +0000401 return __builtin_ia32_cvtpd2dq(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000402}
403
Michael Kupersteine45af542015-06-30 13:36:19 +0000404static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000405_mm_cvtsd_si32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000406{
David Blaikie3302f2b2013-01-16 23:08:36 +0000407 return __builtin_ia32_cvtsd2si(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000408}
409
Michael Kupersteine45af542015-06-30 13:36:19 +0000410static __inline__ __m128 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000411_mm_cvtsd_ss(__m128 __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000412{
David Blaikie3302f2b2013-01-16 23:08:36 +0000413 __a[0] = __b[0];
414 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000415}
416
Michael Kupersteine45af542015-06-30 13:36:19 +0000417static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000418_mm_cvtsi32_sd(__m128d __a, int __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000419{
David Blaikie3302f2b2013-01-16 23:08:36 +0000420 __a[0] = __b;
421 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000422}
423
Michael Kupersteine45af542015-06-30 13:36:19 +0000424static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000425_mm_cvtss_sd(__m128d __a, __m128 __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000426{
David Blaikie3302f2b2013-01-16 23:08:36 +0000427 __a[0] = __b[0];
428 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000429}
430
Michael Kupersteine45af542015-06-30 13:36:19 +0000431static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000432_mm_cvttpd_epi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000433{
David Blaikie3302f2b2013-01-16 23:08:36 +0000434 return (__m128i)__builtin_ia32_cvttpd2dq(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000435}
436
Michael Kupersteine45af542015-06-30 13:36:19 +0000437static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000438_mm_cvttsd_si32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000439{
David Blaikie3302f2b2013-01-16 23:08:36 +0000440 return __a[0];
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000441}
442
Michael Kupersteine45af542015-06-30 13:36:19 +0000443static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000444_mm_cvtpd_pi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000445{
David Blaikie3302f2b2013-01-16 23:08:36 +0000446 return (__m64)__builtin_ia32_cvtpd2pi(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000447}
448
Michael Kupersteine45af542015-06-30 13:36:19 +0000449static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000450_mm_cvttpd_pi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000451{
David Blaikie3302f2b2013-01-16 23:08:36 +0000452 return (__m64)__builtin_ia32_cvttpd2pi(__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000453}
454
Michael Kupersteine45af542015-06-30 13:36:19 +0000455static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000456_mm_cvtpi32_pd(__m64 __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000457{
David Blaikie3302f2b2013-01-16 23:08:36 +0000458 return __builtin_ia32_cvtpi2pd((__v2si)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000459}
460
Michael Kupersteine45af542015-06-30 13:36:19 +0000461static __inline__ double __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000462_mm_cvtsd_f64(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000463{
David Blaikie3302f2b2013-01-16 23:08:36 +0000464 return __a[0];
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000465}
466
Michael Kupersteine45af542015-06-30 13:36:19 +0000467static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000468_mm_load_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000469{
David Blaikie3302f2b2013-01-16 23:08:36 +0000470 return *(__m128d*)__dp;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000471}
472
Michael Kupersteine45af542015-06-30 13:36:19 +0000473static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000474_mm_load1_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000475{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000476 struct __mm_load1_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000477 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000478 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000479 double __u = ((struct __mm_load1_pd_struct*)__dp)->__u;
480 return (__m128d){ __u, __u };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000481}
482
Eli Friedmanf83c2582009-06-02 05:55:48 +0000483#define _mm_load_pd1(dp) _mm_load1_pd(dp)
484
Michael Kupersteine45af542015-06-30 13:36:19 +0000485static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000486_mm_loadr_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000487{
David Blaikie3302f2b2013-01-16 23:08:36 +0000488 __m128d __u = *(__m128d*)__dp;
489 return __builtin_shufflevector(__u, __u, 1, 0);
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000490}
491
Michael Kupersteine45af542015-06-30 13:36:19 +0000492static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000493_mm_loadu_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000494{
Bill Wendling502931f2011-05-13 00:11:39 +0000495 struct __loadu_pd {
David Blaikie3302f2b2013-01-16 23:08:36 +0000496 __m128d __v;
David Majnemer1cf22e62015-02-04 00:26:10 +0000497 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000498 return ((struct __loadu_pd*)__dp)->__v;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000499}
500
Michael Kupersteine45af542015-06-30 13:36:19 +0000501static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000502_mm_load_sd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000503{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000504 struct __mm_load_sd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000505 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000506 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000507 double __u = ((struct __mm_load_sd_struct*)__dp)->__u;
508 return (__m128d){ __u, 0 };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000509}
510
Michael Kupersteine45af542015-06-30 13:36:19 +0000511static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000512_mm_loadh_pd(__m128d __a, double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000513{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000514 struct __mm_loadh_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000515 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000516 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000517 double __u = ((struct __mm_loadh_pd_struct*)__dp)->__u;
518 return (__m128d){ __a[0], __u };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000519}
520
Michael Kupersteine45af542015-06-30 13:36:19 +0000521static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000522_mm_loadl_pd(__m128d __a, double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000523{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000524 struct __mm_loadl_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000525 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000526 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000527 double __u = ((struct __mm_loadl_pd_struct*)__dp)->__u;
528 return (__m128d){ __u, __a[1] };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000529}
530
Michael Kupersteine45af542015-06-30 13:36:19 +0000531static __inline__ __m128d __DEFAULT_FN_ATTRS
Simon Pilgrim5aba9922015-08-26 21:17:12 +0000532_mm_undefined_pd()
533{
534 return (__m128d)__builtin_ia32_undef128();
535}
536
537static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000538_mm_set_sd(double __w)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000539{
David Blaikie3302f2b2013-01-16 23:08:36 +0000540 return (__m128d){ __w, 0 };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000541}
542
Michael Kupersteine45af542015-06-30 13:36:19 +0000543static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000544_mm_set1_pd(double __w)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000545{
David Blaikie3302f2b2013-01-16 23:08:36 +0000546 return (__m128d){ __w, __w };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000547}
548
Michael Kupersteine45af542015-06-30 13:36:19 +0000549static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000550_mm_set_pd(double __w, double __x)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000551{
David Blaikie3302f2b2013-01-16 23:08:36 +0000552 return (__m128d){ __x, __w };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000553}
554
Michael Kupersteine45af542015-06-30 13:36:19 +0000555static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000556_mm_setr_pd(double __w, double __x)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000557{
David Blaikie3302f2b2013-01-16 23:08:36 +0000558 return (__m128d){ __w, __x };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000559}
560
Michael Kupersteine45af542015-06-30 13:36:19 +0000561static __inline__ __m128d __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +0000562_mm_setzero_pd(void)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000563{
564 return (__m128d){ 0, 0 };
565}
566
Michael Kupersteine45af542015-06-30 13:36:19 +0000567static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000568_mm_move_sd(__m128d __a, __m128d __b)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000569{
David Blaikie3302f2b2013-01-16 23:08:36 +0000570 return (__m128d){ __b[0], __a[1] };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000571}
572
Michael Kupersteine45af542015-06-30 13:36:19 +0000573static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000574_mm_store_sd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000575{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000576 struct __mm_store_sd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000577 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000578 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000579 ((struct __mm_store_sd_struct*)__dp)->__u = __a[0];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000580}
581
Michael Kupersteine45af542015-06-30 13:36:19 +0000582static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000583_mm_store1_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000584{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000585 struct __mm_store1_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000586 double __u[2];
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000587 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000588 ((struct __mm_store1_pd_struct*)__dp)->__u[0] = __a[0];
589 ((struct __mm_store1_pd_struct*)__dp)->__u[1] = __a[0];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000590}
591
Michael Kupersteine45af542015-06-30 13:36:19 +0000592static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000593_mm_store_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000594{
David Blaikie3302f2b2013-01-16 23:08:36 +0000595 *(__m128d *)__dp = __a;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000596}
597
Michael Kupersteine45af542015-06-30 13:36:19 +0000598static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000599_mm_storeu_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000600{
David Blaikie3302f2b2013-01-16 23:08:36 +0000601 __builtin_ia32_storeupd(__dp, __a);
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000602}
603
Michael Kupersteine45af542015-06-30 13:36:19 +0000604static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000605_mm_storer_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000606{
David Blaikie3302f2b2013-01-16 23:08:36 +0000607 __a = __builtin_shufflevector(__a, __a, 1, 0);
608 *(__m128d *)__dp = __a;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000609}
610
Michael Kupersteine45af542015-06-30 13:36:19 +0000611static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000612_mm_storeh_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000613{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000614 struct __mm_storeh_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000615 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000616 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000617 ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[1];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000618}
619
Michael Kupersteine45af542015-06-30 13:36:19 +0000620static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000621_mm_storel_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000622{
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000623 struct __mm_storeh_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +0000624 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +0000625 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +0000626 ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[0];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +0000627}
628
Michael Kupersteine45af542015-06-30 13:36:19 +0000629static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000630_mm_add_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000631{
David Blaikie3302f2b2013-01-16 23:08:36 +0000632 return (__m128i)((__v16qi)__a + (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000633}
634
Michael Kupersteine45af542015-06-30 13:36:19 +0000635static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000636_mm_add_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000637{
David Blaikie3302f2b2013-01-16 23:08:36 +0000638 return (__m128i)((__v8hi)__a + (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000639}
640
Michael Kupersteine45af542015-06-30 13:36:19 +0000641static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000642_mm_add_epi32(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000643{
David Blaikie3302f2b2013-01-16 23:08:36 +0000644 return (__m128i)((__v4si)__a + (__v4si)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000645}
646
Michael Kupersteine45af542015-06-30 13:36:19 +0000647static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000648_mm_add_si64(__m64 __a, __m64 __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000649{
Craig Toppera5455522015-11-11 08:00:41 +0000650 return (__m64)__builtin_ia32_paddq(__a, __b);
Anders Carlssona283f912008-12-24 02:41:00 +0000651}
652
Michael Kupersteine45af542015-06-30 13:36:19 +0000653static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000654_mm_add_epi64(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000655{
David Blaikie3302f2b2013-01-16 23:08:36 +0000656 return __a + __b;
Anders Carlssona283f912008-12-24 02:41:00 +0000657}
658
Michael Kupersteine45af542015-06-30 13:36:19 +0000659static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000660_mm_adds_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000661{
David Blaikie3302f2b2013-01-16 23:08:36 +0000662 return (__m128i)__builtin_ia32_paddsb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000663}
664
Michael Kupersteine45af542015-06-30 13:36:19 +0000665static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000666_mm_adds_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000667{
David Blaikie3302f2b2013-01-16 23:08:36 +0000668 return (__m128i)__builtin_ia32_paddsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000669}
670
Michael Kupersteine45af542015-06-30 13:36:19 +0000671static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000672_mm_adds_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000673{
David Blaikie3302f2b2013-01-16 23:08:36 +0000674 return (__m128i)__builtin_ia32_paddusb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000675}
676
Michael Kupersteine45af542015-06-30 13:36:19 +0000677static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000678_mm_adds_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000679{
David Blaikie3302f2b2013-01-16 23:08:36 +0000680 return (__m128i)__builtin_ia32_paddusw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000681}
682
Michael Kupersteine45af542015-06-30 13:36:19 +0000683static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000684_mm_avg_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000685{
David Blaikie3302f2b2013-01-16 23:08:36 +0000686 return (__m128i)__builtin_ia32_pavgb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000687}
688
Michael Kupersteine45af542015-06-30 13:36:19 +0000689static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000690_mm_avg_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000691{
David Blaikie3302f2b2013-01-16 23:08:36 +0000692 return (__m128i)__builtin_ia32_pavgw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000693}
694
Michael Kupersteine45af542015-06-30 13:36:19 +0000695static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000696_mm_madd_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000697{
David Blaikie3302f2b2013-01-16 23:08:36 +0000698 return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000699}
700
Michael Kupersteine45af542015-06-30 13:36:19 +0000701static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000702_mm_max_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000703{
David Blaikie3302f2b2013-01-16 23:08:36 +0000704 return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000705}
706
Michael Kupersteine45af542015-06-30 13:36:19 +0000707static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000708_mm_max_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000709{
David Blaikie3302f2b2013-01-16 23:08:36 +0000710 return (__m128i)__builtin_ia32_pmaxub128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000711}
712
Michael Kupersteine45af542015-06-30 13:36:19 +0000713static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000714_mm_min_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000715{
David Blaikie3302f2b2013-01-16 23:08:36 +0000716 return (__m128i)__builtin_ia32_pminsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000717}
718
Michael Kupersteine45af542015-06-30 13:36:19 +0000719static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000720_mm_min_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000721{
David Blaikie3302f2b2013-01-16 23:08:36 +0000722 return (__m128i)__builtin_ia32_pminub128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000723}
724
Michael Kupersteine45af542015-06-30 13:36:19 +0000725static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000726_mm_mulhi_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000727{
David Blaikie3302f2b2013-01-16 23:08:36 +0000728 return (__m128i)__builtin_ia32_pmulhw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000729}
730
Michael Kupersteine45af542015-06-30 13:36:19 +0000731static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000732_mm_mulhi_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000733{
David Blaikie3302f2b2013-01-16 23:08:36 +0000734 return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000735}
736
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000737/// \brief Multiplies the corresponding elements of two [8 x short] vectors and
738/// returns a vector containing the low-order 16 bits of each 32-bit product
739/// in the corresponding element.
740///
741/// \headerfile <x86intrin.h>
742///
743/// This intrinsic corresponds to the \c VPMULLW / PMULLW instruction.
744///
745/// \param __a
746/// A 128-bit integer vector containing one of the source operands.
747/// \param __b
748/// A 128-bit integer vector containing one of the source operands.
749/// \returns A 128-bit integer vector containing the products of both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000750static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000751_mm_mullo_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000752{
David Blaikie3302f2b2013-01-16 23:08:36 +0000753 return (__m128i)((__v8hi)__a * (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000754}
755
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000756/// \brief Multiplies 32-bit unsigned integer values contained in the lower bits
757/// of the two 64-bit integer vectors and returns the 64-bit unsigned
758/// product.
759///
760/// \headerfile <x86intrin.h>
761///
762/// This intrinsic corresponds to the \c PMULUDQ instruction.
763///
764/// \param __a
765/// A 64-bit integer containing one of the source operands.
766/// \param __b
767/// A 64-bit integer containing one of the source operands.
768/// \returns A 64-bit integer vector containing the product of both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000769static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000770_mm_mul_su32(__m64 __a, __m64 __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000771{
David Blaikie3302f2b2013-01-16 23:08:36 +0000772 return __builtin_ia32_pmuludq((__v2si)__a, (__v2si)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000773}
774
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000775/// \brief Multiplies 32-bit unsigned integer values contained in the lower
776/// bits of the corresponding elements of two [2 x i64] vectors, and returns
777/// the 64-bit products in the corresponding elements of a [2 x i64] vector.
778///
779/// \headerfile <x86intrin.h>
780///
781/// This intrinsic corresponds to the \c VPMULUDQ / PMULUDQ instruction.
782///
783/// \param __a
784/// A [2 x i64] vector containing one of the source operands.
785/// \param __b
786/// A [2 x i64] vector containing one of the source operands.
787/// \returns A [2 x i64] vector containing the product of both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000788static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000789_mm_mul_epu32(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000790{
David Blaikie3302f2b2013-01-16 23:08:36 +0000791 return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000792}
793
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000794/// \brief Computes the absolute differences of corresponding 8-bit integer
795/// values in two 128-bit vectors. Sums the first 8 absolute differences, and
796/// separately sums the second 8 absolute differences. Packss these two
797/// unsigned 16-bit integer sums into the upper and lower elements of a
798/// [2 x i64] vector.
799///
800/// \headerfile <x86intrin.h>
801///
802/// This intrinsic corresponds to the \c VPSADBW / PSADBW instruction.
803///
804/// \param __a
805/// A 128-bit integer vector containing one of the source operands.
806/// \param __b
807/// A 128-bit integer vector containing one of the source operands.
808/// \returns A [2 x i64] vector containing the sums of the sets of absolute
809/// differences between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000810static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000811_mm_sad_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000812{
David Blaikie3302f2b2013-01-16 23:08:36 +0000813 return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000814}
815
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000816/// \brief Subtracts the corresponding 8-bit integer values in the operands.
817///
818/// \headerfile <x86intrin.h>
819///
820/// This intrinsic corresponds to the \c VPSUBB / PSUBB instruction.
821///
822/// \param __a
823/// A 128-bit integer vector containing the minuends.
824/// \param __b
825/// A 128-bit integer vector containing the subtrahends.
826/// \returns A 128-bit integer vector containing the differences of the values
827/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000828static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000829_mm_sub_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000830{
David Blaikie3302f2b2013-01-16 23:08:36 +0000831 return (__m128i)((__v16qi)__a - (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000832}
833
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000834/// \brief Subtracts the corresponding 16-bit integer values in the operands.
835///
836/// \headerfile <x86intrin.h>
837///
838/// This intrinsic corresponds to the \c VPSUBW / PSUBW instruction.
839///
840/// \param __a
841/// A 128-bit integer vector containing the minuends.
842/// \param __b
843/// A 128-bit integer vector containing the subtrahends.
844/// \returns A 128-bit integer vector containing the differences of the values
845/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000846static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000847_mm_sub_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000848{
David Blaikie3302f2b2013-01-16 23:08:36 +0000849 return (__m128i)((__v8hi)__a - (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000850}
851
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000852/// \brief Subtracts the corresponding 32-bit integer values in the operands.
853///
854/// \headerfile <x86intrin.h>
855///
856/// This intrinsic corresponds to the \c VPSUBD / PSUBD instruction.
857///
858/// \param __a
859/// A 128-bit integer vector containing the minuends.
860/// \param __b
861/// A 128-bit integer vector containing the subtrahends.
862/// \returns A 128-bit integer vector containing the differences of the values
863/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000864static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000865_mm_sub_epi32(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000866{
David Blaikie3302f2b2013-01-16 23:08:36 +0000867 return (__m128i)((__v4si)__a - (__v4si)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000868}
869
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000870/// \brief Subtracts signed or unsigned 64-bit integer values and writes the
871/// difference to the corresponding bits in the destination.
872///
873/// \headerfile <x86intrin.h>
874///
875/// This intrinsic corresponds to the \c PSUBQ instruction.
876///
877/// \param __a
878/// A 64-bit integer vector containing the minuend.
879/// \param __b
880/// A 64-bit integer vector containing the subtrahend.
881/// \returns A 64-bit integer vector containing the difference of the values in
882/// the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000883static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000884_mm_sub_si64(__m64 __a, __m64 __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000885{
Craig Toppera5455522015-11-11 08:00:41 +0000886 return (__m64)__builtin_ia32_psubq(__a, __b);
Anders Carlssona283f912008-12-24 02:41:00 +0000887}
888
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000889/// \brief Subtracts the corresponding elements of two [2 x i64] vectors.
890///
891/// \headerfile <x86intrin.h>
892///
893/// This intrinsic corresponds to the \c VPSUBQ / PSUBQ instruction.
894///
895/// \param __a
896/// A 128-bit integer vector containing the minuends.
897/// \param __b
898/// A 128-bit integer vector containing the subtrahends.
899/// \returns A 128-bit integer vector containing the differences of the values
900/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000901static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000902_mm_sub_epi64(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000903{
David Blaikie3302f2b2013-01-16 23:08:36 +0000904 return __a - __b;
Anders Carlssona283f912008-12-24 02:41:00 +0000905}
906
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000907/// \brief Subtracts corresponding 8-bit signed integer values in the input and
908/// returns the differences in the corresponding bytes in the destination.
909/// Differences greater than 7Fh are saturated to 7Fh, and differences less
910/// than 80h are saturated to 80h.
911///
912/// \headerfile <x86intrin.h>
913///
914/// This intrinsic corresponds to the \c VPSUBSB / PSUBSB instruction.
915///
916/// \param __a
917/// A 128-bit integer vector containing the minuends.
918/// \param __b
919/// A 128-bit integer vector containing the subtrahends.
920/// \returns A 128-bit integer vector containing the differences of the values
921/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000922static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000923_mm_subs_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000924{
David Blaikie3302f2b2013-01-16 23:08:36 +0000925 return (__m128i)__builtin_ia32_psubsb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000926}
927
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000928/// \brief Subtracts corresponding 16-bit signed integer values in the input and
929/// returns the differences in the corresponding bytes in the destination.
930/// Differences greater than 7FFFh are saturated to 7FFFh, and values less
931/// than 8000h are saturated to 8000h.
932///
933/// \headerfile <x86intrin.h>
934///
935/// This intrinsic corresponds to the \c VPSUBSW / PSUBSW instruction.
936///
937/// \param __a
938/// A 128-bit integer vector containing the minuends.
939/// \param __b
940/// A 128-bit integer vector containing the subtrahends.
941/// \returns A 128-bit integer vector containing the differences of the values
942/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000943static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000944_mm_subs_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000945{
David Blaikie3302f2b2013-01-16 23:08:36 +0000946 return (__m128i)__builtin_ia32_psubsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000947}
948
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000949/// \brief Subtracts corresponding 8-bit unsigned integer values in the input
950/// and returns the differences in the corresponding bytes in the
951/// destination. Differences less than 00h are saturated to 00h.
952///
953/// \headerfile <x86intrin.h>
954///
955/// This intrinsic corresponds to the \c VPSUBUSB / PSUBUSB instruction.
956///
957/// \param __a
958/// A 128-bit integer vector containing the minuends.
959/// \param __b
960/// A 128-bit integer vector containing the subtrahends.
961/// \returns A 128-bit integer vector containing the unsigned integer
962/// differences of the values in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000963static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000964_mm_subs_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000965{
David Blaikie3302f2b2013-01-16 23:08:36 +0000966 return (__m128i)__builtin_ia32_psubusb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000967}
968
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000969/// \brief Subtracts corresponding 16-bit unsigned integer values in the input
970/// and returns the differences in the corresponding bytes in the
971/// destination. Differences less than 0000h are saturated to 0000h.
972///
973/// \headerfile <x86intrin.h>
974///
975/// This intrinsic corresponds to the \c VPSUBUSW / PSUBUSW instruction.
976///
977/// \param __a
978/// A 128-bit integer vector containing the minuends.
979/// \param __b
980/// A 128-bit integer vector containing the subtrahends.
981/// \returns A 128-bit integer vector containing the unsigned integer
982/// differences of the values in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000983static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000984_mm_subs_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +0000985{
David Blaikie3302f2b2013-01-16 23:08:36 +0000986 return (__m128i)__builtin_ia32_psubusw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +0000987}
988
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +0000989/// \brief Performs a bitwise AND of two 128-bit integer vectors.
990///
991/// \headerfile <x86intrin.h>
992///
993/// This intrinsic corresponds to the \c VPAND / PAND instruction.
994///
995/// \param __a
996/// A 128-bit integer vector containing one of the source operands.
997/// \param __b
998/// A 128-bit integer vector containing one of the source operands.
999/// \returns A 128-bit integer vector containing the bitwise AND of the values
1000/// in both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00001001static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001002_mm_and_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001003{
David Blaikie3302f2b2013-01-16 23:08:36 +00001004 return __a & __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001005}
1006
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001007/// \brief Performs a bitwise AND of two 128-bit integer vectors, using the
1008/// one's complement of the values contained in the first source operand.
1009///
1010/// \headerfile <x86intrin.h>
1011///
1012/// This intrinsic corresponds to the \c VPANDN / PANDN instruction.
1013///
1014/// \param __a
1015/// A 128-bit vector containing the left source operand. The one's complement
1016/// of this value is used in the bitwise AND.
1017/// \param __b
1018/// A 128-bit vector containing the right source operand.
1019/// \returns A 128-bit integer vector containing the bitwise AND of the one's
1020/// complement of the first operand and the values in the second operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00001021static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001022_mm_andnot_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001023{
David Blaikie3302f2b2013-01-16 23:08:36 +00001024 return ~__a & __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001025}
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001026/// \brief Performs a bitwise OR of two 128-bit integer vectors.
1027///
1028/// \headerfile <x86intrin.h>
1029///
1030/// This intrinsic corresponds to the \c VPOR / POR instruction.
1031///
1032/// \param __a
1033/// A 128-bit integer vector containing one of the source operands.
1034/// \param __b
1035/// A 128-bit integer vector containing one of the source operands.
1036/// \returns A 128-bit integer vector containing the bitwise OR of the values
1037/// in both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00001038static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001039_mm_or_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001040{
David Blaikie3302f2b2013-01-16 23:08:36 +00001041 return __a | __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001042}
1043
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001044/// \brief Performs a bitwise exclusive OR of two 128-bit integer vectors.
1045///
1046/// \headerfile <x86intrin.h>
1047///
1048/// This intrinsic corresponds to the \c VPXOR / PXOR instruction.
1049///
1050/// \param __a
1051/// A 128-bit integer vector containing one of the source operands.
1052/// \param __b
1053/// A 128-bit integer vector containing one of the source operands.
1054/// \returns A 128-bit integer vector containing the bitwise exclusive OR of the
1055/// values in both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00001056static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001057_mm_xor_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001058{
David Blaikie3302f2b2013-01-16 23:08:36 +00001059 return __a ^ __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001060}
1061
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001062/// \brief Left-shifts the 128-bit integer vector operand by the specified
1063/// number of bytes. Low-order bits are cleared.
1064///
1065/// \headerfile <x86intrin.h>
1066///
1067/// \code
1068/// __m128i _mm_slli_si128(__m128i a, const int imm);
1069/// \endcode
1070///
1071/// This intrinsic corresponds to the \c VPSLLDQ / PSLLDQ instruction.
1072///
1073/// \param a
1074/// A 128-bit integer vector containing the source operand.
1075/// \param imm
1076/// An immediate value specifying the number of bytes to left-shift
1077/// operand a.
1078/// \returns A 128-bit integer vector containing the left-shifted value.
Craig Topper51e47412015-02-13 06:04:43 +00001079#define _mm_slli_si128(a, imm) __extension__ ({ \
1080 (__m128i)__builtin_shufflevector((__v16qi)_mm_setzero_si128(), \
1081 (__v16qi)(__m128i)(a), \
1082 ((imm)&0xF0) ? 0 : 16 - ((imm)&0xF), \
1083 ((imm)&0xF0) ? 0 : 17 - ((imm)&0xF), \
1084 ((imm)&0xF0) ? 0 : 18 - ((imm)&0xF), \
1085 ((imm)&0xF0) ? 0 : 19 - ((imm)&0xF), \
1086 ((imm)&0xF0) ? 0 : 20 - ((imm)&0xF), \
1087 ((imm)&0xF0) ? 0 : 21 - ((imm)&0xF), \
1088 ((imm)&0xF0) ? 0 : 22 - ((imm)&0xF), \
1089 ((imm)&0xF0) ? 0 : 23 - ((imm)&0xF), \
1090 ((imm)&0xF0) ? 0 : 24 - ((imm)&0xF), \
1091 ((imm)&0xF0) ? 0 : 25 - ((imm)&0xF), \
1092 ((imm)&0xF0) ? 0 : 26 - ((imm)&0xF), \
1093 ((imm)&0xF0) ? 0 : 27 - ((imm)&0xF), \
1094 ((imm)&0xF0) ? 0 : 28 - ((imm)&0xF), \
1095 ((imm)&0xF0) ? 0 : 29 - ((imm)&0xF), \
1096 ((imm)&0xF0) ? 0 : 30 - ((imm)&0xF), \
1097 ((imm)&0xF0) ? 0 : 31 - ((imm)&0xF)); })
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001098
Craig Toppera4624822015-02-13 06:04:45 +00001099#define _mm_bslli_si128(a, imm) \
1100 _mm_slli_si128((a), (imm))
1101
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001102/// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand
1103/// by the specified number of bits. Low-order bits are cleared.
1104///
1105/// \headerfile <x86intrin.h>
1106///
1107/// This intrinsic corresponds to the \c VPSLLW / PSLLW instruction.
1108///
1109/// \param __a
1110/// A 128-bit integer vector containing the source operand.
1111/// \param __count
1112/// An integer value specifying the number of bits to left-shift each value
1113/// in operand __a.
1114/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001115static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001116_mm_slli_epi16(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001117{
David Blaikie3302f2b2013-01-16 23:08:36 +00001118 return (__m128i)__builtin_ia32_psllwi128((__v8hi)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001119}
1120
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001121/// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand
1122/// by the specified number of bits. Low-order bits are cleared.
1123///
1124/// \headerfile <x86intrin.h>
1125///
1126/// This intrinsic corresponds to the \c VPSLLW / PSLLW instruction.
1127///
1128/// \param __a
1129/// A 128-bit integer vector containing the source operand.
1130/// \param __count
1131/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1132/// to left-shift each value in operand __a.
1133/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001134static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001135_mm_sll_epi16(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001136{
David Blaikie3302f2b2013-01-16 23:08:36 +00001137 return (__m128i)__builtin_ia32_psllw128((__v8hi)__a, (__v8hi)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001138}
1139
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001140/// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand
1141/// by the specified number of bits. Low-order bits are cleared.
1142///
1143/// \headerfile <x86intrin.h>
1144///
1145/// This intrinsic corresponds to the \c VPSLLD / PSLLD instruction.
1146///
1147/// \param __a
1148/// A 128-bit integer vector containing the source operand.
1149/// \param __count
1150/// An integer value specifying the number of bits to left-shift each value
1151/// in operand __a.
1152/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001153static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001154_mm_slli_epi32(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001155{
David Blaikie3302f2b2013-01-16 23:08:36 +00001156 return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001157}
1158
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001159/// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand
1160/// by the specified number of bits. Low-order bits are cleared.
1161///
1162/// \headerfile <x86intrin.h>
1163///
1164/// This intrinsic corresponds to the \c VPSLLD / PSLLD instruction.
1165///
1166/// \param __a
1167/// A 128-bit integer vector containing the source operand.
1168/// \param __count
1169/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1170/// to left-shift each value in operand __a.
1171/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001172static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001173_mm_sll_epi32(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001174{
David Blaikie3302f2b2013-01-16 23:08:36 +00001175 return (__m128i)__builtin_ia32_pslld128((__v4si)__a, (__v4si)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001176}
1177
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001178/// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand
1179/// by the specified number of bits. Low-order bits are cleared.
1180///
1181/// \headerfile <x86intrin.h>
1182///
1183/// This intrinsic corresponds to the \c VPSLLQ / PSLLQ instruction.
1184///
1185/// \param __a
1186/// A 128-bit integer vector containing the source operand.
1187/// \param __count
1188/// An integer value specifying the number of bits to left-shift each value
1189/// in operand __a.
1190/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001191static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001192_mm_slli_epi64(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001193{
David Blaikie3302f2b2013-01-16 23:08:36 +00001194 return __builtin_ia32_psllqi128(__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001195}
1196
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001197/// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand
1198/// by the specified number of bits. Low-order bits are cleared.
1199///
1200/// \headerfile <x86intrin.h>
1201///
1202/// This intrinsic corresponds to the \c VPSLLQ / PSLLQ instruction.
1203///
1204/// \param __a
1205/// A 128-bit integer vector containing the source operand.
1206/// \param __count
1207/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1208/// to left-shift each value in operand __a.
1209/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001210static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001211_mm_sll_epi64(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001212{
David Blaikie3302f2b2013-01-16 23:08:36 +00001213 return __builtin_ia32_psllq128(__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001214}
1215
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001216/// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand
1217/// by the specified number of bits. High-order bits are filled with the sign
1218/// bit of the initial value.
1219///
1220/// \headerfile <x86intrin.h>
1221///
1222/// This intrinsic corresponds to the \c VPSRAW / PSRAW instruction.
1223///
1224/// \param __a
1225/// A 128-bit integer vector containing the source operand.
1226/// \param __count
1227/// An integer value specifying the number of bits to right-shift each value
1228/// in operand __a.
1229/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001230static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001231_mm_srai_epi16(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001232{
David Blaikie3302f2b2013-01-16 23:08:36 +00001233 return (__m128i)__builtin_ia32_psrawi128((__v8hi)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001234}
1235
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001236/// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand
1237/// by the specified number of bits. High-order bits are filled with the sign
1238/// bit of the initial value.
1239///
1240/// \headerfile <x86intrin.h>
1241///
1242/// This intrinsic corresponds to the \c VPSRAW / PSRAW instruction.
1243///
1244/// \param __a
1245/// A 128-bit integer vector containing the source operand.
1246/// \param __count
1247/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1248/// to right-shift each value in operand __a.
1249/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001250static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001251_mm_sra_epi16(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001252{
David Blaikie3302f2b2013-01-16 23:08:36 +00001253 return (__m128i)__builtin_ia32_psraw128((__v8hi)__a, (__v8hi)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001254}
1255
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001256/// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand
1257/// by the specified number of bits. High-order bits are filled with the sign
1258/// bit of the initial value.
1259///
1260/// \headerfile <x86intrin.h>
1261///
1262/// This intrinsic corresponds to the \c VPSRAD / PSRAD instruction.
1263///
1264/// \param __a
1265/// A 128-bit integer vector containing the source operand.
1266/// \param __count
1267/// An integer value specifying the number of bits to right-shift each value
1268/// in operand __a.
1269/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001270static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001271_mm_srai_epi32(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001272{
David Blaikie3302f2b2013-01-16 23:08:36 +00001273 return (__m128i)__builtin_ia32_psradi128((__v4si)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001274}
1275
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001276/// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand
1277/// by the specified number of bits. High-order bits are filled with the sign
1278/// bit of the initial value.
1279///
1280/// \headerfile <x86intrin.h>
1281///
1282/// This intrinsic corresponds to the \c VPSRAD / PSRAD instruction.
1283///
1284/// \param __a
1285/// A 128-bit integer vector containing the source operand.
1286/// \param __count
1287/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1288/// to right-shift each value in operand __a.
1289/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001290static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001291_mm_sra_epi32(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001292{
David Blaikie3302f2b2013-01-16 23:08:36 +00001293 return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001294}
1295
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001296/// \brief Right-shifts the 128-bit integer vector operand by the specified
1297/// number of bytes. High-order bits are cleared.
1298///
1299/// \headerfile <x86intrin.h>
1300///
1301/// \code
1302/// __m128i _mm_srli_si128(__m128i a, const int imm);
1303/// \endcode
1304///
1305/// This intrinsic corresponds to the \c VPSRLDQ / PSRLDQ instruction.
1306///
1307/// \param a
1308/// A 128-bit integer vector containing the source operand.
1309/// \param imm
1310/// An immediate value specifying the number of bytes to right-shift operand
1311/// a.
1312/// \returns A 128-bit integer vector containing the right-shifted value.
Craig Topper51e47412015-02-13 06:04:43 +00001313#define _mm_srli_si128(a, imm) __extension__ ({ \
1314 (__m128i)__builtin_shufflevector((__v16qi)(__m128i)(a), \
1315 (__v16qi)_mm_setzero_si128(), \
1316 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 0, \
1317 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 1, \
1318 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 2, \
1319 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 3, \
1320 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 4, \
1321 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 5, \
1322 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 6, \
1323 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 7, \
1324 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 8, \
1325 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 9, \
1326 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 10, \
1327 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 11, \
1328 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 12, \
1329 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 13, \
1330 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 14, \
1331 ((imm)&0xF0) ? 16 : ((imm)&0xF) + 15); })
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001332
Craig Toppera4624822015-02-13 06:04:45 +00001333#define _mm_bsrli_si128(a, imm) \
1334 _mm_srli_si128((a), (imm))
1335
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001336/// \brief Right-shifts each of 16-bit values in the 128-bit integer vector
1337/// operand by the specified number of bits. High-order bits are cleared.
1338///
1339/// \headerfile <x86intrin.h>
1340///
1341/// This intrinsic corresponds to the \c VPSRLW / PSRLW instruction.
1342///
1343/// \param __a
1344/// A 128-bit integer vector containing the source operand.
1345/// \param __count
1346/// An integer value specifying the number of bits to right-shift each value
1347/// in operand __a.
1348/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001349static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001350_mm_srli_epi16(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001351{
David Blaikie3302f2b2013-01-16 23:08:36 +00001352 return (__m128i)__builtin_ia32_psrlwi128((__v8hi)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001353}
1354
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001355/// \brief Right-shifts each of 16-bit values in the 128-bit integer vector
1356/// operand by the specified number of bits. High-order bits are cleared.
1357///
1358/// \headerfile <x86intrin.h>
1359///
1360/// This intrinsic corresponds to the \c VPSRLW / PSRLW instruction.
1361///
1362/// \param __a
1363/// A 128-bit integer vector containing the source operand.
1364/// \param __count
1365/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1366/// to right-shift each value in operand __a.
1367/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001368static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001369_mm_srl_epi16(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001370{
David Blaikie3302f2b2013-01-16 23:08:36 +00001371 return (__m128i)__builtin_ia32_psrlw128((__v8hi)__a, (__v8hi)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001372}
1373
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001374/// \brief Right-shifts each of 32-bit values in the 128-bit integer vector
1375/// operand by the specified number of bits. High-order bits are cleared.
1376///
1377/// \headerfile <x86intrin.h>
1378///
1379/// This intrinsic corresponds to the \c VPSRLD / PSRLD instruction.
1380///
1381/// \param __a
1382/// A 128-bit integer vector containing the source operand.
1383/// \param __count
1384/// An integer value specifying the number of bits to right-shift each value
1385/// in operand __a.
1386/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001387static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001388_mm_srli_epi32(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001389{
David Blaikie3302f2b2013-01-16 23:08:36 +00001390 return (__m128i)__builtin_ia32_psrldi128((__v4si)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001391}
1392
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001393/// \brief Right-shifts each of 32-bit values in the 128-bit integer vector
1394/// operand by the specified number of bits. High-order bits are cleared.
1395///
1396/// \headerfile <x86intrin.h>
1397///
1398/// This intrinsic corresponds to the \c VPSRLD / PSRLD instruction.
1399///
1400/// \param __a
1401/// A 128-bit integer vector containing the source operand.
1402/// \param __count
1403/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1404/// to right-shift each value in operand __a.
1405/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001406static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001407_mm_srl_epi32(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001408{
David Blaikie3302f2b2013-01-16 23:08:36 +00001409 return (__m128i)__builtin_ia32_psrld128((__v4si)__a, (__v4si)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001410}
1411
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001412/// \brief Right-shifts each of 64-bit values in the 128-bit integer vector
1413/// operand by the specified number of bits. High-order bits are cleared.
1414///
1415/// \headerfile <x86intrin.h>
1416///
1417/// This intrinsic corresponds to the \c VPSRLQ / PSRLQ instruction.
1418///
1419/// \param __a
1420/// A 128-bit integer vector containing the source operand.
1421/// \param __count
1422/// An integer value specifying the number of bits to right-shift each value
1423/// in operand __a.
1424/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001425static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001426_mm_srli_epi64(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001427{
David Blaikie3302f2b2013-01-16 23:08:36 +00001428 return __builtin_ia32_psrlqi128(__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001429}
1430
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001431/// \brief Right-shifts each of 64-bit values in the 128-bit integer vector
1432/// operand by the specified number of bits. High-order bits are cleared.
1433///
1434/// \headerfile <x86intrin.h>
1435///
1436/// This intrinsic corresponds to the \c VPSRLQ / PSRLQ instruction.
1437///
1438/// \param __a
1439/// A 128-bit integer vector containing the source operand.
1440/// \param __count
1441/// A 128-bit integer vector in which bits [63:0] specify the number of bits
1442/// to right-shift each value in operand __a.
1443/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001444static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001445_mm_srl_epi64(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001446{
David Blaikie3302f2b2013-01-16 23:08:36 +00001447 return __builtin_ia32_psrlq128(__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001448}
1449
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001450/// \brief Compares each of the corresponding 8-bit values of the 128-bit
1451/// integer vectors for equality. Each comparison yields 0h for false, FFh
1452/// for true.
1453///
1454/// \headerfile <x86intrin.h>
1455///
1456/// This intrinsic corresponds to the \c VPCMPEQB / PCMPEQB instruction.
1457///
1458/// \param __a
1459/// A 128-bit integer vector.
1460/// \param __b
1461/// A 128-bit integer vector.
1462/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001463static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001464_mm_cmpeq_epi8(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001465{
David Blaikie3302f2b2013-01-16 23:08:36 +00001466 return (__m128i)((__v16qi)__a == (__v16qi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001467}
1468
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001469/// \brief Compares each of the corresponding 16-bit values of the 128-bit
1470/// integer vectors for equality. Each comparison yields 0h for false, FFFFh
1471/// for true.
1472///
1473/// \headerfile <x86intrin.h>
1474///
1475/// This intrinsic corresponds to the \c VPCMPEQW / PCMPEQW instruction.
1476///
1477/// \param __a
1478/// A 128-bit integer vector.
1479/// \param __b
1480/// A 128-bit integer vector.
1481/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001482static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001483_mm_cmpeq_epi16(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001484{
David Blaikie3302f2b2013-01-16 23:08:36 +00001485 return (__m128i)((__v8hi)__a == (__v8hi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001486}
1487
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001488/// \brief Compares each of the corresponding 32-bit values of the 128-bit
1489/// integer vectors for equality. Each comparison yields 0h for false,
1490/// FFFFFFFFh for true.
1491///
1492/// \headerfile <x86intrin.h>
1493///
1494/// This intrinsic corresponds to the \c VPCMPEQD / PCMPEQD instruction.
1495///
1496/// \param __a
1497/// A 128-bit integer vector.
1498/// \param __b
1499/// A 128-bit integer vector.
1500/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001501static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001502_mm_cmpeq_epi32(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001503{
David Blaikie3302f2b2013-01-16 23:08:36 +00001504 return (__m128i)((__v4si)__a == (__v4si)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001505}
1506
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001507/// \brief Compares each of the corresponding signed 8-bit values of the 128-bit
1508/// integer vectors to determine if the values in the first operand are
1509/// greater than those in the second operand. Each comparison yields 0h for
1510/// false, FFh for true.
1511///
1512/// \headerfile <x86intrin.h>
1513///
1514/// This intrinsic corresponds to the \c VPCMPGTB / PCMPGTB instruction.
1515///
1516/// \param __a
1517/// A 128-bit integer vector.
1518/// \param __b
1519/// A 128-bit integer vector.
1520/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001521static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001522_mm_cmpgt_epi8(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001523{
Nick Lewyckyd0ba3792012-02-04 02:16:48 +00001524 /* This function always performs a signed comparison, but __v16qi is a char
Chandler Carruthcbe64112015-10-01 23:40:12 +00001525 which may be signed or unsigned, so use __v16qs. */
David Blaikie3302f2b2013-01-16 23:08:36 +00001526 return (__m128i)((__v16qs)__a > (__v16qs)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001527}
1528
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001529/// \brief Compares each of the corresponding signed 16-bit values of the
1530/// 128-bit integer vectors to determine if the values in the first operand
1531/// are greater than those in the second operand. Each comparison yields 0h
1532/// for false, FFFFh for true.
1533///
1534/// \headerfile <x86intrin.h>
1535///
1536/// This intrinsic corresponds to the \c VPCMPGTW / PCMPGTW instruction.
1537///
1538/// \param __a
1539/// A 128-bit integer vector.
1540/// \param __b
1541/// A 128-bit integer vector.
1542/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001543static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001544_mm_cmpgt_epi16(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001545{
David Blaikie3302f2b2013-01-16 23:08:36 +00001546 return (__m128i)((__v8hi)__a > (__v8hi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001547}
1548
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001549/// \brief Compares each of the corresponding signed 32-bit values of the
1550/// 128-bit integer vectors to determine if the values in the first operand
1551/// are greater than those in the second operand. Each comparison yields 0h
1552/// for false, FFFFFFFFh for true.
1553///
1554/// \headerfile <x86intrin.h>
1555///
1556/// This intrinsic corresponds to the \c VPCMPGTD / PCMPGTD instruction.
1557///
1558/// \param __a
1559/// A 128-bit integer vector.
1560/// \param __b
1561/// A 128-bit integer vector.
1562/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001563static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001564_mm_cmpgt_epi32(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001565{
David Blaikie3302f2b2013-01-16 23:08:36 +00001566 return (__m128i)((__v4si)__a > (__v4si)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001567}
1568
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001569/// \brief Compares each of the corresponding signed 8-bit values of the 128-bit
1570/// integer vectors to determine if the values in the first operand are less
1571/// than those in the second operand. Each comparison yields 0h for false,
1572/// FFh for true.
1573///
1574/// \headerfile <x86intrin.h>
1575///
1576/// This intrinsic corresponds to the \c VPCMPGTB / PCMPGTB instruction.
1577///
1578/// \param __a
1579/// A 128-bit integer vector.
1580/// \param __b
1581/// A 128-bit integer vector.
1582/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001583static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001584_mm_cmplt_epi8(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001585{
David Blaikie3302f2b2013-01-16 23:08:36 +00001586 return _mm_cmpgt_epi8(__b, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001587}
1588
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001589/// \brief Compares each of the corresponding signed 16-bit values of the
1590/// 128-bit integer vectors to determine if the values in the first operand
1591/// are less than those in the second operand. Each comparison yields 0h for
1592/// false, FFFFh for true.
1593///
1594/// \headerfile <x86intrin.h>
1595///
1596/// This intrinsic corresponds to the \c VPCMPGTW / PCMPGTW instruction.
1597///
1598/// \param __a
1599/// A 128-bit integer vector.
1600/// \param __b
1601/// A 128-bit integer vector.
1602/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001603static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001604_mm_cmplt_epi16(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001605{
David Blaikie3302f2b2013-01-16 23:08:36 +00001606 return _mm_cmpgt_epi16(__b, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001607}
1608
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001609/// \brief Compares each of the corresponding signed 32-bit values of the
1610/// 128-bit integer vectors to determine if the values in the first operand
1611/// are less than those in the second operand. Each comparison yields 0h for
1612/// false, FFFFFFFFh for true.
1613///
1614/// \headerfile <x86intrin.h>
1615///
1616/// This intrinsic corresponds to the \c VPCMPGTD / PCMPGTD instruction.
1617///
1618/// \param __a
1619/// A 128-bit integer vector.
1620/// \param __b
1621/// A 128-bit integer vector.
1622/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00001623static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001624_mm_cmplt_epi32(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001625{
David Blaikie3302f2b2013-01-16 23:08:36 +00001626 return _mm_cmpgt_epi32(__b, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001627}
1628
1629#ifdef __x86_64__
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001630/// \brief Converts a 64-bit signed integer value from the second operand into a
1631/// double-precision value and returns it in the lower element of a [2 x
1632/// double] vector; the upper element of the returned vector is copied from
1633/// the upper element of the first operand.
1634///
1635/// \headerfile <x86intrin.h>
1636///
1637/// This intrinsic corresponds to the \c VCVTSI2SD / CVTSI2SD instruction.
1638///
1639/// \param __a
1640/// A 128-bit vector of [2 x double]. The upper 64 bits of this operand are
1641/// copied to the upper 64 bits of the destination.
1642/// \param __b
1643/// A 64-bit signed integer operand containing the value to be converted.
1644/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
1645/// converted value of the second operand. The upper 64 bits are copied from
1646/// the upper 64 bits of the first operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00001647static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001648_mm_cvtsi64_sd(__m128d __a, long long __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001649{
David Blaikie3302f2b2013-01-16 23:08:36 +00001650 __a[0] = __b;
1651 return __a;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001652}
1653
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001654/// \brief Converts the first (lower) element of a vector of [2 x double] into a
1655/// 64-bit signed integer value, according to the current rounding mode.
1656///
1657/// \headerfile <x86intrin.h>
1658///
1659/// This intrinsic corresponds to the \c VCVTSD2SI / CVTSD2SI instruction.
1660///
1661/// \param __a
1662/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the
1663/// conversion.
1664/// \returns A 64-bit signed integer containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001665static __inline__ long long __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001666_mm_cvtsd_si64(__m128d __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001667{
David Blaikie3302f2b2013-01-16 23:08:36 +00001668 return __builtin_ia32_cvtsd2si64(__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001669}
1670
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001671/// \brief Converts the first (lower) element of a vector of [2 x double] into a
1672/// 64-bit signed integer value, truncating the result when it is inexact.
1673///
1674/// \headerfile <x86intrin.h>
1675///
1676/// This intrinsic corresponds to the \c VCVTTSD2SI / CVTTSD2SI instruction.
1677///
1678/// \param __a
1679/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the
1680/// conversion.
1681/// \returns A 64-bit signed integer containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001682static __inline__ long long __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001683_mm_cvttsd_si64(__m128d __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001684{
David Blaikie3302f2b2013-01-16 23:08:36 +00001685 return __a[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001686}
1687#endif
1688
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001689/// \brief Converts a vector of [4 x i32] into a vector of [4 x float].
1690///
1691/// \headerfile <x86intrin.h>
1692///
1693/// This intrinsic corresponds to the \c VCVTDQ2PS / CVTDQ2PS instruction.
1694///
1695/// \param __a
1696/// A 128-bit integer vector.
1697/// \returns A 128-bit vector of [4 x float] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001698static __inline__ __m128 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001699_mm_cvtepi32_ps(__m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001700{
David Blaikie3302f2b2013-01-16 23:08:36 +00001701 return __builtin_ia32_cvtdq2ps((__v4si)__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001702}
1703
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001704/// \brief Converts a vector of [4 x float] into a vector of [4 x i32].
1705///
1706/// \headerfile <x86intrin.h>
1707///
1708/// This intrinsic corresponds to the \c VCVTPS2DQ / CVTPS2DQ instruction.
1709///
1710/// \param __a
1711/// A 128-bit vector of [4 x float].
1712/// \returns A 128-bit integer vector of [4 x i32] containing the converted
1713/// values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001714static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001715_mm_cvtps_epi32(__m128 __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001716{
David Blaikie3302f2b2013-01-16 23:08:36 +00001717 return (__m128i)__builtin_ia32_cvtps2dq(__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001718}
1719
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001720/// \brief Converts a vector of [4 x float] into a vector of [4 x i32],
1721/// truncating the result when it is inexact.
1722///
1723/// \headerfile <x86intrin.h>
1724///
1725/// This intrinsic corresponds to the \c VCVTTPS2DQ / CVTTPS2DQ instruction.
1726///
1727/// \param __a
1728/// A 128-bit vector of [4 x float].
1729/// \returns A 128-bit vector of [4 x i32] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001730static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001731_mm_cvttps_epi32(__m128 __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001732{
David Blaikie3302f2b2013-01-16 23:08:36 +00001733 return (__m128i)__builtin_ia32_cvttps2dq(__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001734}
1735
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001736/// \brief Returns a vector of [4 x i32] where the lowest element is the input
1737/// operand and the remaining elements are zero.
1738///
1739/// \headerfile <x86intrin.h>
1740///
1741/// This intrinsic corresponds to the \c VMOVD / MOVD instruction.
1742///
1743/// \param __a
1744/// A 32-bit signed integer operand.
1745/// \returns A 128-bit vector of [4 x i32].
Michael Kupersteine45af542015-06-30 13:36:19 +00001746static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001747_mm_cvtsi32_si128(int __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001748{
David Blaikie3302f2b2013-01-16 23:08:36 +00001749 return (__m128i)(__v4si){ __a, 0, 0, 0 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001750}
1751
1752#ifdef __x86_64__
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001753/// \brief Returns a vector of [2 x i64] where the lower element is the input
1754/// operand and the upper element is zero.
1755///
1756/// \headerfile <x86intrin.h>
1757///
1758/// This intrinsic corresponds to the \c VMOVQ / MOVQ instruction.
1759///
1760/// \param __a
1761/// A 64-bit signed integer operand containing the value to be converted.
1762/// \returns A 128-bit vector of [2 x i64] containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001763static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001764_mm_cvtsi64_si128(long long __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001765{
David Blaikie3302f2b2013-01-16 23:08:36 +00001766 return (__m128i){ __a, 0 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001767}
1768#endif
1769
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001770/// \brief Moves the least significant 32 bits of a vector of [4 x i32] to a
1771/// 32-bit signed integer value.
1772///
1773/// \headerfile <x86intrin.h>
1774///
1775/// This intrinsic corresponds to the \c VMOVD / MOVD instruction.
1776///
1777/// \param __a
1778/// A vector of [4 x i32]. The least significant 32 bits are moved to the
1779/// destination.
1780/// \returns A 32-bit signed integer containing the moved value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001781static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001782_mm_cvtsi128_si32(__m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001783{
David Blaikie3302f2b2013-01-16 23:08:36 +00001784 __v4si __b = (__v4si)__a;
1785 return __b[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001786}
1787
1788#ifdef __x86_64__
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001789/// \brief Moves the least significant 64 bits of a vector of [2 x i64] to a
1790/// 64-bit signed integer value.
1791///
1792/// \headerfile <x86intrin.h>
1793///
1794/// This intrinsic corresponds to the \c VMOVQ / MOVQ instruction.
1795///
1796/// \param __a
1797/// A vector of [2 x i64]. The least significant 64 bits are moved to the
1798/// destination.
1799/// \returns A 64-bit signed integer containing the moved value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001800static __inline__ long long __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001801_mm_cvtsi128_si64(__m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001802{
David Blaikie3302f2b2013-01-16 23:08:36 +00001803 return __a[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001804}
1805#endif
1806
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001807/// \brief Moves packed integer values from an aligned 128-bit memory location
1808/// to elements in a 128-bit integer vector.
1809///
1810/// \headerfile <x86intrin.h>
1811///
1812/// This intrinsic corresponds to the \c VMOVDQA / MOVDQA instruction.
1813///
1814/// \param __p
1815/// An aligned pointer to a memory location containing integer values.
1816/// \returns A 128-bit integer vector containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001817static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001818_mm_load_si128(__m128i const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001819{
David Blaikie3302f2b2013-01-16 23:08:36 +00001820 return *__p;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001821}
1822
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001823/// \brief Moves packed integer values from an unaligned 128-bit memory location
1824/// to elements in a 128-bit integer vector.
1825///
1826/// \headerfile <x86intrin.h>
1827///
1828/// This intrinsic corresponds to the \c VMOVDQU / MOVDQU instruction.
1829///
1830/// \param __p
1831/// A pointer to a memory location containing integer values.
1832/// \returns A 128-bit integer vector containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001833static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001834_mm_loadu_si128(__m128i const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001835{
Bill Wendling502931f2011-05-13 00:11:39 +00001836 struct __loadu_si128 {
David Blaikie3302f2b2013-01-16 23:08:36 +00001837 __m128i __v;
David Majnemer1cf22e62015-02-04 00:26:10 +00001838 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001839 return ((struct __loadu_si128*)__p)->__v;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001840}
1841
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001842/// \brief Returns a vector of [2 x i64] where the lower element is taken from
1843/// the lower element of the operand, and the upper element is zero.
1844///
1845/// \headerfile <x86intrin.h>
1846///
1847/// This intrinsic corresponds to the \c VMOVQ / MOVQ instruction.
1848///
1849/// \param __p
1850/// A 128-bit vector of [2 x i64]. Bits [63:0] are written to bits [63:0] of
1851/// the destination.
1852/// \returns A 128-bit vector of [2 x i64]. The lower order bits contain the
1853/// moved value. The higher order bits are cleared.
Michael Kupersteine45af542015-06-30 13:36:19 +00001854static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001855_mm_loadl_epi64(__m128i const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001856{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001857 struct __mm_loadl_epi64_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00001858 long long __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001859 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001860 return (__m128i) { ((struct __mm_loadl_epi64_struct*)__p)->__u, 0};
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001861}
1862
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001863/// \brief Generates a 128-bit vector of [4 x i32] with unspecified content.
1864/// This could be used as an argument to another intrinsic function where the
1865/// argument is required but the value is not actually used.
1866///
1867/// \headerfile <x86intrin.h>
1868///
1869/// This intrinsic has no corresponding instruction.
1870///
1871/// \returns A 128-bit vector of [4 x i32] with unspecified content.
Michael Kupersteine45af542015-06-30 13:36:19 +00001872static __inline__ __m128i __DEFAULT_FN_ATTRS
Simon Pilgrim5aba9922015-08-26 21:17:12 +00001873_mm_undefined_si128()
1874{
1875 return (__m128i)__builtin_ia32_undef128();
1876}
1877
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001878/// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with
1879/// the specified 64-bit integer values.
1880///
1881/// \headerfile <x86intrin.h>
1882///
1883/// This intrinsic is a utility function and does not correspond to a specific
1884/// instruction.
1885///
1886/// \param __q1
1887/// A 64-bit integer value used to initialize the upper 64 bits of the
1888/// destination vector of [2 x i64].
1889/// \param __q0
1890/// A 64-bit integer value used to initialize the lower 64 bits of the
1891/// destination vector of [2 x i64].
1892/// \returns An initialized 128-bit vector of [2 x i64] containing the values
1893/// provided in the operands.
Simon Pilgrim5aba9922015-08-26 21:17:12 +00001894static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001895_mm_set_epi64x(long long __q1, long long __q0)
Anders Carlssondfa31172009-09-18 17:03:55 +00001896{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001897 return (__m128i){ __q0, __q1 };
Anders Carlssondfa31172009-09-18 17:03:55 +00001898}
1899
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001900/// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with
1901/// the specified 64-bit integer values.
1902///
1903/// \headerfile <x86intrin.h>
1904///
1905/// This intrinsic is a utility function and does not correspond to a specific
1906/// instruction.
1907///
1908/// \param __q1
1909/// A 64-bit integer value used to initialize the upper 64 bits of the
1910/// destination vector of [2 x i64].
1911/// \param __q0
1912/// A 64-bit integer value used to initialize the lower 64 bits of the
1913/// destination vector of [2 x i64].
1914/// \returns An initialized 128-bit vector of [2 x i64] containing the values
1915/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00001916static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001917_mm_set_epi64(__m64 __q1, __m64 __q0)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001918{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001919 return (__m128i){ (long long)__q0, (long long)__q1 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001920}
1921
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001922/// \brief Initializes the 32-bit values in a 128-bit vector of [4 x i32] with
1923/// the specified 32-bit integer values.
1924///
1925/// \headerfile <x86intrin.h>
1926///
1927/// This intrinsic is a utility function and does not correspond to a specific
1928/// instruction.
1929///
1930/// \param __i3
1931/// A 32-bit integer value used to initialize bits [127:96] of the
1932/// destination vector.
1933/// \param __i2
1934/// A 32-bit integer value used to initialize bits [95:64] of the destination
1935/// vector.
1936/// \param __i1
1937/// A 32-bit integer value used to initialize bits [63:32] of the destination
1938/// vector.
1939/// \param __i0
1940/// A 32-bit integer value used to initialize bits [31:0] of the destination
1941/// vector.
1942/// \returns An initialized 128-bit vector of [4 x i32] containing the values
1943/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00001944static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001945_mm_set_epi32(int __i3, int __i2, int __i1, int __i0)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001946{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001947 return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001948}
1949
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001950/// \brief Initializes the 16-bit values in a 128-bit vector of [8 x i16] with
1951/// the specified 16-bit integer values.
1952///
1953/// \headerfile <x86intrin.h>
1954///
1955/// This intrinsic is a utility function and does not correspond to a specific
1956/// instruction.
1957///
1958/// \param __w7
1959/// A 16-bit integer value used to initialize bits [127:112] of the
1960/// destination vector.
1961/// \param __w6
1962/// A 16-bit integer value used to initialize bits [111:96] of the
1963/// destination vector.
1964/// \param __w5
1965/// A 16-bit integer value used to initialize bits [95:80] of the destination
1966/// vector.
1967/// \param __w4
1968/// A 16-bit integer value used to initialize bits [79:64] of the destination
1969/// vector.
1970/// \param __w3
1971/// A 16-bit integer value used to initialize bits [63:48] of the destination
1972/// vector.
1973/// \param __w2
1974/// A 16-bit integer value used to initialize bits [47:32] of the destination
1975/// vector.
1976/// \param __w1
1977/// A 16-bit integer value used to initialize bits [31:16] of the destination
1978/// vector.
1979/// \param __w0
1980/// A 16-bit integer value used to initialize bits [15:0] of the destination
1981/// vector.
1982/// \returns An initialized 128-bit vector of [8 x i16] containing the values
1983/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00001984static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001985_mm_set_epi16(short __w7, short __w6, short __w5, short __w4, short __w3, short __w2, short __w1, short __w0)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001986{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00001987 return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00001988}
1989
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00001990/// \brief Initializes the 8-bit values in a 128-bit vector of [16 x i8] with
1991/// the specified 8-bit integer values.
1992///
1993/// \headerfile <x86intrin.h>
1994///
1995/// This intrinsic is a utility function and does not correspond to a specific
1996/// instruction.
1997///
1998/// \param __b15
1999/// Initializes bits [127:120] of the destination vector.
2000/// \param __b14
2001/// Initializes bits [119:112] of the destination vector.
2002/// \param __b13
2003/// Initializes bits [111:104] of the destination vector.
2004/// \param __b12
2005/// Initializes bits [103:96] of the destination vector.
2006/// \param __b11
2007/// Initializes bits [95:88] of the destination vector.
2008/// \param __b10
2009/// Initializes bits [87:80] of the destination vector.
2010/// \param __b9
2011/// Initializes bits [79:72] of the destination vector.
2012/// \param __b8
2013/// Initializes bits [71:64] of the destination vector.
2014/// \param __b7
2015/// Initializes bits [63:56] of the destination vector.
2016/// \param __b6
2017/// Initializes bits [55:48] of the destination vector.
2018/// \param __b5
2019/// Initializes bits [47:40] of the destination vector.
2020/// \param __b4
2021/// Initializes bits [39:32] of the destination vector.
2022/// \param __b3
2023/// Initializes bits [31:24] of the destination vector.
2024/// \param __b2
2025/// Initializes bits [23:16] of the destination vector.
2026/// \param __b1
2027/// Initializes bits [15:8] of the destination vector.
2028/// \param __b0
2029/// Initializes bits [7:0] of the destination vector.
2030/// \returns An initialized 128-bit vector of [16 x i8] containing the values
2031/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002032static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002033_mm_set_epi8(char __b15, char __b14, char __b13, char __b12, char __b11, char __b10, char __b9, char __b8, char __b7, char __b6, char __b5, char __b4, char __b3, char __b2, char __b1, char __b0)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002034{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002035 return (__m128i)(__v16qi){ __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002036}
2037
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002038/// \brief Initializes both values in a 128-bit integer vector with the
2039/// specified 64-bit integer value.
2040///
2041/// \headerfile <x86intrin.h>
2042///
2043/// This intrinsic is a utility function and does not correspond to a specific
2044/// instruction.
2045///
2046/// \param __q
2047/// Integer value used to initialize the elements of the destination integer
2048/// vector.
2049/// \returns An initialized 128-bit integer vector of [2 x i64] with both
2050/// elements containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00002051static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002052_mm_set1_epi64x(long long __q)
Anders Carlssondfa31172009-09-18 17:03:55 +00002053{
David Blaikie3302f2b2013-01-16 23:08:36 +00002054 return (__m128i){ __q, __q };
Anders Carlssondfa31172009-09-18 17:03:55 +00002055}
2056
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002057/// \brief Initializes both values in a 128-bit vector of [2 x i64] with the
2058/// specified 64-bit value.
2059///
2060/// \headerfile <x86intrin.h>
2061///
2062/// This intrinsic is a utility function and does not correspond to a specific
2063/// instruction.
2064///
2065/// \param __q
2066/// A 64-bit value used to initialize the elements of the destination integer
2067/// vector.
2068/// \returns An initialized 128-bit vector of [2 x i64] with all elements
2069/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00002070static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002071_mm_set1_epi64(__m64 __q)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002072{
David Blaikie3302f2b2013-01-16 23:08:36 +00002073 return (__m128i){ (long long)__q, (long long)__q };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002074}
2075
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002076/// \brief Initializes all values in a 128-bit vector of [4 x i32] with the
2077/// specified 32-bit value.
2078///
2079/// \headerfile <x86intrin.h>
2080///
2081/// This intrinsic is a utility function and does not correspond to a specific
2082/// instruction.
2083///
2084/// \param __i
2085/// A 32-bit value used to initialize the elements of the destination integer
2086/// vector.
2087/// \returns An initialized 128-bit vector of [4 x i32] with all elements
2088/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00002089static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002090_mm_set1_epi32(int __i)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002091{
David Blaikie3302f2b2013-01-16 23:08:36 +00002092 return (__m128i)(__v4si){ __i, __i, __i, __i };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002093}
2094
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002095/// \brief Initializes all values in a 128-bit vector of [8 x i16] with the
2096/// specified 16-bit value.
2097///
2098/// \headerfile <x86intrin.h>
2099///
2100/// This intrinsic is a utility function and does not correspond to a specific
2101/// instruction.
2102///
2103/// \param __w
2104/// A 16-bit value used to initialize the elements of the destination integer
2105/// vector.
2106/// \returns An initialized 128-bit vector of [8 x i16] with all elements
2107/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00002108static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002109_mm_set1_epi16(short __w)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002110{
David Blaikie3302f2b2013-01-16 23:08:36 +00002111 return (__m128i)(__v8hi){ __w, __w, __w, __w, __w, __w, __w, __w };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002112}
2113
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002114/// \brief Initializes all values in a 128-bit vector of [16 x i8] with the
2115/// specified 8-bit value.
2116///
2117/// \headerfile <x86intrin.h>
2118///
2119/// This intrinsic is a utility function and does not correspond to a specific
2120/// instruction.
2121///
2122/// \param __b
2123/// An 8-bit value used to initialize the elements of the destination integer
2124/// vector.
2125/// \returns An initialized 128-bit vector of [16 x i8] with all elements
2126/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00002127static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002128_mm_set1_epi8(char __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002129{
David Blaikie3302f2b2013-01-16 23:08:36 +00002130 return (__m128i)(__v16qi){ __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002131}
2132
Michael Kupersteine45af542015-06-30 13:36:19 +00002133static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002134_mm_setr_epi64(__m64 __q0, __m64 __q1)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002135{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002136 return (__m128i){ (long long)__q0, (long long)__q1 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002137}
2138
Michael Kupersteine45af542015-06-30 13:36:19 +00002139static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002140_mm_setr_epi32(int __i0, int __i1, int __i2, int __i3)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002141{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002142 return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002143}
2144
Michael Kupersteine45af542015-06-30 13:36:19 +00002145static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002146_mm_setr_epi16(short __w0, short __w1, short __w2, short __w3, short __w4, short __w5, short __w6, short __w7)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002147{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002148 return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002149}
2150
Michael Kupersteine45af542015-06-30 13:36:19 +00002151static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002152_mm_setr_epi8(char __b0, char __b1, char __b2, char __b3, char __b4, char __b5, char __b6, char __b7, char __b8, char __b9, char __b10, char __b11, char __b12, char __b13, char __b14, char __b15)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002153{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00002154 return (__m128i)(__v16qi){ __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002155}
2156
Michael Kupersteine45af542015-06-30 13:36:19 +00002157static __inline__ __m128i __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +00002158_mm_setzero_si128(void)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002159{
2160 return (__m128i){ 0LL, 0LL };
2161}
2162
Michael Kupersteine45af542015-06-30 13:36:19 +00002163static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002164_mm_store_si128(__m128i *__p, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002165{
David Blaikie3302f2b2013-01-16 23:08:36 +00002166 *__p = __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002167}
2168
Michael Kupersteine45af542015-06-30 13:36:19 +00002169static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002170_mm_storeu_si128(__m128i *__p, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002171{
David Blaikie3302f2b2013-01-16 23:08:36 +00002172 __builtin_ia32_storedqu((char *)__p, (__v16qi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002173}
2174
Michael Kupersteine45af542015-06-30 13:36:19 +00002175static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002176_mm_maskmoveu_si128(__m128i __d, __m128i __n, char *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002177{
David Blaikie3302f2b2013-01-16 23:08:36 +00002178 __builtin_ia32_maskmovdqu((__v16qi)__d, (__v16qi)__n, __p);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002179}
2180
Michael Kupersteine45af542015-06-30 13:36:19 +00002181static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002182_mm_storel_epi64(__m128i *__p, __m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002183{
Chad Rosier87622b82012-05-01 18:11:51 +00002184 struct __mm_storel_epi64_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00002185 long long __u;
Chad Rosier87622b82012-05-01 18:11:51 +00002186 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00002187 ((struct __mm_storel_epi64_struct*)__p)->__u = __a[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002188}
2189
Michael Kupersteine45af542015-06-30 13:36:19 +00002190static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002191_mm_stream_pd(double *__p, __m128d __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002192{
David Blaikie3302f2b2013-01-16 23:08:36 +00002193 __builtin_ia32_movntpd(__p, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002194}
2195
Michael Kupersteine45af542015-06-30 13:36:19 +00002196static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002197_mm_stream_si128(__m128i *__p, __m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002198{
David Blaikie3302f2b2013-01-16 23:08:36 +00002199 __builtin_ia32_movntdq(__p, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002200}
2201
Michael Kupersteine45af542015-06-30 13:36:19 +00002202static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002203_mm_stream_si32(int *__p, int __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002204{
David Blaikie3302f2b2013-01-16 23:08:36 +00002205 __builtin_ia32_movnti(__p, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002206}
2207
Eli Friedmanf9d8c6c2013-09-23 23:38:39 +00002208#ifdef __x86_64__
Michael Kupersteine45af542015-06-30 13:36:19 +00002209static __inline__ void __DEFAULT_FN_ATTRS
Eli Friedmanf9d8c6c2013-09-23 23:38:39 +00002210_mm_stream_si64(long long *__p, long long __a)
2211{
2212 __builtin_ia32_movnti64(__p, __a);
2213}
2214#endif
2215
Michael Kupersteine45af542015-06-30 13:36:19 +00002216static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002217_mm_clflush(void const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002218{
David Blaikie3302f2b2013-01-16 23:08:36 +00002219 __builtin_ia32_clflush(__p);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002220}
2221
Michael Kupersteine45af542015-06-30 13:36:19 +00002222static __inline__ void __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +00002223_mm_lfence(void)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002224{
2225 __builtin_ia32_lfence();
2226}
2227
Michael Kupersteine45af542015-06-30 13:36:19 +00002228static __inline__ void __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +00002229_mm_mfence(void)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002230{
2231 __builtin_ia32_mfence();
2232}
2233
Michael Kupersteine45af542015-06-30 13:36:19 +00002234static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002235_mm_packs_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002236{
David Blaikie3302f2b2013-01-16 23:08:36 +00002237 return (__m128i)__builtin_ia32_packsswb128((__v8hi)__a, (__v8hi)__b);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002238}
2239
Michael Kupersteine45af542015-06-30 13:36:19 +00002240static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002241_mm_packs_epi32(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002242{
David Blaikie3302f2b2013-01-16 23:08:36 +00002243 return (__m128i)__builtin_ia32_packssdw128((__v4si)__a, (__v4si)__b);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002244}
2245
Michael Kupersteine45af542015-06-30 13:36:19 +00002246static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002247_mm_packus_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002248{
David Blaikie3302f2b2013-01-16 23:08:36 +00002249 return (__m128i)__builtin_ia32_packuswb128((__v8hi)__a, (__v8hi)__b);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002250}
2251
Michael Kupersteine45af542015-06-30 13:36:19 +00002252static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002253_mm_extract_epi16(__m128i __a, int __imm)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002254{
David Blaikie3302f2b2013-01-16 23:08:36 +00002255 __v8hi __b = (__v8hi)__a;
Manman Renbe38b9e2013-10-22 19:24:42 +00002256 return (unsigned short)__b[__imm & 7];
Anders Carlsson85eb1242008-12-26 00:45:50 +00002257}
2258
Michael Kupersteine45af542015-06-30 13:36:19 +00002259static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002260_mm_insert_epi16(__m128i __a, int __b, int __imm)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002261{
David Blaikie3302f2b2013-01-16 23:08:36 +00002262 __v8hi __c = (__v8hi)__a;
2263 __c[__imm & 7] = __b;
2264 return (__m128i)__c;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002265}
2266
Michael Kupersteine45af542015-06-30 13:36:19 +00002267static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002268_mm_movemask_epi8(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002269{
David Blaikie3302f2b2013-01-16 23:08:36 +00002270 return __builtin_ia32_pmovmskb128((__v16qi)__a);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002271}
2272
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002273#define _mm_shuffle_epi32(a, imm) __extension__ ({ \
Craig Topper51e47412015-02-13 06:04:43 +00002274 (__m128i)__builtin_shufflevector((__v4si)(__m128i)(a), \
Craig Topperfd778ee2015-11-10 05:08:08 +00002275 (__v4si)_mm_setzero_si128(), \
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002276 (imm) & 0x3, ((imm) & 0xc) >> 2, \
2277 ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); })
Chris Lattnerf03406f2011-04-25 20:42:40 +00002278
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002279#define _mm_shufflelo_epi16(a, imm) __extension__ ({ \
Craig Topper51e47412015-02-13 06:04:43 +00002280 (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \
Craig Topperfd778ee2015-11-10 05:08:08 +00002281 (__v8hi)_mm_setzero_si128(), \
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002282 (imm) & 0x3, ((imm) & 0xc) >> 2, \
2283 ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \
2284 4, 5, 6, 7); })
Chris Lattnerf03406f2011-04-25 20:42:40 +00002285
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002286#define _mm_shufflehi_epi16(a, imm) __extension__ ({ \
Craig Topper51e47412015-02-13 06:04:43 +00002287 (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \
Craig Topperfd778ee2015-11-10 05:08:08 +00002288 (__v8hi)_mm_setzero_si128(), \
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002289 0, 1, 2, 3, \
2290 4 + (((imm) & 0x03) >> 0), \
2291 4 + (((imm) & 0x0c) >> 2), \
2292 4 + (((imm) & 0x30) >> 4), \
2293 4 + (((imm) & 0xc0) >> 6)); })
Anders Carlsson85eb1242008-12-26 00:45:50 +00002294
Michael Kupersteine45af542015-06-30 13:36:19 +00002295static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002296_mm_unpackhi_epi8(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002297{
David Blaikie3302f2b2013-01-16 23:08:36 +00002298 return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002299}
2300
Michael Kupersteine45af542015-06-30 13:36:19 +00002301static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002302_mm_unpackhi_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002303{
David Blaikie3302f2b2013-01-16 23:08:36 +00002304 return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002305}
2306
Michael Kupersteine45af542015-06-30 13:36:19 +00002307static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002308_mm_unpackhi_epi32(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002309{
David Blaikie3302f2b2013-01-16 23:08:36 +00002310 return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 2, 4+2, 3, 4+3);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002311}
2312
Michael Kupersteine45af542015-06-30 13:36:19 +00002313static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002314_mm_unpackhi_epi64(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002315{
David Blaikie3302f2b2013-01-16 23:08:36 +00002316 return (__m128i)__builtin_shufflevector(__a, __b, 1, 2+1);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002317}
2318
Michael Kupersteine45af542015-06-30 13:36:19 +00002319static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002320_mm_unpacklo_epi8(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002321{
David Blaikie3302f2b2013-01-16 23:08:36 +00002322 return (__m128i)__builtin_shufflevector((__v16qi)__a, (__v16qi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002323}
2324
Michael Kupersteine45af542015-06-30 13:36:19 +00002325static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002326_mm_unpacklo_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002327{
David Blaikie3302f2b2013-01-16 23:08:36 +00002328 return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002329}
2330
Michael Kupersteine45af542015-06-30 13:36:19 +00002331static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002332_mm_unpacklo_epi32(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002333{
David Blaikie3302f2b2013-01-16 23:08:36 +00002334 return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 0, 4+0, 1, 4+1);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002335}
2336
Michael Kupersteine45af542015-06-30 13:36:19 +00002337static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002338_mm_unpacklo_epi64(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002339{
David Blaikie3302f2b2013-01-16 23:08:36 +00002340 return (__m128i)__builtin_shufflevector(__a, __b, 0, 2+0);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002341}
2342
Michael Kupersteine45af542015-06-30 13:36:19 +00002343static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002344_mm_movepi64_pi64(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002345{
David Blaikie3302f2b2013-01-16 23:08:36 +00002346 return (__m64)__a[0];
Anders Carlsson85eb1242008-12-26 00:45:50 +00002347}
2348
Michael Kupersteine45af542015-06-30 13:36:19 +00002349static __inline__ __m128i __DEFAULT_FN_ATTRS
Alp Tokerd480b1b2013-11-23 22:11:57 +00002350_mm_movpi64_epi64(__m64 __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002351{
David Blaikie3302f2b2013-01-16 23:08:36 +00002352 return (__m128i){ (long long)__a, 0 };
Anders Carlsson85eb1242008-12-26 00:45:50 +00002353}
2354
Michael Kupersteine45af542015-06-30 13:36:19 +00002355static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002356_mm_move_epi64(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002357{
David Blaikie3302f2b2013-01-16 23:08:36 +00002358 return __builtin_shufflevector(__a, (__m128i){ 0 }, 0, 2);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002359}
2360
Michael Kupersteine45af542015-06-30 13:36:19 +00002361static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002362_mm_unpackhi_pd(__m128d __a, __m128d __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002363{
David Blaikie3302f2b2013-01-16 23:08:36 +00002364 return __builtin_shufflevector(__a, __b, 1, 2+1);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002365}
2366
Michael Kupersteine45af542015-06-30 13:36:19 +00002367static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002368_mm_unpacklo_pd(__m128d __a, __m128d __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002369{
David Blaikie3302f2b2013-01-16 23:08:36 +00002370 return __builtin_shufflevector(__a, __b, 0, 2+0);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002371}
2372
Michael Kupersteine45af542015-06-30 13:36:19 +00002373static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002374_mm_movemask_pd(__m128d __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002375{
David Blaikie3302f2b2013-01-16 23:08:36 +00002376 return __builtin_ia32_movmskpd(__a);
Anders Carlsson85eb1242008-12-26 00:45:50 +00002377}
2378
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00002379#define _mm_shuffle_pd(a, b, i) __extension__ ({ \
Craig Topperd619eaaa2015-11-11 03:47:10 +00002380 (__m128d)__builtin_shufflevector((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \
2381 (i) & 1, (((i) & 2) >> 1) + 2); })
Anders Carlsson85eb1242008-12-26 00:45:50 +00002382
Michael Kupersteine45af542015-06-30 13:36:19 +00002383static __inline__ __m128 __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002384_mm_castpd_ps(__m128d __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002385{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002386 return (__m128)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002387}
2388
Michael Kupersteine45af542015-06-30 13:36:19 +00002389static __inline__ __m128i __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002390_mm_castpd_si128(__m128d __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002391{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002392 return (__m128i)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002393}
2394
Michael Kupersteine45af542015-06-30 13:36:19 +00002395static __inline__ __m128d __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002396_mm_castps_pd(__m128 __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002397{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002398 return (__m128d)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002399}
2400
Michael Kupersteine45af542015-06-30 13:36:19 +00002401static __inline__ __m128i __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002402_mm_castps_si128(__m128 __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002403{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002404 return (__m128i)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002405}
2406
Michael Kupersteine45af542015-06-30 13:36:19 +00002407static __inline__ __m128 __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002408_mm_castsi128_ps(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002409{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002410 return (__m128)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002411}
2412
Michael Kupersteine45af542015-06-30 13:36:19 +00002413static __inline__ __m128d __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002414_mm_castsi128_pd(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00002415{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00002416 return (__m128d)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00002417}
2418
Michael Kupersteine45af542015-06-30 13:36:19 +00002419static __inline__ void __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +00002420_mm_pause(void)
Anders Carlsson37c23712008-12-26 00:49:43 +00002421{
Craig Topperfb79b5f2015-11-11 08:13:33 +00002422 __builtin_ia32_pause();
Anders Carlsson37c23712008-12-26 00:49:43 +00002423}
2424
Michael Kupersteine45af542015-06-30 13:36:19 +00002425#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +00002426
Anders Carlsson43c2bab2009-01-21 01:49:39 +00002427#define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))
Anders Carlsson37c23712008-12-26 00:49:43 +00002428
Anders Carlssonf15e71d2008-12-24 01:45:22 +00002429#endif /* __EMMINTRIN_H */