blob: 9302321612a24256242c088e9a2aa3fb80d73669 [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
Simon Pilgrim6d1a0c42016-05-29 18:49:08 +000038/* Unsigned types */
39typedef unsigned long long __v2du __attribute__ ((__vector_size__ (16)));
Simon Pilgrim6d1a0c42016-05-29 18:49:08 +000040typedef unsigned short __v8hu __attribute__((__vector_size__(16)));
41typedef unsigned char __v16qu __attribute__((__vector_size__(16)));
42
Chandler Carruthcbe64112015-10-01 23:40:12 +000043/* We need an explicitly signed variant for char. Note that this shouldn't
44 * appear in the interface though. */
45typedef signed char __v16qs __attribute__((__vector_size__(16)));
46
Michael Kupersteina10dff92015-09-21 13:34:47 +000047#include <f16cintrin.h>
48
Eric Christopher4d1851682015-06-17 07:09:20 +000049/* Define the default attributes for the functions in this file. */
Michael Kupersteine45af542015-06-30 13:36:19 +000050#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))
Eric Christopher4d1851682015-06-17 07:09:20 +000051
Ekaterina Romanova493091f2016-10-20 17:59:15 +000052/// \brief Adds lower double-precision values in both operands and returns the
53/// sum in the lower 64 bits of the result. The upper 64 bits of the result
54/// are copied from the upper double-precision value of the first operand.
55///
56/// \headerfile <x86intrin.h>
57///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +000058/// This intrinsic corresponds to the <c> VADDSD / ADDSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +000059///
60/// \param __a
61/// A 128-bit vector of [2 x double] containing one of the source operands.
62/// \param __b
63/// A 128-bit vector of [2 x double] containing one of the source operands.
64/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
65/// sum of the lower 64 bits of both operands. The upper 64 bits are copied
66/// from the upper 64 bits of the first source operand.
Michael Kupersteine45af542015-06-30 13:36:19 +000067static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000068_mm_add_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000069{
David Blaikie3302f2b2013-01-16 23:08:36 +000070 __a[0] += __b[0];
71 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +000072}
73
Ekaterina Romanova493091f2016-10-20 17:59:15 +000074/// \brief Adds two 128-bit vectors of [2 x double].
75///
76/// \headerfile <x86intrin.h>
77///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +000078/// This intrinsic corresponds to the <c> VADDPD / ADDPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +000079///
80/// \param __a
81/// A 128-bit vector of [2 x double] containing one of the source operands.
82/// \param __b
83/// A 128-bit vector of [2 x double] containing one of the source operands.
84/// \returns A 128-bit vector of [2 x double] containing the sums of both
85/// operands.
Michael Kupersteine45af542015-06-30 13:36:19 +000086static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +000087_mm_add_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +000088{
Craig Topper1aa231e2016-05-16 06:38:42 +000089 return (__m128d)((__v2df)__a + (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +000090}
91
Ekaterina Romanova493091f2016-10-20 17:59:15 +000092/// \brief Subtracts the lower double-precision value of the second operand
93/// from the lower double-precision value of the first operand and returns
94/// the difference in the lower 64 bits of the result. The upper 64 bits of
95/// the result are copied from the upper double-precision value of the first
96/// operand.
97///
98/// \headerfile <x86intrin.h>
99///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000100/// This intrinsic corresponds to the <c> VSUBSD / SUBSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000101///
102/// \param __a
103/// A 128-bit vector of [2 x double] containing the minuend.
104/// \param __b
105/// A 128-bit vector of [2 x double] containing the subtrahend.
106/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
107/// difference of the lower 64 bits of both operands. The upper 64 bits are
108/// copied from the upper 64 bits of the first source operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000109static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000110_mm_sub_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000111{
David Blaikie3302f2b2013-01-16 23:08:36 +0000112 __a[0] -= __b[0];
113 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000114}
115
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000116/// \brief Subtracts two 128-bit vectors of [2 x double].
117///
118/// \headerfile <x86intrin.h>
119///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000120/// This intrinsic corresponds to the <c> VSUBPD / SUBPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000121///
122/// \param __a
123/// A 128-bit vector of [2 x double] containing the minuend.
124/// \param __b
125/// A 128-bit vector of [2 x double] containing the subtrahend.
126/// \returns A 128-bit vector of [2 x double] containing the differences between
127/// both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000128static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000129_mm_sub_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000130{
Craig Topper1aa231e2016-05-16 06:38:42 +0000131 return (__m128d)((__v2df)__a - (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000132}
133
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000134/// \brief Multiplies lower double-precision values in both operands and returns
135/// the product in the lower 64 bits of the result. The upper 64 bits of the
136/// result are copied from the upper double-precision value of the first
137/// operand.
138///
139/// \headerfile <x86intrin.h>
140///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000141/// This intrinsic corresponds to the <c> VMULSD / MULSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000142///
143/// \param __a
144/// A 128-bit vector of [2 x double] containing one of the source operands.
145/// \param __b
146/// A 128-bit vector of [2 x double] containing one of the source operands.
147/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
148/// product of the lower 64 bits of both operands. The upper 64 bits are
149/// copied from the upper 64 bits of the first source operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000150static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000151_mm_mul_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000152{
David Blaikie3302f2b2013-01-16 23:08:36 +0000153 __a[0] *= __b[0];
154 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000155}
156
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000157/// \brief Multiplies two 128-bit vectors of [2 x double].
158///
159/// \headerfile <x86intrin.h>
160///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000161/// This intrinsic corresponds to the <c> VMULPD / MULPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000162///
163/// \param __a
164/// A 128-bit vector of [2 x double] containing one of the operands.
165/// \param __b
166/// A 128-bit vector of [2 x double] containing one of the operands.
167/// \returns A 128-bit vector of [2 x double] containing the products of both
168/// operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000169static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000170_mm_mul_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000171{
Craig Topper1aa231e2016-05-16 06:38:42 +0000172 return (__m128d)((__v2df)__a * (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000173}
174
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000175/// \brief Divides the lower double-precision value of the first operand by the
176/// lower double-precision value of the second operand and returns the
177/// quotient in the lower 64 bits of the result. The upper 64 bits of the
178/// result are copied from the upper double-precision value of the first
179/// operand.
180///
181/// \headerfile <x86intrin.h>
182///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000183/// This intrinsic corresponds to the <c> VDIVSD / DIVSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000184///
185/// \param __a
186/// A 128-bit vector of [2 x double] containing the dividend.
187/// \param __b
188/// A 128-bit vector of [2 x double] containing divisor.
189/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
190/// quotient of the lower 64 bits of both operands. The upper 64 bits are
191/// copied from the upper 64 bits of the first source operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000192static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000193_mm_div_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000194{
David Blaikie3302f2b2013-01-16 23:08:36 +0000195 __a[0] /= __b[0];
196 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000197}
198
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000199/// \brief Performs an element-by-element division of two 128-bit vectors of
200/// [2 x double].
201///
202/// \headerfile <x86intrin.h>
203///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000204/// This intrinsic corresponds to the <c> VDIVPD / DIVPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000205///
206/// \param __a
207/// A 128-bit vector of [2 x double] containing the dividend.
208/// \param __b
209/// A 128-bit vector of [2 x double] containing the divisor.
210/// \returns A 128-bit vector of [2 x double] containing the quotients of both
211/// operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000212static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000213_mm_div_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000214{
Craig Topper1aa231e2016-05-16 06:38:42 +0000215 return (__m128d)((__v2df)__a / (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000216}
217
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000218/// \brief Calculates the square root of the lower double-precision value of
219/// the second operand and returns it in the lower 64 bits of the result.
Douglas Yung0686df102018-01-02 20:39:29 +0000220/// The upper 64 bits of the result are copied from the upper
221/// double-precision value of the first operand.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000222///
223/// \headerfile <x86intrin.h>
224///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000225/// This intrinsic corresponds to the <c> VSQRTSD / SQRTSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000226///
227/// \param __a
228/// A 128-bit vector of [2 x double] containing one of the operands. The
229/// upper 64 bits of this operand are copied to the upper 64 bits of the
230/// result.
231/// \param __b
232/// A 128-bit vector of [2 x double] containing one of the operands. The
233/// square root is calculated using the lower 64 bits of this operand.
234/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000235/// square root of the lower 64 bits of operand \a __b, and whose upper 64
236/// bits are copied from the upper 64 bits of operand \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000237static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000238_mm_sqrt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000239{
Craig Topper1aa231e2016-05-16 06:38:42 +0000240 __m128d __c = __builtin_ia32_sqrtsd((__v2df)__b);
David Blaikie3302f2b2013-01-16 23:08:36 +0000241 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000242}
243
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000244/// \brief Calculates the square root of the each of two values stored in a
245/// 128-bit vector of [2 x double].
246///
247/// \headerfile <x86intrin.h>
248///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000249/// This intrinsic corresponds to the <c> VSQRTPD / SQRTPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000250///
251/// \param __a
252/// A 128-bit vector of [2 x double].
253/// \returns A 128-bit vector of [2 x double] containing the square roots of the
254/// values in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000255static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000256_mm_sqrt_pd(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000257{
Craig Topper1aa231e2016-05-16 06:38:42 +0000258 return __builtin_ia32_sqrtpd((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000259}
260
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000261/// \brief Compares lower 64-bit double-precision values of both operands, and
262/// returns the lesser of the pair of values in the lower 64-bits of the
Douglas Yung0686df102018-01-02 20:39:29 +0000263/// result. The upper 64 bits of the result are copied from the upper
264/// double-precision value of the first operand.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000265///
266/// \headerfile <x86intrin.h>
267///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000268/// This intrinsic corresponds to the <c> VMINSD / MINSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000269///
270/// \param __a
271/// A 128-bit vector of [2 x double] containing one of the operands. The
272/// lower 64 bits of this operand are used in the comparison.
273/// \param __b
274/// A 128-bit vector of [2 x double] containing one of the operands. The
275/// lower 64 bits of this operand are used in the comparison.
276/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
277/// minimum value between both operands. The upper 64 bits are copied from
278/// the upper 64 bits of the first source operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000279static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000280_mm_min_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000281{
Craig Topper1aa231e2016-05-16 06:38:42 +0000282 return __builtin_ia32_minsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000283}
284
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000285/// \brief Performs element-by-element comparison of the two 128-bit vectors of
286/// [2 x double] and returns the vector containing the lesser of each pair of
287/// values.
288///
289/// \headerfile <x86intrin.h>
290///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000291/// This intrinsic corresponds to the <c> VMINPD / MINPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000292///
293/// \param __a
294/// A 128-bit vector of [2 x double] containing one of the operands.
295/// \param __b
296/// A 128-bit vector of [2 x double] containing one of the operands.
297/// \returns A 128-bit vector of [2 x double] containing the minimum values
298/// between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000299static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000300_mm_min_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000301{
Craig Topper1aa231e2016-05-16 06:38:42 +0000302 return __builtin_ia32_minpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000303}
304
Ekaterina Romanovacb3603a2017-06-06 22:58:01 +0000305/// \brief Compares lower 64-bit double-precision values of both operands, and
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000306/// returns the greater of the pair of values in the lower 64-bits of the
Douglas Yung0686df102018-01-02 20:39:29 +0000307/// result. The upper 64 bits of the result are copied from the upper
308/// double-precision value of the first operand.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000309///
310/// \headerfile <x86intrin.h>
311///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000312/// This intrinsic corresponds to the <c> VMAXSD / MAXSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000313///
314/// \param __a
315/// A 128-bit vector of [2 x double] containing one of the operands. The
316/// lower 64 bits of this operand are used in the comparison.
317/// \param __b
318/// A 128-bit vector of [2 x double] containing one of the operands. The
319/// lower 64 bits of this operand are used in the comparison.
320/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
321/// maximum value between both operands. The upper 64 bits are copied from
322/// the upper 64 bits of the first source operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000323static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000324_mm_max_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000325{
Craig Topper1aa231e2016-05-16 06:38:42 +0000326 return __builtin_ia32_maxsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000327}
328
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000329/// \brief Performs element-by-element comparison of the two 128-bit vectors of
330/// [2 x double] and returns the vector containing the greater of each pair
331/// of values.
332///
333/// \headerfile <x86intrin.h>
334///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000335/// This intrinsic corresponds to the <c> VMAXPD / MAXPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000336///
337/// \param __a
338/// A 128-bit vector of [2 x double] containing one of the operands.
339/// \param __b
340/// A 128-bit vector of [2 x double] containing one of the operands.
341/// \returns A 128-bit vector of [2 x double] containing the maximum values
342/// between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000343static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000344_mm_max_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000345{
Craig Topper1aa231e2016-05-16 06:38:42 +0000346 return __builtin_ia32_maxpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000347}
348
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000349/// \brief Performs a bitwise AND of two 128-bit vectors of [2 x double].
350///
351/// \headerfile <x86intrin.h>
352///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000353/// This intrinsic corresponds to the <c> VPAND / PAND </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000354///
355/// \param __a
356/// A 128-bit vector of [2 x double] containing one of the source operands.
357/// \param __b
358/// A 128-bit vector of [2 x double] containing one of the source operands.
359/// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the
360/// values between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000361static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000362_mm_and_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000363{
Craig Topperd0681d52016-08-31 05:38:55 +0000364 return (__m128d)((__v2du)__a & (__v2du)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000365}
366
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000367/// \brief Performs a bitwise AND of two 128-bit vectors of [2 x double], using
368/// the one's complement of the values contained in the first source operand.
369///
370/// \headerfile <x86intrin.h>
371///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000372/// This intrinsic corresponds to the <c> VPANDN / PANDN </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000373///
374/// \param __a
375/// A 128-bit vector of [2 x double] containing the left source operand. The
376/// one's complement of this value is used in the bitwise AND.
377/// \param __b
378/// A 128-bit vector of [2 x double] containing the right source operand.
379/// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the
380/// values in the second operand and the one's complement of the first
381/// operand.
Michael Kupersteine45af542015-06-30 13:36:19 +0000382static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000383_mm_andnot_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000384{
Craig Topperd0681d52016-08-31 05:38:55 +0000385 return (__m128d)(~(__v2du)__a & (__v2du)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000386}
387
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000388/// \brief Performs a bitwise OR of two 128-bit vectors of [2 x double].
389///
390/// \headerfile <x86intrin.h>
391///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000392/// This intrinsic corresponds to the <c> VPOR / POR </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000393///
394/// \param __a
395/// A 128-bit vector of [2 x double] containing one of the source operands.
396/// \param __b
397/// A 128-bit vector of [2 x double] containing one of the source operands.
398/// \returns A 128-bit vector of [2 x double] containing the bitwise OR of the
399/// values between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000400static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000401_mm_or_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000402{
Craig Topperd0681d52016-08-31 05:38:55 +0000403 return (__m128d)((__v2du)__a | (__v2du)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000404}
405
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000406/// \brief Performs a bitwise XOR of two 128-bit vectors of [2 x double].
407///
408/// \headerfile <x86intrin.h>
409///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000410/// This intrinsic corresponds to the <c> VPXOR / PXOR </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000411///
412/// \param __a
413/// A 128-bit vector of [2 x double] containing one of the source operands.
414/// \param __b
415/// A 128-bit vector of [2 x double] containing one of the source operands.
416/// \returns A 128-bit vector of [2 x double] containing the bitwise XOR of the
417/// values between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +0000418static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000419_mm_xor_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000420{
Craig Topperd0681d52016-08-31 05:38:55 +0000421 return (__m128d)((__v2du)__a ^ (__v2du)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000422}
423
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000424/// \brief Compares each of the corresponding double-precision values of the
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000425/// 128-bit vectors of [2 x double] for equality. Each comparison yields 0x0
426/// for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000427///
428/// \headerfile <x86intrin.h>
429///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000430/// This intrinsic corresponds to the <c> VCMPEQPD / CMPEQPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000431///
432/// \param __a
433/// A 128-bit vector of [2 x double].
434/// \param __b
435/// A 128-bit vector of [2 x double].
436/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000437static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000438_mm_cmpeq_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000439{
Craig Topper1aa231e2016-05-16 06:38:42 +0000440 return (__m128d)__builtin_ia32_cmpeqpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000441}
442
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000443/// \brief Compares each of the corresponding double-precision values of the
444/// 128-bit vectors of [2 x double] to determine if the values in the first
445/// operand are less than those in the second operand. Each comparison
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000446/// yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000447///
448/// \headerfile <x86intrin.h>
449///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000450/// This intrinsic corresponds to the <c> VCMPLTPD / CMPLTPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000451///
452/// \param __a
453/// A 128-bit vector of [2 x double].
454/// \param __b
455/// A 128-bit vector of [2 x double].
456/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000457static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000458_mm_cmplt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000459{
Craig Topper1aa231e2016-05-16 06:38:42 +0000460 return (__m128d)__builtin_ia32_cmpltpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000461}
462
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000463/// \brief Compares each of the corresponding double-precision values of the
464/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000465/// operand are less than or equal to those in the second operand.
466///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000467/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000468///
469/// \headerfile <x86intrin.h>
470///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000471/// This intrinsic corresponds to the <c> VCMPLEPD / CMPLEPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000472///
473/// \param __a
474/// A 128-bit vector of [2 x double].
475/// \param __b
476/// A 128-bit vector of [2 x double].
477/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000478static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000479_mm_cmple_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000480{
Craig Topper1aa231e2016-05-16 06:38:42 +0000481 return (__m128d)__builtin_ia32_cmplepd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000482}
483
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000484/// \brief Compares each of the corresponding double-precision values of the
485/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000486/// operand are greater than those in the second operand.
487///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000488/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000489///
490/// \headerfile <x86intrin.h>
491///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000492/// This intrinsic corresponds to the <c> VCMPLTPD / CMPLTPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000493///
494/// \param __a
495/// A 128-bit vector of [2 x double].
496/// \param __b
497/// A 128-bit vector of [2 x double].
498/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000499static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000500_mm_cmpgt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000501{
Craig Topper1aa231e2016-05-16 06:38:42 +0000502 return (__m128d)__builtin_ia32_cmpltpd((__v2df)__b, (__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000503}
504
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000505/// \brief Compares each of the corresponding double-precision values of the
506/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000507/// operand are greater than or equal to those in the second operand.
508///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000509/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000510///
511/// \headerfile <x86intrin.h>
512///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000513/// This intrinsic corresponds to the <c> VCMPLEPD / CMPLEPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000514///
515/// \param __a
516/// A 128-bit vector of [2 x double].
517/// \param __b
518/// A 128-bit vector of [2 x double].
519/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000520static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000521_mm_cmpge_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000522{
Craig Topper1aa231e2016-05-16 06:38:42 +0000523 return (__m128d)__builtin_ia32_cmplepd((__v2df)__b, (__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000524}
525
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000526/// \brief Compares each of the corresponding double-precision values of the
527/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000528/// operand are ordered with respect to those in the second operand.
529///
530/// A pair of double-precision values are "ordered" with respect to each
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000531/// other if neither value is a NaN. Each comparison yields 0x0 for false,
532/// 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000533///
534/// \headerfile <x86intrin.h>
535///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000536/// This intrinsic corresponds to the <c> VCMPORDPD / CMPORDPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000537///
538/// \param __a
539/// A 128-bit vector of [2 x double].
540/// \param __b
541/// A 128-bit vector of [2 x double].
542/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000543static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000544_mm_cmpord_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000545{
Craig Topper1aa231e2016-05-16 06:38:42 +0000546 return (__m128d)__builtin_ia32_cmpordpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000547}
548
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000549/// \brief Compares each of the corresponding double-precision values of the
550/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000551/// operand are unordered with respect to those in the second operand.
552///
553/// A pair of double-precision values are "unordered" with respect to each
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000554/// other if one or both values are NaN. Each comparison yields 0x0 for
555/// false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000556///
557/// \headerfile <x86intrin.h>
558///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +0000559/// This intrinsic corresponds to the <c> VCMPUNORDPD / CMPUNORDPD </c>
560/// instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000561///
562/// \param __a
563/// A 128-bit vector of [2 x double].
564/// \param __b
565/// A 128-bit vector of [2 x double].
566/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000567static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000568_mm_cmpunord_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000569{
Craig Topper1aa231e2016-05-16 06:38:42 +0000570 return (__m128d)__builtin_ia32_cmpunordpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000571}
572
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000573/// \brief Compares each of the corresponding double-precision values of the
574/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000575/// operand are unequal to those in the second operand.
576///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000577/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000578///
579/// \headerfile <x86intrin.h>
580///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000581/// This intrinsic corresponds to the <c> VCMPNEQPD / CMPNEQPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000582///
583/// \param __a
584/// A 128-bit vector of [2 x double].
585/// \param __b
586/// A 128-bit vector of [2 x double].
587/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000588static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000589_mm_cmpneq_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000590{
Craig Topper1aa231e2016-05-16 06:38:42 +0000591 return (__m128d)__builtin_ia32_cmpneqpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000592}
593
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000594/// \brief Compares each of the corresponding double-precision values of the
595/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000596/// operand are not less than those in the second operand.
597///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000598/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000599///
600/// \headerfile <x86intrin.h>
601///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000602/// This intrinsic corresponds to the <c> VCMPNLTPD / CMPNLTPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000603///
604/// \param __a
605/// A 128-bit vector of [2 x double].
606/// \param __b
607/// A 128-bit vector of [2 x double].
608/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000609static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000610_mm_cmpnlt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000611{
Craig Topper1aa231e2016-05-16 06:38:42 +0000612 return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000613}
614
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000615/// \brief Compares each of the corresponding double-precision values of the
616/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000617/// operand are not less than or equal to those in the second operand.
618///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000619/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000620///
621/// \headerfile <x86intrin.h>
622///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000623/// This intrinsic corresponds to the <c> VCMPNLEPD / CMPNLEPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000624///
625/// \param __a
626/// A 128-bit vector of [2 x double].
627/// \param __b
628/// A 128-bit vector of [2 x double].
629/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000630static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000631_mm_cmpnle_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000632{
Craig Topper1aa231e2016-05-16 06:38:42 +0000633 return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000634}
635
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000636/// \brief Compares each of the corresponding double-precision values of the
637/// 128-bit vectors of [2 x double] to determine if the values in the first
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000638/// operand are not greater than those in the second operand.
639///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000640/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000641///
642/// \headerfile <x86intrin.h>
643///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000644/// This intrinsic corresponds to the <c> VCMPNLTPD / CMPNLTPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000645///
646/// \param __a
647/// A 128-bit vector of [2 x double].
648/// \param __b
649/// A 128-bit vector of [2 x double].
650/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000651static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000652_mm_cmpngt_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000653{
Craig Topper1aa231e2016-05-16 06:38:42 +0000654 return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__b, (__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000655}
656
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000657/// \brief Compares each of the corresponding double-precision values of the
658/// 128-bit vectors of [2 x double] to determine if the values in the first
659/// operand are not greater than or equal to those in the second operand.
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000660///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000661/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000662///
663/// \headerfile <x86intrin.h>
664///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000665/// This intrinsic corresponds to the <c> VCMPNLEPD / CMPNLEPD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000666///
667/// \param __a
668/// A 128-bit vector of [2 x double].
669/// \param __b
670/// A 128-bit vector of [2 x double].
671/// \returns A 128-bit vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +0000672static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000673_mm_cmpnge_pd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000674{
Craig Topper1aa231e2016-05-16 06:38:42 +0000675 return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__b, (__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000676}
677
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000678/// \brief Compares the lower double-precision floating-point values in each of
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000679/// the two 128-bit floating-point vectors of [2 x double] for equality.
680///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000681/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000682///
683/// \headerfile <x86intrin.h>
684///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000685/// This intrinsic corresponds to the <c> VCMPEQSD / CMPEQSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000686///
687/// \param __a
688/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000689/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000690/// \param __b
691/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000692/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000693/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000694/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000695static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000696_mm_cmpeq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000697{
Craig Topper1aa231e2016-05-16 06:38:42 +0000698 return (__m128d)__builtin_ia32_cmpeqsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000699}
700
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000701/// \brief Compares the lower double-precision floating-point values in each of
702/// the two 128-bit floating-point vectors of [2 x double] to determine if
703/// the value in the first parameter is less than the corresponding value in
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000704/// the second parameter.
705///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000706/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000707///
708/// \headerfile <x86intrin.h>
709///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000710/// This intrinsic corresponds to the <c> VCMPLTSD / CMPLTSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000711///
712/// \param __a
713/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000714/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000715/// \param __b
716/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000717/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000718/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000719/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000720static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000721_mm_cmplt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000722{
Craig Topper1aa231e2016-05-16 06:38:42 +0000723 return (__m128d)__builtin_ia32_cmpltsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000724}
725
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000726/// \brief Compares the lower double-precision floating-point values in each of
727/// the two 128-bit floating-point vectors of [2 x double] to determine if
728/// the value in the first parameter is less than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000729/// corresponding value in the second parameter.
730///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000731/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000732///
733/// \headerfile <x86intrin.h>
734///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000735/// This intrinsic corresponds to the <c> VCMPLESD / CMPLESD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000736///
737/// \param __a
738/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000739/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000740/// \param __b
741/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000742/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000743/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000744/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000745static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000746_mm_cmple_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000747{
Craig Topper1aa231e2016-05-16 06:38:42 +0000748 return (__m128d)__builtin_ia32_cmplesd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000749}
750
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +0000751/// \brief Compares the lower double-precision floating-point values in each of
752/// the two 128-bit floating-point vectors of [2 x double] to determine if
753/// the value in the first parameter is greater than the corresponding value
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000754/// in the second parameter.
755///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000756/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000757///
758/// \headerfile <x86intrin.h>
759///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000760/// This intrinsic corresponds to the <c> VCMPLTSD / CMPLTSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000761///
762/// \param __a
763/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000764/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000765/// \param __b
766/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000767/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000768/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000769/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000770static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000771_mm_cmpgt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000772{
Craig Topper1aa231e2016-05-16 06:38:42 +0000773 __m128d __c = __builtin_ia32_cmpltsd((__v2df)__b, (__v2df)__a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000774 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000775}
776
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000777/// \brief Compares the lower double-precision floating-point values in each of
778/// the two 128-bit floating-point vectors of [2 x double] to determine if
779/// the value in the first parameter is greater than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000780/// corresponding value in the second parameter.
781///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000782/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000783///
784/// \headerfile <x86intrin.h>
785///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000786/// This intrinsic corresponds to the <c> VCMPLESD / CMPLESD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000787///
788/// \param __a
789/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000790/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000791/// \param __b
792/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000793/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000794/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000795/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000796static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000797_mm_cmpge_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000798{
Craig Topper1aa231e2016-05-16 06:38:42 +0000799 __m128d __c = __builtin_ia32_cmplesd((__v2df)__b, (__v2df)__a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000800 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000801}
802
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +0000803/// \brief Compares the lower double-precision floating-point values in each of
804/// the two 128-bit floating-point vectors of [2 x double] to determine if
805/// the value in the first parameter is "ordered" with respect to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000806/// corresponding value in the second parameter.
807///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000808/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. A pair
809/// of double-precision values are "ordered" with respect to each other if
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000810/// neither value is a NaN.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000811///
812/// \headerfile <x86intrin.h>
813///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000814/// This intrinsic corresponds to the <c> VCMPORDSD / CMPORDSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000815///
816/// \param __a
817/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000818/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000819/// \param __b
820/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000821/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000822/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000823/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000824static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000825_mm_cmpord_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000826{
Craig Topper1aa231e2016-05-16 06:38:42 +0000827 return (__m128d)__builtin_ia32_cmpordsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000828}
829
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +0000830/// \brief Compares the lower double-precision floating-point values in each of
831/// the two 128-bit floating-point vectors of [2 x double] to determine if
832/// the value in the first parameter is "unordered" with respect to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000833/// corresponding value in the second parameter.
834///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000835/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. A pair
836/// of double-precision values are "unordered" with respect to each other if
837/// one or both values are NaN.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000838///
839/// \headerfile <x86intrin.h>
840///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +0000841/// This intrinsic corresponds to the <c> VCMPUNORDSD / CMPUNORDSD </c>
842/// instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000843///
844/// \param __a
845/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000846/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000847/// \param __b
848/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000849/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000850/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000851/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000852static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000853_mm_cmpunord_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000854{
Craig Topper1aa231e2016-05-16 06:38:42 +0000855 return (__m128d)__builtin_ia32_cmpunordsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000856}
857
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000858/// \brief Compares the lower double-precision floating-point values in each of
859/// the two 128-bit floating-point vectors of [2 x double] to determine if
860/// the value in the first parameter is unequal to the corresponding value in
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000861/// the second parameter.
862///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000863/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000864///
865/// \headerfile <x86intrin.h>
866///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000867/// This intrinsic corresponds to the <c> VCMPNEQSD / CMPNEQSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000868///
869/// \param __a
870/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000871/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000872/// \param __b
873/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000874/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000875/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000876/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000877static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000878_mm_cmpneq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000879{
Craig Topper1aa231e2016-05-16 06:38:42 +0000880 return (__m128d)__builtin_ia32_cmpneqsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000881}
882
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000883/// \brief Compares the lower double-precision floating-point values in each of
884/// the two 128-bit floating-point vectors of [2 x double] to determine if
885/// the value in the first parameter is not less than the corresponding
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000886/// value in the second parameter.
887///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000888/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000889///
890/// \headerfile <x86intrin.h>
891///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000892/// This intrinsic corresponds to the <c> VCMPNLTSD / CMPNLTSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000893///
894/// \param __a
895/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000896/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000897/// \param __b
898/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000899/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000900/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000901/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000902static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000903_mm_cmpnlt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000904{
Craig Topper1aa231e2016-05-16 06:38:42 +0000905 return (__m128d)__builtin_ia32_cmpnltsd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000906}
907
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000908/// \brief Compares the lower double-precision floating-point values in each of
909/// the two 128-bit floating-point vectors of [2 x double] to determine if
910/// the value in the first parameter is not less than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000911/// corresponding value in the second parameter.
912///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000913/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000914///
915/// \headerfile <x86intrin.h>
916///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000917/// This intrinsic corresponds to the <c> VCMPNLESD / CMPNLESD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000918///
919/// \param __a
920/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000921/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000922/// \param __b
923/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000924/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000925/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000926/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000927static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000928_mm_cmpnle_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000929{
Craig Topper1aa231e2016-05-16 06:38:42 +0000930 return (__m128d)__builtin_ia32_cmpnlesd((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000931}
932
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000933/// \brief Compares the lower double-precision floating-point values in each of
934/// the two 128-bit floating-point vectors of [2 x double] to determine if
935/// the value in the first parameter is not greater than the corresponding
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000936/// value in the second parameter.
937///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000938/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000939///
940/// \headerfile <x86intrin.h>
941///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000942/// This intrinsic corresponds to the <c> VCMPNLTSD / CMPNLTSD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000943///
944/// \param __a
945/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000946/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000947/// \param __b
948/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000949/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000950/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000951/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000952static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000953_mm_cmpngt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000954{
Craig Topper1aa231e2016-05-16 06:38:42 +0000955 __m128d __c = __builtin_ia32_cmpnltsd((__v2df)__b, (__v2df)__a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000956 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000957}
958
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000959/// \brief Compares the lower double-precision floating-point values in each of
960/// the two 128-bit floating-point vectors of [2 x double] to determine if
961/// the value in the first parameter is not greater than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +0000962/// corresponding value in the second parameter.
963///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +0000964/// The comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000965///
966/// \headerfile <x86intrin.h>
967///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000968/// This intrinsic corresponds to the <c> VCMPNLESD / CMPNLESD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000969///
970/// \param __a
971/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000972/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000973/// \param __b
974/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000975/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000976/// \returns A 128-bit vector. The lower 64 bits contains the comparison
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000977/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +0000978static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +0000979_mm_cmpnge_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000980{
Craig Topper1aa231e2016-05-16 06:38:42 +0000981 __m128d __c = __builtin_ia32_cmpnlesd((__v2df)__b, (__v2df)__a);
Manman Ren9bb34d62013-06-17 19:42:49 +0000982 return (__m128d) { __c[0], __a[1] };
Anders Carlssonf15e71d2008-12-24 01:45:22 +0000983}
984
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000985/// \brief Compares the lower double-precision floating-point values in each of
Douglas Yung0686df102018-01-02 20:39:29 +0000986/// the two 128-bit floating-point vectors of [2 x double] for equality.
987///
988/// The comparison yields 0 for false, 1 for true. If either of the two
989/// lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000990///
991/// \headerfile <x86intrin.h>
992///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +0000993/// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000994///
995/// \param __a
996/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +0000997/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +0000998/// \param __b
999/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001000/// compared to the lower double-precision value of \a __a.
Douglas Yung0686df102018-01-02 20:39:29 +00001001/// \returns An integer containing the comparison results. If either of the two
1002/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001003static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001004_mm_comieq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001005{
Craig Topper1aa231e2016-05-16 06:38:42 +00001006 return __builtin_ia32_comisdeq((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001007}
1008
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001009/// \brief Compares the lower double-precision floating-point values in each of
1010/// the two 128-bit floating-point vectors of [2 x double] to determine if
1011/// the value in the first parameter is less than the corresponding value in
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001012/// the second parameter.
1013///
Douglas Yung0686df102018-01-02 20:39:29 +00001014/// The comparison yields 0 for false, 1 for true. If either of the two
1015/// lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001016///
1017/// \headerfile <x86intrin.h>
1018///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001019/// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001020///
1021/// \param __a
1022/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001023/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001024/// \param __b
1025/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001026/// compared to the lower double-precision value of \a __a.
Douglas Yung0686df102018-01-02 20:39:29 +00001027/// \returns An integer containing the comparison results. If either of the two
1028/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001029static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001030_mm_comilt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001031{
Craig Topper1aa231e2016-05-16 06:38:42 +00001032 return __builtin_ia32_comisdlt((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001033}
1034
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001035/// \brief Compares the lower double-precision floating-point values in each of
1036/// the two 128-bit floating-point vectors of [2 x double] to determine if
1037/// the value in the first parameter is less than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001038/// corresponding value in the second parameter.
1039///
Douglas Yung0686df102018-01-02 20:39:29 +00001040/// The comparison yields 0 for false, 1 for true. If either of the two
1041/// lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001042///
1043/// \headerfile <x86intrin.h>
1044///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001045/// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001046///
1047/// \param __a
1048/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001049/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001050/// \param __b
1051/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001052/// compared to the lower double-precision value of \a __a.
Douglas Yung0686df102018-01-02 20:39:29 +00001053/// \returns An integer containing the comparison results. If either of the two
1054/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001055static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001056_mm_comile_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001057{
Craig Topper1aa231e2016-05-16 06:38:42 +00001058 return __builtin_ia32_comisdle((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001059}
1060
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001061/// \brief Compares the lower double-precision floating-point values in each of
1062/// the two 128-bit floating-point vectors of [2 x double] to determine if
1063/// the value in the first parameter is greater than the corresponding value
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001064/// in the second parameter.
1065///
Douglas Yung0686df102018-01-02 20:39:29 +00001066/// The comparison yields 0 for false, 1 for true. If either of the two
1067/// lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001068///
1069/// \headerfile <x86intrin.h>
1070///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001071/// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001072///
1073/// \param __a
1074/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001075/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001076/// \param __b
1077/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001078/// compared to the lower double-precision value of \a __a.
Douglas Yung0686df102018-01-02 20:39:29 +00001079/// \returns An integer containing the comparison results. If either of the two
1080/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001081static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001082_mm_comigt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001083{
Craig Topper1aa231e2016-05-16 06:38:42 +00001084 return __builtin_ia32_comisdgt((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001085}
1086
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001087/// \brief Compares the lower double-precision floating-point values in each of
1088/// the two 128-bit floating-point vectors of [2 x double] to determine if
1089/// the value in the first parameter is greater than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001090/// corresponding value in the second parameter.
1091///
Douglas Yung0686df102018-01-02 20:39:29 +00001092/// The comparison yields 0 for false, 1 for true. If either of the two
1093/// lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001094///
1095/// \headerfile <x86intrin.h>
1096///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001097/// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001098///
1099/// \param __a
1100/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001101/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001102/// \param __b
1103/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001104/// compared to the lower double-precision value of \a __a.
Douglas Yung0686df102018-01-02 20:39:29 +00001105/// \returns An integer containing the comparison results. If either of the two
1106/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001107static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001108_mm_comige_sd(__m128d __a, __m128d __b)
Eli Friedman89c11332011-10-06 20:31:50 +00001109{
Craig Topper1aa231e2016-05-16 06:38:42 +00001110 return __builtin_ia32_comisdge((__v2df)__a, (__v2df)__b);
Eli Friedman89c11332011-10-06 20:31:50 +00001111}
1112
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001113/// \brief Compares the lower double-precision floating-point values in each of
1114/// the two 128-bit floating-point vectors of [2 x double] to determine if
1115/// the value in the first parameter is unequal to the corresponding value in
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001116/// the second parameter.
1117///
Douglas Yung0686df102018-01-02 20:39:29 +00001118/// The comparison yields 0 for false, 1 for true. If either of the two
1119/// lower double-precision values is NaN, 1 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001120///
1121/// \headerfile <x86intrin.h>
1122///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001123/// This intrinsic corresponds to the <c> VCOMISD / COMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001124///
1125/// \param __a
1126/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001127/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001128/// \param __b
1129/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001130/// compared to the lower double-precision value of \a __a.
Douglas Yung0686df102018-01-02 20:39:29 +00001131/// \returns An integer containing the comparison results. If either of the two
1132/// lower double-precision values is NaN, 1 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001133static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001134_mm_comineq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001135{
Craig Topper1aa231e2016-05-16 06:38:42 +00001136 return __builtin_ia32_comisdneq((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001137}
1138
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001139/// \brief Compares the lower double-precision floating-point values in each of
1140/// the two 128-bit floating-point vectors of [2 x double] for equality. The
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001141/// comparison yields 0 for false, 1 for true.
1142///
Douglas Yung0686df102018-01-02 20:39:29 +00001143/// If either of the two lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001144///
1145/// \headerfile <x86intrin.h>
1146///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001147/// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001148///
1149/// \param __a
1150/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001151/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001152/// \param __b
1153/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001154/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001155/// \returns An integer containing the comparison results. If either of the two
Douglas Yung0686df102018-01-02 20:39:29 +00001156/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001157static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001158_mm_ucomieq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001159{
Craig Topper1aa231e2016-05-16 06:38:42 +00001160 return __builtin_ia32_ucomisdeq((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001161}
1162
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001163/// \brief Compares the lower double-precision floating-point values in each of
1164/// the two 128-bit floating-point vectors of [2 x double] to determine if
1165/// the value in the first parameter is less than the corresponding value in
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001166/// the second parameter.
1167///
1168/// The comparison yields 0 for false, 1 for true. If either of the two lower
Douglas Yung0686df102018-01-02 20:39:29 +00001169/// double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001170///
1171/// \headerfile <x86intrin.h>
1172///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001173/// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001174///
1175/// \param __a
1176/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001177/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001178/// \param __b
1179/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001180/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001181/// \returns An integer containing the comparison results. If either of the two
Douglas Yung0686df102018-01-02 20:39:29 +00001182/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001183static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001184_mm_ucomilt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001185{
Craig Topper1aa231e2016-05-16 06:38:42 +00001186 return __builtin_ia32_ucomisdlt((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001187}
1188
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001189/// \brief Compares the lower double-precision floating-point values in each of
1190/// the two 128-bit floating-point vectors of [2 x double] to determine if
1191/// the value in the first parameter is less than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001192/// corresponding value in the second parameter.
1193///
1194/// The comparison yields 0 for false, 1 for true. If either of the two lower
Douglas Yung0686df102018-01-02 20:39:29 +00001195/// double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001196///
1197/// \headerfile <x86intrin.h>
1198///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001199/// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001200///
1201/// \param __a
1202/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001203/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001204/// \param __b
1205/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001206/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001207/// \returns An integer containing the comparison results. If either of the two
Douglas Yung0686df102018-01-02 20:39:29 +00001208/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001209static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001210_mm_ucomile_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001211{
Craig Topper1aa231e2016-05-16 06:38:42 +00001212 return __builtin_ia32_ucomisdle((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001213}
1214
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001215/// \brief Compares the lower double-precision floating-point values in each of
1216/// the two 128-bit floating-point vectors of [2 x double] to determine if
1217/// the value in the first parameter is greater than the corresponding value
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001218/// in the second parameter.
1219///
1220/// The comparison yields 0 for false, 1 for true. If either of the two lower
1221/// double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001222///
1223/// \headerfile <x86intrin.h>
1224///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001225/// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001226///
1227/// \param __a
1228/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001229/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001230/// \param __b
1231/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001232/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001233/// \returns An integer containing the comparison results. If either of the two
1234/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001235static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001236_mm_ucomigt_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001237{
Craig Topper1aa231e2016-05-16 06:38:42 +00001238 return __builtin_ia32_ucomisdgt((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001239}
1240
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001241/// \brief Compares the lower double-precision floating-point values in each of
1242/// the two 128-bit floating-point vectors of [2 x double] to determine if
1243/// the value in the first parameter is greater than or equal to the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001244/// corresponding value in the second parameter.
1245///
1246/// The comparison yields 0 for false, 1 for true. If either of the two
1247/// lower double-precision values is NaN, 0 is returned.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001248///
1249/// \headerfile <x86intrin.h>
1250///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001251/// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001252///
1253/// \param __a
1254/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001255/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001256/// \param __b
1257/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001258/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova493091f2016-10-20 17:59:15 +00001259/// \returns An integer containing the comparison results. If either of the two
1260/// lower double-precision values is NaN, 0 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001261static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001262_mm_ucomige_sd(__m128d __a, __m128d __b)
Eli Friedmanf8cb4802011-08-29 21:26:24 +00001263{
Craig Topper1aa231e2016-05-16 06:38:42 +00001264 return __builtin_ia32_ucomisdge((__v2df)__a, (__v2df)__b);
Eli Friedmanf8cb4802011-08-29 21:26:24 +00001265}
1266
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001267/// \brief Compares the lower double-precision floating-point values in each of
1268/// the two 128-bit floating-point vectors of [2 x double] to determine if
1269/// the value in the first parameter is unequal to the corresponding value in
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001270/// the second parameter.
1271///
1272/// The comparison yields 0 for false, 1 for true. If either of the two lower
Douglas Yung0686df102018-01-02 20:39:29 +00001273/// double-precision values is NaN, 1 is returned.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001274///
1275/// \headerfile <x86intrin.h>
1276///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001277/// This intrinsic corresponds to the <c> VUCOMISD / UCOMISD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001278///
1279/// \param __a
1280/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001281/// compared to the lower double-precision value of \a __b.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001282/// \param __b
1283/// A 128-bit vector of [2 x double]. The lower double-precision value is
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001284/// compared to the lower double-precision value of \a __a.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001285/// \returns An integer containing the comparison result. If either of the two
Douglas Yung0686df102018-01-02 20:39:29 +00001286/// lower double-precision values is NaN, 1 is returned.
Michael Kupersteine45af542015-06-30 13:36:19 +00001287static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001288_mm_ucomineq_sd(__m128d __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001289{
Craig Topper1aa231e2016-05-16 06:38:42 +00001290 return __builtin_ia32_ucomisdneq((__v2df)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001291}
1292
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001293/// \brief Converts the two double-precision floating-point elements of a
1294/// 128-bit vector of [2 x double] into two single-precision floating-point
1295/// values, returned in the lower 64 bits of a 128-bit vector of [4 x float].
1296/// The upper 64 bits of the result vector are set to zero.
1297///
1298/// \headerfile <x86intrin.h>
1299///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001300/// This intrinsic corresponds to the <c> VCVTPD2PS / CVTPD2PS </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001301///
1302/// \param __a
1303/// A 128-bit vector of [2 x double].
1304/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the
1305/// converted values. The upper 64 bits are set to zero.
Michael Kupersteine45af542015-06-30 13:36:19 +00001306static __inline__ __m128 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001307_mm_cvtpd_ps(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001308{
Craig Topper1aa231e2016-05-16 06:38:42 +00001309 return __builtin_ia32_cvtpd2ps((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001310}
1311
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001312/// \brief Converts the lower two single-precision floating-point elements of a
1313/// 128-bit vector of [4 x float] into two double-precision floating-point
1314/// values, returned in a 128-bit vector of [2 x double]. The upper two
1315/// elements of the input vector are unused.
1316///
1317/// \headerfile <x86intrin.h>
1318///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001319/// This intrinsic corresponds to the <c> VCVTPS2PD / CVTPS2PD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001320///
1321/// \param __a
1322/// A 128-bit vector of [4 x float]. The lower two single-precision
1323/// floating-point elements are converted to double-precision values. The
1324/// upper two elements are unused.
1325/// \returns A 128-bit vector of [2 x double] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001326static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001327_mm_cvtps_pd(__m128 __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001328{
Simon Pilgrim90770c72016-05-23 22:13:02 +00001329 return (__m128d) __builtin_convertvector(
1330 __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1), __v2df);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001331}
1332
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001333/// \brief Converts the lower two integer elements of a 128-bit vector of
1334/// [4 x i32] into two double-precision floating-point values, returned in a
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001335/// 128-bit vector of [2 x double].
1336///
1337/// The upper two elements of the input vector are unused.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001338///
1339/// \headerfile <x86intrin.h>
1340///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001341/// This intrinsic corresponds to the <c> VCVTDQ2PD / CVTDQ2PD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001342///
1343/// \param __a
1344/// A 128-bit integer vector of [4 x i32]. The lower two integer elements are
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001345/// converted to double-precision values.
1346///
1347/// The upper two elements are unused.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001348/// \returns A 128-bit vector of [2 x double] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001349static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001350_mm_cvtepi32_pd(__m128i __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001351{
Simon Pilgrim90770c72016-05-23 22:13:02 +00001352 return (__m128d) __builtin_convertvector(
1353 __builtin_shufflevector((__v4si)__a, (__v4si)__a, 0, 1), __v2df);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001354}
1355
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001356/// \brief Converts the two double-precision floating-point elements of a
1357/// 128-bit vector of [2 x double] into two signed 32-bit integer values,
1358/// returned in the lower 64 bits of a 128-bit vector of [4 x i32]. The upper
1359/// 64 bits of the result vector are set to zero.
1360///
1361/// \headerfile <x86intrin.h>
1362///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001363/// This intrinsic corresponds to the <c> VCVTPD2DQ / CVTPD2DQ </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001364///
1365/// \param __a
1366/// A 128-bit vector of [2 x double].
1367/// \returns A 128-bit vector of [4 x i32] whose lower 64 bits contain the
1368/// converted values. The upper 64 bits are set to zero.
Michael Kupersteine45af542015-06-30 13:36:19 +00001369static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001370_mm_cvtpd_epi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001371{
Craig Topper1aa231e2016-05-16 06:38:42 +00001372 return __builtin_ia32_cvtpd2dq((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001373}
1374
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001375/// \brief Converts the low-order element of a 128-bit vector of [2 x double]
1376/// into a 32-bit signed integer value.
1377///
1378/// \headerfile <x86intrin.h>
1379///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001380/// This intrinsic corresponds to the <c> VCVTSD2SI / CVTSD2SI </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001381///
1382/// \param __a
1383/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the
1384/// conversion.
1385/// \returns A 32-bit signed integer containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001386static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001387_mm_cvtsd_si32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001388{
Craig Topper1aa231e2016-05-16 06:38:42 +00001389 return __builtin_ia32_cvtsd2si((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001390}
1391
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001392/// \brief Converts the lower double-precision floating-point element of a
1393/// 128-bit vector of [2 x double], in the second parameter, into a
1394/// single-precision floating-point value, returned in the lower 32 bits of a
1395/// 128-bit vector of [4 x float]. The upper 96 bits of the result vector are
1396/// copied from the upper 96 bits of the first parameter.
1397///
1398/// \headerfile <x86intrin.h>
1399///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001400/// This intrinsic corresponds to the <c> VCVTSD2SS / CVTSD2SS </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001401///
1402/// \param __a
1403/// A 128-bit vector of [4 x float]. The upper 96 bits of this parameter are
1404/// copied to the upper 96 bits of the result.
1405/// \param __b
1406/// A 128-bit vector of [2 x double]. The lower double-precision
1407/// floating-point element is used in the conversion.
1408/// \returns A 128-bit vector of [4 x float]. The lower 32 bits contain the
1409/// converted value from the second parameter. The upper 96 bits are copied
1410/// from the upper 96 bits of the first parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00001411static __inline__ __m128 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001412_mm_cvtsd_ss(__m128 __a, __m128d __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001413{
Simon Pilgrime3b9ee02016-07-20 10:18:01 +00001414 return (__m128)__builtin_ia32_cvtsd2ss((__v4sf)__a, (__v2df)__b);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001415}
1416
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001417/// \brief Converts a 32-bit signed integer value, in the second parameter, into
1418/// a double-precision floating-point value, returned in the lower 64 bits of
1419/// a 128-bit vector of [2 x double]. The upper 64 bits of the result vector
1420/// are copied from the upper 64 bits of the first parameter.
1421///
1422/// \headerfile <x86intrin.h>
1423///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001424/// This intrinsic corresponds to the <c> VCVTSI2SD / CVTSI2SD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001425///
1426/// \param __a
1427/// A 128-bit vector of [2 x double]. The upper 64 bits of this parameter are
1428/// copied to the upper 64 bits of the result.
1429/// \param __b
1430/// A 32-bit signed integer containing the value to be converted.
1431/// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the
1432/// converted value from the second parameter. The upper 64 bits are copied
1433/// from the upper 64 bits of the first parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00001434static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001435_mm_cvtsi32_sd(__m128d __a, int __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001436{
David Blaikie3302f2b2013-01-16 23:08:36 +00001437 __a[0] = __b;
1438 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001439}
1440
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001441/// \brief Converts the lower single-precision floating-point element of a
1442/// 128-bit vector of [4 x float], in the second parameter, into a
1443/// double-precision floating-point value, returned in the lower 64 bits of
1444/// a 128-bit vector of [2 x double]. The upper 64 bits of the result vector
1445/// are copied from the upper 64 bits of the first parameter.
1446///
1447/// \headerfile <x86intrin.h>
1448///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001449/// This intrinsic corresponds to the <c> VCVTSS2SD / CVTSS2SD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001450///
1451/// \param __a
1452/// A 128-bit vector of [2 x double]. The upper 64 bits of this parameter are
1453/// copied to the upper 64 bits of the result.
1454/// \param __b
1455/// A 128-bit vector of [4 x float]. The lower single-precision
1456/// floating-point element is used in the conversion.
1457/// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the
1458/// converted value from the second parameter. The upper 64 bits are copied
1459/// from the upper 64 bits of the first parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00001460static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001461_mm_cvtss_sd(__m128d __a, __m128 __b)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001462{
David Blaikie3302f2b2013-01-16 23:08:36 +00001463 __a[0] = __b[0];
1464 return __a;
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001465}
1466
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001467/// \brief Converts the two double-precision floating-point elements of a
1468/// 128-bit vector of [2 x double] into two signed 32-bit integer values,
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001469/// returned in the lower 64 bits of a 128-bit vector of [4 x i32].
1470///
1471/// If the result of either conversion is inexact, the result is truncated
1472/// (rounded towards zero) regardless of the current MXCSR setting. The upper
1473/// 64 bits of the result vector are set to zero.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001474///
1475/// \headerfile <x86intrin.h>
1476///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00001477/// This intrinsic corresponds to the <c> VCVTTPD2DQ / CVTTPD2DQ </c>
1478/// instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001479///
1480/// \param __a
1481/// A 128-bit vector of [2 x double].
1482/// \returns A 128-bit vector of [4 x i32] whose lower 64 bits contain the
1483/// converted values. The upper 64 bits are set to zero.
Michael Kupersteine45af542015-06-30 13:36:19 +00001484static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001485_mm_cvttpd_epi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001486{
Craig Topper1aa231e2016-05-16 06:38:42 +00001487 return (__m128i)__builtin_ia32_cvttpd2dq((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001488}
1489
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001490/// \brief Converts the low-order element of a [2 x double] vector into a 32-bit
1491/// signed integer value, truncating the result when it is inexact.
1492///
1493/// \headerfile <x86intrin.h>
1494///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00001495/// This intrinsic corresponds to the <c> VCVTTSD2SI / CVTTSD2SI </c>
1496/// instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001497///
1498/// \param __a
1499/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the
1500/// conversion.
1501/// \returns A 32-bit signed integer containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001502static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001503_mm_cvttsd_si32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001504{
Simon Pilgrime3b9ee02016-07-20 10:18:01 +00001505 return __builtin_ia32_cvttsd2si((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001506}
1507
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001508/// \brief Converts the two double-precision floating-point elements of a
1509/// 128-bit vector of [2 x double] into two signed 32-bit integer values,
1510/// returned in a 64-bit vector of [2 x i32].
1511///
1512/// \headerfile <x86intrin.h>
1513///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001514/// This intrinsic corresponds to the <c> CVTPD2PI </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001515///
1516/// \param __a
1517/// A 128-bit vector of [2 x double].
1518/// \returns A 64-bit vector of [2 x i32] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001519static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001520_mm_cvtpd_pi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001521{
Craig Topper1aa231e2016-05-16 06:38:42 +00001522 return (__m64)__builtin_ia32_cvtpd2pi((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001523}
1524
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001525/// \brief Converts the two double-precision floating-point elements of a
1526/// 128-bit vector of [2 x double] into two signed 32-bit integer values,
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00001527/// returned in a 64-bit vector of [2 x i32].
1528///
1529/// If the result of either conversion is inexact, the result is truncated
1530/// (rounded towards zero) regardless of the current MXCSR setting.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001531///
1532/// \headerfile <x86intrin.h>
1533///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001534/// This intrinsic corresponds to the <c> CVTTPD2PI </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001535///
1536/// \param __a
1537/// A 128-bit vector of [2 x double].
1538/// \returns A 64-bit vector of [2 x i32] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001539static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001540_mm_cvttpd_pi32(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001541{
Craig Topper1aa231e2016-05-16 06:38:42 +00001542 return (__m64)__builtin_ia32_cvttpd2pi((__v2df)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001543}
1544
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001545/// \brief Converts the two signed 32-bit integer elements of a 64-bit vector of
1546/// [2 x i32] into two double-precision floating-point values, returned in a
1547/// 128-bit vector of [2 x double].
1548///
1549/// \headerfile <x86intrin.h>
1550///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001551/// This intrinsic corresponds to the <c> CVTPI2PD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001552///
1553/// \param __a
1554/// A 64-bit vector of [2 x i32].
1555/// \returns A 128-bit vector of [2 x double] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001556static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001557_mm_cvtpi32_pd(__m64 __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001558{
David Blaikie3302f2b2013-01-16 23:08:36 +00001559 return __builtin_ia32_cvtpi2pd((__v2si)__a);
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001560}
1561
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001562/// \brief Returns the low-order element of a 128-bit vector of [2 x double] as
1563/// a double-precision floating-point value.
1564///
1565/// \headerfile <x86intrin.h>
1566///
1567/// This intrinsic has no corresponding instruction.
1568///
1569/// \param __a
1570/// A 128-bit vector of [2 x double]. The lower 64 bits are returned.
1571/// \returns A double-precision floating-point value copied from the lower 64
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00001572/// bits of \a __a.
Michael Kupersteine45af542015-06-30 13:36:19 +00001573static __inline__ double __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001574_mm_cvtsd_f64(__m128d __a)
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001575{
David Blaikie3302f2b2013-01-16 23:08:36 +00001576 return __a[0];
Anders Carlssonf15e71d2008-12-24 01:45:22 +00001577}
1578
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001579/// \brief Loads a 128-bit floating-point vector of [2 x double] from an aligned
1580/// memory location.
1581///
1582/// \headerfile <x86intrin.h>
1583///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001584/// This intrinsic corresponds to the <c> VMOVAPD / MOVAPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001585///
1586/// \param __dp
1587/// A pointer to a 128-bit memory location. The address of the memory
1588/// location has to be 16-byte aligned.
1589/// \returns A 128-bit vector of [2 x double] containing the loaded values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001590static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001591_mm_load_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001592{
David Blaikie3302f2b2013-01-16 23:08:36 +00001593 return *(__m128d*)__dp;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001594}
1595
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001596/// \brief Loads a double-precision floating-point value from a specified memory
1597/// location and duplicates it to both vector elements of a 128-bit vector of
1598/// [2 x double].
1599///
1600/// \headerfile <x86intrin.h>
1601///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001602/// This intrinsic corresponds to the <c> VMOVDDUP / MOVDDUP </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001603///
1604/// \param __dp
1605/// A pointer to a memory location containing a double-precision value.
1606/// \returns A 128-bit vector of [2 x double] containing the loaded and
1607/// duplicated values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001608static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001609_mm_load1_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001610{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001611 struct __mm_load1_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00001612 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001613 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001614 double __u = ((struct __mm_load1_pd_struct*)__dp)->__u;
1615 return (__m128d){ __u, __u };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001616}
1617
Eli Friedmanf83c2582009-06-02 05:55:48 +00001618#define _mm_load_pd1(dp) _mm_load1_pd(dp)
1619
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001620/// \brief Loads two double-precision values, in reverse order, from an aligned
1621/// memory location into a 128-bit vector of [2 x double].
1622///
1623/// \headerfile <x86intrin.h>
1624///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00001625/// This intrinsic corresponds to the <c> VMOVAPD / MOVAPD </c> instruction +
1626/// needed shuffling instructions. In AVX mode, the shuffling may be combined
1627/// with the \c VMOVAPD, resulting in only a \c VPERMILPD instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001628///
1629/// \param __dp
1630/// A 16-byte aligned pointer to an array of double-precision values to be
1631/// loaded in reverse order.
1632/// \returns A 128-bit vector of [2 x double] containing the reversed loaded
1633/// values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001634static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001635_mm_loadr_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001636{
David Blaikie3302f2b2013-01-16 23:08:36 +00001637 __m128d __u = *(__m128d*)__dp;
Craig Topper1aa231e2016-05-16 06:38:42 +00001638 return __builtin_shufflevector((__v2df)__u, (__v2df)__u, 1, 0);
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001639}
1640
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001641/// \brief Loads a 128-bit floating-point vector of [2 x double] from an
1642/// unaligned memory location.
1643///
1644/// \headerfile <x86intrin.h>
1645///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001646/// This intrinsic corresponds to the <c> VMOVUPD / MOVUPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001647///
1648/// \param __dp
1649/// A pointer to a 128-bit memory location. The address of the memory
1650/// location does not have to be aligned.
1651/// \returns A 128-bit vector of [2 x double] containing the loaded values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001652static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001653_mm_loadu_pd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001654{
Bill Wendling502931f2011-05-13 00:11:39 +00001655 struct __loadu_pd {
David Blaikie3302f2b2013-01-16 23:08:36 +00001656 __m128d __v;
David Majnemer1cf22e62015-02-04 00:26:10 +00001657 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001658 return ((struct __loadu_pd*)__dp)->__v;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001659}
1660
Ekaterina Romanova2e041c92017-01-13 01:14:08 +00001661/// \brief Loads a 64-bit integer value to the low element of a 128-bit integer
1662/// vector and clears the upper element.
1663///
1664/// \headerfile <x86intrin.h>
1665///
1666/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
1667///
Ekaterina Romanovacb3603a2017-06-06 22:58:01 +00001668/// \param __a
Ekaterina Romanova2e041c92017-01-13 01:14:08 +00001669/// A pointer to a 64-bit memory location. The address of the memory
1670/// location does not have to be aligned.
1671/// \returns A 128-bit vector of [2 x i64] containing the loaded value.
Asaf Badouh57819aa2016-06-26 13:51:54 +00001672static __inline__ __m128i __DEFAULT_FN_ATTRS
1673_mm_loadu_si64(void const *__a)
1674{
1675 struct __loadu_si64 {
1676 long long __v;
1677 } __attribute__((__packed__, __may_alias__));
1678 long long __u = ((struct __loadu_si64*)__a)->__v;
1679 return (__m128i){__u, 0L};
1680}
1681
Ekaterina Romanova2e041c92017-01-13 01:14:08 +00001682/// \brief Loads a 64-bit double-precision value to the low element of a
1683/// 128-bit integer vector and clears the upper element.
1684///
1685/// \headerfile <x86intrin.h>
1686///
1687/// This intrinsic corresponds to the <c> VMOVSD / MOVSD </c> instruction.
1688///
1689/// \param __dp
Ekaterina Romanovacb3603a2017-06-06 22:58:01 +00001690/// A pointer to a memory location containing a double-precision value.
Ekaterina Romanova2e041c92017-01-13 01:14:08 +00001691/// The address of the memory location does not have to be aligned.
1692/// \returns A 128-bit vector of [2 x double] containing the loaded value.
Michael Kupersteine45af542015-06-30 13:36:19 +00001693static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001694_mm_load_sd(double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001695{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001696 struct __mm_load_sd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00001697 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001698 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001699 double __u = ((struct __mm_load_sd_struct*)__dp)->__u;
1700 return (__m128d){ __u, 0 };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001701}
1702
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001703/// \brief Loads a double-precision value into the high-order bits of a 128-bit
1704/// vector of [2 x double]. The low-order bits are copied from the low-order
1705/// bits of the first operand.
1706///
1707/// \headerfile <x86intrin.h>
1708///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001709/// This intrinsic corresponds to the <c> VMOVHPD / MOVHPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001710///
1711/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00001712/// A 128-bit vector of [2 x double]. \n
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001713/// Bits [63:0] are written to bits [63:0] of the result.
1714/// \param __dp
1715/// A pointer to a 64-bit memory location containing a double-precision
1716/// floating-point value that is loaded. The loaded value is written to bits
1717/// [127:64] of the result. The address of the memory location does not have
1718/// to be aligned.
1719/// \returns A 128-bit vector of [2 x double] containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001720static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001721_mm_loadh_pd(__m128d __a, double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001722{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001723 struct __mm_loadh_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00001724 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001725 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001726 double __u = ((struct __mm_loadh_pd_struct*)__dp)->__u;
1727 return (__m128d){ __a[0], __u };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001728}
1729
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001730/// \brief Loads a double-precision value into the low-order bits of a 128-bit
1731/// vector of [2 x double]. The high-order bits are copied from the
1732/// high-order bits of the first operand.
1733///
1734/// \headerfile <x86intrin.h>
1735///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001736/// This intrinsic corresponds to the <c> VMOVLPD / MOVLPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001737///
1738/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00001739/// A 128-bit vector of [2 x double]. \n
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001740/// Bits [127:64] are written to bits [127:64] of the result.
1741/// \param __dp
1742/// A pointer to a 64-bit memory location containing a double-precision
1743/// floating-point value that is loaded. The loaded value is written to bits
1744/// [63:0] of the result. The address of the memory location does not have to
1745/// be aligned.
1746/// \returns A 128-bit vector of [2 x double] containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001747static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001748_mm_loadl_pd(__m128d __a, double const *__dp)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001749{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001750 struct __mm_loadl_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00001751 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001752 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001753 double __u = ((struct __mm_loadl_pd_struct*)__dp)->__u;
1754 return (__m128d){ __u, __a[1] };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001755}
1756
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001757/// \brief Constructs a 128-bit floating-point vector of [2 x double] with
1758/// unspecified content. This could be used as an argument to another
1759/// intrinsic function where the argument is required but the value is not
1760/// actually used.
1761///
1762/// \headerfile <x86intrin.h>
1763///
1764/// This intrinsic has no corresponding instruction.
1765///
1766/// \returns A 128-bit floating-point vector of [2 x double] with unspecified
1767/// content.
Michael Kupersteine45af542015-06-30 13:36:19 +00001768static __inline__ __m128d __DEFAULT_FN_ATTRS
Craig Topper3a0c7262016-06-09 05:14:28 +00001769_mm_undefined_pd(void)
Simon Pilgrim5aba9922015-08-26 21:17:12 +00001770{
1771 return (__m128d)__builtin_ia32_undef128();
1772}
1773
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001774/// \brief Constructs a 128-bit floating-point vector of [2 x double]. The lower
1775/// 64 bits of the vector are initialized with the specified double-precision
1776/// floating-point value. The upper 64 bits are set to zero.
1777///
1778/// \headerfile <x86intrin.h>
1779///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001780/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001781///
1782/// \param __w
1783/// A double-precision floating-point value used to initialize the lower 64
1784/// bits of the result.
1785/// \returns An initialized 128-bit floating-point vector of [2 x double]. The
1786/// lower 64 bits contain the value of the parameter. The upper 64 bits are
1787/// set to zero.
Simon Pilgrim5aba9922015-08-26 21:17:12 +00001788static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001789_mm_set_sd(double __w)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001790{
David Blaikie3302f2b2013-01-16 23:08:36 +00001791 return (__m128d){ __w, 0 };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001792}
1793
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001794/// \brief Constructs a 128-bit floating-point vector of [2 x double], with each
1795/// of the two double-precision floating-point vector elements set to the
1796/// specified double-precision floating-point value.
1797///
1798/// \headerfile <x86intrin.h>
1799///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001800/// This intrinsic corresponds to the <c> VMOVDDUP / MOVLHPS </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001801///
1802/// \param __w
1803/// A double-precision floating-point value used to initialize each vector
1804/// element of the result.
1805/// \returns An initialized 128-bit floating-point vector of [2 x double].
Michael Kupersteine45af542015-06-30 13:36:19 +00001806static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001807_mm_set1_pd(double __w)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001808{
David Blaikie3302f2b2013-01-16 23:08:36 +00001809 return (__m128d){ __w, __w };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001810}
1811
Simon Pilgrim99ed2702017-04-28 10:28:32 +00001812/// \brief Constructs a 128-bit floating-point vector of [2 x double], with each
1813/// of the two double-precision floating-point vector elements set to the
1814/// specified double-precision floating-point value.
1815///
1816/// \headerfile <x86intrin.h>
1817///
1818/// This intrinsic corresponds to the <c> VMOVDDUP / MOVLHPS </c> instruction.
1819///
1820/// \param __w
1821/// A double-precision floating-point value used to initialize each vector
1822/// element of the result.
1823/// \returns An initialized 128-bit floating-point vector of [2 x double].
1824static __inline__ __m128d __DEFAULT_FN_ATTRS
1825_mm_set_pd1(double __w)
1826{
1827 return _mm_set1_pd(__w);
1828}
1829
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001830/// \brief Constructs a 128-bit floating-point vector of [2 x double]
1831/// initialized with the specified double-precision floating-point values.
1832///
1833/// \headerfile <x86intrin.h>
1834///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001835/// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001836///
1837/// \param __w
1838/// A double-precision floating-point value used to initialize the upper 64
1839/// bits of the result.
1840/// \param __x
1841/// A double-precision floating-point value used to initialize the lower 64
1842/// bits of the result.
1843/// \returns An initialized 128-bit floating-point vector of [2 x double].
Michael Kupersteine45af542015-06-30 13:36:19 +00001844static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001845_mm_set_pd(double __w, double __x)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001846{
David Blaikie3302f2b2013-01-16 23:08:36 +00001847 return (__m128d){ __x, __w };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001848}
1849
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001850/// \brief Constructs a 128-bit floating-point vector of [2 x double],
1851/// initialized in reverse order with the specified double-precision
1852/// floating-point values.
1853///
1854/// \headerfile <x86intrin.h>
1855///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001856/// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001857///
1858/// \param __w
1859/// A double-precision floating-point value used to initialize the lower 64
1860/// bits of the result.
1861/// \param __x
1862/// A double-precision floating-point value used to initialize the upper 64
1863/// bits of the result.
1864/// \returns An initialized 128-bit floating-point vector of [2 x double].
Michael Kupersteine45af542015-06-30 13:36:19 +00001865static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001866_mm_setr_pd(double __w, double __x)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001867{
David Blaikie3302f2b2013-01-16 23:08:36 +00001868 return (__m128d){ __w, __x };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001869}
1870
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001871/// \brief Constructs a 128-bit floating-point vector of [2 x double]
1872/// initialized to zero.
1873///
1874/// \headerfile <x86intrin.h>
1875///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001876/// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001877///
1878/// \returns An initialized 128-bit floating-point vector of [2 x double] with
1879/// all elements set to zero.
Michael Kupersteine45af542015-06-30 13:36:19 +00001880static __inline__ __m128d __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +00001881_mm_setzero_pd(void)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001882{
1883 return (__m128d){ 0, 0 };
1884}
1885
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001886/// \brief Constructs a 128-bit floating-point vector of [2 x double]. The lower
1887/// 64 bits are set to the lower 64 bits of the second parameter. The upper
1888/// 64 bits are set to the upper 64 bits of the first parameter.
Ekaterina Romanova6a5702a2017-03-21 13:34:06 +00001889///
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001890/// \headerfile <x86intrin.h>
1891///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001892/// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001893///
1894/// \param __a
1895/// A 128-bit vector of [2 x double]. The upper 64 bits are written to the
1896/// upper 64 bits of the result.
1897/// \param __b
1898/// A 128-bit vector of [2 x double]. The lower 64 bits are written to the
1899/// lower 64 bits of the result.
1900/// \returns A 128-bit vector of [2 x double] containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00001901static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001902_mm_move_sd(__m128d __a, __m128d __b)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001903{
David Blaikie3302f2b2013-01-16 23:08:36 +00001904 return (__m128d){ __b[0], __a[1] };
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001905}
1906
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001907/// \brief Stores the lower 64 bits of a 128-bit vector of [2 x double] to a
1908/// memory location.
1909///
1910/// \headerfile <x86intrin.h>
1911///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001912/// This intrinsic corresponds to the <c> VMOVSD / MOVSD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001913///
1914/// \param __dp
1915/// A pointer to a 64-bit memory location.
1916/// \param __a
1917/// A 128-bit vector of [2 x double] containing the value to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00001918static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00001919_mm_store_sd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001920{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001921 struct __mm_store_sd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00001922 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00001923 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00001924 ((struct __mm_store_sd_struct*)__dp)->__u = __a[0];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001925}
1926
Ekaterina Romanovacb3603a2017-06-06 22:58:01 +00001927/// \brief Moves packed double-precision values from a 128-bit vector of
1928/// [2 x double] to a memory location.
1929///
1930/// \headerfile <x86intrin.h>
1931///
1932/// This intrinsic corresponds to the <c>VMOVAPD / MOVAPS</c> instruction.
1933///
1934/// \param __dp
1935/// A pointer to an aligned memory location that can store two
1936/// double-precision values.
1937/// \param __a
1938/// A packed 128-bit vector of [2 x double] containing the values to be
1939/// moved.
Michael Kupersteine45af542015-06-30 13:36:19 +00001940static __inline__ void __DEFAULT_FN_ATTRS
Simon Pilgrim645e1ad2016-05-30 17:55:25 +00001941_mm_store_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001942{
Simon Pilgrim645e1ad2016-05-30 17:55:25 +00001943 *(__m128d*)__dp = __a;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001944}
1945
Ekaterina Romanovacb3603a2017-06-06 22:58:01 +00001946/// \brief Moves the lower 64 bits of a 128-bit vector of [2 x double] twice to
1947/// the upper and lower 64 bits of a memory location.
1948///
1949/// \headerfile <x86intrin.h>
1950///
Douglas Yung0686df102018-01-02 20:39:29 +00001951/// This intrinsic corresponds to the
1952/// <c> VMOVDDUP + VMOVAPD / MOVLHPS + MOVAPS </c> instruction.
Ekaterina Romanovacb3603a2017-06-06 22:58:01 +00001953///
1954/// \param __dp
1955/// A pointer to a memory location that can store two double-precision
1956/// values.
1957/// \param __a
1958/// A 128-bit vector of [2 x double] whose lower 64 bits are copied to each
Douglas Yung0686df102018-01-02 20:39:29 +00001959/// of the values in \a __dp.
Michael Kupersteine45af542015-06-30 13:36:19 +00001960static __inline__ void __DEFAULT_FN_ATTRS
Simon Pilgrim645e1ad2016-05-30 17:55:25 +00001961_mm_store1_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001962{
Simon Pilgrim645e1ad2016-05-30 17:55:25 +00001963 __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
1964 _mm_store_pd(__dp, __a);
1965}
1966
Douglas Yung0686df102018-01-02 20:39:29 +00001967/// \brief Moves the lower 64 bits of a 128-bit vector of [2 x double] twice to
1968/// the upper and lower 64 bits of a memory location.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001969///
1970/// \headerfile <x86intrin.h>
1971///
Douglas Yung0686df102018-01-02 20:39:29 +00001972/// This intrinsic corresponds to the
1973/// <c> VMOVDDUP + VMOVAPD / MOVLHPS + MOVAPS </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001974///
1975/// \param __dp
Douglas Yung0686df102018-01-02 20:39:29 +00001976/// A pointer to a memory location that can store two double-precision
1977/// values.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001978/// \param __a
Douglas Yung0686df102018-01-02 20:39:29 +00001979/// A 128-bit vector of [2 x double] whose lower 64 bits are copied to each
1980/// of the values in \a __dp.
Simon Pilgrim645e1ad2016-05-30 17:55:25 +00001981static __inline__ void __DEFAULT_FN_ATTRS
1982_mm_store_pd1(double *__dp, __m128d __a)
1983{
1984 return _mm_store1_pd(__dp, __a);
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00001985}
1986
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001987/// \brief Stores a 128-bit vector of [2 x double] into an unaligned memory
1988/// location.
1989///
1990/// \headerfile <x86intrin.h>
1991///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00001992/// This intrinsic corresponds to the <c> VMOVUPD / MOVUPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00001993///
1994/// \param __dp
1995/// A pointer to a 128-bit memory location. The address of the memory
1996/// location does not have to be aligned.
1997/// \param __a
1998/// A 128-bit vector of [2 x double] containing the values to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00001999static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002000_mm_storeu_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002001{
Craig Topper09175da2016-05-30 17:10:30 +00002002 struct __storeu_pd {
2003 __m128d __v;
2004 } __attribute__((__packed__, __may_alias__));
2005 ((struct __storeu_pd*)__dp)->__v = __a;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002006}
2007
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002008/// \brief Stores two double-precision values, in reverse order, from a 128-bit
2009/// vector of [2 x double] to a 16-byte aligned memory location.
2010///
2011/// \headerfile <x86intrin.h>
2012///
2013/// This intrinsic corresponds to a shuffling instruction followed by a
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002014/// <c> VMOVAPD / MOVAPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002015///
2016/// \param __dp
2017/// A pointer to a 16-byte aligned memory location that can store two
2018/// double-precision values.
2019/// \param __a
2020/// A 128-bit vector of [2 x double] containing the values to be reversed and
2021/// stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00002022static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002023_mm_storer_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002024{
Craig Topper1aa231e2016-05-16 06:38:42 +00002025 __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 1, 0);
David Blaikie3302f2b2013-01-16 23:08:36 +00002026 *(__m128d *)__dp = __a;
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002027}
2028
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002029/// \brief Stores the upper 64 bits of a 128-bit vector of [2 x double] to a
2030/// memory location.
2031///
2032/// \headerfile <x86intrin.h>
2033///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002034/// This intrinsic corresponds to the <c> VMOVHPD / MOVHPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002035///
2036/// \param __dp
2037/// A pointer to a 64-bit memory location.
2038/// \param __a
2039/// A 128-bit vector of [2 x double] containing the value to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00002040static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002041_mm_storeh_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002042{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00002043 struct __mm_storeh_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00002044 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00002045 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00002046 ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[1];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002047}
2048
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002049/// \brief Stores the lower 64 bits of a 128-bit vector of [2 x double] to a
2050/// memory location.
2051///
2052/// \headerfile <x86intrin.h>
2053///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002054/// This intrinsic corresponds to the <c> VMOVLPD / MOVLPD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002055///
2056/// \param __dp
2057/// A pointer to a 64-bit memory location.
2058/// \param __a
2059/// A 128-bit vector of [2 x double] containing the value to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00002060static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002061_mm_storel_pd(double *__dp, __m128d __a)
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002062{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00002063 struct __mm_storeh_pd_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00002064 double __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00002065 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00002066 ((struct __mm_storeh_pd_struct*)__dp)->__u = __a[0];
Anders Carlssonb08ac0b2008-12-24 02:11:54 +00002067}
2068
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002069/// \brief Adds the corresponding elements of two 128-bit vectors of [16 x i8],
2070/// saving the lower 8 bits of each sum in the corresponding element of a
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00002071/// 128-bit result vector of [16 x i8].
2072///
2073/// The integer elements of both parameters can be either signed or unsigned.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002074///
2075/// \headerfile <x86intrin.h>
2076///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002077/// This intrinsic corresponds to the <c> VPADDB / PADDB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002078///
2079/// \param __a
2080/// A 128-bit vector of [16 x i8].
2081/// \param __b
2082/// A 128-bit vector of [16 x i8].
2083/// \returns A 128-bit vector of [16 x i8] containing the sums of both
2084/// parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002085static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002086_mm_add_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002087{
Craig Topper6a77b622016-06-04 05:43:41 +00002088 return (__m128i)((__v16qu)__a + (__v16qu)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002089}
2090
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002091/// \brief Adds the corresponding elements of two 128-bit vectors of [8 x i16],
2092/// saving the lower 16 bits of each sum in the corresponding element of a
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00002093/// 128-bit result vector of [8 x i16].
2094///
2095/// The integer elements of both parameters can be either signed or unsigned.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002096///
2097/// \headerfile <x86intrin.h>
2098///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002099/// This intrinsic corresponds to the <c> VPADDW / PADDW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002100///
2101/// \param __a
2102/// A 128-bit vector of [8 x i16].
2103/// \param __b
2104/// A 128-bit vector of [8 x i16].
2105/// \returns A 128-bit vector of [8 x i16] containing the sums of both
2106/// parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002107static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002108_mm_add_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002109{
Craig Topper6a77b622016-06-04 05:43:41 +00002110 return (__m128i)((__v8hu)__a + (__v8hu)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002111}
2112
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002113/// \brief Adds the corresponding elements of two 128-bit vectors of [4 x i32],
2114/// saving the lower 32 bits of each sum in the corresponding element of a
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00002115/// 128-bit result vector of [4 x i32].
2116///
2117/// The integer elements of both parameters can be either signed or unsigned.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002118///
2119/// \headerfile <x86intrin.h>
2120///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002121/// This intrinsic corresponds to the <c> VPADDD / PADDD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002122///
2123/// \param __a
2124/// A 128-bit vector of [4 x i32].
2125/// \param __b
2126/// A 128-bit vector of [4 x i32].
2127/// \returns A 128-bit vector of [4 x i32] containing the sums of both
2128/// parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002129static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002130_mm_add_epi32(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002131{
Craig Topper6a77b622016-06-04 05:43:41 +00002132 return (__m128i)((__v4su)__a + (__v4su)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002133}
2134
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002135/// \brief Adds two signed or unsigned 64-bit integer values, returning the
2136/// lower 64 bits of the sum.
2137///
2138/// \headerfile <x86intrin.h>
2139///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002140/// This intrinsic corresponds to the <c> PADDQ </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002141///
2142/// \param __a
2143/// A 64-bit integer.
2144/// \param __b
2145/// A 64-bit integer.
2146/// \returns A 64-bit integer containing the sum of both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002147static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002148_mm_add_si64(__m64 __a, __m64 __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002149{
Craig Topper1aa231e2016-05-16 06:38:42 +00002150 return (__m64)__builtin_ia32_paddq((__v1di)__a, (__v1di)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002151}
2152
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002153/// \brief Adds the corresponding elements of two 128-bit vectors of [2 x i64],
2154/// saving the lower 64 bits of each sum in the corresponding element of a
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00002155/// 128-bit result vector of [2 x i64].
2156///
2157/// The integer elements of both parameters can be either signed or unsigned.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002158///
2159/// \headerfile <x86intrin.h>
2160///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002161/// This intrinsic corresponds to the <c> VPADDQ / PADDQ </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002162///
2163/// \param __a
2164/// A 128-bit vector of [2 x i64].
2165/// \param __b
2166/// A 128-bit vector of [2 x i64].
2167/// \returns A 128-bit vector of [2 x i64] containing the sums of both
2168/// parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002169static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002170_mm_add_epi64(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002171{
Craig Topper6a77b622016-06-04 05:43:41 +00002172 return (__m128i)((__v2du)__a + (__v2du)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002173}
2174
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002175/// \brief Adds, with saturation, the corresponding elements of two 128-bit
2176/// signed [16 x i8] vectors, saving each sum in the corresponding element of
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002177/// a 128-bit result vector of [16 x i8]. Positive sums greater than 0x7F are
2178/// saturated to 0x7F. Negative sums less than 0x80 are saturated to 0x80.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002179///
2180/// \headerfile <x86intrin.h>
2181///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002182/// This intrinsic corresponds to the <c> VPADDSB / PADDSB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002183///
2184/// \param __a
2185/// A 128-bit signed [16 x i8] vector.
2186/// \param __b
2187/// A 128-bit signed [16 x i8] vector.
2188/// \returns A 128-bit signed [16 x i8] vector containing the saturated sums of
2189/// both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002190static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002191_mm_adds_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002192{
David Blaikie3302f2b2013-01-16 23:08:36 +00002193 return (__m128i)__builtin_ia32_paddsb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002194}
2195
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002196/// \brief Adds, with saturation, the corresponding elements of two 128-bit
2197/// signed [8 x i16] vectors, saving each sum in the corresponding element of
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002198/// a 128-bit result vector of [8 x i16]. Positive sums greater than 0x7FFF
2199/// are saturated to 0x7FFF. Negative sums less than 0x8000 are saturated to
2200/// 0x8000.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002201///
2202/// \headerfile <x86intrin.h>
2203///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002204/// This intrinsic corresponds to the <c> VPADDSW / PADDSW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002205///
2206/// \param __a
2207/// A 128-bit signed [8 x i16] vector.
2208/// \param __b
2209/// A 128-bit signed [8 x i16] vector.
2210/// \returns A 128-bit signed [8 x i16] vector containing the saturated sums of
2211/// both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002212static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002213_mm_adds_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002214{
David Blaikie3302f2b2013-01-16 23:08:36 +00002215 return (__m128i)__builtin_ia32_paddsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002216}
2217
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002218/// \brief Adds, with saturation, the corresponding elements of two 128-bit
2219/// unsigned [16 x i8] vectors, saving each sum in the corresponding element
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002220/// of a 128-bit result vector of [16 x i8]. Positive sums greater than 0xFF
2221/// are saturated to 0xFF. Negative sums are saturated to 0x00.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002222///
2223/// \headerfile <x86intrin.h>
2224///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002225/// This intrinsic corresponds to the <c> VPADDUSB / PADDUSB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002226///
2227/// \param __a
2228/// A 128-bit unsigned [16 x i8] vector.
2229/// \param __b
2230/// A 128-bit unsigned [16 x i8] vector.
2231/// \returns A 128-bit unsigned [16 x i8] vector containing the saturated sums
2232/// of both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002233static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002234_mm_adds_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002235{
David Blaikie3302f2b2013-01-16 23:08:36 +00002236 return (__m128i)__builtin_ia32_paddusb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002237}
2238
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002239/// \brief Adds, with saturation, the corresponding elements of two 128-bit
2240/// unsigned [8 x i16] vectors, saving each sum in the corresponding element
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002241/// of a 128-bit result vector of [8 x i16]. Positive sums greater than
2242/// 0xFFFF are saturated to 0xFFFF. Negative sums are saturated to 0x0000.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002243///
2244/// \headerfile <x86intrin.h>
2245///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002246/// This intrinsic corresponds to the <c> VPADDUSB / PADDUSB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002247///
2248/// \param __a
2249/// A 128-bit unsigned [8 x i16] vector.
2250/// \param __b
2251/// A 128-bit unsigned [8 x i16] vector.
2252/// \returns A 128-bit unsigned [8 x i16] vector containing the saturated sums
2253/// of both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002254static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002255_mm_adds_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002256{
David Blaikie3302f2b2013-01-16 23:08:36 +00002257 return (__m128i)__builtin_ia32_paddusw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002258}
2259
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002260/// \brief Computes the rounded avarages of corresponding elements of two
2261/// 128-bit unsigned [16 x i8] vectors, saving each result in the
2262/// corresponding element of a 128-bit result vector of [16 x i8].
2263///
2264/// \headerfile <x86intrin.h>
2265///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002266/// This intrinsic corresponds to the <c> VPAVGB / PAVGB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002267///
2268/// \param __a
2269/// A 128-bit unsigned [16 x i8] vector.
2270/// \param __b
2271/// A 128-bit unsigned [16 x i8] vector.
2272/// \returns A 128-bit unsigned [16 x i8] vector containing the rounded
2273/// averages of both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002274static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002275_mm_avg_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002276{
Yael Tsafrir23e77332017-09-12 07:46:32 +00002277 typedef unsigned short __v16hu __attribute__ ((__vector_size__ (32)));
2278 return (__m128i)__builtin_convertvector(
2279 ((__builtin_convertvector((__v16qu)__a, __v16hu) +
2280 __builtin_convertvector((__v16qu)__b, __v16hu)) + 1)
2281 >> 1, __v16qu);
Anders Carlssona283f912008-12-24 02:41:00 +00002282}
2283
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002284/// \brief Computes the rounded avarages of corresponding elements of two
2285/// 128-bit unsigned [8 x i16] vectors, saving each result in the
2286/// corresponding element of a 128-bit result vector of [8 x i16].
2287///
2288/// \headerfile <x86intrin.h>
2289///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002290/// This intrinsic corresponds to the <c> VPAVGW / PAVGW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002291///
2292/// \param __a
2293/// A 128-bit unsigned [8 x i16] vector.
2294/// \param __b
2295/// A 128-bit unsigned [8 x i16] vector.
2296/// \returns A 128-bit unsigned [8 x i16] vector containing the rounded
2297/// averages of both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002298static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002299_mm_avg_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002300{
Yael Tsafrir23e77332017-09-12 07:46:32 +00002301 typedef unsigned int __v8su __attribute__ ((__vector_size__ (32)));
2302 return (__m128i)__builtin_convertvector(
2303 ((__builtin_convertvector((__v8hu)__a, __v8su) +
2304 __builtin_convertvector((__v8hu)__b, __v8su)) + 1)
2305 >> 1, __v8hu);
Anders Carlssona283f912008-12-24 02:41:00 +00002306}
2307
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002308/// \brief Multiplies the corresponding elements of two 128-bit signed [8 x i16]
2309/// vectors, producing eight intermediate 32-bit signed integer products, and
2310/// adds the consecutive pairs of 32-bit products to form a 128-bit signed
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00002311/// [4 x i32] vector.
2312///
2313/// For example, bits [15:0] of both parameters are multiplied producing a
2314/// 32-bit product, bits [31:16] of both parameters are multiplied producing
2315/// a 32-bit product, and the sum of those two products becomes bits [31:0]
2316/// of the result.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002317///
2318/// \headerfile <x86intrin.h>
2319///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002320/// This intrinsic corresponds to the <c> VPMADDWD / PMADDWD </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002321///
2322/// \param __a
2323/// A 128-bit signed [8 x i16] vector.
2324/// \param __b
2325/// A 128-bit signed [8 x i16] vector.
2326/// \returns A 128-bit signed [4 x i32] vector containing the sums of products
2327/// of both parameters.
Michael Kupersteine45af542015-06-30 13:36:19 +00002328static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002329_mm_madd_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002330{
David Blaikie3302f2b2013-01-16 23:08:36 +00002331 return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002332}
2333
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002334/// \brief Compares corresponding elements of two 128-bit signed [8 x i16]
2335/// vectors, saving the greater value from each comparison in the
2336/// corresponding element of a 128-bit result vector of [8 x i16].
2337///
2338/// \headerfile <x86intrin.h>
2339///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002340/// This intrinsic corresponds to the <c> VPMAXSW / PMAXSW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002341///
2342/// \param __a
2343/// A 128-bit signed [8 x i16] vector.
2344/// \param __b
2345/// A 128-bit signed [8 x i16] vector.
2346/// \returns A 128-bit signed [8 x i16] vector containing the greater value of
2347/// each comparison.
Michael Kupersteine45af542015-06-30 13:36:19 +00002348static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002349_mm_max_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002350{
David Blaikie3302f2b2013-01-16 23:08:36 +00002351 return (__m128i)__builtin_ia32_pmaxsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002352}
2353
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002354/// \brief Compares corresponding elements of two 128-bit unsigned [16 x i8]
2355/// vectors, saving the greater value from each comparison in the
2356/// corresponding element of a 128-bit result vector of [16 x i8].
2357///
2358/// \headerfile <x86intrin.h>
2359///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002360/// This intrinsic corresponds to the <c> VPMAXUB / PMAXUB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002361///
2362/// \param __a
2363/// A 128-bit unsigned [16 x i8] vector.
2364/// \param __b
2365/// A 128-bit unsigned [16 x i8] vector.
2366/// \returns A 128-bit unsigned [16 x i8] vector containing the greater value of
2367/// each comparison.
Michael Kupersteine45af542015-06-30 13:36:19 +00002368static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002369_mm_max_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002370{
David Blaikie3302f2b2013-01-16 23:08:36 +00002371 return (__m128i)__builtin_ia32_pmaxub128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002372}
2373
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002374/// \brief Compares corresponding elements of two 128-bit signed [8 x i16]
2375/// vectors, saving the smaller value from each comparison in the
2376/// corresponding element of a 128-bit result vector of [8 x i16].
2377///
2378/// \headerfile <x86intrin.h>
2379///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002380/// This intrinsic corresponds to the <c> VPMINSW / PMINSW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002381///
2382/// \param __a
2383/// A 128-bit signed [8 x i16] vector.
2384/// \param __b
2385/// A 128-bit signed [8 x i16] vector.
2386/// \returns A 128-bit signed [8 x i16] vector containing the smaller value of
2387/// each comparison.
Michael Kupersteine45af542015-06-30 13:36:19 +00002388static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002389_mm_min_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002390{
David Blaikie3302f2b2013-01-16 23:08:36 +00002391 return (__m128i)__builtin_ia32_pminsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002392}
2393
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002394/// \brief Compares corresponding elements of two 128-bit unsigned [16 x i8]
2395/// vectors, saving the smaller value from each comparison in the
2396/// corresponding element of a 128-bit result vector of [16 x i8].
2397///
2398/// \headerfile <x86intrin.h>
2399///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002400/// This intrinsic corresponds to the <c> VPMINUB / PMINUB </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002401///
2402/// \param __a
2403/// A 128-bit unsigned [16 x i8] vector.
2404/// \param __b
2405/// A 128-bit unsigned [16 x i8] vector.
2406/// \returns A 128-bit unsigned [16 x i8] vector containing the smaller value of
2407/// each comparison.
Michael Kupersteine45af542015-06-30 13:36:19 +00002408static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002409_mm_min_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002410{
David Blaikie3302f2b2013-01-16 23:08:36 +00002411 return (__m128i)__builtin_ia32_pminub128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002412}
2413
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002414/// \brief Multiplies the corresponding elements of two signed [8 x i16]
2415/// vectors, saving the upper 16 bits of each 32-bit product in the
2416/// corresponding element of a 128-bit signed [8 x i16] result vector.
2417///
2418/// \headerfile <x86intrin.h>
2419///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002420/// This intrinsic corresponds to the <c> VPMULHW / PMULHW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002421///
2422/// \param __a
2423/// A 128-bit signed [8 x i16] vector.
2424/// \param __b
2425/// A 128-bit signed [8 x i16] vector.
2426/// \returns A 128-bit signed [8 x i16] vector containing the upper 16 bits of
2427/// each of the eight 32-bit products.
Michael Kupersteine45af542015-06-30 13:36:19 +00002428static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002429_mm_mulhi_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002430{
David Blaikie3302f2b2013-01-16 23:08:36 +00002431 return (__m128i)__builtin_ia32_pmulhw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002432}
2433
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002434/// \brief Multiplies the corresponding elements of two unsigned [8 x i16]
2435/// vectors, saving the upper 16 bits of each 32-bit product in the
2436/// corresponding element of a 128-bit unsigned [8 x i16] result vector.
2437///
2438/// \headerfile <x86intrin.h>
2439///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002440/// This intrinsic corresponds to the <c> VPMULHUW / PMULHUW </c> instruction.
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002441///
2442/// \param __a
2443/// A 128-bit unsigned [8 x i16] vector.
2444/// \param __b
2445/// A 128-bit unsigned [8 x i16] vector.
2446/// \returns A 128-bit unsigned [8 x i16] vector containing the upper 16 bits
2447/// of each of the eight 32-bit products.
Michael Kupersteine45af542015-06-30 13:36:19 +00002448static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002449_mm_mulhi_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002450{
David Blaikie3302f2b2013-01-16 23:08:36 +00002451 return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002452}
2453
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002454/// \brief Multiplies the corresponding elements of two signed [8 x i16]
2455/// vectors, saving the lower 16 bits of each 32-bit product in the
2456/// corresponding element of a 128-bit signed [8 x i16] result vector.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002457///
2458/// \headerfile <x86intrin.h>
2459///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002460/// This intrinsic corresponds to the <c> VPMULLW / PMULLW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002461///
2462/// \param __a
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002463/// A 128-bit signed [8 x i16] vector.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002464/// \param __b
Ekaterina Romanova06477bf2016-10-23 07:30:50 +00002465/// A 128-bit signed [8 x i16] vector.
2466/// \returns A 128-bit signed [8 x i16] vector containing the lower 16 bits of
2467/// each of the eight 32-bit products.
Michael Kupersteine45af542015-06-30 13:36:19 +00002468static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002469_mm_mullo_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002470{
Craig Topper6a77b622016-06-04 05:43:41 +00002471 return (__m128i)((__v8hu)__a * (__v8hu)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002472}
2473
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002474/// \brief Multiplies 32-bit unsigned integer values contained in the lower bits
2475/// of the two 64-bit integer vectors and returns the 64-bit unsigned
2476/// product.
2477///
2478/// \headerfile <x86intrin.h>
2479///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002480/// This intrinsic corresponds to the <c> PMULUDQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002481///
2482/// \param __a
2483/// A 64-bit integer containing one of the source operands.
2484/// \param __b
2485/// A 64-bit integer containing one of the source operands.
2486/// \returns A 64-bit integer vector containing the product of both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002487static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002488_mm_mul_su32(__m64 __a, __m64 __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002489{
David Blaikie3302f2b2013-01-16 23:08:36 +00002490 return __builtin_ia32_pmuludq((__v2si)__a, (__v2si)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002491}
2492
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002493/// \brief Multiplies 32-bit unsigned integer values contained in the lower
2494/// bits of the corresponding elements of two [2 x i64] vectors, and returns
2495/// the 64-bit products in the corresponding elements of a [2 x i64] vector.
2496///
2497/// \headerfile <x86intrin.h>
2498///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002499/// This intrinsic corresponds to the <c> VPMULUDQ / PMULUDQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002500///
2501/// \param __a
2502/// A [2 x i64] vector containing one of the source operands.
2503/// \param __b
2504/// A [2 x i64] vector containing one of the source operands.
2505/// \returns A [2 x i64] vector containing the product of both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002506static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002507_mm_mul_epu32(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002508{
David Blaikie3302f2b2013-01-16 23:08:36 +00002509 return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002510}
2511
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002512/// \brief Computes the absolute differences of corresponding 8-bit integer
2513/// values in two 128-bit vectors. Sums the first 8 absolute differences, and
Ekaterina Romanovaff266f52017-02-17 02:49:50 +00002514/// separately sums the second 8 absolute differences. Packs these two
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002515/// unsigned 16-bit integer sums into the upper and lower elements of a
2516/// [2 x i64] vector.
2517///
2518/// \headerfile <x86intrin.h>
2519///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002520/// This intrinsic corresponds to the <c> VPSADBW / PSADBW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002521///
2522/// \param __a
2523/// A 128-bit integer vector containing one of the source operands.
2524/// \param __b
2525/// A 128-bit integer vector containing one of the source operands.
2526/// \returns A [2 x i64] vector containing the sums of the sets of absolute
2527/// differences between both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002528static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002529_mm_sad_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002530{
David Blaikie3302f2b2013-01-16 23:08:36 +00002531 return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002532}
2533
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002534/// \brief Subtracts the corresponding 8-bit integer values in the operands.
2535///
2536/// \headerfile <x86intrin.h>
2537///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002538/// This intrinsic corresponds to the <c> VPSUBB / PSUBB </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002539///
2540/// \param __a
2541/// A 128-bit integer vector containing the minuends.
2542/// \param __b
2543/// A 128-bit integer vector containing the subtrahends.
2544/// \returns A 128-bit integer vector containing the differences of the values
2545/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002546static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002547_mm_sub_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002548{
Craig Topper6a77b622016-06-04 05:43:41 +00002549 return (__m128i)((__v16qu)__a - (__v16qu)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002550}
2551
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002552/// \brief Subtracts the corresponding 16-bit integer values in the operands.
2553///
2554/// \headerfile <x86intrin.h>
2555///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002556/// This intrinsic corresponds to the <c> VPSUBW / PSUBW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002557///
2558/// \param __a
2559/// A 128-bit integer vector containing the minuends.
2560/// \param __b
2561/// A 128-bit integer vector containing the subtrahends.
2562/// \returns A 128-bit integer vector containing the differences of the values
2563/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002564static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002565_mm_sub_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002566{
Craig Topper6a77b622016-06-04 05:43:41 +00002567 return (__m128i)((__v8hu)__a - (__v8hu)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002568}
2569
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002570/// \brief Subtracts the corresponding 32-bit integer values in the operands.
2571///
2572/// \headerfile <x86intrin.h>
2573///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002574/// This intrinsic corresponds to the <c> VPSUBD / PSUBD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002575///
2576/// \param __a
2577/// A 128-bit integer vector containing the minuends.
2578/// \param __b
2579/// A 128-bit integer vector containing the subtrahends.
2580/// \returns A 128-bit integer vector containing the differences of the values
2581/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002582static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002583_mm_sub_epi32(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002584{
Craig Topper6a77b622016-06-04 05:43:41 +00002585 return (__m128i)((__v4su)__a - (__v4su)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002586}
2587
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002588/// \brief Subtracts signed or unsigned 64-bit integer values and writes the
2589/// difference to the corresponding bits in the destination.
2590///
2591/// \headerfile <x86intrin.h>
2592///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002593/// This intrinsic corresponds to the <c> PSUBQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002594///
2595/// \param __a
2596/// A 64-bit integer vector containing the minuend.
2597/// \param __b
2598/// A 64-bit integer vector containing the subtrahend.
2599/// \returns A 64-bit integer vector containing the difference of the values in
2600/// the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002601static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002602_mm_sub_si64(__m64 __a, __m64 __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002603{
Craig Topper1aa231e2016-05-16 06:38:42 +00002604 return (__m64)__builtin_ia32_psubq((__v1di)__a, (__v1di)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002605}
2606
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002607/// \brief Subtracts the corresponding elements of two [2 x i64] vectors.
2608///
2609/// \headerfile <x86intrin.h>
2610///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002611/// This intrinsic corresponds to the <c> VPSUBQ / PSUBQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002612///
2613/// \param __a
2614/// A 128-bit integer vector containing the minuends.
2615/// \param __b
2616/// A 128-bit integer vector containing the subtrahends.
2617/// \returns A 128-bit integer vector containing the differences of the values
2618/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002619static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002620_mm_sub_epi64(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002621{
Craig Topper6a77b622016-06-04 05:43:41 +00002622 return (__m128i)((__v2du)__a - (__v2du)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002623}
2624
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002625/// \brief Subtracts corresponding 8-bit signed integer values in the input and
2626/// returns the differences in the corresponding bytes in the destination.
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002627/// Differences greater than 0x7F are saturated to 0x7F, and differences less
2628/// than 0x80 are saturated to 0x80.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002629///
2630/// \headerfile <x86intrin.h>
2631///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002632/// This intrinsic corresponds to the <c> VPSUBSB / PSUBSB </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002633///
2634/// \param __a
2635/// A 128-bit integer vector containing the minuends.
2636/// \param __b
2637/// A 128-bit integer vector containing the subtrahends.
2638/// \returns A 128-bit integer vector containing the differences of the values
2639/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002640static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002641_mm_subs_epi8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002642{
David Blaikie3302f2b2013-01-16 23:08:36 +00002643 return (__m128i)__builtin_ia32_psubsb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002644}
2645
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002646/// \brief Subtracts corresponding 16-bit signed integer values in the input and
2647/// returns the differences in the corresponding bytes in the destination.
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002648/// Differences greater than 0x7FFF are saturated to 0x7FFF, and values less
2649/// than 0x8000 are saturated to 0x8000.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002650///
2651/// \headerfile <x86intrin.h>
2652///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002653/// This intrinsic corresponds to the <c> VPSUBSW / PSUBSW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002654///
2655/// \param __a
2656/// A 128-bit integer vector containing the minuends.
2657/// \param __b
2658/// A 128-bit integer vector containing the subtrahends.
2659/// \returns A 128-bit integer vector containing the differences of the values
2660/// in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002661static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002662_mm_subs_epi16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002663{
David Blaikie3302f2b2013-01-16 23:08:36 +00002664 return (__m128i)__builtin_ia32_psubsw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002665}
2666
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002667/// \brief Subtracts corresponding 8-bit unsigned integer values in the input
2668/// and returns the differences in the corresponding bytes in the
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002669/// destination. Differences less than 0x00 are saturated to 0x00.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002670///
2671/// \headerfile <x86intrin.h>
2672///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002673/// This intrinsic corresponds to the <c> VPSUBUSB / PSUBUSB </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002674///
2675/// \param __a
2676/// A 128-bit integer vector containing the minuends.
2677/// \param __b
2678/// A 128-bit integer vector containing the subtrahends.
2679/// \returns A 128-bit integer vector containing the unsigned integer
2680/// differences of the values in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002681static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002682_mm_subs_epu8(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002683{
David Blaikie3302f2b2013-01-16 23:08:36 +00002684 return (__m128i)__builtin_ia32_psubusb128((__v16qi)__a, (__v16qi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002685}
2686
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002687/// \brief Subtracts corresponding 16-bit unsigned integer values in the input
2688/// and returns the differences in the corresponding bytes in the
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00002689/// destination. Differences less than 0x0000 are saturated to 0x0000.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002690///
2691/// \headerfile <x86intrin.h>
2692///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002693/// This intrinsic corresponds to the <c> VPSUBUSW / PSUBUSW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002694///
2695/// \param __a
2696/// A 128-bit integer vector containing the minuends.
2697/// \param __b
2698/// A 128-bit integer vector containing the subtrahends.
2699/// \returns A 128-bit integer vector containing the unsigned integer
2700/// differences of the values in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002701static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002702_mm_subs_epu16(__m128i __a, __m128i __b)
Anders Carlssona283f912008-12-24 02:41:00 +00002703{
David Blaikie3302f2b2013-01-16 23:08:36 +00002704 return (__m128i)__builtin_ia32_psubusw128((__v8hi)__a, (__v8hi)__b);
Anders Carlssona283f912008-12-24 02:41:00 +00002705}
2706
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002707/// \brief Performs a bitwise AND of two 128-bit integer vectors.
2708///
2709/// \headerfile <x86intrin.h>
2710///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002711/// This intrinsic corresponds to the <c> VPAND / PAND </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002712///
2713/// \param __a
2714/// A 128-bit integer vector containing one of the source operands.
2715/// \param __b
2716/// A 128-bit integer vector containing one of the source operands.
2717/// \returns A 128-bit integer vector containing the bitwise AND of the values
2718/// in both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002719static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002720_mm_and_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002721{
Craig Topper6a77b622016-06-04 05:43:41 +00002722 return (__m128i)((__v2du)__a & (__v2du)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002723}
2724
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002725/// \brief Performs a bitwise AND of two 128-bit integer vectors, using the
2726/// one's complement of the values contained in the first source operand.
2727///
2728/// \headerfile <x86intrin.h>
2729///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002730/// This intrinsic corresponds to the <c> VPANDN / PANDN </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002731///
2732/// \param __a
2733/// A 128-bit vector containing the left source operand. The one's complement
2734/// of this value is used in the bitwise AND.
2735/// \param __b
2736/// A 128-bit vector containing the right source operand.
2737/// \returns A 128-bit integer vector containing the bitwise AND of the one's
2738/// complement of the first operand and the values in the second operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00002739static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002740_mm_andnot_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002741{
Craig Topper6a77b622016-06-04 05:43:41 +00002742 return (__m128i)(~(__v2du)__a & (__v2du)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002743}
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002744/// \brief Performs a bitwise OR of two 128-bit integer vectors.
2745///
2746/// \headerfile <x86intrin.h>
2747///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002748/// This intrinsic corresponds to the <c> VPOR / POR </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002749///
2750/// \param __a
2751/// A 128-bit integer vector containing one of the source operands.
2752/// \param __b
2753/// A 128-bit integer vector containing one of the source operands.
2754/// \returns A 128-bit integer vector containing the bitwise OR of the values
2755/// in both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002756static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002757_mm_or_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002758{
Craig Topper6a77b622016-06-04 05:43:41 +00002759 return (__m128i)((__v2du)__a | (__v2du)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002760}
2761
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002762/// \brief Performs a bitwise exclusive OR of two 128-bit integer vectors.
2763///
2764/// \headerfile <x86intrin.h>
2765///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002766/// This intrinsic corresponds to the <c> VPXOR / PXOR </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002767///
2768/// \param __a
2769/// A 128-bit integer vector containing one of the source operands.
2770/// \param __b
2771/// A 128-bit integer vector containing one of the source operands.
2772/// \returns A 128-bit integer vector containing the bitwise exclusive OR of the
2773/// values in both operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00002774static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002775_mm_xor_si128(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002776{
Craig Topper6a77b622016-06-04 05:43:41 +00002777 return (__m128i)((__v2du)__a ^ (__v2du)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002778}
2779
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002780/// \brief Left-shifts the 128-bit integer vector operand by the specified
2781/// number of bytes. Low-order bits are cleared.
2782///
2783/// \headerfile <x86intrin.h>
2784///
2785/// \code
2786/// __m128i _mm_slli_si128(__m128i a, const int imm);
2787/// \endcode
2788///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002789/// This intrinsic corresponds to the <c> VPSLLDQ / PSLLDQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002790///
2791/// \param a
2792/// A 128-bit integer vector containing the source operand.
2793/// \param imm
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00002794/// An immediate value specifying the number of bytes to left-shift operand
2795/// \a a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002796/// \returns A 128-bit integer vector containing the left-shifted value.
Craig Topper50e3dfe2016-06-25 07:31:14 +00002797#define _mm_slli_si128(a, imm) __extension__ ({ \
2798 (__m128i)__builtin_shufflevector( \
2799 (__v16qi)_mm_setzero_si128(), \
2800 (__v16qi)(__m128i)(a), \
2801 ((char)(imm)&0xF0) ? 0 : 16 - (char)(imm), \
2802 ((char)(imm)&0xF0) ? 1 : 17 - (char)(imm), \
2803 ((char)(imm)&0xF0) ? 2 : 18 - (char)(imm), \
2804 ((char)(imm)&0xF0) ? 3 : 19 - (char)(imm), \
2805 ((char)(imm)&0xF0) ? 4 : 20 - (char)(imm), \
2806 ((char)(imm)&0xF0) ? 5 : 21 - (char)(imm), \
2807 ((char)(imm)&0xF0) ? 6 : 22 - (char)(imm), \
2808 ((char)(imm)&0xF0) ? 7 : 23 - (char)(imm), \
2809 ((char)(imm)&0xF0) ? 8 : 24 - (char)(imm), \
2810 ((char)(imm)&0xF0) ? 9 : 25 - (char)(imm), \
2811 ((char)(imm)&0xF0) ? 10 : 26 - (char)(imm), \
2812 ((char)(imm)&0xF0) ? 11 : 27 - (char)(imm), \
2813 ((char)(imm)&0xF0) ? 12 : 28 - (char)(imm), \
2814 ((char)(imm)&0xF0) ? 13 : 29 - (char)(imm), \
2815 ((char)(imm)&0xF0) ? 14 : 30 - (char)(imm), \
2816 ((char)(imm)&0xF0) ? 15 : 31 - (char)(imm)); })
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002817
Craig Toppera4624822015-02-13 06:04:45 +00002818#define _mm_bslli_si128(a, imm) \
2819 _mm_slli_si128((a), (imm))
2820
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002821/// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand
2822/// by the specified number of bits. Low-order bits are cleared.
2823///
2824/// \headerfile <x86intrin.h>
2825///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002826/// This intrinsic corresponds to the <c> VPSLLW / PSLLW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002827///
2828/// \param __a
2829/// A 128-bit integer vector containing the source operand.
2830/// \param __count
2831/// An integer value specifying the number of bits to left-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002832/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002833/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002834static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002835_mm_slli_epi16(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002836{
David Blaikie3302f2b2013-01-16 23:08:36 +00002837 return (__m128i)__builtin_ia32_psllwi128((__v8hi)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002838}
2839
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002840/// \brief Left-shifts each 16-bit value in the 128-bit integer vector operand
2841/// by the specified number of bits. Low-order bits are cleared.
2842///
2843/// \headerfile <x86intrin.h>
2844///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002845/// This intrinsic corresponds to the <c> VPSLLW / PSLLW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002846///
2847/// \param __a
2848/// A 128-bit integer vector containing the source operand.
2849/// \param __count
2850/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002851/// to left-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002852/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002853static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002854_mm_sll_epi16(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002855{
David Blaikie3302f2b2013-01-16 23:08:36 +00002856 return (__m128i)__builtin_ia32_psllw128((__v8hi)__a, (__v8hi)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002857}
2858
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002859/// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand
2860/// by the specified number of bits. Low-order bits are cleared.
2861///
2862/// \headerfile <x86intrin.h>
2863///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002864/// This intrinsic corresponds to the <c> VPSLLD / PSLLD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002865///
2866/// \param __a
2867/// A 128-bit integer vector containing the source operand.
2868/// \param __count
2869/// An integer value specifying the number of bits to left-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002870/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002871/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002872static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002873_mm_slli_epi32(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002874{
David Blaikie3302f2b2013-01-16 23:08:36 +00002875 return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002876}
2877
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002878/// \brief Left-shifts each 32-bit value in the 128-bit integer vector operand
2879/// by the specified number of bits. Low-order bits are cleared.
2880///
2881/// \headerfile <x86intrin.h>
2882///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002883/// This intrinsic corresponds to the <c> VPSLLD / PSLLD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002884///
2885/// \param __a
2886/// A 128-bit integer vector containing the source operand.
2887/// \param __count
2888/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002889/// to left-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002890/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002891static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002892_mm_sll_epi32(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002893{
David Blaikie3302f2b2013-01-16 23:08:36 +00002894 return (__m128i)__builtin_ia32_pslld128((__v4si)__a, (__v4si)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002895}
2896
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002897/// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand
2898/// by the specified number of bits. Low-order bits are cleared.
2899///
2900/// \headerfile <x86intrin.h>
2901///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002902/// This intrinsic corresponds to the <c> VPSLLQ / PSLLQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002903///
2904/// \param __a
2905/// A 128-bit integer vector containing the source operand.
2906/// \param __count
2907/// An integer value specifying the number of bits to left-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002908/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002909/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002910static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002911_mm_slli_epi64(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002912{
Craig Topper1aa231e2016-05-16 06:38:42 +00002913 return __builtin_ia32_psllqi128((__v2di)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002914}
2915
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002916/// \brief Left-shifts each 64-bit value in the 128-bit integer vector operand
2917/// by the specified number of bits. Low-order bits are cleared.
2918///
2919/// \headerfile <x86intrin.h>
2920///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002921/// This intrinsic corresponds to the <c> VPSLLQ / PSLLQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002922///
2923/// \param __a
2924/// A 128-bit integer vector containing the source operand.
2925/// \param __count
2926/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002927/// to left-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002928/// \returns A 128-bit integer vector containing the left-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002929static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002930_mm_sll_epi64(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002931{
Craig Topper1aa231e2016-05-16 06:38:42 +00002932 return __builtin_ia32_psllq128((__v2di)__a, (__v2di)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002933}
2934
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002935/// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand
2936/// by the specified number of bits. High-order bits are filled with the sign
2937/// bit of the initial value.
2938///
2939/// \headerfile <x86intrin.h>
2940///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002941/// This intrinsic corresponds to the <c> VPSRAW / PSRAW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002942///
2943/// \param __a
2944/// A 128-bit integer vector containing the source operand.
2945/// \param __count
2946/// An integer value specifying the number of bits to right-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002947/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002948/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002949static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002950_mm_srai_epi16(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002951{
David Blaikie3302f2b2013-01-16 23:08:36 +00002952 return (__m128i)__builtin_ia32_psrawi128((__v8hi)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002953}
2954
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002955/// \brief Right-shifts each 16-bit value in the 128-bit integer vector operand
2956/// by the specified number of bits. High-order bits are filled with the sign
2957/// bit of the initial value.
2958///
2959/// \headerfile <x86intrin.h>
2960///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002961/// This intrinsic corresponds to the <c> VPSRAW / PSRAW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002962///
2963/// \param __a
2964/// A 128-bit integer vector containing the source operand.
2965/// \param __count
2966/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002967/// to right-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002968/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002969static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002970_mm_sra_epi16(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002971{
David Blaikie3302f2b2013-01-16 23:08:36 +00002972 return (__m128i)__builtin_ia32_psraw128((__v8hi)__a, (__v8hi)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002973}
2974
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002975/// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand
2976/// by the specified number of bits. High-order bits are filled with the sign
2977/// bit of the initial value.
2978///
2979/// \headerfile <x86intrin.h>
2980///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00002981/// This intrinsic corresponds to the <c> VPSRAD / PSRAD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002982///
2983/// \param __a
2984/// A 128-bit integer vector containing the source operand.
2985/// \param __count
2986/// An integer value specifying the number of bits to right-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00002987/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002988/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00002989static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00002990_mm_srai_epi32(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002991{
David Blaikie3302f2b2013-01-16 23:08:36 +00002992 return (__m128i)__builtin_ia32_psradi128((__v4si)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00002993}
2994
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00002995/// \brief Right-shifts each 32-bit value in the 128-bit integer vector operand
2996/// by the specified number of bits. High-order bits are filled with the sign
2997/// bit of the initial value.
2998///
2999/// \headerfile <x86intrin.h>
3000///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003001/// This intrinsic corresponds to the <c> VPSRAD / PSRAD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003002///
3003/// \param __a
3004/// A 128-bit integer vector containing the source operand.
3005/// \param __count
3006/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003007/// to right-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003008/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003009static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003010_mm_sra_epi32(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003011{
David Blaikie3302f2b2013-01-16 23:08:36 +00003012 return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003013}
3014
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003015/// \brief Right-shifts the 128-bit integer vector operand by the specified
3016/// number of bytes. High-order bits are cleared.
3017///
3018/// \headerfile <x86intrin.h>
3019///
3020/// \code
3021/// __m128i _mm_srli_si128(__m128i a, const int imm);
3022/// \endcode
3023///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003024/// This intrinsic corresponds to the <c> VPSRLDQ / PSRLDQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003025///
3026/// \param a
3027/// A 128-bit integer vector containing the source operand.
3028/// \param imm
3029/// An immediate value specifying the number of bytes to right-shift operand
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003030/// \a a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003031/// \returns A 128-bit integer vector containing the right-shifted value.
Craig Topper50e3dfe2016-06-25 07:31:14 +00003032#define _mm_srli_si128(a, imm) __extension__ ({ \
3033 (__m128i)__builtin_shufflevector( \
3034 (__v16qi)(__m128i)(a), \
3035 (__v16qi)_mm_setzero_si128(), \
3036 ((char)(imm)&0xF0) ? 16 : (char)(imm) + 0, \
3037 ((char)(imm)&0xF0) ? 17 : (char)(imm) + 1, \
3038 ((char)(imm)&0xF0) ? 18 : (char)(imm) + 2, \
3039 ((char)(imm)&0xF0) ? 19 : (char)(imm) + 3, \
3040 ((char)(imm)&0xF0) ? 20 : (char)(imm) + 4, \
3041 ((char)(imm)&0xF0) ? 21 : (char)(imm) + 5, \
3042 ((char)(imm)&0xF0) ? 22 : (char)(imm) + 6, \
3043 ((char)(imm)&0xF0) ? 23 : (char)(imm) + 7, \
3044 ((char)(imm)&0xF0) ? 24 : (char)(imm) + 8, \
3045 ((char)(imm)&0xF0) ? 25 : (char)(imm) + 9, \
3046 ((char)(imm)&0xF0) ? 26 : (char)(imm) + 10, \
3047 ((char)(imm)&0xF0) ? 27 : (char)(imm) + 11, \
3048 ((char)(imm)&0xF0) ? 28 : (char)(imm) + 12, \
3049 ((char)(imm)&0xF0) ? 29 : (char)(imm) + 13, \
3050 ((char)(imm)&0xF0) ? 30 : (char)(imm) + 14, \
3051 ((char)(imm)&0xF0) ? 31 : (char)(imm) + 15); })
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003052
Craig Toppera4624822015-02-13 06:04:45 +00003053#define _mm_bsrli_si128(a, imm) \
3054 _mm_srli_si128((a), (imm))
3055
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003056/// \brief Right-shifts each of 16-bit values in the 128-bit integer vector
3057/// operand by the specified number of bits. High-order bits are cleared.
3058///
3059/// \headerfile <x86intrin.h>
3060///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003061/// This intrinsic corresponds to the <c> VPSRLW / PSRLW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003062///
3063/// \param __a
3064/// A 128-bit integer vector containing the source operand.
3065/// \param __count
3066/// An integer value specifying the number of bits to right-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003067/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003068/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003069static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003070_mm_srli_epi16(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003071{
David Blaikie3302f2b2013-01-16 23:08:36 +00003072 return (__m128i)__builtin_ia32_psrlwi128((__v8hi)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003073}
3074
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003075/// \brief Right-shifts each of 16-bit values in the 128-bit integer vector
3076/// operand by the specified number of bits. High-order bits are cleared.
3077///
3078/// \headerfile <x86intrin.h>
3079///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003080/// This intrinsic corresponds to the <c> VPSRLW / PSRLW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003081///
3082/// \param __a
3083/// A 128-bit integer vector containing the source operand.
3084/// \param __count
3085/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003086/// to right-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003087/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003088static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003089_mm_srl_epi16(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003090{
David Blaikie3302f2b2013-01-16 23:08:36 +00003091 return (__m128i)__builtin_ia32_psrlw128((__v8hi)__a, (__v8hi)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003092}
3093
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003094/// \brief Right-shifts each of 32-bit values in the 128-bit integer vector
3095/// operand by the specified number of bits. High-order bits are cleared.
3096///
3097/// \headerfile <x86intrin.h>
3098///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003099/// This intrinsic corresponds to the <c> VPSRLD / PSRLD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003100///
3101/// \param __a
3102/// A 128-bit integer vector containing the source operand.
3103/// \param __count
3104/// An integer value specifying the number of bits to right-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003105/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003106/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003107static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003108_mm_srli_epi32(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003109{
David Blaikie3302f2b2013-01-16 23:08:36 +00003110 return (__m128i)__builtin_ia32_psrldi128((__v4si)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003111}
3112
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003113/// \brief Right-shifts each of 32-bit values in the 128-bit integer vector
3114/// operand by the specified number of bits. High-order bits are cleared.
3115///
3116/// \headerfile <x86intrin.h>
3117///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003118/// This intrinsic corresponds to the <c> VPSRLD / PSRLD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003119///
3120/// \param __a
3121/// A 128-bit integer vector containing the source operand.
3122/// \param __count
3123/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003124/// to right-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003125/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003126static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003127_mm_srl_epi32(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003128{
David Blaikie3302f2b2013-01-16 23:08:36 +00003129 return (__m128i)__builtin_ia32_psrld128((__v4si)__a, (__v4si)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003130}
3131
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003132/// \brief Right-shifts each of 64-bit values in the 128-bit integer vector
3133/// operand by the specified number of bits. High-order bits are cleared.
3134///
3135/// \headerfile <x86intrin.h>
3136///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003137/// This intrinsic corresponds to the <c> VPSRLQ / PSRLQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003138///
3139/// \param __a
3140/// A 128-bit integer vector containing the source operand.
3141/// \param __count
3142/// An integer value specifying the number of bits to right-shift each value
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003143/// in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003144/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003145static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003146_mm_srli_epi64(__m128i __a, int __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003147{
Craig Topper1aa231e2016-05-16 06:38:42 +00003148 return __builtin_ia32_psrlqi128((__v2di)__a, __count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003149}
3150
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003151/// \brief Right-shifts each of 64-bit values in the 128-bit integer vector
3152/// operand by the specified number of bits. High-order bits are cleared.
3153///
3154/// \headerfile <x86intrin.h>
3155///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003156/// This intrinsic corresponds to the <c> VPSRLQ / PSRLQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003157///
3158/// \param __a
3159/// A 128-bit integer vector containing the source operand.
3160/// \param __count
3161/// A 128-bit integer vector in which bits [63:0] specify the number of bits
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00003162/// to right-shift each value in operand \a __a.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003163/// \returns A 128-bit integer vector containing the right-shifted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003164static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003165_mm_srl_epi64(__m128i __a, __m128i __count)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003166{
Craig Topper1aa231e2016-05-16 06:38:42 +00003167 return __builtin_ia32_psrlq128((__v2di)__a, (__v2di)__count);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003168}
3169
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003170/// \brief Compares each of the corresponding 8-bit values of the 128-bit
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003171/// integer vectors for equality. Each comparison yields 0x0 for false, 0xFF
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003172/// for true.
3173///
3174/// \headerfile <x86intrin.h>
3175///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003176/// This intrinsic corresponds to the <c> VPCMPEQB / PCMPEQB </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003177///
3178/// \param __a
3179/// A 128-bit integer vector.
3180/// \param __b
3181/// A 128-bit integer vector.
3182/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003183static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003184_mm_cmpeq_epi8(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003185{
David Blaikie3302f2b2013-01-16 23:08:36 +00003186 return (__m128i)((__v16qi)__a == (__v16qi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003187}
3188
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003189/// \brief Compares each of the corresponding 16-bit values of the 128-bit
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003190/// integer vectors for equality. Each comparison yields 0x0 for false,
3191/// 0xFFFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003192///
3193/// \headerfile <x86intrin.h>
3194///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003195/// This intrinsic corresponds to the <c> VPCMPEQW / PCMPEQW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003196///
3197/// \param __a
3198/// A 128-bit integer vector.
3199/// \param __b
3200/// A 128-bit integer vector.
3201/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003202static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003203_mm_cmpeq_epi16(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003204{
David Blaikie3302f2b2013-01-16 23:08:36 +00003205 return (__m128i)((__v8hi)__a == (__v8hi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003206}
3207
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003208/// \brief Compares each of the corresponding 32-bit values of the 128-bit
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003209/// integer vectors for equality. Each comparison yields 0x0 for false,
3210/// 0xFFFFFFFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003211///
3212/// \headerfile <x86intrin.h>
3213///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003214/// This intrinsic corresponds to the <c> VPCMPEQD / PCMPEQD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003215///
3216/// \param __a
3217/// A 128-bit integer vector.
3218/// \param __b
3219/// A 128-bit integer vector.
3220/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003221static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003222_mm_cmpeq_epi32(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003223{
David Blaikie3302f2b2013-01-16 23:08:36 +00003224 return (__m128i)((__v4si)__a == (__v4si)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003225}
3226
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003227/// \brief Compares each of the corresponding signed 8-bit values of the 128-bit
3228/// integer vectors to determine if the values in the first operand are
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003229/// greater than those in the second operand. Each comparison yields 0x0 for
3230/// false, 0xFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003231///
3232/// \headerfile <x86intrin.h>
3233///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003234/// This intrinsic corresponds to the <c> VPCMPGTB / PCMPGTB </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003235///
3236/// \param __a
3237/// A 128-bit integer vector.
3238/// \param __b
3239/// A 128-bit integer vector.
3240/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003241static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003242_mm_cmpgt_epi8(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003243{
Nick Lewyckyd0ba3792012-02-04 02:16:48 +00003244 /* This function always performs a signed comparison, but __v16qi is a char
Chandler Carruthcbe64112015-10-01 23:40:12 +00003245 which may be signed or unsigned, so use __v16qs. */
David Blaikie3302f2b2013-01-16 23:08:36 +00003246 return (__m128i)((__v16qs)__a > (__v16qs)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003247}
3248
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003249/// \brief Compares each of the corresponding signed 16-bit values of the
3250/// 128-bit integer vectors to determine if the values in the first operand
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00003251/// are greater than those in the second operand.
3252///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003253/// Each comparison yields 0x0 for false, 0xFFFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003254///
3255/// \headerfile <x86intrin.h>
3256///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003257/// This intrinsic corresponds to the <c> VPCMPGTW / PCMPGTW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003258///
3259/// \param __a
3260/// A 128-bit integer vector.
3261/// \param __b
3262/// A 128-bit integer vector.
3263/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003264static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003265_mm_cmpgt_epi16(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003266{
David Blaikie3302f2b2013-01-16 23:08:36 +00003267 return (__m128i)((__v8hi)__a > (__v8hi)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003268}
3269
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003270/// \brief Compares each of the corresponding signed 32-bit values of the
3271/// 128-bit integer vectors to determine if the values in the first operand
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00003272/// are greater than those in the second operand.
3273///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003274/// Each comparison yields 0x0 for false, 0xFFFFFFFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003275///
3276/// \headerfile <x86intrin.h>
3277///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003278/// This intrinsic corresponds to the <c> VPCMPGTD / PCMPGTD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003279///
3280/// \param __a
3281/// A 128-bit integer vector.
3282/// \param __b
3283/// A 128-bit integer vector.
3284/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003285static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003286_mm_cmpgt_epi32(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003287{
David Blaikie3302f2b2013-01-16 23:08:36 +00003288 return (__m128i)((__v4si)__a > (__v4si)__b);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003289}
3290
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003291/// \brief Compares each of the corresponding signed 8-bit values of the 128-bit
3292/// integer vectors to determine if the values in the first operand are less
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00003293/// than those in the second operand.
3294///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003295/// Each comparison yields 0x0 for false, 0xFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003296///
3297/// \headerfile <x86intrin.h>
3298///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003299/// This intrinsic corresponds to the <c> VPCMPGTB / PCMPGTB </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003300///
3301/// \param __a
3302/// A 128-bit integer vector.
3303/// \param __b
3304/// A 128-bit integer vector.
3305/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003306static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003307_mm_cmplt_epi8(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003308{
David Blaikie3302f2b2013-01-16 23:08:36 +00003309 return _mm_cmpgt_epi8(__b, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003310}
3311
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003312/// \brief Compares each of the corresponding signed 16-bit values of the
3313/// 128-bit integer vectors to determine if the values in the first operand
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00003314/// are less than those in the second operand.
3315///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003316/// Each comparison yields 0x0 for false, 0xFFFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003317///
3318/// \headerfile <x86intrin.h>
3319///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003320/// This intrinsic corresponds to the <c> VPCMPGTW / PCMPGTW </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003321///
3322/// \param __a
3323/// A 128-bit integer vector.
3324/// \param __b
3325/// A 128-bit integer vector.
3326/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003327static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003328_mm_cmplt_epi16(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003329{
David Blaikie3302f2b2013-01-16 23:08:36 +00003330 return _mm_cmpgt_epi16(__b, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003331}
3332
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003333/// \brief Compares each of the corresponding signed 32-bit values of the
3334/// 128-bit integer vectors to determine if the values in the first operand
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00003335/// are less than those in the second operand.
3336///
Ekaterina Romanovaf2875182018-02-16 03:11:35 +00003337/// Each comparison yields 0x0 for false, 0xFFFFFFFF for true.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003338///
3339/// \headerfile <x86intrin.h>
3340///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003341/// This intrinsic corresponds to the <c> VPCMPGTD / PCMPGTD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003342///
3343/// \param __a
3344/// A 128-bit integer vector.
3345/// \param __b
3346/// A 128-bit integer vector.
3347/// \returns A 128-bit integer vector containing the comparison results.
Michael Kupersteine45af542015-06-30 13:36:19 +00003348static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003349_mm_cmplt_epi32(__m128i __a, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003350{
David Blaikie3302f2b2013-01-16 23:08:36 +00003351 return _mm_cmpgt_epi32(__b, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003352}
3353
3354#ifdef __x86_64__
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003355/// \brief Converts a 64-bit signed integer value from the second operand into a
3356/// double-precision value and returns it in the lower element of a [2 x
3357/// double] vector; the upper element of the returned vector is copied from
3358/// the upper element of the first operand.
3359///
3360/// \headerfile <x86intrin.h>
3361///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003362/// This intrinsic corresponds to the <c> VCVTSI2SD / CVTSI2SD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003363///
3364/// \param __a
3365/// A 128-bit vector of [2 x double]. The upper 64 bits of this operand are
3366/// copied to the upper 64 bits of the destination.
3367/// \param __b
3368/// A 64-bit signed integer operand containing the value to be converted.
3369/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
3370/// converted value of the second operand. The upper 64 bits are copied from
3371/// the upper 64 bits of the first operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00003372static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003373_mm_cvtsi64_sd(__m128d __a, long long __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003374{
David Blaikie3302f2b2013-01-16 23:08:36 +00003375 __a[0] = __b;
3376 return __a;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003377}
3378
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003379/// \brief Converts the first (lower) element of a vector of [2 x double] into a
3380/// 64-bit signed integer value, according to the current rounding mode.
3381///
3382/// \headerfile <x86intrin.h>
3383///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003384/// This intrinsic corresponds to the <c> VCVTSD2SI / CVTSD2SI </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003385///
3386/// \param __a
3387/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the
3388/// conversion.
3389/// \returns A 64-bit signed integer containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00003390static __inline__ long long __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003391_mm_cvtsd_si64(__m128d __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003392{
Craig Topper1aa231e2016-05-16 06:38:42 +00003393 return __builtin_ia32_cvtsd2si64((__v2df)__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003394}
3395
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003396/// \brief Converts the first (lower) element of a vector of [2 x double] into a
3397/// 64-bit signed integer value, truncating the result when it is inexact.
3398///
3399/// \headerfile <x86intrin.h>
3400///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00003401/// This intrinsic corresponds to the <c> VCVTTSD2SI / CVTTSD2SI </c>
3402/// instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003403///
3404/// \param __a
3405/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the
3406/// conversion.
3407/// \returns A 64-bit signed integer containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00003408static __inline__ long long __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003409_mm_cvttsd_si64(__m128d __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003410{
Simon Pilgrime3b9ee02016-07-20 10:18:01 +00003411 return __builtin_ia32_cvttsd2si64((__v2df)__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003412}
3413#endif
3414
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003415/// \brief Converts a vector of [4 x i32] into a vector of [4 x float].
3416///
3417/// \headerfile <x86intrin.h>
3418///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003419/// This intrinsic corresponds to the <c> VCVTDQ2PS / CVTDQ2PS </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003420///
3421/// \param __a
3422/// A 128-bit integer vector.
3423/// \returns A 128-bit vector of [4 x float] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003424static __inline__ __m128 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003425_mm_cvtepi32_ps(__m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003426{
David Blaikie3302f2b2013-01-16 23:08:36 +00003427 return __builtin_ia32_cvtdq2ps((__v4si)__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003428}
3429
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003430/// \brief Converts a vector of [4 x float] into a vector of [4 x i32].
3431///
3432/// \headerfile <x86intrin.h>
3433///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003434/// This intrinsic corresponds to the <c> VCVTPS2DQ / CVTPS2DQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003435///
3436/// \param __a
3437/// A 128-bit vector of [4 x float].
3438/// \returns A 128-bit integer vector of [4 x i32] containing the converted
3439/// values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003440static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003441_mm_cvtps_epi32(__m128 __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003442{
Craig Topper1aa231e2016-05-16 06:38:42 +00003443 return (__m128i)__builtin_ia32_cvtps2dq((__v4sf)__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003444}
3445
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003446/// \brief Converts a vector of [4 x float] into a vector of [4 x i32],
3447/// truncating the result when it is inexact.
3448///
3449/// \headerfile <x86intrin.h>
3450///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00003451/// This intrinsic corresponds to the <c> VCVTTPS2DQ / CVTTPS2DQ </c>
3452/// instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003453///
3454/// \param __a
3455/// A 128-bit vector of [4 x float].
3456/// \returns A 128-bit vector of [4 x i32] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003457static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003458_mm_cvttps_epi32(__m128 __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003459{
Simon Pilgrime3b9ee02016-07-20 10:18:01 +00003460 return (__m128i)__builtin_ia32_cvttps2dq((__v4sf)__a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003461}
3462
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003463/// \brief Returns a vector of [4 x i32] where the lowest element is the input
3464/// operand and the remaining elements are zero.
3465///
3466/// \headerfile <x86intrin.h>
3467///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003468/// This intrinsic corresponds to the <c> VMOVD / MOVD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003469///
3470/// \param __a
3471/// A 32-bit signed integer operand.
3472/// \returns A 128-bit vector of [4 x i32].
Michael Kupersteine45af542015-06-30 13:36:19 +00003473static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003474_mm_cvtsi32_si128(int __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003475{
David Blaikie3302f2b2013-01-16 23:08:36 +00003476 return (__m128i)(__v4si){ __a, 0, 0, 0 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003477}
3478
3479#ifdef __x86_64__
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003480/// \brief Returns a vector of [2 x i64] where the lower element is the input
3481/// operand and the upper element is zero.
3482///
3483/// \headerfile <x86intrin.h>
3484///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003485/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003486///
3487/// \param __a
3488/// A 64-bit signed integer operand containing the value to be converted.
3489/// \returns A 128-bit vector of [2 x i64] containing the converted value.
Michael Kupersteine45af542015-06-30 13:36:19 +00003490static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003491_mm_cvtsi64_si128(long long __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003492{
David Blaikie3302f2b2013-01-16 23:08:36 +00003493 return (__m128i){ __a, 0 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003494}
3495#endif
3496
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003497/// \brief Moves the least significant 32 bits of a vector of [4 x i32] to a
3498/// 32-bit signed integer value.
3499///
3500/// \headerfile <x86intrin.h>
3501///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003502/// This intrinsic corresponds to the <c> VMOVD / MOVD </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003503///
3504/// \param __a
3505/// A vector of [4 x i32]. The least significant 32 bits are moved to the
3506/// destination.
3507/// \returns A 32-bit signed integer containing the moved value.
Michael Kupersteine45af542015-06-30 13:36:19 +00003508static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003509_mm_cvtsi128_si32(__m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003510{
David Blaikie3302f2b2013-01-16 23:08:36 +00003511 __v4si __b = (__v4si)__a;
3512 return __b[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003513}
3514
3515#ifdef __x86_64__
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003516/// \brief Moves the least significant 64 bits of a vector of [2 x i64] to a
3517/// 64-bit signed integer value.
3518///
3519/// \headerfile <x86intrin.h>
3520///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003521/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003522///
3523/// \param __a
3524/// A vector of [2 x i64]. The least significant 64 bits are moved to the
3525/// destination.
3526/// \returns A 64-bit signed integer containing the moved value.
Michael Kupersteine45af542015-06-30 13:36:19 +00003527static __inline__ long long __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003528_mm_cvtsi128_si64(__m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003529{
David Blaikie3302f2b2013-01-16 23:08:36 +00003530 return __a[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003531}
3532#endif
3533
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003534/// \brief Moves packed integer values from an aligned 128-bit memory location
3535/// to elements in a 128-bit integer vector.
3536///
3537/// \headerfile <x86intrin.h>
3538///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003539/// This intrinsic corresponds to the <c> VMOVDQA / MOVDQA </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003540///
3541/// \param __p
3542/// An aligned pointer to a memory location containing integer values.
3543/// \returns A 128-bit integer vector containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003544static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003545_mm_load_si128(__m128i const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003546{
David Blaikie3302f2b2013-01-16 23:08:36 +00003547 return *__p;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003548}
3549
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003550/// \brief Moves packed integer values from an unaligned 128-bit memory location
3551/// to elements in a 128-bit integer vector.
3552///
3553/// \headerfile <x86intrin.h>
3554///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003555/// This intrinsic corresponds to the <c> VMOVDQU / MOVDQU </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003556///
3557/// \param __p
3558/// A pointer to a memory location containing integer values.
3559/// \returns A 128-bit integer vector containing the moved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00003560static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003561_mm_loadu_si128(__m128i const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003562{
Bill Wendling502931f2011-05-13 00:11:39 +00003563 struct __loadu_si128 {
David Blaikie3302f2b2013-01-16 23:08:36 +00003564 __m128i __v;
David Majnemer1cf22e62015-02-04 00:26:10 +00003565 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00003566 return ((struct __loadu_si128*)__p)->__v;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003567}
3568
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003569/// \brief Returns a vector of [2 x i64] where the lower element is taken from
3570/// the lower element of the operand, and the upper element is zero.
3571///
3572/// \headerfile <x86intrin.h>
3573///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003574/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003575///
3576/// \param __p
3577/// A 128-bit vector of [2 x i64]. Bits [63:0] are written to bits [63:0] of
3578/// the destination.
3579/// \returns A 128-bit vector of [2 x i64]. The lower order bits contain the
3580/// moved value. The higher order bits are cleared.
Michael Kupersteine45af542015-06-30 13:36:19 +00003581static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003582_mm_loadl_epi64(__m128i const *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003583{
Eli Friedman9bb51ad2011-09-15 23:15:27 +00003584 struct __mm_loadl_epi64_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00003585 long long __u;
Eli Friedman9bb51ad2011-09-15 23:15:27 +00003586 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00003587 return (__m128i) { ((struct __mm_loadl_epi64_struct*)__p)->__u, 0};
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003588}
3589
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003590/// \brief Generates a 128-bit vector of [4 x i32] with unspecified content.
3591/// This could be used as an argument to another intrinsic function where the
3592/// argument is required but the value is not actually used.
3593///
3594/// \headerfile <x86intrin.h>
3595///
3596/// This intrinsic has no corresponding instruction.
3597///
3598/// \returns A 128-bit vector of [4 x i32] with unspecified content.
Michael Kupersteine45af542015-06-30 13:36:19 +00003599static __inline__ __m128i __DEFAULT_FN_ATTRS
Craig Topper3a0c7262016-06-09 05:14:28 +00003600_mm_undefined_si128(void)
Simon Pilgrim5aba9922015-08-26 21:17:12 +00003601{
3602 return (__m128i)__builtin_ia32_undef128();
3603}
3604
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003605/// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with
3606/// the specified 64-bit integer values.
3607///
3608/// \headerfile <x86intrin.h>
3609///
3610/// This intrinsic is a utility function and does not correspond to a specific
3611/// instruction.
3612///
3613/// \param __q1
3614/// A 64-bit integer value used to initialize the upper 64 bits of the
3615/// destination vector of [2 x i64].
3616/// \param __q0
3617/// A 64-bit integer value used to initialize the lower 64 bits of the
3618/// destination vector of [2 x i64].
3619/// \returns An initialized 128-bit vector of [2 x i64] containing the values
3620/// provided in the operands.
Simon Pilgrim5aba9922015-08-26 21:17:12 +00003621static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003622_mm_set_epi64x(long long __q1, long long __q0)
Anders Carlssondfa31172009-09-18 17:03:55 +00003623{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003624 return (__m128i){ __q0, __q1 };
Anders Carlssondfa31172009-09-18 17:03:55 +00003625}
3626
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003627/// \brief Initializes both 64-bit values in a 128-bit vector of [2 x i64] with
3628/// the specified 64-bit integer values.
3629///
3630/// \headerfile <x86intrin.h>
3631///
3632/// This intrinsic is a utility function and does not correspond to a specific
3633/// instruction.
3634///
3635/// \param __q1
3636/// A 64-bit integer value used to initialize the upper 64 bits of the
3637/// destination vector of [2 x i64].
3638/// \param __q0
3639/// A 64-bit integer value used to initialize the lower 64 bits of the
3640/// destination vector of [2 x i64].
3641/// \returns An initialized 128-bit vector of [2 x i64] containing the values
3642/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00003643static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003644_mm_set_epi64(__m64 __q1, __m64 __q0)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003645{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003646 return (__m128i){ (long long)__q0, (long long)__q1 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003647}
3648
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003649/// \brief Initializes the 32-bit values in a 128-bit vector of [4 x i32] with
3650/// the specified 32-bit integer values.
3651///
3652/// \headerfile <x86intrin.h>
3653///
3654/// This intrinsic is a utility function and does not correspond to a specific
3655/// instruction.
3656///
3657/// \param __i3
3658/// A 32-bit integer value used to initialize bits [127:96] of the
3659/// destination vector.
3660/// \param __i2
3661/// A 32-bit integer value used to initialize bits [95:64] of the destination
3662/// vector.
3663/// \param __i1
3664/// A 32-bit integer value used to initialize bits [63:32] of the destination
3665/// vector.
3666/// \param __i0
3667/// A 32-bit integer value used to initialize bits [31:0] of the destination
3668/// vector.
3669/// \returns An initialized 128-bit vector of [4 x i32] containing the values
3670/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00003671static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003672_mm_set_epi32(int __i3, int __i2, int __i1, int __i0)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003673{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003674 return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003675}
3676
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003677/// \brief Initializes the 16-bit values in a 128-bit vector of [8 x i16] with
3678/// the specified 16-bit integer values.
3679///
3680/// \headerfile <x86intrin.h>
3681///
3682/// This intrinsic is a utility function and does not correspond to a specific
3683/// instruction.
3684///
3685/// \param __w7
3686/// A 16-bit integer value used to initialize bits [127:112] of the
3687/// destination vector.
3688/// \param __w6
3689/// A 16-bit integer value used to initialize bits [111:96] of the
3690/// destination vector.
3691/// \param __w5
3692/// A 16-bit integer value used to initialize bits [95:80] of the destination
3693/// vector.
3694/// \param __w4
3695/// A 16-bit integer value used to initialize bits [79:64] of the destination
3696/// vector.
3697/// \param __w3
3698/// A 16-bit integer value used to initialize bits [63:48] of the destination
3699/// vector.
3700/// \param __w2
3701/// A 16-bit integer value used to initialize bits [47:32] of the destination
3702/// vector.
3703/// \param __w1
3704/// A 16-bit integer value used to initialize bits [31:16] of the destination
3705/// vector.
3706/// \param __w0
3707/// A 16-bit integer value used to initialize bits [15:0] of the destination
3708/// vector.
3709/// \returns An initialized 128-bit vector of [8 x i16] containing the values
3710/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00003711static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003712_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 +00003713{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003714 return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003715}
3716
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003717/// \brief Initializes the 8-bit values in a 128-bit vector of [16 x i8] with
3718/// the specified 8-bit integer values.
3719///
3720/// \headerfile <x86intrin.h>
3721///
3722/// This intrinsic is a utility function and does not correspond to a specific
3723/// instruction.
3724///
3725/// \param __b15
3726/// Initializes bits [127:120] of the destination vector.
3727/// \param __b14
3728/// Initializes bits [119:112] of the destination vector.
3729/// \param __b13
3730/// Initializes bits [111:104] of the destination vector.
3731/// \param __b12
3732/// Initializes bits [103:96] of the destination vector.
3733/// \param __b11
3734/// Initializes bits [95:88] of the destination vector.
3735/// \param __b10
3736/// Initializes bits [87:80] of the destination vector.
3737/// \param __b9
3738/// Initializes bits [79:72] of the destination vector.
3739/// \param __b8
3740/// Initializes bits [71:64] of the destination vector.
3741/// \param __b7
3742/// Initializes bits [63:56] of the destination vector.
3743/// \param __b6
3744/// Initializes bits [55:48] of the destination vector.
3745/// \param __b5
3746/// Initializes bits [47:40] of the destination vector.
3747/// \param __b4
3748/// Initializes bits [39:32] of the destination vector.
3749/// \param __b3
3750/// Initializes bits [31:24] of the destination vector.
3751/// \param __b2
3752/// Initializes bits [23:16] of the destination vector.
3753/// \param __b1
3754/// Initializes bits [15:8] of the destination vector.
3755/// \param __b0
3756/// Initializes bits [7:0] of the destination vector.
3757/// \returns An initialized 128-bit vector of [16 x i8] containing the values
3758/// provided in the operands.
Michael Kupersteine45af542015-06-30 13:36:19 +00003759static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003760_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 +00003761{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003762 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 +00003763}
3764
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003765/// \brief Initializes both values in a 128-bit integer vector with the
3766/// specified 64-bit integer value.
3767///
3768/// \headerfile <x86intrin.h>
3769///
3770/// This intrinsic is a utility function and does not correspond to a specific
3771/// instruction.
3772///
3773/// \param __q
3774/// Integer value used to initialize the elements of the destination integer
3775/// vector.
3776/// \returns An initialized 128-bit integer vector of [2 x i64] with both
3777/// elements containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00003778static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003779_mm_set1_epi64x(long long __q)
Anders Carlssondfa31172009-09-18 17:03:55 +00003780{
David Blaikie3302f2b2013-01-16 23:08:36 +00003781 return (__m128i){ __q, __q };
Anders Carlssondfa31172009-09-18 17:03:55 +00003782}
3783
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003784/// \brief Initializes both values in a 128-bit vector of [2 x i64] with the
3785/// specified 64-bit value.
3786///
3787/// \headerfile <x86intrin.h>
3788///
3789/// This intrinsic is a utility function and does not correspond to a specific
3790/// instruction.
3791///
3792/// \param __q
3793/// A 64-bit value used to initialize the elements of the destination integer
3794/// vector.
3795/// \returns An initialized 128-bit vector of [2 x i64] with all elements
3796/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00003797static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003798_mm_set1_epi64(__m64 __q)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003799{
David Blaikie3302f2b2013-01-16 23:08:36 +00003800 return (__m128i){ (long long)__q, (long long)__q };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003801}
3802
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003803/// \brief Initializes all values in a 128-bit vector of [4 x i32] with the
3804/// specified 32-bit value.
3805///
3806/// \headerfile <x86intrin.h>
3807///
3808/// This intrinsic is a utility function and does not correspond to a specific
3809/// instruction.
3810///
3811/// \param __i
3812/// A 32-bit value used to initialize the elements of the destination integer
3813/// vector.
3814/// \returns An initialized 128-bit vector of [4 x i32] with all elements
3815/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00003816static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003817_mm_set1_epi32(int __i)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003818{
David Blaikie3302f2b2013-01-16 23:08:36 +00003819 return (__m128i)(__v4si){ __i, __i, __i, __i };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003820}
3821
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003822/// \brief Initializes all values in a 128-bit vector of [8 x i16] with the
3823/// specified 16-bit value.
3824///
3825/// \headerfile <x86intrin.h>
3826///
3827/// This intrinsic is a utility function and does not correspond to a specific
3828/// instruction.
3829///
3830/// \param __w
3831/// A 16-bit value used to initialize the elements of the destination integer
3832/// vector.
3833/// \returns An initialized 128-bit vector of [8 x i16] with all elements
3834/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00003835static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003836_mm_set1_epi16(short __w)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003837{
David Blaikie3302f2b2013-01-16 23:08:36 +00003838 return (__m128i)(__v8hi){ __w, __w, __w, __w, __w, __w, __w, __w };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003839}
3840
Ekaterina Romanovaf2ed6202016-04-08 20:45:48 +00003841/// \brief Initializes all values in a 128-bit vector of [16 x i8] with the
3842/// specified 8-bit value.
3843///
3844/// \headerfile <x86intrin.h>
3845///
3846/// This intrinsic is a utility function and does not correspond to a specific
3847/// instruction.
3848///
3849/// \param __b
3850/// An 8-bit value used to initialize the elements of the destination integer
3851/// vector.
3852/// \returns An initialized 128-bit vector of [16 x i8] with all elements
3853/// containing the value provided in the operand.
Michael Kupersteine45af542015-06-30 13:36:19 +00003854static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00003855_mm_set1_epi8(char __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003856{
David Blaikie3302f2b2013-01-16 23:08:36 +00003857 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 +00003858}
3859
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003860/// \brief Constructs a 128-bit integer vector, initialized in reverse order
3861/// with the specified 64-bit integral values.
3862///
3863/// \headerfile <x86intrin.h>
3864///
Douglas Yung0686df102018-01-02 20:39:29 +00003865/// This intrinsic does not correspond to a specific instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003866///
3867/// \param __q0
3868/// A 64-bit integral value used to initialize the lower 64 bits of the
3869/// result.
3870/// \param __q1
3871/// A 64-bit integral value used to initialize the upper 64 bits of the
3872/// result.
3873/// \returns An initialized 128-bit integer vector.
Michael Kupersteine45af542015-06-30 13:36:19 +00003874static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003875_mm_setr_epi64(__m64 __q0, __m64 __q1)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003876{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003877 return (__m128i){ (long long)__q0, (long long)__q1 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003878}
3879
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003880/// \brief Constructs a 128-bit integer vector, initialized in reverse order
3881/// with the specified 32-bit integral values.
3882///
3883/// \headerfile <x86intrin.h>
3884///
3885/// This intrinsic is a utility function and does not correspond to a specific
3886/// instruction.
3887///
3888/// \param __i0
3889/// A 32-bit integral value used to initialize bits [31:0] of the result.
3890/// \param __i1
3891/// A 32-bit integral value used to initialize bits [63:32] of the result.
3892/// \param __i2
3893/// A 32-bit integral value used to initialize bits [95:64] of the result.
3894/// \param __i3
3895/// A 32-bit integral value used to initialize bits [127:96] of the result.
3896/// \returns An initialized 128-bit integer vector.
Michael Kupersteine45af542015-06-30 13:36:19 +00003897static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003898_mm_setr_epi32(int __i0, int __i1, int __i2, int __i3)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003899{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003900 return (__m128i)(__v4si){ __i0, __i1, __i2, __i3};
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003901}
3902
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003903/// \brief Constructs a 128-bit integer vector, initialized in reverse order
3904/// with the specified 16-bit integral values.
3905///
3906/// \headerfile <x86intrin.h>
3907///
3908/// This intrinsic is a utility function and does not correspond to a specific
3909/// instruction.
3910///
3911/// \param __w0
3912/// A 16-bit integral value used to initialize bits [15:0] of the result.
3913/// \param __w1
3914/// A 16-bit integral value used to initialize bits [31:16] of the result.
3915/// \param __w2
3916/// A 16-bit integral value used to initialize bits [47:32] of the result.
3917/// \param __w3
3918/// A 16-bit integral value used to initialize bits [63:48] of the result.
3919/// \param __w4
3920/// A 16-bit integral value used to initialize bits [79:64] of the result.
3921/// \param __w5
3922/// A 16-bit integral value used to initialize bits [95:80] of the result.
3923/// \param __w6
3924/// A 16-bit integral value used to initialize bits [111:96] of the result.
3925/// \param __w7
3926/// A 16-bit integral value used to initialize bits [127:112] of the result.
3927/// \returns An initialized 128-bit integer vector.
Michael Kupersteine45af542015-06-30 13:36:19 +00003928static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003929_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 +00003930{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003931 return (__m128i)(__v8hi){ __w0, __w1, __w2, __w3, __w4, __w5, __w6, __w7 };
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003932}
3933
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003934/// \brief Constructs a 128-bit integer vector, initialized in reverse order
3935/// with the specified 8-bit integral values.
3936///
3937/// \headerfile <x86intrin.h>
3938///
3939/// This intrinsic is a utility function and does not correspond to a specific
3940/// instruction.
3941///
3942/// \param __b0
3943/// An 8-bit integral value used to initialize bits [7:0] of the result.
3944/// \param __b1
3945/// An 8-bit integral value used to initialize bits [15:8] of the result.
3946/// \param __b2
3947/// An 8-bit integral value used to initialize bits [23:16] of the result.
3948/// \param __b3
3949/// An 8-bit integral value used to initialize bits [31:24] of the result.
3950/// \param __b4
3951/// An 8-bit integral value used to initialize bits [39:32] of the result.
3952/// \param __b5
3953/// An 8-bit integral value used to initialize bits [47:40] of the result.
3954/// \param __b6
3955/// An 8-bit integral value used to initialize bits [55:48] of the result.
3956/// \param __b7
3957/// An 8-bit integral value used to initialize bits [63:56] of the result.
3958/// \param __b8
3959/// An 8-bit integral value used to initialize bits [71:64] of the result.
3960/// \param __b9
3961/// An 8-bit integral value used to initialize bits [79:72] of the result.
3962/// \param __b10
3963/// An 8-bit integral value used to initialize bits [87:80] of the result.
3964/// \param __b11
3965/// An 8-bit integral value used to initialize bits [95:88] of the result.
3966/// \param __b12
3967/// An 8-bit integral value used to initialize bits [103:96] of the result.
3968/// \param __b13
3969/// An 8-bit integral value used to initialize bits [111:104] of the result.
3970/// \param __b14
3971/// An 8-bit integral value used to initialize bits [119:112] of the result.
3972/// \param __b15
3973/// An 8-bit integral value used to initialize bits [127:120] of the result.
3974/// \returns An initialized 128-bit integer vector.
Michael Kupersteine45af542015-06-30 13:36:19 +00003975static __inline__ __m128i __DEFAULT_FN_ATTRS
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003976_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 +00003977{
Michael Kuperstein5c2cb0e2015-09-21 11:45:27 +00003978 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 +00003979}
3980
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003981/// \brief Creates a 128-bit integer vector initialized to zero.
3982///
3983/// \headerfile <x86intrin.h>
3984///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00003985/// This intrinsic corresponds to the <c> VXORPS / XORPS </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003986///
3987/// \returns An initialized 128-bit integer vector with all elements set to
3988/// zero.
Michael Kupersteine45af542015-06-30 13:36:19 +00003989static __inline__ __m128i __DEFAULT_FN_ATTRS
Mike Stump5b31ed32009-02-13 14:24:50 +00003990_mm_setzero_si128(void)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00003991{
3992 return (__m128i){ 0LL, 0LL };
3993}
3994
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00003995/// \brief Stores a 128-bit integer vector to a memory location aligned on a
3996/// 128-bit boundary.
3997///
3998/// \headerfile <x86intrin.h>
3999///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004000/// This intrinsic corresponds to the <c> VMOVAPS / MOVAPS </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004001///
4002/// \param __p
4003/// A pointer to an aligned memory location that will receive the integer
4004/// values.
4005/// \param __b
4006/// A 128-bit integer vector containing the values to be moved.
Michael Kupersteine45af542015-06-30 13:36:19 +00004007static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004008_mm_store_si128(__m128i *__p, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004009{
David Blaikie3302f2b2013-01-16 23:08:36 +00004010 *__p = __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004011}
4012
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004013/// \brief Stores a 128-bit integer vector to an unaligned memory location.
4014///
4015/// \headerfile <x86intrin.h>
4016///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004017/// This intrinsic corresponds to the <c> VMOVUPS / MOVUPS </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004018///
4019/// \param __p
4020/// A pointer to a memory location that will receive the integer values.
4021/// \param __b
4022/// A 128-bit integer vector containing the values to be moved.
Michael Kupersteine45af542015-06-30 13:36:19 +00004023static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004024_mm_storeu_si128(__m128i *__p, __m128i __b)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004025{
Craig Topper09175da2016-05-30 17:10:30 +00004026 struct __storeu_si128 {
4027 __m128i __v;
4028 } __attribute__((__packed__, __may_alias__));
4029 ((struct __storeu_si128*)__p)->__v = __b;
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004030}
4031
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004032/// \brief Moves bytes selected by the mask from the first operand to the
4033/// specified unaligned memory location. When a mask bit is 1, the
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00004034/// corresponding byte is written, otherwise it is not written.
4035///
Douglas Yung0686df102018-01-02 20:39:29 +00004036/// To minimize caching, the data is flagged as non-temporal (unlikely to be
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00004037/// used again soon). Exception and trap behavior for elements not selected
4038/// for storage to memory are implementation dependent.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004039///
4040/// \headerfile <x86intrin.h>
4041///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004042/// This intrinsic corresponds to the <c> VMASKMOVDQU / MASKMOVDQU </c>
4043/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004044///
4045/// \param __d
4046/// A 128-bit integer vector containing the values to be moved.
4047/// \param __n
4048/// A 128-bit integer vector containing the mask. The most significant bit of
4049/// each byte represents the mask bits.
4050/// \param __p
4051/// A pointer to an unaligned 128-bit memory location where the specified
4052/// values are moved.
Michael Kupersteine45af542015-06-30 13:36:19 +00004053static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004054_mm_maskmoveu_si128(__m128i __d, __m128i __n, char *__p)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004055{
David Blaikie3302f2b2013-01-16 23:08:36 +00004056 __builtin_ia32_maskmovdqu((__v16qi)__d, (__v16qi)__n, __p);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004057}
4058
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004059/// \brief Stores the lower 64 bits of a 128-bit integer vector of [2 x i64] to
4060/// a memory location.
4061///
4062/// \headerfile <x86intrin.h>
4063///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004064/// This intrinsic corresponds to the <c> VMOVLPS / MOVLPS </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004065///
4066/// \param __p
4067/// A pointer to a 64-bit memory location that will receive the lower 64 bits
4068/// of the integer vector parameter.
4069/// \param __a
4070/// A 128-bit integer vector of [2 x i64]. The lower 64 bits contain the
4071/// value to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00004072static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004073_mm_storel_epi64(__m128i *__p, __m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004074{
Chad Rosier87622b82012-05-01 18:11:51 +00004075 struct __mm_storel_epi64_struct {
David Blaikie3302f2b2013-01-16 23:08:36 +00004076 long long __u;
Chad Rosier87622b82012-05-01 18:11:51 +00004077 } __attribute__((__packed__, __may_alias__));
David Blaikie3302f2b2013-01-16 23:08:36 +00004078 ((struct __mm_storel_epi64_struct*)__p)->__u = __a[0];
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004079}
4080
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004081/// \brief Stores a 128-bit floating point vector of [2 x double] to a 128-bit
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00004082/// aligned memory location.
4083///
4084/// To minimize caching, the data is flagged as non-temporal (unlikely to be
4085/// used again soon).
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004086///
4087/// \headerfile <x86intrin.h>
4088///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004089/// This intrinsic corresponds to the <c> VMOVNTPS / MOVNTPS </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004090///
4091/// \param __p
4092/// A pointer to the 128-bit aligned memory location used to store the value.
4093/// \param __a
4094/// A vector of [2 x double] containing the 64-bit values to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00004095static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004096_mm_stream_pd(double *__p, __m128d __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004097{
Simon Pilgrimbeca5f22016-06-13 09:57:52 +00004098 __builtin_nontemporal_store((__v2df)__a, (__v2df*)__p);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004099}
4100
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004101/// \brief Stores a 128-bit integer vector to a 128-bit aligned memory location.
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00004102///
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004103/// To minimize caching, the data is flagged as non-temporal (unlikely to be
4104/// used again soon).
4105///
4106/// \headerfile <x86intrin.h>
4107///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004108/// This intrinsic corresponds to the <c> VMOVNTPS / MOVNTPS </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004109///
4110/// \param __p
4111/// A pointer to the 128-bit aligned memory location used to store the value.
4112/// \param __a
4113/// A 128-bit integer vector containing the values to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00004114static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004115_mm_stream_si128(__m128i *__p, __m128i __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004116{
Simon Pilgrimbeca5f22016-06-13 09:57:52 +00004117 __builtin_nontemporal_store((__v2di)__a, (__v2di*)__p);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004118}
4119
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00004120/// \brief Stores a 32-bit integer value in the specified memory location.
4121///
4122/// To minimize caching, the data is flagged as non-temporal (unlikely to be
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004123/// used again soon).
4124///
4125/// \headerfile <x86intrin.h>
4126///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004127/// This intrinsic corresponds to the <c> MOVNTI </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004128///
4129/// \param __p
4130/// A pointer to the 32-bit memory location used to store the value.
4131/// \param __a
4132/// A 32-bit integer containing the value to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00004133static __inline__ void __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004134_mm_stream_si32(int *__p, int __a)
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004135{
David Blaikie3302f2b2013-01-16 23:08:36 +00004136 __builtin_ia32_movnti(__p, __a);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004137}
4138
Eli Friedmanf9d8c6c2013-09-23 23:38:39 +00004139#ifdef __x86_64__
Ekaterina Romanova1d4a0f22017-05-15 03:25:04 +00004140/// \brief Stores a 64-bit integer value in the specified memory location.
4141///
4142/// To minimize caching, the data is flagged as non-temporal (unlikely to be
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004143/// used again soon).
4144///
4145/// \headerfile <x86intrin.h>
4146///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004147/// This intrinsic corresponds to the <c> MOVNTIQ </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004148///
4149/// \param __p
4150/// A pointer to the 64-bit memory location used to store the value.
4151/// \param __a
4152/// A 64-bit integer containing the value to be stored.
Michael Kupersteine45af542015-06-30 13:36:19 +00004153static __inline__ void __DEFAULT_FN_ATTRS
Eli Friedmanf9d8c6c2013-09-23 23:38:39 +00004154_mm_stream_si64(long long *__p, long long __a)
4155{
4156 __builtin_ia32_movnti64(__p, __a);
4157}
4158#endif
4159
Albert Gutowski727ab8a2016-09-14 21:19:43 +00004160#if defined(__cplusplus)
4161extern "C" {
4162#endif
4163
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004164/// \brief The cache line containing \a __p is flushed and invalidated from all
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004165/// caches in the coherency domain.
4166///
4167/// \headerfile <x86intrin.h>
4168///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004169/// This intrinsic corresponds to the <c> CLFLUSH </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004170///
4171/// \param __p
4172/// A pointer to the memory location used to identify the cache line to be
4173/// flushed.
Ekaterina Romanova2e041c92017-01-13 01:14:08 +00004174void _mm_clflush(void const * __p);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004175
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004176/// \brief Forces strong memory ordering (serialization) between load
4177/// instructions preceding this instruction and load instructions following
4178/// this instruction, ensuring the system completes all previous loads before
4179/// executing subsequent loads.
4180///
4181/// \headerfile <x86intrin.h>
4182///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004183/// This intrinsic corresponds to the <c> LFENCE </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004184///
Albert Gutowski727ab8a2016-09-14 21:19:43 +00004185void _mm_lfence(void);
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004186
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004187/// \brief Forces strong memory ordering (serialization) between load and store
4188/// instructions preceding this instruction and load and store instructions
4189/// following this instruction, ensuring that the system completes all
4190/// previous memory accesses before executing subsequent memory accesses.
4191///
4192/// \headerfile <x86intrin.h>
4193///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004194/// This intrinsic corresponds to the <c> MFENCE </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004195///
Albert Gutowski727ab8a2016-09-14 21:19:43 +00004196void _mm_mfence(void);
4197
4198#if defined(__cplusplus)
4199} // extern "C"
4200#endif
Anders Carlssona0d5ca22008-12-25 23:48:58 +00004201
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004202/// \brief Converts 16-bit signed integers from both 128-bit integer vector
4203/// operands into 8-bit signed integers, and packs the results into the
4204/// destination. Positive values greater than 0x7F are saturated to 0x7F.
4205/// Negative values less than 0x80 are saturated to 0x80.
4206///
4207/// \headerfile <x86intrin.h>
4208///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004209/// This intrinsic corresponds to the <c> VPACKSSWB / PACKSSWB </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004210///
4211/// \param __a
4212/// A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4213/// a signed integer and is converted to a 8-bit signed integer with
4214/// saturation. Values greater than 0x7F are saturated to 0x7F. Values less
4215/// than 0x80 are saturated to 0x80. The converted [8 x i8] values are
4216/// written to the lower 64 bits of the result.
4217/// \param __b
4218/// A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4219/// a signed integer and is converted to a 8-bit signed integer with
4220/// saturation. Values greater than 0x7F are saturated to 0x7F. Values less
4221/// than 0x80 are saturated to 0x80. The converted [8 x i8] values are
4222/// written to the higher 64 bits of the result.
4223/// \returns A 128-bit vector of [16 x i8] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004224static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004225_mm_packs_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004226{
David Blaikie3302f2b2013-01-16 23:08:36 +00004227 return (__m128i)__builtin_ia32_packsswb128((__v8hi)__a, (__v8hi)__b);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004228}
4229
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004230/// \brief Converts 32-bit signed integers from both 128-bit integer vector
4231/// operands into 16-bit signed integers, and packs the results into the
4232/// destination. Positive values greater than 0x7FFF are saturated to 0x7FFF.
4233/// Negative values less than 0x8000 are saturated to 0x8000.
4234///
4235/// \headerfile <x86intrin.h>
4236///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004237/// This intrinsic corresponds to the <c> VPACKSSDW / PACKSSDW </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004238///
4239/// \param __a
4240/// A 128-bit integer vector of [4 x i32]. Each 32-bit element is treated as
4241/// a signed integer and is converted to a 16-bit signed integer with
4242/// saturation. Values greater than 0x7FFF are saturated to 0x7FFF. Values
4243/// less than 0x8000 are saturated to 0x8000. The converted [4 x i16] values
4244/// are written to the lower 64 bits of the result.
4245/// \param __b
4246/// A 128-bit integer vector of [4 x i32]. Each 32-bit element is treated as
4247/// a signed integer and is converted to a 16-bit signed integer with
4248/// saturation. Values greater than 0x7FFF are saturated to 0x7FFF. Values
4249/// less than 0x8000 are saturated to 0x8000. The converted [4 x i16] values
4250/// are written to the higher 64 bits of the result.
4251/// \returns A 128-bit vector of [8 x i16] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004252static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004253_mm_packs_epi32(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004254{
David Blaikie3302f2b2013-01-16 23:08:36 +00004255 return (__m128i)__builtin_ia32_packssdw128((__v4si)__a, (__v4si)__b);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004256}
4257
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004258/// \brief Converts 16-bit signed integers from both 128-bit integer vector
4259/// operands into 8-bit unsigned integers, and packs the results into the
4260/// destination. Values greater than 0xFF are saturated to 0xFF. Values less
4261/// than 0x00 are saturated to 0x00.
4262///
4263/// \headerfile <x86intrin.h>
4264///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004265/// This intrinsic corresponds to the <c> VPACKUSWB / PACKUSWB </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004266///
4267/// \param __a
4268/// A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4269/// a signed integer and is converted to an 8-bit unsigned integer with
4270/// saturation. Values greater than 0xFF are saturated to 0xFF. Values less
4271/// than 0x00 are saturated to 0x00. The converted [8 x i8] values are
4272/// written to the lower 64 bits of the result.
4273/// \param __b
4274/// A 128-bit integer vector of [8 x i16]. Each 16-bit element is treated as
4275/// a signed integer and is converted to an 8-bit unsigned integer with
4276/// saturation. Values greater than 0xFF are saturated to 0xFF. Values less
4277/// than 0x00 are saturated to 0x00. The converted [8 x i8] values are
4278/// written to the higher 64 bits of the result.
4279/// \returns A 128-bit vector of [16 x i8] containing the converted values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004280static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004281_mm_packus_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004282{
David Blaikie3302f2b2013-01-16 23:08:36 +00004283 return (__m128i)__builtin_ia32_packuswb128((__v8hi)__a, (__v8hi)__b);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004284}
4285
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004286/// \brief Extracts 16 bits from a 128-bit integer vector of [8 x i16], using
4287/// the immediate-value parameter as a selector.
4288///
4289/// \headerfile <x86intrin.h>
4290///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004291/// This intrinsic corresponds to the <c> VPEXTRW / PEXTRW </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004292///
4293/// \param __a
4294/// A 128-bit integer vector.
4295/// \param __imm
Ekaterina Romanova2e041c92017-01-13 01:14:08 +00004296/// An immediate value. Bits [2:0] selects values from \a __a to be assigned
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004297/// to bits[15:0] of the result. \n
4298/// 000: assign values from bits [15:0] of \a __a. \n
4299/// 001: assign values from bits [31:16] of \a __a. \n
4300/// 010: assign values from bits [47:32] of \a __a. \n
4301/// 011: assign values from bits [63:48] of \a __a. \n
4302/// 100: assign values from bits [79:64] of \a __a. \n
4303/// 101: assign values from bits [95:80] of \a __a. \n
4304/// 110: assign values from bits [111:96] of \a __a. \n
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004305/// 111: assign values from bits [127:112] of \a __a.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004306/// \returns An integer, whose lower 16 bits are selected from the 128-bit
4307/// integer vector parameter and the remaining bits are assigned zeros.
Michael Kupersteine45af542015-06-30 13:36:19 +00004308static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004309_mm_extract_epi16(__m128i __a, int __imm)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004310{
David Blaikie3302f2b2013-01-16 23:08:36 +00004311 __v8hi __b = (__v8hi)__a;
Manman Renbe38b9e2013-10-22 19:24:42 +00004312 return (unsigned short)__b[__imm & 7];
Anders Carlsson85eb1242008-12-26 00:45:50 +00004313}
4314
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004315/// \brief Constructs a 128-bit integer vector by first making a copy of the
4316/// 128-bit integer vector parameter, and then inserting the lower 16 bits
4317/// of an integer parameter into an offset specified by the immediate-value
4318/// parameter.
4319///
4320/// \headerfile <x86intrin.h>
4321///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004322/// This intrinsic corresponds to the <c> VPINSRW / PINSRW </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004323///
4324/// \param __a
4325/// A 128-bit integer vector of [8 x i16]. This vector is copied to the
4326/// result and then one of the eight elements in the result is replaced by
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004327/// the lower 16 bits of \a __b.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004328/// \param __b
4329/// An integer. The lower 16 bits of this parameter are written to the
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004330/// result beginning at an offset specified by \a __imm.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004331/// \param __imm
4332/// An immediate value specifying the bit offset in the result at which the
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004333/// lower 16 bits of \a __b are written.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004334/// \returns A 128-bit integer vector containing the constructed values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004335static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004336_mm_insert_epi16(__m128i __a, int __b, int __imm)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004337{
David Blaikie3302f2b2013-01-16 23:08:36 +00004338 __v8hi __c = (__v8hi)__a;
4339 __c[__imm & 7] = __b;
4340 return (__m128i)__c;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004341}
4342
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004343/// \brief Copies the values of the most significant bits from each 8-bit
4344/// element in a 128-bit integer vector of [16 x i8] to create a 16-bit mask
4345/// value, zero-extends the value, and writes it to the destination.
4346///
4347/// \headerfile <x86intrin.h>
4348///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004349/// This intrinsic corresponds to the <c> VPMOVMSKB / PMOVMSKB </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004350///
4351/// \param __a
4352/// A 128-bit integer vector containing the values with bits to be extracted.
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004353/// \returns The most significant bits from each 8-bit element in \a __a,
4354/// written to bits [15:0]. The other bits are assigned zeros.
Michael Kupersteine45af542015-06-30 13:36:19 +00004355static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004356_mm_movemask_epi8(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004357{
David Blaikie3302f2b2013-01-16 23:08:36 +00004358 return __builtin_ia32_pmovmskb128((__v16qi)__a);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004359}
4360
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004361/// \brief Constructs a 128-bit integer vector by shuffling four 32-bit
4362/// elements of a 128-bit integer vector parameter, using the immediate-value
4363/// parameter as a specifier.
4364///
4365/// \headerfile <x86intrin.h>
4366///
4367/// \code
4368/// __m128i _mm_shuffle_epi32(__m128i a, const int imm);
4369/// \endcode
4370///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004371/// This intrinsic corresponds to the <c> VPSHUFD / PSHUFD </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004372///
4373/// \param a
4374/// A 128-bit integer vector containing the values to be copied.
4375/// \param imm
4376/// An immediate value containing an 8-bit value specifying which elements to
4377/// copy from a. The destinations within the 128-bit destination are assigned
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004378/// values as follows: \n
4379/// Bits [1:0] are used to assign values to bits [31:0] of the result. \n
4380/// Bits [3:2] are used to assign values to bits [63:32] of the result. \n
4381/// Bits [5:4] are used to assign values to bits [95:64] of the result. \n
4382/// Bits [7:6] are used to assign values to bits [127:96] of the result. \n
4383/// Bit value assignments: \n
4384/// 00: assign values from bits [31:0] of \a a. \n
4385/// 01: assign values from bits [63:32] of \a a. \n
4386/// 10: assign values from bits [95:64] of \a a. \n
4387/// 11: assign values from bits [127:96] of \a a.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004388/// \returns A 128-bit integer vector containing the shuffled values.
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00004389#define _mm_shuffle_epi32(a, imm) __extension__ ({ \
Craig Topper51e47412015-02-13 06:04:43 +00004390 (__m128i)__builtin_shufflevector((__v4si)(__m128i)(a), \
Craig Topper2a383c92016-07-04 22:18:01 +00004391 (__v4si)_mm_undefined_si128(), \
4392 ((imm) >> 0) & 0x3, ((imm) >> 2) & 0x3, \
4393 ((imm) >> 4) & 0x3, ((imm) >> 6) & 0x3); })
Chris Lattnerf03406f2011-04-25 20:42:40 +00004394
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004395/// \brief Constructs a 128-bit integer vector by shuffling four lower 16-bit
4396/// elements of a 128-bit integer vector of [8 x i16], using the immediate
4397/// value parameter as a specifier.
4398///
4399/// \headerfile <x86intrin.h>
4400///
4401/// \code
4402/// __m128i _mm_shufflelo_epi16(__m128i a, const int imm);
4403/// \endcode
4404///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004405/// This intrinsic corresponds to the <c> VPSHUFLW / PSHUFLW </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004406///
4407/// \param a
4408/// A 128-bit integer vector of [8 x i16]. Bits [127:64] are copied to bits
4409/// [127:64] of the result.
4410/// \param imm
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004411/// An 8-bit immediate value specifying which elements to copy from \a a. \n
4412/// Bits[1:0] are used to assign values to bits [15:0] of the result. \n
4413/// Bits[3:2] are used to assign values to bits [31:16] of the result. \n
4414/// Bits[5:4] are used to assign values to bits [47:32] of the result. \n
4415/// Bits[7:6] are used to assign values to bits [63:48] of the result. \n
4416/// Bit value assignments: \n
4417/// 00: assign values from bits [15:0] of \a a. \n
4418/// 01: assign values from bits [31:16] of \a a. \n
4419/// 10: assign values from bits [47:32] of \a a. \n
4420/// 11: assign values from bits [63:48] of \a a. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004421/// \returns A 128-bit integer vector containing the shuffled values.
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00004422#define _mm_shufflelo_epi16(a, imm) __extension__ ({ \
Craig Topper51e47412015-02-13 06:04:43 +00004423 (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \
Craig Topper2a383c92016-07-04 22:18:01 +00004424 (__v8hi)_mm_undefined_si128(), \
4425 ((imm) >> 0) & 0x3, ((imm) >> 2) & 0x3, \
4426 ((imm) >> 4) & 0x3, ((imm) >> 6) & 0x3, \
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00004427 4, 5, 6, 7); })
Chris Lattnerf03406f2011-04-25 20:42:40 +00004428
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004429/// \brief Constructs a 128-bit integer vector by shuffling four upper 16-bit
4430/// elements of a 128-bit integer vector of [8 x i16], using the immediate
4431/// value parameter as a specifier.
4432///
4433/// \headerfile <x86intrin.h>
4434///
4435/// \code
4436/// __m128i _mm_shufflehi_epi16(__m128i a, const int imm);
4437/// \endcode
4438///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004439/// This intrinsic corresponds to the <c> VPSHUFHW / PSHUFHW </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004440///
4441/// \param a
4442/// A 128-bit integer vector of [8 x i16]. Bits [63:0] are copied to bits
4443/// [63:0] of the result.
4444/// \param imm
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004445/// An 8-bit immediate value specifying which elements to copy from \a a. \n
4446/// Bits[1:0] are used to assign values to bits [79:64] of the result. \n
4447/// Bits[3:2] are used to assign values to bits [95:80] of the result. \n
4448/// Bits[5:4] are used to assign values to bits [111:96] of the result. \n
4449/// Bits[7:6] are used to assign values to bits [127:112] of the result. \n
4450/// Bit value assignments: \n
4451/// 00: assign values from bits [79:64] of \a a. \n
4452/// 01: assign values from bits [95:80] of \a a. \n
4453/// 10: assign values from bits [111:96] of \a a. \n
4454/// 11: assign values from bits [127:112] of \a a. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004455/// \returns A 128-bit integer vector containing the shuffled values.
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00004456#define _mm_shufflehi_epi16(a, imm) __extension__ ({ \
Craig Topper51e47412015-02-13 06:04:43 +00004457 (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), \
Craig Topper2a383c92016-07-04 22:18:01 +00004458 (__v8hi)_mm_undefined_si128(), \
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00004459 0, 1, 2, 3, \
Craig Topper2a383c92016-07-04 22:18:01 +00004460 4 + (((imm) >> 0) & 0x3), \
4461 4 + (((imm) >> 2) & 0x3), \
4462 4 + (((imm) >> 4) & 0x3), \
4463 4 + (((imm) >> 6) & 0x3)); })
Anders Carlsson85eb1242008-12-26 00:45:50 +00004464
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004465/// \brief Unpacks the high-order (index 8-15) values from two 128-bit vectors
4466/// of [16 x i8] and interleaves them into a 128-bit vector of [16 x i8].
4467///
4468/// \headerfile <x86intrin.h>
4469///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004470/// This intrinsic corresponds to the <c> VPUNPCKHBW / PUNPCKHBW </c>
4471/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004472///
4473/// \param __a
4474/// A 128-bit vector of [16 x i8].
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004475/// Bits [71:64] are written to bits [7:0] of the result. \n
4476/// Bits [79:72] are written to bits [23:16] of the result. \n
4477/// Bits [87:80] are written to bits [39:32] of the result. \n
4478/// Bits [95:88] are written to bits [55:48] of the result. \n
4479/// Bits [103:96] are written to bits [71:64] of the result. \n
4480/// Bits [111:104] are written to bits [87:80] of the result. \n
4481/// Bits [119:112] are written to bits [103:96] of the result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004482/// Bits [127:120] are written to bits [119:112] of the result.
4483/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004484/// A 128-bit vector of [16 x i8]. \n
4485/// Bits [71:64] are written to bits [15:8] of the result. \n
4486/// Bits [79:72] are written to bits [31:24] of the result. \n
4487/// Bits [87:80] are written to bits [47:40] of the result. \n
4488/// Bits [95:88] are written to bits [63:56] of the result. \n
4489/// Bits [103:96] are written to bits [79:72] of the result. \n
4490/// Bits [111:104] are written to bits [95:88] of the result. \n
4491/// Bits [119:112] are written to bits [111:104] of the result. \n
4492/// Bits [127:120] are written to bits [127:120] of the result.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004493/// \returns A 128-bit vector of [16 x i8] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004494static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004495_mm_unpackhi_epi8(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004496{
David Blaikie3302f2b2013-01-16 23:08:36 +00004497 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 +00004498}
4499
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004500/// \brief Unpacks the high-order (index 4-7) values from two 128-bit vectors of
4501/// [8 x i16] and interleaves them into a 128-bit vector of [8 x i16].
4502///
4503/// \headerfile <x86intrin.h>
4504///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004505/// This intrinsic corresponds to the <c> VPUNPCKHWD / PUNPCKHWD </c>
4506/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004507///
4508/// \param __a
4509/// A 128-bit vector of [8 x i16].
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004510/// Bits [79:64] are written to bits [15:0] of the result. \n
4511/// Bits [95:80] are written to bits [47:32] of the result. \n
4512/// Bits [111:96] are written to bits [79:64] of the result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004513/// Bits [127:112] are written to bits [111:96] of the result.
4514/// \param __b
4515/// A 128-bit vector of [8 x i16].
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004516/// Bits [79:64] are written to bits [31:16] of the result. \n
4517/// Bits [95:80] are written to bits [63:48] of the result. \n
4518/// Bits [111:96] are written to bits [95:80] of the result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004519/// Bits [127:112] are written to bits [127:112] of the result.
4520/// \returns A 128-bit vector of [8 x i16] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004521static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004522_mm_unpackhi_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004523{
David Blaikie3302f2b2013-01-16 23:08:36 +00004524 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 +00004525}
4526
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004527/// \brief Unpacks the high-order (index 2,3) values from two 128-bit vectors of
4528/// [4 x i32] and interleaves them into a 128-bit vector of [4 x i32].
4529///
4530/// \headerfile <x86intrin.h>
4531///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004532/// This intrinsic corresponds to the <c> VPUNPCKHDQ / PUNPCKHDQ </c>
4533/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004534///
4535/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004536/// A 128-bit vector of [4 x i32]. \n
4537/// Bits [95:64] are written to bits [31:0] of the destination. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004538/// Bits [127:96] are written to bits [95:64] of the destination.
4539/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004540/// A 128-bit vector of [4 x i32]. \n
4541/// Bits [95:64] are written to bits [64:32] of the destination. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004542/// Bits [127:96] are written to bits [127:96] of the destination.
4543/// \returns A 128-bit vector of [4 x i32] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004544static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004545_mm_unpackhi_epi32(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004546{
David Blaikie3302f2b2013-01-16 23:08:36 +00004547 return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 2, 4+2, 3, 4+3);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004548}
4549
Douglas Yung0686df102018-01-02 20:39:29 +00004550/// \brief Unpacks the high-order 64-bit elements from two 128-bit vectors of
4551/// [2 x i64] and interleaves them into a 128-bit vector of [2 x i64].
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004552///
4553/// \headerfile <x86intrin.h>
4554///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004555/// This intrinsic corresponds to the <c> VPUNPCKHQDQ / PUNPCKHQDQ </c>
4556/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004557///
4558/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004559/// A 128-bit vector of [2 x i64]. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004560/// Bits [127:64] are written to bits [63:0] of the destination.
4561/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004562/// A 128-bit vector of [2 x i64]. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004563/// Bits [127:64] are written to bits [127:64] of the destination.
4564/// \returns A 128-bit vector of [2 x i64] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004565static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004566_mm_unpackhi_epi64(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004567{
Craig Topper1aa231e2016-05-16 06:38:42 +00004568 return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 1, 2+1);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004569}
4570
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004571/// \brief Unpacks the low-order (index 0-7) values from two 128-bit vectors of
4572/// [16 x i8] and interleaves them into a 128-bit vector of [16 x i8].
4573///
4574/// \headerfile <x86intrin.h>
4575///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004576/// This intrinsic corresponds to the <c> VPUNPCKLBW / PUNPCKLBW </c>
4577/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004578///
4579/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004580/// A 128-bit vector of [16 x i8]. \n
4581/// Bits [7:0] are written to bits [7:0] of the result. \n
4582/// Bits [15:8] are written to bits [23:16] of the result. \n
4583/// Bits [23:16] are written to bits [39:32] of the result. \n
4584/// Bits [31:24] are written to bits [55:48] of the result. \n
4585/// Bits [39:32] are written to bits [71:64] of the result. \n
4586/// Bits [47:40] are written to bits [87:80] of the result. \n
4587/// Bits [55:48] are written to bits [103:96] of the result. \n
4588/// Bits [63:56] are written to bits [119:112] of the result.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004589/// \param __b
4590/// A 128-bit vector of [16 x i8].
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004591/// Bits [7:0] are written to bits [15:8] of the result. \n
4592/// Bits [15:8] are written to bits [31:24] of the result. \n
4593/// Bits [23:16] are written to bits [47:40] of the result. \n
4594/// Bits [31:24] are written to bits [63:56] of the result. \n
4595/// Bits [39:32] are written to bits [79:72] of the result. \n
4596/// Bits [47:40] are written to bits [95:88] of the result. \n
4597/// Bits [55:48] are written to bits [111:104] of the result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004598/// Bits [63:56] are written to bits [127:120] of the result.
4599/// \returns A 128-bit vector of [16 x i8] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004600static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004601_mm_unpacklo_epi8(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004602{
David Blaikie3302f2b2013-01-16 23:08:36 +00004603 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 +00004604}
4605
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004606/// \brief Unpacks the low-order (index 0-3) values from each of the two 128-bit
4607/// vectors of [8 x i16] and interleaves them into a 128-bit vector of
4608/// [8 x i16].
4609///
4610/// \headerfile <x86intrin.h>
4611///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004612/// This intrinsic corresponds to the <c> VPUNPCKLWD / PUNPCKLWD </c>
4613/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004614///
4615/// \param __a
4616/// A 128-bit vector of [8 x i16].
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004617/// Bits [15:0] are written to bits [15:0] of the result. \n
4618/// Bits [31:16] are written to bits [47:32] of the result. \n
4619/// Bits [47:32] are written to bits [79:64] of the result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004620/// Bits [63:48] are written to bits [111:96] of the result.
4621/// \param __b
4622/// A 128-bit vector of [8 x i16].
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004623/// Bits [15:0] are written to bits [31:16] of the result. \n
4624/// Bits [31:16] are written to bits [63:48] of the result. \n
4625/// Bits [47:32] are written to bits [95:80] of the result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004626/// Bits [63:48] are written to bits [127:112] of the result.
4627/// \returns A 128-bit vector of [8 x i16] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004628static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004629_mm_unpacklo_epi16(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004630{
David Blaikie3302f2b2013-01-16 23:08:36 +00004631 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 +00004632}
4633
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004634/// \brief Unpacks the low-order (index 0,1) values from two 128-bit vectors of
4635/// [4 x i32] and interleaves them into a 128-bit vector of [4 x i32].
4636///
4637/// \headerfile <x86intrin.h>
4638///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004639/// This intrinsic corresponds to the <c> VPUNPCKLDQ / PUNPCKLDQ </c>
4640/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004641///
4642/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004643/// A 128-bit vector of [4 x i32]. \n
4644/// Bits [31:0] are written to bits [31:0] of the destination. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004645/// Bits [63:32] are written to bits [95:64] of the destination.
4646/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004647/// A 128-bit vector of [4 x i32]. \n
4648/// Bits [31:0] are written to bits [64:32] of the destination. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004649/// Bits [63:32] are written to bits [127:96] of the destination.
4650/// \returns A 128-bit vector of [4 x i32] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004651static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004652_mm_unpacklo_epi32(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004653{
David Blaikie3302f2b2013-01-16 23:08:36 +00004654 return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 0, 4+0, 1, 4+1);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004655}
4656
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004657/// \brief Unpacks the low-order 64-bit elements from two 128-bit vectors of
4658/// [2 x i64] and interleaves them into a 128-bit vector of [2 x i64].
4659///
4660/// \headerfile <x86intrin.h>
4661///
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004662/// This intrinsic corresponds to the <c> VPUNPCKLQDQ / PUNPCKLQDQ </c>
4663/// instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004664///
4665/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004666/// A 128-bit vector of [2 x i64]. \n
4667/// Bits [63:0] are written to bits [63:0] of the destination. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004668/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004669/// A 128-bit vector of [2 x i64]. \n
4670/// Bits [63:0] are written to bits [127:64] of the destination. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004671/// \returns A 128-bit vector of [2 x i64] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004672static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004673_mm_unpacklo_epi64(__m128i __a, __m128i __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004674{
Craig Topper1aa231e2016-05-16 06:38:42 +00004675 return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 0, 2+0);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004676}
4677
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004678/// \brief Returns the lower 64 bits of a 128-bit integer vector as a 64-bit
Ekaterina Romanova493091f2016-10-20 17:59:15 +00004679/// integer.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004680///
4681/// \headerfile <x86intrin.h>
4682///
Douglas Yung0686df102018-01-02 20:39:29 +00004683/// This intrinsic corresponds to the <c> MOVDQ2Q </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004684///
4685/// \param __a
4686/// A 128-bit integer vector operand. The lower 64 bits are moved to the
4687/// destination.
4688/// \returns A 64-bit integer containing the lower 64 bits of the parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004689static __inline__ __m64 __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004690_mm_movepi64_pi64(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004691{
David Blaikie3302f2b2013-01-16 23:08:36 +00004692 return (__m64)__a[0];
Anders Carlsson85eb1242008-12-26 00:45:50 +00004693}
4694
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004695/// \brief Moves the 64-bit operand to a 128-bit integer vector, zeroing the
4696/// upper bits.
4697///
4698/// \headerfile <x86intrin.h>
4699///
Douglas Yung0686df102018-01-02 20:39:29 +00004700/// This intrinsic corresponds to the <c> MOVD+VMOVQ </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004701///
4702/// \param __a
4703/// A 64-bit value.
4704/// \returns A 128-bit integer vector. The lower 64 bits contain the value from
4705/// the operand. The upper 64 bits are assigned zeros.
Michael Kupersteine45af542015-06-30 13:36:19 +00004706static __inline__ __m128i __DEFAULT_FN_ATTRS
Alp Tokerd480b1b2013-11-23 22:11:57 +00004707_mm_movpi64_epi64(__m64 __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004708{
David Blaikie3302f2b2013-01-16 23:08:36 +00004709 return (__m128i){ (long long)__a, 0 };
Anders Carlsson85eb1242008-12-26 00:45:50 +00004710}
4711
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004712/// \brief Moves the lower 64 bits of a 128-bit integer vector to a 128-bit
4713/// integer vector, zeroing the upper bits.
4714///
4715/// \headerfile <x86intrin.h>
4716///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004717/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004718///
4719/// \param __a
4720/// A 128-bit integer vector operand. The lower 64 bits are moved to the
4721/// destination.
4722/// \returns A 128-bit integer vector. The lower 64 bits contain the value from
4723/// the operand. The upper 64 bits are assigned zeros.
Michael Kupersteine45af542015-06-30 13:36:19 +00004724static __inline__ __m128i __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004725_mm_move_epi64(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004726{
Craig Topper1aa231e2016-05-16 06:38:42 +00004727 return __builtin_shufflevector((__v2di)__a, (__m128i){ 0 }, 0, 2);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004728}
4729
Douglas Yung0686df102018-01-02 20:39:29 +00004730/// \brief Unpacks the high-order 64-bit elements from two 128-bit vectors of
4731/// [2 x double] and interleaves them into a 128-bit vector of [2 x
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004732/// double].
4733///
4734/// \headerfile <x86intrin.h>
4735///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004736/// This intrinsic corresponds to the <c> VUNPCKHPD / UNPCKHPD </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004737///
4738/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004739/// A 128-bit vector of [2 x double]. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004740/// Bits [127:64] are written to bits [63:0] of the destination.
4741/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004742/// A 128-bit vector of [2 x double]. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004743/// Bits [127:64] are written to bits [127:64] of the destination.
4744/// \returns A 128-bit vector of [2 x double] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004745static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004746_mm_unpackhi_pd(__m128d __a, __m128d __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004747{
Craig Topper1aa231e2016-05-16 06:38:42 +00004748 return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 1, 2+1);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004749}
4750
Douglas Yung0686df102018-01-02 20:39:29 +00004751/// \brief Unpacks the low-order 64-bit elements from two 128-bit vectors
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004752/// of [2 x double] and interleaves them into a 128-bit vector of [2 x
4753/// double].
4754///
4755/// \headerfile <x86intrin.h>
4756///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004757/// This intrinsic corresponds to the <c> VUNPCKLPD / UNPCKLPD </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004758///
4759/// \param __a
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004760/// A 128-bit vector of [2 x double]. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004761/// Bits [63:0] are written to bits [63:0] of the destination.
4762/// \param __b
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004763/// A 128-bit vector of [2 x double]. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004764/// Bits [63:0] are written to bits [127:64] of the destination.
4765/// \returns A 128-bit vector of [2 x double] containing the interleaved values.
Michael Kupersteine45af542015-06-30 13:36:19 +00004766static __inline__ __m128d __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004767_mm_unpacklo_pd(__m128d __a, __m128d __b)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004768{
Craig Topper1aa231e2016-05-16 06:38:42 +00004769 return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 0, 2+0);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004770}
4771
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004772/// \brief Extracts the sign bits of the double-precision values in the 128-bit
4773/// vector of [2 x double], zero-extends the value, and writes it to the
4774/// low-order bits of the destination.
4775///
4776/// \headerfile <x86intrin.h>
4777///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004778/// This intrinsic corresponds to the <c> VMOVMSKPD / MOVMSKPD </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004779///
4780/// \param __a
4781/// A 128-bit vector of [2 x double] containing the values with sign bits to
4782/// be extracted.
Ekaterina Romanova797b0eb2016-12-08 22:10:51 +00004783/// \returns The sign bits from each of the double-precision elements in \a __a,
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004784/// written to bits [1:0]. The remaining bits are assigned values of zero.
Michael Kupersteine45af542015-06-30 13:36:19 +00004785static __inline__ int __DEFAULT_FN_ATTRS
David Blaikie3302f2b2013-01-16 23:08:36 +00004786_mm_movemask_pd(__m128d __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004787{
Craig Topper1aa231e2016-05-16 06:38:42 +00004788 return __builtin_ia32_movmskpd((__v2df)__a);
Anders Carlsson85eb1242008-12-26 00:45:50 +00004789}
4790
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004791
4792/// \brief Constructs a 128-bit floating-point vector of [2 x double] from two
4793/// 128-bit vector parameters of [2 x double], using the immediate-value
4794/// parameter as a specifier.
4795///
4796/// \headerfile <x86intrin.h>
4797///
4798/// \code
4799/// __m128d _mm_shuffle_pd(__m128d a, __m128d b, const int i);
4800/// \endcode
4801///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004802/// This intrinsic corresponds to the <c> VSHUFPD / SHUFPD </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004803///
4804/// \param a
4805/// A 128-bit vector of [2 x double].
4806/// \param b
4807/// A 128-bit vector of [2 x double].
4808/// \param i
4809/// An 8-bit immediate value. The least significant two bits specify which
Douglas Yung0686df102018-01-02 20:39:29 +00004810/// elements to copy from \a a and \a b: \n
4811/// Bit[0] = 0: lower element of \a a copied to lower element of result. \n
4812/// Bit[0] = 1: upper element of \a a copied to lower element of result. \n
Ekaterina Romanovadffe45b2016-12-27 00:49:38 +00004813/// Bit[1] = 0: lower element of \a b copied to upper element of result. \n
4814/// Bit[1] = 1: upper element of \a b copied to upper element of result. \n
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004815/// \returns A 128-bit vector of [2 x double] containing the shuffled values.
Bob Wilsonc9b97cc2011-11-05 06:08:06 +00004816#define _mm_shuffle_pd(a, b, i) __extension__ ({ \
Craig Topperd619eaaa2015-11-11 03:47:10 +00004817 (__m128d)__builtin_shufflevector((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \
Craig Topper2a383c92016-07-04 22:18:01 +00004818 0 + (((i) >> 0) & 0x1), \
4819 2 + (((i) >> 1) & 0x1)); })
Anders Carlsson85eb1242008-12-26 00:45:50 +00004820
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004821/// \brief Casts a 128-bit floating-point vector of [2 x double] into a 128-bit
4822/// floating-point vector of [4 x float].
4823///
4824/// \headerfile <x86intrin.h>
4825///
4826/// This intrinsic has no corresponding instruction.
4827///
4828/// \param __a
4829/// A 128-bit floating-point vector of [2 x double].
4830/// \returns A 128-bit floating-point vector of [4 x float] containing the same
4831/// bitwise pattern as the parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004832static __inline__ __m128 __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004833_mm_castpd_ps(__m128d __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004834{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004835 return (__m128)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004836}
4837
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004838/// \brief Casts a 128-bit floating-point vector of [2 x double] into a 128-bit
4839/// integer vector.
4840///
4841/// \headerfile <x86intrin.h>
4842///
4843/// This intrinsic has no corresponding instruction.
4844///
4845/// \param __a
4846/// A 128-bit floating-point vector of [2 x double].
4847/// \returns A 128-bit integer vector containing the same bitwise pattern as the
4848/// parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004849static __inline__ __m128i __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004850_mm_castpd_si128(__m128d __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004851{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004852 return (__m128i)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004853}
4854
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004855/// \brief Casts a 128-bit floating-point vector of [4 x float] into a 128-bit
4856/// floating-point vector of [2 x double].
4857///
4858/// \headerfile <x86intrin.h>
4859///
4860/// This intrinsic has no corresponding instruction.
4861///
4862/// \param __a
4863/// A 128-bit floating-point vector of [4 x float].
4864/// \returns A 128-bit floating-point vector of [2 x double] containing the same
4865/// bitwise pattern as the parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004866static __inline__ __m128d __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004867_mm_castps_pd(__m128 __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004868{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004869 return (__m128d)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004870}
4871
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004872/// \brief Casts a 128-bit floating-point vector of [4 x float] into a 128-bit
4873/// integer vector.
4874///
4875/// \headerfile <x86intrin.h>
4876///
4877/// This intrinsic has no corresponding instruction.
4878///
4879/// \param __a
4880/// A 128-bit floating-point vector of [4 x float].
4881/// \returns A 128-bit integer vector containing the same bitwise pattern as the
4882/// parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004883static __inline__ __m128i __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004884_mm_castps_si128(__m128 __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004885{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004886 return (__m128i)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004887}
4888
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004889/// \brief Casts a 128-bit integer vector into a 128-bit floating-point vector
4890/// of [4 x float].
4891///
4892/// \headerfile <x86intrin.h>
4893///
4894/// This intrinsic has no corresponding instruction.
4895///
4896/// \param __a
4897/// A 128-bit integer vector.
4898/// \returns A 128-bit floating-point vector of [4 x float] containing the same
4899/// bitwise pattern as the parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004900static __inline__ __m128 __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004901_mm_castsi128_ps(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004902{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004903 return (__m128)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004904}
4905
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004906/// \brief Casts a 128-bit integer vector into a 128-bit floating-point vector
4907/// of [2 x double].
4908///
4909/// \headerfile <x86intrin.h>
4910///
4911/// This intrinsic has no corresponding instruction.
4912///
4913/// \param __a
4914/// A 128-bit integer vector.
4915/// \returns A 128-bit floating-point vector of [2 x double] containing the same
4916/// bitwise pattern as the parameter.
Michael Kupersteine45af542015-06-30 13:36:19 +00004917static __inline__ __m128d __DEFAULT_FN_ATTRS
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004918_mm_castsi128_pd(__m128i __a)
Anders Carlsson85eb1242008-12-26 00:45:50 +00004919{
Reid Kleckner7ab75b32013-04-19 17:00:14 +00004920 return (__m128d)__a;
Anders Carlsson85eb1242008-12-26 00:45:50 +00004921}
4922
Ekaterina Romanova2174b6f2016-11-17 23:02:00 +00004923#if defined(__cplusplus)
4924extern "C" {
4925#endif
4926
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004927/// \brief Indicates that a spin loop is being executed for the purposes of
4928/// optimizing power consumption during the loop.
4929///
4930/// \headerfile <x86intrin.h>
4931///
Ekaterina Romanova0c1c3bb2016-12-09 18:35:50 +00004932/// This intrinsic corresponds to the <c> PAUSE </c> instruction.
Ekaterina Romanovaa84c24f2016-07-22 23:49:37 +00004933///
Albert Gutowski727ab8a2016-09-14 21:19:43 +00004934void _mm_pause(void);
Anders Carlsson37c23712008-12-26 00:49:43 +00004935
Ekaterina Romanova2174b6f2016-11-17 23:02:00 +00004936#if defined(__cplusplus)
4937} // extern "C"
4938#endif
Michael Kupersteine45af542015-06-30 13:36:19 +00004939#undef __DEFAULT_FN_ATTRS
Eric Christopher4d1851682015-06-17 07:09:20 +00004940
Anders Carlsson43c2bab2009-01-21 01:49:39 +00004941#define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))
Anders Carlsson37c23712008-12-26 00:49:43 +00004942
Oren Ben Simhon259b0912017-02-26 11:58:15 +00004943#define _MM_DENORMALS_ZERO_ON (0x0040)
4944#define _MM_DENORMALS_ZERO_OFF (0x0000)
4945
4946#define _MM_DENORMALS_ZERO_MASK (0x0040)
4947
4948#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
4949#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))
4950
Anders Carlssonf15e71d2008-12-24 01:45:22 +00004951#endif /* __EMMINTRIN_H */