smmintrin.h revision 341825
1206084Srdivacky/*===---- smmintrin.h - SSE4 intrinsics ------------------------------------===
2206084Srdivacky *
3206084Srdivacky * Permission is hereby granted, free of charge, to any person obtaining a copy
4206084Srdivacky * of this software and associated documentation files (the "Software"), to deal
5206084Srdivacky * in the Software without restriction, including without limitation the rights
6206084Srdivacky * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7206084Srdivacky * copies of the Software, and to permit persons to whom the Software is
8206084Srdivacky * furnished to do so, subject to the following conditions:
9206084Srdivacky *
10206084Srdivacky * The above copyright notice and this permission notice shall be included in
11206084Srdivacky * all copies or substantial portions of the Software.
12206084Srdivacky *
13206084Srdivacky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14206084Srdivacky * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15206084Srdivacky * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16206084Srdivacky * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17206084Srdivacky * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18206084Srdivacky * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19206084Srdivacky * THE SOFTWARE.
20206084Srdivacky *
21206084Srdivacky *===-----------------------------------------------------------------------===
22206084Srdivacky */
23204793Srdivacky
24341825Sdim#ifndef __SMMINTRIN_H
25341825Sdim#define __SMMINTRIN_H
26204793Srdivacky
27204793Srdivacky#include <tmmintrin.h>
28204793Srdivacky
29288943Sdim/* Define the default attributes for the functions in this file. */
30341825Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.1"), __min_vector_width__(128)))
31288943Sdim
32204793Srdivacky/* SSE4 Rounding macros. */
33204793Srdivacky#define _MM_FROUND_TO_NEAREST_INT    0x00
34204793Srdivacky#define _MM_FROUND_TO_NEG_INF        0x01
35204793Srdivacky#define _MM_FROUND_TO_POS_INF        0x02
36204793Srdivacky#define _MM_FROUND_TO_ZERO           0x03
37204793Srdivacky#define _MM_FROUND_CUR_DIRECTION     0x04
38204793Srdivacky
39204793Srdivacky#define _MM_FROUND_RAISE_EXC         0x00
40204793Srdivacky#define _MM_FROUND_NO_EXC            0x08
41204793Srdivacky
42204793Srdivacky#define _MM_FROUND_NINT      (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEAREST_INT)
43204793Srdivacky#define _MM_FROUND_FLOOR     (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEG_INF)
44204793Srdivacky#define _MM_FROUND_CEIL      (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_POS_INF)
45204793Srdivacky#define _MM_FROUND_TRUNC     (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_ZERO)
46204793Srdivacky#define _MM_FROUND_RINT      (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION)
47204962Srdivacky#define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION)
48204793Srdivacky
49341825Sdim/// Rounds up each element of the 128-bit vector of [4 x float] to an
50321369Sdim///    integer and returns the rounded values in a 128-bit vector of
51321369Sdim///    [4 x float].
52321369Sdim///
53321369Sdim/// \headerfile <x86intrin.h>
54321369Sdim///
55321369Sdim/// \code
56321369Sdim/// __m128 _mm_ceil_ps(__m128 X);
57321369Sdim/// \endcode
58321369Sdim///
59321369Sdim/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
60321369Sdim///
61321369Sdim/// \param X
62321369Sdim///    A 128-bit vector of [4 x float] values to be rounded up.
63321369Sdim/// \returns A 128-bit vector of [4 x float] containing the rounded values.
64204793Srdivacky#define _mm_ceil_ps(X)       _mm_round_ps((X), _MM_FROUND_CEIL)
65321369Sdim
66341825Sdim/// Rounds up each element of the 128-bit vector of [2 x double] to an
67321369Sdim///    integer and returns the rounded values in a 128-bit vector of
68321369Sdim///    [2 x double].
69321369Sdim///
70321369Sdim/// \headerfile <x86intrin.h>
71321369Sdim///
72321369Sdim/// \code
73321369Sdim/// __m128d _mm_ceil_pd(__m128d X);
74321369Sdim/// \endcode
75321369Sdim///
76321369Sdim/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
77321369Sdim///
78321369Sdim/// \param X
79321369Sdim///    A 128-bit vector of [2 x double] values to be rounded up.
80321369Sdim/// \returns A 128-bit vector of [2 x double] containing the rounded values.
81204793Srdivacky#define _mm_ceil_pd(X)       _mm_round_pd((X), _MM_FROUND_CEIL)
82321369Sdim
83341825Sdim/// Copies three upper elements of the first 128-bit vector operand to
84321369Sdim///    the corresponding three upper elements of the 128-bit result vector of
85321369Sdim///    [4 x float]. Rounds up the lowest element of the second 128-bit vector
86321369Sdim///    operand to an integer and copies it to the lowest element of the 128-bit
87321369Sdim///    result vector of [4 x float].
88321369Sdim///
89321369Sdim/// \headerfile <x86intrin.h>
90321369Sdim///
91321369Sdim/// \code
92321369Sdim/// __m128 _mm_ceil_ss(__m128 X, __m128 Y);
93321369Sdim/// \endcode
94321369Sdim///
95321369Sdim/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
96321369Sdim///
97321369Sdim/// \param X
98321369Sdim///    A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
99321369Sdim///    copied to the corresponding bits of the result.
100321369Sdim/// \param Y
101321369Sdim///    A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
102321369Sdim///    rounded up to the nearest integer and copied to the corresponding bits
103321369Sdim///    of the result.
104321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and rounded
105321369Sdim///    values.
106204793Srdivacky#define _mm_ceil_ss(X, Y)    _mm_round_ss((X), (Y), _MM_FROUND_CEIL)
107321369Sdim
108341825Sdim/// Copies the upper element of the first 128-bit vector operand to the
109321369Sdim///    corresponding upper element of the 128-bit result vector of [2 x double].
110321369Sdim///    Rounds up the lower element of the second 128-bit vector operand to an
111321369Sdim///    integer and copies it to the lower element of the 128-bit result vector
112321369Sdim///    of [2 x double].
113321369Sdim///
114321369Sdim/// \headerfile <x86intrin.h>
115321369Sdim///
116321369Sdim/// \code
117321369Sdim/// __m128d _mm_ceil_sd(__m128d X, __m128d Y);
118321369Sdim/// \endcode
119321369Sdim///
120321369Sdim/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
121321369Sdim///
122321369Sdim/// \param X
123321369Sdim///    A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
124321369Sdim///    copied to the corresponding bits of the result.
125321369Sdim/// \param Y
126321369Sdim///    A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
127321369Sdim///    rounded up to the nearest integer and copied to the corresponding bits
128321369Sdim///    of the result.
129321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied and rounded
130321369Sdim///    values.
131204793Srdivacky#define _mm_ceil_sd(X, Y)    _mm_round_sd((X), (Y), _MM_FROUND_CEIL)
132204793Srdivacky
133341825Sdim/// Rounds down each element of the 128-bit vector of [4 x float] to an
134321369Sdim///    an integer and returns the rounded values in a 128-bit vector of
135321369Sdim///    [4 x float].
136321369Sdim///
137321369Sdim/// \headerfile <x86intrin.h>
138321369Sdim///
139321369Sdim/// \code
140321369Sdim/// __m128 _mm_floor_ps(__m128 X);
141321369Sdim/// \endcode
142321369Sdim///
143321369Sdim/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
144321369Sdim///
145321369Sdim/// \param X
146321369Sdim///    A 128-bit vector of [4 x float] values to be rounded down.
147321369Sdim/// \returns A 128-bit vector of [4 x float] containing the rounded values.
148204793Srdivacky#define _mm_floor_ps(X)      _mm_round_ps((X), _MM_FROUND_FLOOR)
149321369Sdim
150341825Sdim/// Rounds down each element of the 128-bit vector of [2 x double] to an
151321369Sdim///    integer and returns the rounded values in a 128-bit vector of
152321369Sdim///    [2 x double].
153321369Sdim///
154321369Sdim/// \headerfile <x86intrin.h>
155321369Sdim///
156321369Sdim/// \code
157321369Sdim/// __m128d _mm_floor_pd(__m128d X);
158321369Sdim/// \endcode
159321369Sdim///
160321369Sdim/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
161321369Sdim///
162321369Sdim/// \param X
163321369Sdim///    A 128-bit vector of [2 x double].
164321369Sdim/// \returns A 128-bit vector of [2 x double] containing the rounded values.
165204793Srdivacky#define _mm_floor_pd(X)      _mm_round_pd((X), _MM_FROUND_FLOOR)
166321369Sdim
167341825Sdim/// Copies three upper elements of the first 128-bit vector operand to
168321369Sdim///    the corresponding three upper elements of the 128-bit result vector of
169321369Sdim///    [4 x float]. Rounds down the lowest element of the second 128-bit vector
170321369Sdim///    operand to an integer and copies it to the lowest element of the 128-bit
171321369Sdim///    result vector of [4 x float].
172321369Sdim///
173321369Sdim/// \headerfile <x86intrin.h>
174321369Sdim///
175321369Sdim/// \code
176321369Sdim/// __m128 _mm_floor_ss(__m128 X, __m128 Y);
177321369Sdim/// \endcode
178321369Sdim///
179321369Sdim/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
180321369Sdim///
181321369Sdim/// \param X
182321369Sdim///    A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
183321369Sdim///    copied to the corresponding bits of the result.
184321369Sdim/// \param Y
185321369Sdim///    A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
186321369Sdim///    rounded down to the nearest integer and copied to the corresponding bits
187321369Sdim///    of the result.
188321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and rounded
189321369Sdim///    values.
190204793Srdivacky#define _mm_floor_ss(X, Y)   _mm_round_ss((X), (Y), _MM_FROUND_FLOOR)
191321369Sdim
192341825Sdim/// Copies the upper element of the first 128-bit vector operand to the
193321369Sdim///    corresponding upper element of the 128-bit result vector of [2 x double].
194321369Sdim///    Rounds down the lower element of the second 128-bit vector operand to an
195321369Sdim///    integer and copies it to the lower element of the 128-bit result vector
196321369Sdim///    of [2 x double].
197321369Sdim///
198321369Sdim/// \headerfile <x86intrin.h>
199321369Sdim///
200321369Sdim/// \code
201321369Sdim/// __m128d _mm_floor_sd(__m128d X, __m128d Y);
202321369Sdim/// \endcode
203321369Sdim///
204321369Sdim/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
205321369Sdim///
206321369Sdim/// \param X
207321369Sdim///    A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
208321369Sdim///    copied to the corresponding bits of the result.
209321369Sdim/// \param Y
210321369Sdim///    A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
211321369Sdim///    rounded down to the nearest integer and copied to the corresponding bits
212321369Sdim///    of the result.
213321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied and rounded
214321369Sdim///    values.
215204793Srdivacky#define _mm_floor_sd(X, Y)   _mm_round_sd((X), (Y), _MM_FROUND_FLOOR)
216204793Srdivacky
217341825Sdim/// Rounds each element of the 128-bit vector of [4 x float] to an
218321369Sdim///    integer value according to the rounding control specified by the second
219321369Sdim///    argument and returns the rounded values in a 128-bit vector of
220321369Sdim///    [4 x float].
221321369Sdim///
222321369Sdim/// \headerfile <x86intrin.h>
223321369Sdim///
224321369Sdim/// \code
225321369Sdim/// __m128 _mm_round_ps(__m128 X, const int M);
226321369Sdim/// \endcode
227321369Sdim///
228321369Sdim/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
229321369Sdim///
230321369Sdim/// \param X
231321369Sdim///    A 128-bit vector of [4 x float].
232321369Sdim/// \param M
233321369Sdim///    An integer value that specifies the rounding operation. \n
234321369Sdim///    Bits [7:4] are reserved. \n
235321369Sdim///    Bit [3] is a precision exception value: \n
236321369Sdim///      0: A normal PE exception is used \n
237321369Sdim///      1: The PE field is not updated \n
238321369Sdim///    Bit [2] is the rounding control source: \n
239321369Sdim///      0: Use bits [1:0] of \a M \n
240321369Sdim///      1: Use the current MXCSR setting \n
241321369Sdim///    Bits [1:0] contain the rounding control definition: \n
242321369Sdim///      00: Nearest \n
243321369Sdim///      01: Downward (toward negative infinity) \n
244321369Sdim///      10: Upward (toward positive infinity) \n
245321369Sdim///      11: Truncated
246321369Sdim/// \returns A 128-bit vector of [4 x float] containing the rounded values.
247341825Sdim#define _mm_round_ps(X, M) \
248341825Sdim  (__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M))
249204793Srdivacky
250341825Sdim/// Copies three upper elements of the first 128-bit vector operand to
251321369Sdim///    the corresponding three upper elements of the 128-bit result vector of
252321369Sdim///    [4 x float]. Rounds the lowest element of the second 128-bit vector
253321369Sdim///    operand to an integer value according to the rounding control specified
254321369Sdim///    by the third argument and copies it to the lowest element of the 128-bit
255321369Sdim///    result vector of [4 x float].
256321369Sdim///
257321369Sdim/// \headerfile <x86intrin.h>
258321369Sdim///
259321369Sdim/// \code
260321369Sdim/// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M);
261321369Sdim/// \endcode
262321369Sdim///
263321369Sdim/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
264321369Sdim///
265321369Sdim/// \param X
266321369Sdim///    A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
267321369Sdim///    copied to the corresponding bits of the result.
268321369Sdim/// \param Y
269321369Sdim///    A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
270321369Sdim///    rounded to the nearest integer using the specified rounding control and
271321369Sdim///    copied to the corresponding bits of the result.
272321369Sdim/// \param M
273321369Sdim///    An integer value that specifies the rounding operation. \n
274321369Sdim///    Bits [7:4] are reserved. \n
275321369Sdim///    Bit [3] is a precision exception value: \n
276321369Sdim///      0: A normal PE exception is used \n
277321369Sdim///      1: The PE field is not updated \n
278321369Sdim///    Bit [2] is the rounding control source: \n
279321369Sdim///      0: Use bits [1:0] of \a M \n
280321369Sdim///      1: Use the current MXCSR setting \n
281321369Sdim///    Bits [1:0] contain the rounding control definition: \n
282321369Sdim///      00: Nearest \n
283321369Sdim///      01: Downward (toward negative infinity) \n
284321369Sdim///      10: Upward (toward positive infinity) \n
285321369Sdim///      11: Truncated
286321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and rounded
287321369Sdim///    values.
288341825Sdim#define _mm_round_ss(X, Y, M) \
289296417Sdim  (__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), \
290341825Sdim                                 (__v4sf)(__m128)(Y), (M))
291234353Sdim
292341825Sdim/// Rounds each element of the 128-bit vector of [2 x double] to an
293321369Sdim///    integer value according to the rounding control specified by the second
294321369Sdim///    argument and returns the rounded values in a 128-bit vector of
295321369Sdim///    [2 x double].
296321369Sdim///
297321369Sdim/// \headerfile <x86intrin.h>
298321369Sdim///
299321369Sdim/// \code
300321369Sdim/// __m128d _mm_round_pd(__m128d X, const int M);
301321369Sdim/// \endcode
302321369Sdim///
303321369Sdim/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
304321369Sdim///
305321369Sdim/// \param X
306321369Sdim///    A 128-bit vector of [2 x double].
307321369Sdim/// \param M
308321369Sdim///    An integer value that specifies the rounding operation. \n
309321369Sdim///    Bits [7:4] are reserved. \n
310321369Sdim///    Bit [3] is a precision exception value: \n
311321369Sdim///      0: A normal PE exception is used \n
312321369Sdim///      1: The PE field is not updated \n
313321369Sdim///    Bit [2] is the rounding control source: \n
314321369Sdim///      0: Use bits [1:0] of \a M \n
315321369Sdim///      1: Use the current MXCSR setting \n
316321369Sdim///    Bits [1:0] contain the rounding control definition: \n
317321369Sdim///      00: Nearest \n
318321369Sdim///      01: Downward (toward negative infinity) \n
319321369Sdim///      10: Upward (toward positive infinity) \n
320321369Sdim///      11: Truncated
321321369Sdim/// \returns A 128-bit vector of [2 x double] containing the rounded values.
322341825Sdim#define _mm_round_pd(X, M) \
323341825Sdim  (__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M))
324234353Sdim
325341825Sdim/// Copies the upper element of the first 128-bit vector operand to the
326321369Sdim///    corresponding upper element of the 128-bit result vector of [2 x double].
327321369Sdim///    Rounds the lower element of the second 128-bit vector operand to an
328321369Sdim///    integer value according to the rounding control specified by the third
329321369Sdim///    argument and copies it to the lower element of the 128-bit result vector
330321369Sdim///    of [2 x double].
331321369Sdim///
332321369Sdim/// \headerfile <x86intrin.h>
333321369Sdim///
334321369Sdim/// \code
335321369Sdim/// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M);
336321369Sdim/// \endcode
337321369Sdim///
338321369Sdim/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
339321369Sdim///
340321369Sdim/// \param X
341321369Sdim///    A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
342321369Sdim///    copied to the corresponding bits of the result.
343321369Sdim/// \param Y
344321369Sdim///    A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
345321369Sdim///    rounded to the nearest integer using the specified rounding control and
346321369Sdim///    copied to the corresponding bits of the result.
347321369Sdim/// \param M
348321369Sdim///    An integer value that specifies the rounding operation. \n
349321369Sdim///    Bits [7:4] are reserved. \n
350321369Sdim///    Bit [3] is a precision exception value: \n
351321369Sdim///      0: A normal PE exception is used \n
352321369Sdim///      1: The PE field is not updated \n
353321369Sdim///    Bit [2] is the rounding control source: \n
354321369Sdim///      0: Use bits [1:0] of \a M \n
355321369Sdim///      1: Use the current MXCSR setting \n
356321369Sdim///    Bits [1:0] contain the rounding control definition: \n
357321369Sdim///      00: Nearest \n
358321369Sdim///      01: Downward (toward negative infinity) \n
359321369Sdim///      10: Upward (toward positive infinity) \n
360321369Sdim///      11: Truncated
361321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied and rounded
362321369Sdim///    values.
363341825Sdim#define _mm_round_sd(X, Y, M) \
364296417Sdim  (__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), \
365341825Sdim                                  (__v2df)(__m128d)(Y), (M))
366234353Sdim
367204793Srdivacky/* SSE4 Packed Blending Intrinsics.  */
368341825Sdim/// Returns a 128-bit vector of [2 x double] where the values are
369321369Sdim///    selected from either the first or second operand as specified by the
370321369Sdim///    third operand, the control mask.
371321369Sdim///
372321369Sdim/// \headerfile <x86intrin.h>
373321369Sdim///
374321369Sdim/// \code
375321369Sdim/// __m128d _mm_blend_pd(__m128d V1, __m128d V2, const int M);
376321369Sdim/// \endcode
377321369Sdim///
378321369Sdim/// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction.
379321369Sdim///
380321369Sdim/// \param V1
381321369Sdim///    A 128-bit vector of [2 x double].
382321369Sdim/// \param V2
383321369Sdim///    A 128-bit vector of [2 x double].
384321369Sdim/// \param M
385321369Sdim///    An immediate integer operand, with mask bits [1:0] specifying how the
386321369Sdim///    values are to be copied. The position of the mask bit corresponds to the
387321369Sdim///    index of a copied value. When a mask bit is 0, the corresponding 64-bit
388321369Sdim///    element in operand \a V1 is copied to the same position in the result.
389321369Sdim///    When a mask bit is 1, the corresponding 64-bit element in operand \a V2
390321369Sdim///    is copied to the same position in the result.
391321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied values.
392341825Sdim#define _mm_blend_pd(V1, V2, M) \
393341825Sdim  (__m128d) __builtin_ia32_blendpd ((__v2df)(__m128d)(V1), \
394341825Sdim                                    (__v2df)(__m128d)(V2), (int)(M))
395204793Srdivacky
396341825Sdim/// Returns a 128-bit vector of [4 x float] where the values are selected
397321369Sdim///    from either the first or second operand as specified by the third
398321369Sdim///    operand, the control mask.
399321369Sdim///
400321369Sdim/// \headerfile <x86intrin.h>
401321369Sdim///
402321369Sdim/// \code
403321369Sdim/// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M);
404321369Sdim/// \endcode
405321369Sdim///
406321369Sdim/// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS </c> instruction.
407321369Sdim///
408321369Sdim/// \param V1
409321369Sdim///    A 128-bit vector of [4 x float].
410321369Sdim/// \param V2
411321369Sdim///    A 128-bit vector of [4 x float].
412321369Sdim/// \param M
413321369Sdim///    An immediate integer operand, with mask bits [3:0] specifying how the
414321369Sdim///    values are to be copied. The position of the mask bit corresponds to the
415321369Sdim///    index of a copied value. When a mask bit is 0, the corresponding 32-bit
416321369Sdim///    element in operand \a V1 is copied to the same position in the result.
417321369Sdim///    When a mask bit is 1, the corresponding 32-bit element in operand \a V2
418321369Sdim///    is copied to the same position in the result.
419321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied values.
420341825Sdim#define _mm_blend_ps(V1, V2, M) \
421341825Sdim  (__m128) __builtin_ia32_blendps ((__v4sf)(__m128)(V1), \
422341825Sdim                                   (__v4sf)(__m128)(V2), (int)(M))
423204793Srdivacky
424341825Sdim/// Returns a 128-bit vector of [2 x double] where the values are
425321369Sdim///    selected from either the first or second operand as specified by the
426321369Sdim///    third operand, the control mask.
427321369Sdim///
428321369Sdim/// \headerfile <x86intrin.h>
429321369Sdim///
430321369Sdim/// This intrinsic corresponds to the <c> VBLENDVPD / BLENDVPD </c> instruction.
431321369Sdim///
432321369Sdim/// \param __V1
433321369Sdim///    A 128-bit vector of [2 x double].
434321369Sdim/// \param __V2
435321369Sdim///    A 128-bit vector of [2 x double].
436321369Sdim/// \param __M
437321369Sdim///    A 128-bit vector operand, with mask bits 127 and 63 specifying how the
438321369Sdim///    values are to be copied. The position of the mask bit corresponds to the
439321369Sdim///    most significant bit of a copied value. When a mask bit is 0, the
440321369Sdim///    corresponding 64-bit element in operand \a __V1 is copied to the same
441321369Sdim///    position in the result. When a mask bit is 1, the corresponding 64-bit
442321369Sdim///    element in operand \a __V2 is copied to the same position in the result.
443321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied values.
444288943Sdimstatic __inline__ __m128d __DEFAULT_FN_ATTRS
445204793Srdivacky_mm_blendv_pd (__m128d __V1, __m128d __V2, __m128d __M)
446204793Srdivacky{
447204793Srdivacky  return (__m128d) __builtin_ia32_blendvpd ((__v2df)__V1, (__v2df)__V2,
448204793Srdivacky                                            (__v2df)__M);
449204793Srdivacky}
450204793Srdivacky
451341825Sdim/// Returns a 128-bit vector of [4 x float] where the values are
452321369Sdim///    selected from either the first or second operand as specified by the
453321369Sdim///    third operand, the control mask.
454321369Sdim///
455321369Sdim/// \headerfile <x86intrin.h>
456321369Sdim///
457321369Sdim/// This intrinsic corresponds to the <c> VBLENDVPS / BLENDVPS </c> instruction.
458321369Sdim///
459321369Sdim/// \param __V1
460321369Sdim///    A 128-bit vector of [4 x float].
461321369Sdim/// \param __V2
462321369Sdim///    A 128-bit vector of [4 x float].
463321369Sdim/// \param __M
464321369Sdim///    A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying
465321369Sdim///    how the values are to be copied. The position of the mask bit corresponds
466321369Sdim///    to the most significant bit of a copied value. When a mask bit is 0, the
467321369Sdim///    corresponding 32-bit element in operand \a __V1 is copied to the same
468321369Sdim///    position in the result. When a mask bit is 1, the corresponding 32-bit
469321369Sdim///    element in operand \a __V2 is copied to the same position in the result.
470321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied values.
471288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS
472204793Srdivacky_mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M)
473204793Srdivacky{
474204793Srdivacky  return (__m128) __builtin_ia32_blendvps ((__v4sf)__V1, (__v4sf)__V2,
475204793Srdivacky                                           (__v4sf)__M);
476204793Srdivacky}
477204793Srdivacky
478341825Sdim/// Returns a 128-bit vector of [16 x i8] where the values are selected
479321369Sdim///    from either of the first or second operand as specified by the third
480321369Sdim///    operand, the control mask.
481321369Sdim///
482321369Sdim/// \headerfile <x86intrin.h>
483321369Sdim///
484321369Sdim/// This intrinsic corresponds to the <c> VPBLENDVB / PBLENDVB </c> instruction.
485321369Sdim///
486321369Sdim/// \param __V1
487321369Sdim///    A 128-bit vector of [16 x i8].
488321369Sdim/// \param __V2
489321369Sdim///    A 128-bit vector of [16 x i8].
490321369Sdim/// \param __M
491341825Sdim///    A 128-bit vector operand, with mask bits 127, 119, 111...7 specifying
492321369Sdim///    how the values are to be copied. The position of the mask bit corresponds
493321369Sdim///    to the most significant bit of a copied value. When a mask bit is 0, the
494321369Sdim///    corresponding 8-bit element in operand \a __V1 is copied to the same
495321369Sdim///    position in the result. When a mask bit is 1, the corresponding 8-bit
496321369Sdim///    element in operand \a __V2 is copied to the same position in the result.
497321369Sdim/// \returns A 128-bit vector of [16 x i8] containing the copied values.
498288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
499204793Srdivacky_mm_blendv_epi8 (__m128i __V1, __m128i __V2, __m128i __M)
500204793Srdivacky{
501204793Srdivacky  return (__m128i) __builtin_ia32_pblendvb128 ((__v16qi)__V1, (__v16qi)__V2,
502204793Srdivacky                                               (__v16qi)__M);
503204793Srdivacky}
504204793Srdivacky
505341825Sdim/// Returns a 128-bit vector of [8 x i16] where the values are selected
506321369Sdim///    from either of the first or second operand as specified by the third
507321369Sdim///    operand, the control mask.
508321369Sdim///
509321369Sdim/// \headerfile <x86intrin.h>
510321369Sdim///
511321369Sdim/// \code
512321369Sdim/// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M);
513321369Sdim/// \endcode
514321369Sdim///
515321369Sdim/// This intrinsic corresponds to the <c> VPBLENDW / PBLENDW </c> instruction.
516321369Sdim///
517321369Sdim/// \param V1
518321369Sdim///    A 128-bit vector of [8 x i16].
519321369Sdim/// \param V2
520321369Sdim///    A 128-bit vector of [8 x i16].
521321369Sdim/// \param M
522321369Sdim///    An immediate integer operand, with mask bits [7:0] specifying how the
523321369Sdim///    values are to be copied. The position of the mask bit corresponds to the
524321369Sdim///    index of a copied value. When a mask bit is 0, the corresponding 16-bit
525321369Sdim///    element in operand \a V1 is copied to the same position in the result.
526321369Sdim///    When a mask bit is 1, the corresponding 16-bit element in operand \a V2
527321369Sdim///    is copied to the same position in the result.
528321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the copied values.
529341825Sdim#define _mm_blend_epi16(V1, V2, M) \
530341825Sdim  (__m128i) __builtin_ia32_pblendw128 ((__v8hi)(__m128i)(V1), \
531341825Sdim                                       (__v8hi)(__m128i)(V2), (int)(M))
532204793Srdivacky
533204962Srdivacky/* SSE4 Dword Multiply Instructions.  */
534341825Sdim/// Multiples corresponding elements of two 128-bit vectors of [4 x i32]
535321369Sdim///    and returns the lower 32 bits of the each product in a 128-bit vector of
536321369Sdim///    [4 x i32].
537321369Sdim///
538321369Sdim/// \headerfile <x86intrin.h>
539321369Sdim///
540321369Sdim/// This intrinsic corresponds to the <c> VPMULLD / PMULLD </c> instruction.
541321369Sdim///
542321369Sdim/// \param __V1
543321369Sdim///    A 128-bit integer vector.
544321369Sdim/// \param __V2
545321369Sdim///    A 128-bit integer vector.
546321369Sdim/// \returns A 128-bit integer vector containing the products of both operands.
547288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
548204962Srdivacky_mm_mullo_epi32 (__m128i __V1, __m128i __V2)
549204962Srdivacky{
550309124Sdim  return (__m128i) ((__v4su)__V1 * (__v4su)__V2);
551204962Srdivacky}
552204962Srdivacky
553341825Sdim/// Multiplies corresponding even-indexed elements of two 128-bit
554321369Sdim///    vectors of [4 x i32] and returns a 128-bit vector of [2 x i64]
555321369Sdim///    containing the products.
556321369Sdim///
557321369Sdim/// \headerfile <x86intrin.h>
558321369Sdim///
559321369Sdim/// This intrinsic corresponds to the <c> VPMULDQ / PMULDQ </c> instruction.
560321369Sdim///
561321369Sdim/// \param __V1
562321369Sdim///    A 128-bit vector of [4 x i32].
563321369Sdim/// \param __V2
564321369Sdim///    A 128-bit vector of [4 x i32].
565321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the products of both
566321369Sdim///    operands.
567288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
568204962Srdivacky_mm_mul_epi32 (__m128i __V1, __m128i __V2)
569204962Srdivacky{
570204962Srdivacky  return (__m128i) __builtin_ia32_pmuldq128 ((__v4si)__V1, (__v4si)__V2);
571204962Srdivacky}
572204962Srdivacky
573204962Srdivacky/* SSE4 Floating Point Dot Product Instructions.  */
574341825Sdim/// Computes the dot product of the two 128-bit vectors of [4 x float]
575321369Sdim///    and returns it in the elements of the 128-bit result vector of
576321369Sdim///    [4 x float].
577321369Sdim///
578321369Sdim///    The immediate integer operand controls which input elements
579321369Sdim///    will contribute to the dot product, and where the final results are
580321369Sdim///    returned.
581321369Sdim///
582321369Sdim/// \headerfile <x86intrin.h>
583321369Sdim///
584321369Sdim/// \code
585321369Sdim/// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M);
586321369Sdim/// \endcode
587321369Sdim///
588321369Sdim/// This intrinsic corresponds to the <c> VDPPS / DPPS </c> instruction.
589321369Sdim///
590321369Sdim/// \param X
591321369Sdim///    A 128-bit vector of [4 x float].
592321369Sdim/// \param Y
593321369Sdim///    A 128-bit vector of [4 x float].
594321369Sdim/// \param M
595321369Sdim///    An immediate integer operand. Mask bits [7:4] determine which elements
596321369Sdim///    of the input vectors are used, with bit [4] corresponding to the lowest
597321369Sdim///    element and bit [7] corresponding to the highest element of each [4 x
598321369Sdim///    float] vector. If a bit is set, the corresponding elements from the two
599321369Sdim///    input vectors are used as an input for dot product; otherwise that input
600321369Sdim///    is treated as zero. Bits [3:0] determine which elements of the result
601321369Sdim///    will receive a copy of the final dot product, with bit [0] corresponding
602321369Sdim///    to the lowest element and bit [3] corresponding to the highest element of
603321369Sdim///    each [4 x float] subvector. If a bit is set, the dot product is returned
604321369Sdim///    in the corresponding element; otherwise that element is set to zero.
605321369Sdim/// \returns A 128-bit vector of [4 x float] containing the dot product.
606341825Sdim#define _mm_dp_ps(X, Y, M) \
607296417Sdim  (__m128) __builtin_ia32_dpps((__v4sf)(__m128)(X), \
608341825Sdim                               (__v4sf)(__m128)(Y), (M))
609204962Srdivacky
610341825Sdim/// Computes the dot product of the two 128-bit vectors of [2 x double]
611321369Sdim///    and returns it in the elements of the 128-bit result vector of
612321369Sdim///    [2 x double].
613321369Sdim///
614321369Sdim///    The immediate integer operand controls which input
615321369Sdim///    elements will contribute to the dot product, and where the final results
616321369Sdim///    are returned.
617321369Sdim///
618321369Sdim/// \headerfile <x86intrin.h>
619321369Sdim///
620321369Sdim/// \code
621321369Sdim/// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M);
622321369Sdim/// \endcode
623321369Sdim///
624321369Sdim/// This intrinsic corresponds to the <c> VDPPD / DPPD </c> instruction.
625321369Sdim///
626321369Sdim/// \param X
627321369Sdim///    A 128-bit vector of [2 x double].
628321369Sdim/// \param Y
629321369Sdim///    A 128-bit vector of [2 x double].
630321369Sdim/// \param M
631321369Sdim///    An immediate integer operand. Mask bits [5:4] determine which elements
632321369Sdim///    of the input vectors are used, with bit [4] corresponding to the lowest
633321369Sdim///    element and bit [5] corresponding to the highest element of each of [2 x
634321369Sdim///    double] vector. If a bit is set, the corresponding elements from the two
635321369Sdim///    input vectors are used as an input for dot product; otherwise that input
636321369Sdim///    is treated as zero. Bits [1:0] determine which elements of the result
637321369Sdim///    will receive a copy of the final dot product, with bit [0] corresponding
638327952Sdim///    to the lowest element and bit [1] corresponding to the highest element of
639321369Sdim///    each [2 x double] vector. If a bit is set, the dot product is returned in
640321369Sdim///    the corresponding element; otherwise that element is set to zero.
641341825Sdim#define _mm_dp_pd(X, Y, M) \
642296417Sdim  (__m128d) __builtin_ia32_dppd((__v2df)(__m128d)(X), \
643341825Sdim                                (__v2df)(__m128d)(Y), (M))
644234353Sdim
645204962Srdivacky/* SSE4 Streaming Load Hint Instruction.  */
646341825Sdim/// Loads integer values from a 128-bit aligned memory location to a
647321369Sdim///    128-bit integer vector.
648321369Sdim///
649321369Sdim/// \headerfile <x86intrin.h>
650321369Sdim///
651321369Sdim/// This intrinsic corresponds to the <c> VMOVNTDQA / MOVNTDQA </c> instruction.
652321369Sdim///
653321369Sdim/// \param __V
654321369Sdim///    A pointer to a 128-bit aligned memory location that contains the integer
655321369Sdim///    values.
656321369Sdim/// \returns A 128-bit integer vector containing the data stored at the
657321369Sdim///    specified memory location.
658288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
659296417Sdim_mm_stream_load_si128 (__m128i const *__V)
660204962Srdivacky{
661321369Sdim  return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V);
662204962Srdivacky}
663204962Srdivacky
664204962Srdivacky/* SSE4 Packed Integer Min/Max Instructions.  */
665341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
666321369Sdim///    [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser
667321369Sdim///    of the two values.
668321369Sdim///
669321369Sdim/// \headerfile <x86intrin.h>
670321369Sdim///
671321369Sdim/// This intrinsic corresponds to the <c> VPMINSB / PMINSB </c> instruction.
672321369Sdim///
673321369Sdim/// \param __V1
674321369Sdim///    A 128-bit vector of [16 x i8].
675321369Sdim/// \param __V2
676321369Sdim///    A 128-bit vector of [16 x i8]
677321369Sdim/// \returns A 128-bit vector of [16 x i8] containing the lesser values.
678288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
679204962Srdivacky_mm_min_epi8 (__m128i __V1, __m128i __V2)
680204962Srdivacky{
681204962Srdivacky  return (__m128i) __builtin_ia32_pminsb128 ((__v16qi) __V1, (__v16qi) __V2);
682204962Srdivacky}
683204962Srdivacky
684341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
685321369Sdim///    [16 x i8] and returns a 128-bit vector of [16 x i8] containing the
686321369Sdim///    greater value of the two.
687321369Sdim///
688321369Sdim/// \headerfile <x86intrin.h>
689321369Sdim///
690321369Sdim/// This intrinsic corresponds to the <c> VPMAXSB / PMAXSB </c> instruction.
691321369Sdim///
692321369Sdim/// \param __V1
693321369Sdim///    A 128-bit vector of [16 x i8].
694321369Sdim/// \param __V2
695321369Sdim///    A 128-bit vector of [16 x i8].
696321369Sdim/// \returns A 128-bit vector of [16 x i8] containing the greater values.
697288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
698204962Srdivacky_mm_max_epi8 (__m128i __V1, __m128i __V2)
699204962Srdivacky{
700204962Srdivacky  return (__m128i) __builtin_ia32_pmaxsb128 ((__v16qi) __V1, (__v16qi) __V2);
701204962Srdivacky}
702204962Srdivacky
703341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
704321369Sdim///    [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser
705321369Sdim///    value of the two.
706321369Sdim///
707321369Sdim/// \headerfile <x86intrin.h>
708321369Sdim///
709321369Sdim/// This intrinsic corresponds to the <c> VPMINUW / PMINUW </c> instruction.
710321369Sdim///
711321369Sdim/// \param __V1
712321369Sdim///    A 128-bit vector of [8 x u16].
713321369Sdim/// \param __V2
714321369Sdim///    A 128-bit vector of [8 x u16].
715321369Sdim/// \returns A 128-bit vector of [8 x u16] containing the lesser values.
716288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
717204962Srdivacky_mm_min_epu16 (__m128i __V1, __m128i __V2)
718204962Srdivacky{
719204962Srdivacky  return (__m128i) __builtin_ia32_pminuw128 ((__v8hi) __V1, (__v8hi) __V2);
720204962Srdivacky}
721204962Srdivacky
722341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
723321369Sdim///    [8 x u16] and returns a 128-bit vector of [8 x u16] containing the
724321369Sdim///    greater value of the two.
725321369Sdim///
726321369Sdim/// \headerfile <x86intrin.h>
727321369Sdim///
728321369Sdim/// This intrinsic corresponds to the <c> VPMAXUW / PMAXUW </c> instruction.
729321369Sdim///
730321369Sdim/// \param __V1
731321369Sdim///    A 128-bit vector of [8 x u16].
732321369Sdim/// \param __V2
733321369Sdim///    A 128-bit vector of [8 x u16].
734321369Sdim/// \returns A 128-bit vector of [8 x u16] containing the greater values.
735288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
736204962Srdivacky_mm_max_epu16 (__m128i __V1, __m128i __V2)
737204962Srdivacky{
738204962Srdivacky  return (__m128i) __builtin_ia32_pmaxuw128 ((__v8hi) __V1, (__v8hi) __V2);
739204962Srdivacky}
740204962Srdivacky
741341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
742321369Sdim///    [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser
743321369Sdim///    value of the two.
744321369Sdim///
745321369Sdim/// \headerfile <x86intrin.h>
746321369Sdim///
747321369Sdim/// This intrinsic corresponds to the <c> VPMINSD / PMINSD </c> instruction.
748321369Sdim///
749321369Sdim/// \param __V1
750321369Sdim///    A 128-bit vector of [4 x i32].
751321369Sdim/// \param __V2
752321369Sdim///    A 128-bit vector of [4 x i32].
753321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the lesser values.
754288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
755204962Srdivacky_mm_min_epi32 (__m128i __V1, __m128i __V2)
756204962Srdivacky{
757204962Srdivacky  return (__m128i) __builtin_ia32_pminsd128 ((__v4si) __V1, (__v4si) __V2);
758204962Srdivacky}
759204962Srdivacky
760341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
761321369Sdim///    [4 x i32] and returns a 128-bit vector of [4 x i32] containing the
762321369Sdim///    greater value of the two.
763321369Sdim///
764321369Sdim/// \headerfile <x86intrin.h>
765321369Sdim///
766321369Sdim/// This intrinsic corresponds to the <c> VPMAXSD / PMAXSD </c> instruction.
767321369Sdim///
768321369Sdim/// \param __V1
769321369Sdim///    A 128-bit vector of [4 x i32].
770321369Sdim/// \param __V2
771321369Sdim///    A 128-bit vector of [4 x i32].
772321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the greater values.
773288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
774204962Srdivacky_mm_max_epi32 (__m128i __V1, __m128i __V2)
775204962Srdivacky{
776204962Srdivacky  return (__m128i) __builtin_ia32_pmaxsd128 ((__v4si) __V1, (__v4si) __V2);
777204962Srdivacky}
778204962Srdivacky
779341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
780321369Sdim///    [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser
781321369Sdim///    value of the two.
782321369Sdim///
783321369Sdim/// \headerfile <x86intrin.h>
784321369Sdim///
785321369Sdim/// This intrinsic corresponds to the <c> VPMINUD / PMINUD </c>  instruction.
786321369Sdim///
787321369Sdim/// \param __V1
788321369Sdim///    A 128-bit vector of [4 x u32].
789321369Sdim/// \param __V2
790321369Sdim///    A 128-bit vector of [4 x u32].
791321369Sdim/// \returns A 128-bit vector of [4 x u32] containing the lesser values.
792288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
793204962Srdivacky_mm_min_epu32 (__m128i __V1, __m128i __V2)
794204962Srdivacky{
795204962Srdivacky  return (__m128i) __builtin_ia32_pminud128((__v4si) __V1, (__v4si) __V2);
796204962Srdivacky}
797204962Srdivacky
798341825Sdim/// Compares the corresponding elements of two 128-bit vectors of
799321369Sdim///    [4 x u32] and returns a 128-bit vector of [4 x u32] containing the
800321369Sdim///    greater value of the two.
801321369Sdim///
802321369Sdim/// \headerfile <x86intrin.h>
803321369Sdim///
804321369Sdim/// This intrinsic corresponds to the <c> VPMAXUD / PMAXUD </c> instruction.
805321369Sdim///
806321369Sdim/// \param __V1
807321369Sdim///    A 128-bit vector of [4 x u32].
808321369Sdim/// \param __V2
809321369Sdim///    A 128-bit vector of [4 x u32].
810321369Sdim/// \returns A 128-bit vector of [4 x u32] containing the greater values.
811288943Sdimstatic __inline__  __m128i __DEFAULT_FN_ATTRS
812204962Srdivacky_mm_max_epu32 (__m128i __V1, __m128i __V2)
813204962Srdivacky{
814204962Srdivacky  return (__m128i) __builtin_ia32_pmaxud128((__v4si) __V1, (__v4si) __V2);
815204962Srdivacky}
816204962Srdivacky
817204962Srdivacky/* SSE4 Insertion and Extraction from XMM Register Instructions.  */
818341825Sdim/// Takes the first argument \a X and inserts an element from the second
819321369Sdim///    argument \a Y as selected by the third argument \a N. That result then
820321369Sdim///    has elements zeroed out also as selected by the third argument \a N. The
821321369Sdim///    resulting 128-bit vector of [4 x float] is then returned.
822321369Sdim///
823321369Sdim/// \headerfile <x86intrin.h>
824321369Sdim///
825321369Sdim/// \code
826321369Sdim/// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N);
827321369Sdim/// \endcode
828321369Sdim///
829321369Sdim/// This intrinsic corresponds to the <c> VINSERTPS </c> instruction.
830321369Sdim///
831321369Sdim/// \param X
832321369Sdim///    A 128-bit vector source operand of [4 x float]. With the exception of
833321369Sdim///    those bits in the result copied from parameter \a Y and zeroed by bits
834321369Sdim///    [3:0] of \a N, all bits from this parameter are copied to the result.
835321369Sdim/// \param Y
836321369Sdim///    A 128-bit vector source operand of [4 x float]. One single-precision
837321369Sdim///    floating-point element from this source, as determined by the immediate
838321369Sdim///    parameter, is copied to the result.
839321369Sdim/// \param N
840321369Sdim///    Specifies which bits from operand \a Y will be copied, which bits in the
841321369Sdim///    result they will be be copied to, and which bits in the result will be
842321369Sdim///    cleared. The following assignments are made: \n
843321369Sdim///    Bits [7:6] specify the bits to copy from operand \a Y: \n
844321369Sdim///      00: Selects bits [31:0] from operand \a Y. \n
845321369Sdim///      01: Selects bits [63:32] from operand \a Y. \n
846321369Sdim///      10: Selects bits [95:64] from operand \a Y. \n
847321369Sdim///      11: Selects bits [127:96] from operand \a Y. \n
848321369Sdim///    Bits [5:4] specify the bits in the result to which the selected bits
849321369Sdim///    from operand \a Y are copied: \n
850321369Sdim///      00: Copies the selected bits from \a Y to result bits [31:0]. \n
851321369Sdim///      01: Copies the selected bits from \a Y to result bits [63:32]. \n
852321369Sdim///      10: Copies the selected bits from \a Y to result bits [95:64]. \n
853321369Sdim///      11: Copies the selected bits from \a Y to result bits [127:96]. \n
854321369Sdim///    Bits[3:0]: If any of these bits are set, the corresponding result
855321369Sdim///    element is cleared.
856327952Sdim/// \returns A 128-bit vector of [4 x float] containing the copied
857327952Sdim///    single-precision floating point elements from the operands.
858204962Srdivacky#define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))
859321369Sdim
860341825Sdim/// Extracts a 32-bit integer from a 128-bit vector of [4 x float] and
861321369Sdim///    returns it, using the immediate value parameter \a N as a selector.
862321369Sdim///
863321369Sdim/// \headerfile <x86intrin.h>
864321369Sdim///
865321369Sdim/// \code
866321369Sdim/// int _mm_extract_ps(__m128 X, const int N);
867321369Sdim/// \endcode
868321369Sdim///
869321369Sdim/// This intrinsic corresponds to the <c> VEXTRACTPS / EXTRACTPS </c>
870321369Sdim/// instruction.
871321369Sdim///
872321369Sdim/// \param X
873321369Sdim///    A 128-bit vector of [4 x float].
874321369Sdim/// \param N
875321369Sdim///    An immediate value. Bits [1:0] determines which bits from the argument
876321369Sdim///    \a X are extracted and returned: \n
877321369Sdim///    00: Bits [31:0] of parameter \a X are returned. \n
878321369Sdim///    01: Bits [63:32] of parameter \a X are returned. \n
879321369Sdim///    10: Bits [95:64] of parameter \a X are returned. \n
880321369Sdim///    11: Bits [127:96] of parameter \a X are returned.
881321369Sdim/// \returns A 32-bit integer containing the extracted 32 bits of float data.
882204962Srdivacky#define _mm_extract_ps(X, N) (__extension__                      \
883341825Sdim  ({ union { int __i; float __f; } __t;  \
884341825Sdim     __t.__f = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); \
885341825Sdim     __t.__i;}))
886204962Srdivacky
887204962Srdivacky/* Miscellaneous insert and extract macros.  */
888204962Srdivacky/* Extract a single-precision float from X at index N into D.  */
889341825Sdim#define _MM_EXTRACT_FLOAT(D, X, N) \
890341825Sdim  { (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); }
891296417Sdim
892204962Srdivacky/* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create
893204962Srdivacky   an index suitable for _mm_insert_ps.  */
894204962Srdivacky#define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z))
895296417Sdim
896204962Srdivacky/* Extract a float from X at index N into the first index of the return.  */
897204962Srdivacky#define _MM_PICK_OUT_PS(X, N) _mm_insert_ps (_mm_setzero_ps(), (X),   \
898204962Srdivacky                                             _MM_MK_INSERTPS_NDX((N), 0, 0x0e))
899296417Sdim
900205219Srdivacky/* Insert int into packed integer array at index.  */
901341825Sdim/// Constructs a 128-bit vector of [16 x i8] by first making a copy of
902321369Sdim///    the 128-bit integer vector parameter, and then inserting the lower 8 bits
903321369Sdim///    of an integer parameter \a I into an offset specified by the immediate
904321369Sdim///    value parameter \a N.
905321369Sdim///
906321369Sdim/// \headerfile <x86intrin.h>
907321369Sdim///
908321369Sdim/// \code
909321369Sdim/// __m128i _mm_insert_epi8(__m128i X, int I, const int N);
910321369Sdim/// \endcode
911321369Sdim///
912321369Sdim/// This intrinsic corresponds to the <c> VPINSRB / PINSRB </c> instruction.
913321369Sdim///
914321369Sdim/// \param X
915321369Sdim///    A 128-bit integer vector of [16 x i8]. This vector is copied to the
916321369Sdim///    result and then one of the sixteen elements in the result vector is
917321369Sdim///    replaced by the lower 8 bits of \a I.
918321369Sdim/// \param I
919321369Sdim///    An integer. The lower 8 bits of this operand are written to the result
920321369Sdim///    beginning at the offset specified by \a N.
921321369Sdim/// \param N
922321369Sdim///    An immediate value. Bits [3:0] specify the bit offset in the result at
923321369Sdim///    which the lower 8 bits of \a I are written. \n
924321369Sdim///    0000: Bits [7:0] of the result are used for insertion. \n
925321369Sdim///    0001: Bits [15:8] of the result are used for insertion. \n
926321369Sdim///    0010: Bits [23:16] of the result are used for insertion. \n
927321369Sdim///    0011: Bits [31:24] of the result are used for insertion. \n
928321369Sdim///    0100: Bits [39:32] of the result are used for insertion. \n
929321369Sdim///    0101: Bits [47:40] of the result are used for insertion. \n
930321369Sdim///    0110: Bits [55:48] of the result are used for insertion. \n
931321369Sdim///    0111: Bits [63:56] of the result are used for insertion. \n
932321369Sdim///    1000: Bits [71:64] of the result are used for insertion. \n
933321369Sdim///    1001: Bits [79:72] of the result are used for insertion. \n
934321369Sdim///    1010: Bits [87:80] of the result are used for insertion. \n
935321369Sdim///    1011: Bits [95:88] of the result are used for insertion. \n
936321369Sdim///    1100: Bits [103:96] of the result are used for insertion. \n
937321369Sdim///    1101: Bits [111:104] of the result are used for insertion. \n
938321369Sdim///    1110: Bits [119:112] of the result are used for insertion. \n
939321369Sdim///    1111: Bits [127:120] of the result are used for insertion.
940321369Sdim/// \returns A 128-bit integer vector containing the constructed values.
941341825Sdim#define _mm_insert_epi8(X, I, N) \
942341825Sdim  (__m128i)__builtin_ia32_vec_set_v16qi((__v16qi)(__m128i)(X), \
943341825Sdim                                        (int)(I), (int)(N))
944321369Sdim
945341825Sdim/// Constructs a 128-bit vector of [4 x i32] by first making a copy of
946321369Sdim///    the 128-bit integer vector parameter, and then inserting the 32-bit
947321369Sdim///    integer parameter \a I at the offset specified by the immediate value
948321369Sdim///    parameter \a N.
949321369Sdim///
950321369Sdim/// \headerfile <x86intrin.h>
951321369Sdim///
952321369Sdim/// \code
953321369Sdim/// __m128i _mm_insert_epi32(__m128i X, int I, const int N);
954321369Sdim/// \endcode
955321369Sdim///
956321369Sdim/// This intrinsic corresponds to the <c> VPINSRD / PINSRD </c> instruction.
957321369Sdim///
958321369Sdim/// \param X
959321369Sdim///    A 128-bit integer vector of [4 x i32]. This vector is copied to the
960321369Sdim///    result and then one of the four elements in the result vector is
961321369Sdim///    replaced by \a I.
962321369Sdim/// \param I
963321369Sdim///    A 32-bit integer that is written to the result beginning at the offset
964321369Sdim///    specified by \a N.
965321369Sdim/// \param N
966321369Sdim///    An immediate value. Bits [1:0] specify the bit offset in the result at
967321369Sdim///    which the integer \a I is written. \n
968321369Sdim///    00: Bits [31:0] of the result are used for insertion. \n
969321369Sdim///    01: Bits [63:32] of the result are used for insertion. \n
970321369Sdim///    10: Bits [95:64] of the result are used for insertion. \n
971321369Sdim///    11: Bits [127:96] of the result are used for insertion.
972321369Sdim/// \returns A 128-bit integer vector containing the constructed values.
973341825Sdim#define _mm_insert_epi32(X, I, N) \
974341825Sdim  (__m128i)__builtin_ia32_vec_set_v4si((__v4si)(__m128i)(X), \
975341825Sdim                                       (int)(I), (int)(N))
976321369Sdim
977205219Srdivacky#ifdef __x86_64__
978341825Sdim/// Constructs a 128-bit vector of [2 x i64] by first making a copy of
979321369Sdim///    the 128-bit integer vector parameter, and then inserting the 64-bit
980321369Sdim///    integer parameter \a I, using the immediate value parameter \a N as an
981321369Sdim///    insertion location selector.
982321369Sdim///
983321369Sdim/// \headerfile <x86intrin.h>
984321369Sdim///
985321369Sdim/// \code
986321369Sdim/// __m128i _mm_insert_epi64(__m128i X, long long I, const int N);
987321369Sdim/// \endcode
988321369Sdim///
989321369Sdim/// This intrinsic corresponds to the <c> VPINSRQ / PINSRQ </c> instruction.
990321369Sdim///
991321369Sdim/// \param X
992321369Sdim///    A 128-bit integer vector of [2 x i64]. This vector is copied to the
993321369Sdim///    result and then one of the two elements in the result vector is replaced
994321369Sdim///    by \a I.
995321369Sdim/// \param I
996321369Sdim///    A 64-bit integer that is written to the result beginning at the offset
997321369Sdim///    specified by \a N.
998321369Sdim/// \param N
999321369Sdim///    An immediate value. Bit [0] specifies the bit offset in the result at
1000321369Sdim///    which the integer \a I is written. \n
1001321369Sdim///    0: Bits [63:0] of the result are used for insertion. \n
1002321369Sdim///    1: Bits [127:64] of the result are used for insertion. \n
1003321369Sdim/// \returns A 128-bit integer vector containing the constructed values.
1004341825Sdim#define _mm_insert_epi64(X, I, N) \
1005341825Sdim  (__m128i)__builtin_ia32_vec_set_v2di((__v2di)(__m128i)(X), \
1006341825Sdim                                       (long long)(I), (int)(N))
1007205219Srdivacky#endif /* __x86_64__ */
1008204962Srdivacky
1009212904Sdim/* Extract int from packed integer array at index.  This returns the element
1010212904Sdim * as a zero extended value, so it is unsigned.
1011212904Sdim */
1012341825Sdim/// Extracts an 8-bit element from the 128-bit integer vector of
1013321369Sdim///    [16 x i8], using the immediate value parameter \a N as a selector.
1014321369Sdim///
1015321369Sdim/// \headerfile <x86intrin.h>
1016321369Sdim///
1017321369Sdim/// \code
1018321369Sdim/// int _mm_extract_epi8(__m128i X, const int N);
1019321369Sdim/// \endcode
1020321369Sdim///
1021321369Sdim/// This intrinsic corresponds to the <c> VPEXTRB / PEXTRB </c> instruction.
1022321369Sdim///
1023321369Sdim/// \param X
1024321369Sdim///    A 128-bit integer vector.
1025321369Sdim/// \param N
1026321369Sdim///    An immediate value. Bits [3:0] specify which 8-bit vector element from
1027321369Sdim///    the argument \a X to extract and copy to the result. \n
1028321369Sdim///    0000: Bits [7:0] of parameter \a X are extracted. \n
1029321369Sdim///    0001: Bits [15:8] of the parameter \a X are extracted. \n
1030321369Sdim///    0010: Bits [23:16] of the parameter \a X are extracted. \n
1031321369Sdim///    0011: Bits [31:24] of the parameter \a X are extracted. \n
1032321369Sdim///    0100: Bits [39:32] of the parameter \a X are extracted. \n
1033321369Sdim///    0101: Bits [47:40] of the parameter \a X are extracted. \n
1034321369Sdim///    0110: Bits [55:48] of the parameter \a X are extracted. \n
1035321369Sdim///    0111: Bits [63:56] of the parameter \a X are extracted. \n
1036321369Sdim///    1000: Bits [71:64] of the parameter \a X are extracted. \n
1037321369Sdim///    1001: Bits [79:72] of the parameter \a X are extracted. \n
1038321369Sdim///    1010: Bits [87:80] of the parameter \a X are extracted. \n
1039321369Sdim///    1011: Bits [95:88] of the parameter \a X are extracted. \n
1040321369Sdim///    1100: Bits [103:96] of the parameter \a X are extracted. \n
1041321369Sdim///    1101: Bits [111:104] of the parameter \a X are extracted. \n
1042321369Sdim///    1110: Bits [119:112] of the parameter \a X are extracted. \n
1043321369Sdim///    1111: Bits [127:120] of the parameter \a X are extracted.
1044321369Sdim/// \returns  An unsigned integer, whose lower 8 bits are selected from the
1045321369Sdim///    128-bit integer vector parameter and the remaining bits are assigned
1046321369Sdim///    zeros.
1047341825Sdim#define _mm_extract_epi8(X, N) \
1048341825Sdim  (int)(unsigned char)__builtin_ia32_vec_ext_v16qi((__v16qi)(__m128i)(X), \
1049341825Sdim                                                   (int)(N))
1050321369Sdim
1051341825Sdim/// Extracts a 32-bit element from the 128-bit integer vector of
1052321369Sdim///    [4 x i32], using the immediate value parameter \a N as a selector.
1053321369Sdim///
1054321369Sdim/// \headerfile <x86intrin.h>
1055321369Sdim///
1056321369Sdim/// \code
1057321369Sdim/// int _mm_extract_epi32(__m128i X, const int N);
1058321369Sdim/// \endcode
1059321369Sdim///
1060321369Sdim/// This intrinsic corresponds to the <c> VPEXTRD / PEXTRD </c> instruction.
1061321369Sdim///
1062321369Sdim/// \param X
1063321369Sdim///    A 128-bit integer vector.
1064321369Sdim/// \param N
1065321369Sdim///    An immediate value. Bits [1:0] specify which 32-bit vector element from
1066321369Sdim///    the argument \a X to extract and copy to the result. \n
1067321369Sdim///    00: Bits [31:0] of the parameter \a X are extracted. \n
1068321369Sdim///    01: Bits [63:32] of the parameter \a X are extracted. \n
1069321369Sdim///    10: Bits [95:64] of the parameter \a X are extracted. \n
1070321369Sdim///    11: Bits [127:96] of the parameter \a X are exracted.
1071321369Sdim/// \returns  An integer, whose lower 32 bits are selected from the 128-bit
1072321369Sdim///    integer vector parameter and the remaining bits are assigned zeros.
1073341825Sdim#define _mm_extract_epi32(X, N) \
1074341825Sdim  (int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N))
1075321369Sdim
1076205219Srdivacky#ifdef __x86_64__
1077341825Sdim/// Extracts a 64-bit element from the 128-bit integer vector of
1078321369Sdim///    [2 x i64], using the immediate value parameter \a N as a selector.
1079321369Sdim///
1080321369Sdim/// \headerfile <x86intrin.h>
1081321369Sdim///
1082321369Sdim/// \code
1083321369Sdim/// long long _mm_extract_epi64(__m128i X, const int N);
1084321369Sdim/// \endcode
1085321369Sdim///
1086321369Sdim/// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
1087321369Sdim///
1088321369Sdim/// \param X
1089321369Sdim///    A 128-bit integer vector.
1090321369Sdim/// \param N
1091321369Sdim///    An immediate value. Bit [0] specifies which 64-bit vector element from
1092321369Sdim///    the argument \a X to return. \n
1093321369Sdim///    0: Bits [63:0] are returned. \n
1094321369Sdim///    1: Bits [127:64] are returned. \n
1095321369Sdim/// \returns  A 64-bit integer.
1096341825Sdim#define _mm_extract_epi64(X, N) \
1097341825Sdim  (long long)__builtin_ia32_vec_ext_v2di((__v2di)(__m128i)(X), (int)(N))
1098205219Srdivacky#endif /* __x86_64 */
1099205219Srdivacky
1100205219Srdivacky/* SSE4 128-bit Packed Integer Comparisons.  */
1101341825Sdim/// Tests whether the specified bits in a 128-bit integer vector are all
1102321369Sdim///    zeros.
1103321369Sdim///
1104321369Sdim/// \headerfile <x86intrin.h>
1105321369Sdim///
1106321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1107321369Sdim///
1108321369Sdim/// \param __M
1109321369Sdim///    A 128-bit integer vector containing the bits to be tested.
1110321369Sdim/// \param __V
1111321369Sdim///    A 128-bit integer vector selecting which bits to test in operand \a __M.
1112321369Sdim/// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1113288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1114205219Srdivacky_mm_testz_si128(__m128i __M, __m128i __V)
1115205219Srdivacky{
1116205219Srdivacky  return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V);
1117205219Srdivacky}
1118205219Srdivacky
1119341825Sdim/// Tests whether the specified bits in a 128-bit integer vector are all
1120321369Sdim///    ones.
1121321369Sdim///
1122321369Sdim/// \headerfile <x86intrin.h>
1123321369Sdim///
1124321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1125321369Sdim///
1126321369Sdim/// \param __M
1127321369Sdim///    A 128-bit integer vector containing the bits to be tested.
1128321369Sdim/// \param __V
1129321369Sdim///    A 128-bit integer vector selecting which bits to test in operand \a __M.
1130321369Sdim/// \returns TRUE if the specified bits are all ones; FALSE otherwise.
1131288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1132205219Srdivacky_mm_testc_si128(__m128i __M, __m128i __V)
1133205219Srdivacky{
1134205219Srdivacky  return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V);
1135205219Srdivacky}
1136205219Srdivacky
1137341825Sdim/// Tests whether the specified bits in a 128-bit integer vector are
1138321369Sdim///    neither all zeros nor all ones.
1139321369Sdim///
1140321369Sdim/// \headerfile <x86intrin.h>
1141321369Sdim///
1142321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1143321369Sdim///
1144321369Sdim/// \param __M
1145321369Sdim///    A 128-bit integer vector containing the bits to be tested.
1146321369Sdim/// \param __V
1147321369Sdim///    A 128-bit integer vector selecting which bits to test in operand \a __M.
1148321369Sdim/// \returns TRUE if the specified bits are neither all zeros nor all ones;
1149321369Sdim///    FALSE otherwise.
1150288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS
1151205219Srdivacky_mm_testnzc_si128(__m128i __M, __m128i __V)
1152205219Srdivacky{
1153205219Srdivacky  return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V);
1154205219Srdivacky}
1155205219Srdivacky
1156341825Sdim/// Tests whether the specified bits in a 128-bit integer vector are all
1157321369Sdim///    ones.
1158321369Sdim///
1159321369Sdim/// \headerfile <x86intrin.h>
1160321369Sdim///
1161321369Sdim/// \code
1162321369Sdim/// int _mm_test_all_ones(__m128i V);
1163321369Sdim/// \endcode
1164321369Sdim///
1165321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1166321369Sdim///
1167321369Sdim/// \param V
1168321369Sdim///    A 128-bit integer vector containing the bits to be tested.
1169321369Sdim/// \returns TRUE if the bits specified in the operand are all set to 1; FALSE
1170321369Sdim///    otherwise.
1171205219Srdivacky#define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V)))
1172321369Sdim
1173341825Sdim/// Tests whether the specified bits in a 128-bit integer vector are
1174321369Sdim///    neither all zeros nor all ones.
1175321369Sdim///
1176321369Sdim/// \headerfile <x86intrin.h>
1177321369Sdim///
1178321369Sdim/// \code
1179321369Sdim/// int _mm_test_mix_ones_zeros(__m128i M, __m128i V);
1180321369Sdim/// \endcode
1181321369Sdim///
1182321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1183321369Sdim///
1184321369Sdim/// \param M
1185321369Sdim///    A 128-bit integer vector containing the bits to be tested.
1186321369Sdim/// \param V
1187321369Sdim///    A 128-bit integer vector selecting which bits to test in operand \a M.
1188321369Sdim/// \returns TRUE if the specified bits are neither all zeros nor all ones;
1189321369Sdim///    FALSE otherwise.
1190205219Srdivacky#define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V))
1191321369Sdim
1192341825Sdim/// Tests whether the specified bits in a 128-bit integer vector are all
1193321369Sdim///    zeros.
1194321369Sdim///
1195321369Sdim/// \headerfile <x86intrin.h>
1196321369Sdim///
1197321369Sdim/// \code
1198321369Sdim/// int _mm_test_all_zeros(__m128i M, __m128i V);
1199321369Sdim/// \endcode
1200321369Sdim///
1201321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1202321369Sdim///
1203321369Sdim/// \param M
1204321369Sdim///    A 128-bit integer vector containing the bits to be tested.
1205321369Sdim/// \param V
1206321369Sdim///    A 128-bit integer vector selecting which bits to test in operand \a M.
1207321369Sdim/// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1208234353Sdim#define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V))
1209205219Srdivacky
1210205219Srdivacky/* SSE4 64-bit Packed Integer Comparisons.  */
1211341825Sdim/// Compares each of the corresponding 64-bit values of the 128-bit
1212321369Sdim///    integer vectors for equality.
1213321369Sdim///
1214321369Sdim/// \headerfile <x86intrin.h>
1215321369Sdim///
1216321369Sdim/// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction.
1217321369Sdim///
1218321369Sdim/// \param __V1
1219321369Sdim///    A 128-bit integer vector.
1220321369Sdim/// \param __V2
1221321369Sdim///    A 128-bit integer vector.
1222321369Sdim/// \returns A 128-bit integer vector containing the comparison results.
1223288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1224205219Srdivacky_mm_cmpeq_epi64(__m128i __V1, __m128i __V2)
1225205219Srdivacky{
1226234353Sdim  return (__m128i)((__v2di)__V1 == (__v2di)__V2);
1227205219Srdivacky}
1228205219Srdivacky
1229205219Srdivacky/* SSE4 Packed Integer Sign-Extension.  */
1230341825Sdim/// Sign-extends each of the lower eight 8-bit integer elements of a
1231321369Sdim///    128-bit vector of [16 x i8] to 16-bit values and returns them in a
1232321369Sdim///    128-bit vector of [8 x i16]. The upper eight elements of the input vector
1233321369Sdim///    are unused.
1234321369Sdim///
1235321369Sdim/// \headerfile <x86intrin.h>
1236321369Sdim///
1237321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXBW / PMOVSXBW </c> instruction.
1238321369Sdim///
1239321369Sdim/// \param __V
1240321369Sdim///    A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are sign-
1241321369Sdim///    extended to 16-bit values.
1242321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the sign-extended values.
1243288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1244205219Srdivacky_mm_cvtepi8_epi16(__m128i __V)
1245205219Srdivacky{
1246296417Sdim  /* This function always performs a signed extension, but __v16qi is a char
1247296417Sdim     which may be signed or unsigned, so use __v16qs. */
1248296417Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1249205219Srdivacky}
1250205219Srdivacky
1251341825Sdim/// Sign-extends each of the lower four 8-bit integer elements of a
1252321369Sdim///    128-bit vector of [16 x i8] to 32-bit values and returns them in a
1253321369Sdim///    128-bit vector of [4 x i32]. The upper twelve elements of the input
1254321369Sdim///    vector are unused.
1255321369Sdim///
1256321369Sdim/// \headerfile <x86intrin.h>
1257321369Sdim///
1258321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXBD / PMOVSXBD </c> instruction.
1259321369Sdim///
1260321369Sdim/// \param __V
1261341825Sdim///    A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
1262341825Sdim///    sign-extended to 32-bit values.
1263321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1264288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1265205219Srdivacky_mm_cvtepi8_epi32(__m128i __V)
1266205219Srdivacky{
1267296417Sdim  /* This function always performs a signed extension, but __v16qi is a char
1268296417Sdim     which may be signed or unsigned, so use __v16qs. */
1269296417Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si);
1270205219Srdivacky}
1271205219Srdivacky
1272341825Sdim/// Sign-extends each of the lower two 8-bit integer elements of a
1273321369Sdim///    128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1274321369Sdim///    a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1275321369Sdim///    vector are unused.
1276321369Sdim///
1277321369Sdim/// \headerfile <x86intrin.h>
1278321369Sdim///
1279321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXBQ / PMOVSXBQ </c> instruction.
1280321369Sdim///
1281321369Sdim/// \param __V
1282341825Sdim///    A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
1283341825Sdim///    sign-extended to 64-bit values.
1284321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1285288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1286205219Srdivacky_mm_cvtepi8_epi64(__m128i __V)
1287205219Srdivacky{
1288296417Sdim  /* This function always performs a signed extension, but __v16qi is a char
1289296417Sdim     which may be signed or unsigned, so use __v16qs. */
1290296417Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di);
1291205219Srdivacky}
1292205219Srdivacky
1293341825Sdim/// Sign-extends each of the lower four 16-bit integer elements of a
1294321369Sdim///    128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1295321369Sdim///    a 128-bit vector of [4 x i32]. The upper four elements of the input
1296321369Sdim///    vector are unused.
1297321369Sdim///
1298321369Sdim/// \headerfile <x86intrin.h>
1299321369Sdim///
1300321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXWD / PMOVSXWD </c> instruction.
1301321369Sdim///
1302321369Sdim/// \param __V
1303341825Sdim///    A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
1304341825Sdim///    sign-extended to 32-bit values.
1305321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1306288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1307205219Srdivacky_mm_cvtepi16_epi32(__m128i __V)
1308205219Srdivacky{
1309296417Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si);
1310205219Srdivacky}
1311205219Srdivacky
1312341825Sdim/// Sign-extends each of the lower two 16-bit integer elements of a
1313321369Sdim///    128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1314321369Sdim///    a 128-bit vector of [2 x i64]. The upper six elements of the input
1315321369Sdim///    vector are unused.
1316321369Sdim///
1317321369Sdim/// \headerfile <x86intrin.h>
1318321369Sdim///
1319321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXWQ / PMOVSXWQ </c> instruction.
1320321369Sdim///
1321321369Sdim/// \param __V
1322341825Sdim///    A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
1323341825Sdim///     sign-extended to 64-bit values.
1324321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1325288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1326205219Srdivacky_mm_cvtepi16_epi64(__m128i __V)
1327205219Srdivacky{
1328296417Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di);
1329205219Srdivacky}
1330205219Srdivacky
1331341825Sdim/// Sign-extends each of the lower two 32-bit integer elements of a
1332321369Sdim///    128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1333321369Sdim///    a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1334321369Sdim///    are unused.
1335321369Sdim///
1336321369Sdim/// \headerfile <x86intrin.h>
1337321369Sdim///
1338321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXDQ / PMOVSXDQ </c> instruction.
1339321369Sdim///
1340321369Sdim/// \param __V
1341341825Sdim///    A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
1342341825Sdim///    sign-extended to 64-bit values.
1343321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1344288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1345205219Srdivacky_mm_cvtepi32_epi64(__m128i __V)
1346205219Srdivacky{
1347296417Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di);
1348205219Srdivacky}
1349205219Srdivacky
1350205219Srdivacky/* SSE4 Packed Integer Zero-Extension.  */
1351341825Sdim/// Zero-extends each of the lower eight 8-bit integer elements of a
1352321369Sdim///    128-bit vector of [16 x i8] to 16-bit values and returns them in a
1353321369Sdim///    128-bit vector of [8 x i16]. The upper eight elements of the input vector
1354321369Sdim///    are unused.
1355321369Sdim///
1356321369Sdim/// \headerfile <x86intrin.h>
1357321369Sdim///
1358321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXBW / PMOVZXBW </c> instruction.
1359321369Sdim///
1360321369Sdim/// \param __V
1361341825Sdim///    A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are
1362341825Sdim///    zero-extended to 16-bit values.
1363321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the zero-extended values.
1364288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1365205219Srdivacky_mm_cvtepu8_epi16(__m128i __V)
1366205219Srdivacky{
1367309124Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1368205219Srdivacky}
1369205219Srdivacky
1370341825Sdim/// Zero-extends each of the lower four 8-bit integer elements of a
1371321369Sdim///    128-bit vector of [16 x i8] to 32-bit values and returns them in a
1372321369Sdim///    128-bit vector of [4 x i32]. The upper twelve elements of the input
1373321369Sdim///    vector are unused.
1374321369Sdim///
1375321369Sdim/// \headerfile <x86intrin.h>
1376321369Sdim///
1377321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXBD / PMOVZXBD </c> instruction.
1378321369Sdim///
1379321369Sdim/// \param __V
1380341825Sdim///    A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
1381341825Sdim///    zero-extended to 32-bit values.
1382321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1383288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1384205219Srdivacky_mm_cvtepu8_epi32(__m128i __V)
1385205219Srdivacky{
1386309124Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si);
1387205219Srdivacky}
1388205219Srdivacky
1389341825Sdim/// Zero-extends each of the lower two 8-bit integer elements of a
1390321369Sdim///    128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1391321369Sdim///    a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1392321369Sdim///    vector are unused.
1393321369Sdim///
1394321369Sdim/// \headerfile <x86intrin.h>
1395321369Sdim///
1396321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXBQ / PMOVZXBQ </c> instruction.
1397321369Sdim///
1398321369Sdim/// \param __V
1399341825Sdim///    A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
1400341825Sdim///    zero-extended to 64-bit values.
1401321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1402288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1403205219Srdivacky_mm_cvtepu8_epi64(__m128i __V)
1404205219Srdivacky{
1405309124Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di);
1406205219Srdivacky}
1407205219Srdivacky
1408341825Sdim/// Zero-extends each of the lower four 16-bit integer elements of a
1409321369Sdim///    128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1410321369Sdim///    a 128-bit vector of [4 x i32]. The upper four elements of the input
1411321369Sdim///    vector are unused.
1412321369Sdim///
1413321369Sdim/// \headerfile <x86intrin.h>
1414321369Sdim///
1415321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXWD / PMOVZXWD </c> instruction.
1416321369Sdim///
1417321369Sdim/// \param __V
1418341825Sdim///    A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
1419341825Sdim///    zero-extended to 32-bit values.
1420321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1421288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1422205219Srdivacky_mm_cvtepu16_epi32(__m128i __V)
1423205219Srdivacky{
1424309124Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si);
1425205219Srdivacky}
1426205219Srdivacky
1427341825Sdim/// Zero-extends each of the lower two 16-bit integer elements of a
1428321369Sdim///    128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1429321369Sdim///    a 128-bit vector of [2 x i64]. The upper six elements of the input vector
1430321369Sdim///    are unused.
1431321369Sdim///
1432321369Sdim/// \headerfile <x86intrin.h>
1433321369Sdim///
1434321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXWQ / PMOVZXWQ </c> instruction.
1435321369Sdim///
1436321369Sdim/// \param __V
1437341825Sdim///    A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
1438341825Sdim///    zero-extended to 64-bit values.
1439321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1440288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1441205219Srdivacky_mm_cvtepu16_epi64(__m128i __V)
1442205219Srdivacky{
1443309124Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di);
1444205219Srdivacky}
1445205219Srdivacky
1446341825Sdim/// Zero-extends each of the lower two 32-bit integer elements of a
1447321369Sdim///    128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1448321369Sdim///    a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1449321369Sdim///    are unused.
1450321369Sdim///
1451321369Sdim/// \headerfile <x86intrin.h>
1452321369Sdim///
1453321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXDQ / PMOVZXDQ </c> instruction.
1454321369Sdim///
1455321369Sdim/// \param __V
1456341825Sdim///    A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
1457341825Sdim///    zero-extended to 64-bit values.
1458321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1459288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1460205219Srdivacky_mm_cvtepu32_epi64(__m128i __V)
1461205219Srdivacky{
1462309124Sdim  return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di);
1463205219Srdivacky}
1464205219Srdivacky
1465205219Srdivacky/* SSE4 Pack with Unsigned Saturation.  */
1466341825Sdim/// Converts 32-bit signed integers from both 128-bit integer vector
1467321369Sdim///    operands into 16-bit unsigned integers, and returns the packed result.
1468321369Sdim///    Values greater than 0xFFFF are saturated to 0xFFFF. Values less than
1469321369Sdim///    0x0000 are saturated to 0x0000.
1470321369Sdim///
1471321369Sdim/// \headerfile <x86intrin.h>
1472321369Sdim///
1473321369Sdim/// This intrinsic corresponds to the <c> VPACKUSDW / PACKUSDW </c> instruction.
1474321369Sdim///
1475321369Sdim/// \param __V1
1476321369Sdim///    A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1477321369Sdim///    signed integer and is converted to a 16-bit unsigned integer with
1478321369Sdim///    saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1479321369Sdim///    less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1480321369Sdim///    are written to the lower 64 bits of the result.
1481321369Sdim/// \param __V2
1482321369Sdim///    A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1483321369Sdim///    signed integer and is converted to a 16-bit unsigned integer with
1484321369Sdim///    saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1485321369Sdim///    less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1486321369Sdim///    are written to the higher 64 bits of the result.
1487321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the converted values.
1488288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1489205219Srdivacky_mm_packus_epi32(__m128i __V1, __m128i __V2)
1490205219Srdivacky{
1491205219Srdivacky  return (__m128i) __builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2);
1492205219Srdivacky}
1493205219Srdivacky
1494205219Srdivacky/* SSE4 Multiple Packed Sums of Absolute Difference.  */
1495341825Sdim/// Subtracts 8-bit unsigned integer values and computes the absolute
1496321369Sdim///    values of the differences to the corresponding bits in the destination.
1497321369Sdim///    Then sums of the absolute differences are returned according to the bit
1498321369Sdim///    fields in the immediate operand.
1499321369Sdim///
1500321369Sdim/// \headerfile <x86intrin.h>
1501321369Sdim///
1502321369Sdim/// \code
1503321369Sdim/// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M);
1504321369Sdim/// \endcode
1505321369Sdim///
1506321369Sdim/// This intrinsic corresponds to the <c> VMPSADBW / MPSADBW </c> instruction.
1507321369Sdim///
1508321369Sdim/// \param X
1509321369Sdim///    A 128-bit vector of [16 x i8].
1510321369Sdim/// \param Y
1511321369Sdim///    A 128-bit vector of [16 x i8].
1512321369Sdim/// \param M
1513321369Sdim///    An 8-bit immediate operand specifying how the absolute differences are to
1514321369Sdim///    be calculated, according to the following algorithm:
1515321369Sdim///    \code
1516321369Sdim///    // M2 represents bit 2 of the immediate operand
1517321369Sdim///    // M10 represents bits [1:0] of the immediate operand
1518341825Sdim///    i = M2 * 4;
1519341825Sdim///    j = M10 * 4;
1520321369Sdim///    for (k = 0; k < 8; k = k + 1) {
1521341825Sdim///      d0 = abs(X[i + k + 0] - Y[j + 0]);
1522341825Sdim///      d1 = abs(X[i + k + 1] - Y[j + 1]);
1523341825Sdim///      d2 = abs(X[i + k + 2] - Y[j + 2]);
1524341825Sdim///      d3 = abs(X[i + k + 3] - Y[j + 3]);
1525341825Sdim///      r[k] = d0 + d1 + d2 + d3;
1526321369Sdim///    }
1527321369Sdim///    \endcode
1528321369Sdim/// \returns A 128-bit integer vector containing the sums of the sets of
1529321369Sdim///    absolute differences between both operands.
1530341825Sdim#define _mm_mpsadbw_epu8(X, Y, M) \
1531296417Sdim  (__m128i) __builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \
1532341825Sdim                                      (__v16qi)(__m128i)(Y), (M))
1533205219Srdivacky
1534341825Sdim/// Finds the minimum unsigned 16-bit element in the input 128-bit
1535321369Sdim///    vector of [8 x u16] and returns it and along with its index.
1536321369Sdim///
1537321369Sdim/// \headerfile <x86intrin.h>
1538321369Sdim///
1539321369Sdim/// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c>
1540321369Sdim/// instruction.
1541321369Sdim///
1542321369Sdim/// \param __V
1543321369Sdim///    A 128-bit vector of [8 x u16].
1544321369Sdim/// \returns A 128-bit value where bits [15:0] contain the minimum value found
1545321369Sdim///    in parameter \a __V, bits [18:16] contain the index of the minimum value
1546321369Sdim///    and the remaining bits are set to 0.
1547288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
1548234353Sdim_mm_minpos_epu16(__m128i __V)
1549234353Sdim{
1550234353Sdim  return (__m128i) __builtin_ia32_phminposuw128((__v8hi)__V);
1551234353Sdim}
1552234353Sdim
1553296417Sdim/* Handle the sse4.2 definitions here. */
1554296417Sdim
1555205408Srdivacky/* These definitions are normally in nmmintrin.h, but gcc puts them in here
1556205408Srdivacky   so we'll do the same.  */
1557205408Srdivacky
1558296417Sdim#undef __DEFAULT_FN_ATTRS
1559296417Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))
1560296417Sdim
1561205408Srdivacky/* These specify the type of data that we're comparing.  */
1562205408Srdivacky#define _SIDD_UBYTE_OPS                 0x00
1563205408Srdivacky#define _SIDD_UWORD_OPS                 0x01
1564205408Srdivacky#define _SIDD_SBYTE_OPS                 0x02
1565205408Srdivacky#define _SIDD_SWORD_OPS                 0x03
1566205408Srdivacky
1567205408Srdivacky/* These specify the type of comparison operation.  */
1568205408Srdivacky#define _SIDD_CMP_EQUAL_ANY             0x00
1569205408Srdivacky#define _SIDD_CMP_RANGES                0x04
1570205408Srdivacky#define _SIDD_CMP_EQUAL_EACH            0x08
1571205408Srdivacky#define _SIDD_CMP_EQUAL_ORDERED         0x0c
1572205408Srdivacky
1573205408Srdivacky/* These macros specify the polarity of the operation.  */
1574205408Srdivacky#define _SIDD_POSITIVE_POLARITY         0x00
1575205408Srdivacky#define _SIDD_NEGATIVE_POLARITY         0x10
1576205408Srdivacky#define _SIDD_MASKED_POSITIVE_POLARITY  0x20
1577205408Srdivacky#define _SIDD_MASKED_NEGATIVE_POLARITY  0x30
1578205408Srdivacky
1579205408Srdivacky/* These macros are used in _mm_cmpXstri() to specify the return.  */
1580205408Srdivacky#define _SIDD_LEAST_SIGNIFICANT         0x00
1581205408Srdivacky#define _SIDD_MOST_SIGNIFICANT          0x40
1582205408Srdivacky
1583205408Srdivacky/* These macros are used in _mm_cmpXstri() to specify the return.  */
1584205408Srdivacky#define _SIDD_BIT_MASK                  0x00
1585205408Srdivacky#define _SIDD_UNIT_MASK                 0x40
1586205408Srdivacky
1587205408Srdivacky/* SSE4.2 Packed Comparison Intrinsics.  */
1588341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1589321369Sdim///    data with implicitly defined lengths that is contained in source operands
1590321369Sdim///    \a A and \a B. Returns a 128-bit integer vector representing the result
1591321369Sdim///    mask of the comparison.
1592321369Sdim///
1593321369Sdim/// \headerfile <x86intrin.h>
1594321369Sdim///
1595321369Sdim/// \code
1596321369Sdim/// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M);
1597321369Sdim/// \endcode
1598321369Sdim///
1599321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRM / PCMPISTRM </c>
1600321369Sdim/// instruction.
1601321369Sdim///
1602321369Sdim/// \param A
1603321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1604321369Sdim///    compared.
1605321369Sdim/// \param B
1606321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1607321369Sdim///    compared.
1608321369Sdim/// \param M
1609321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1610321369Sdim///    words, the type of comparison to perform, and the format of the return
1611321369Sdim///    value. \n
1612321369Sdim///    Bits [1:0]: Determine source data format. \n
1613321369Sdim///      00: 16 unsigned bytes \n
1614321369Sdim///      01: 8 unsigned words \n
1615321369Sdim///      10: 16 signed bytes \n
1616321369Sdim///      11: 8 signed words \n
1617321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1618321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1619321369Sdim///          the characters in \a A. \n
1620321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1621321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1622321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1623321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1624321369Sdim///          \a B for equality. \n
1625321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
1626321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1627321369Sdim///                mask of the comparison results. \n
1628321369Sdim///      00: No effect. \n
1629321369Sdim///      01: Negate the bit mask. \n
1630321369Sdim///      10: No effect. \n
1631321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1632321369Sdim///          to the size of \a A or \a B. \n
1633321369Sdim///    Bit [6]: Determines whether the result is zero-extended or expanded to 16
1634321369Sdim///             bytes. \n
1635321369Sdim///      0: The result is zero-extended to 16 bytes. \n
1636321369Sdim///      1: The result is expanded to 16 bytes (this expansion is performed by
1637321369Sdim///         repeating each bit 8 or 16 times).
1638321369Sdim/// \returns Returns a 128-bit integer vector representing the result mask of
1639321369Sdim///    the comparison.
1640296417Sdim#define _mm_cmpistrm(A, B, M) \
1641296417Sdim  (__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \
1642296417Sdim                                       (__v16qi)(__m128i)(B), (int)(M))
1643321369Sdim
1644341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1645321369Sdim///    data with implicitly defined lengths that is contained in source operands
1646321369Sdim///    \a A and \a B. Returns an integer representing the result index of the
1647321369Sdim///    comparison.
1648321369Sdim///
1649321369Sdim/// \headerfile <x86intrin.h>
1650321369Sdim///
1651321369Sdim/// \code
1652321369Sdim/// int _mm_cmpistri(__m128i A, __m128i B, const int M);
1653321369Sdim/// \endcode
1654321369Sdim///
1655321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1656321369Sdim/// instruction.
1657321369Sdim///
1658321369Sdim/// \param A
1659321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1660321369Sdim///    compared.
1661321369Sdim/// \param B
1662321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1663321369Sdim///    compared.
1664321369Sdim/// \param M
1665321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1666321369Sdim///    words, the type of comparison to perform, and the format of the return
1667321369Sdim///    value. \n
1668321369Sdim///    Bits [1:0]: Determine source data format. \n
1669321369Sdim///      00: 16 unsigned bytes \n
1670321369Sdim///      01: 8 unsigned words \n
1671321369Sdim///      10: 16 signed bytes \n
1672321369Sdim///      11: 8 signed words \n
1673321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1674321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1675321369Sdim///          the characters in \a A. \n
1676321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1677321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1678321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1679321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1680321369Sdim///          \a B for equality. \n
1681321369Sdim///      11: Substring: Search B for substring matches of \a A. \n
1682321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1683321369Sdim///                mask of the comparison results. \n
1684321369Sdim///      00: No effect. \n
1685321369Sdim///      01: Negate the bit mask. \n
1686321369Sdim///      10: No effect. \n
1687321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1688321369Sdim///          to the size of \a A or \a B. \n
1689321369Sdim///    Bit [6]: Determines whether the index of the lowest set bit or the
1690321369Sdim///             highest set bit is returned. \n
1691321369Sdim///      0: The index of the least significant set bit. \n
1692321369Sdim///      1: The index of the most significant set bit. \n
1693321369Sdim/// \returns Returns an integer representing the result index of the comparison.
1694296417Sdim#define _mm_cmpistri(A, B, M) \
1695296417Sdim  (int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \
1696296417Sdim                                   (__v16qi)(__m128i)(B), (int)(M))
1697205408Srdivacky
1698341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1699321369Sdim///    data with explicitly defined lengths that is contained in source operands
1700321369Sdim///    \a A and \a B. Returns a 128-bit integer vector representing the result
1701321369Sdim///    mask of the comparison.
1702321369Sdim///
1703321369Sdim/// \headerfile <x86intrin.h>
1704321369Sdim///
1705321369Sdim/// \code
1706321369Sdim/// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M);
1707321369Sdim/// \endcode
1708321369Sdim///
1709321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRM / PCMPESTRM </c>
1710321369Sdim/// instruction.
1711321369Sdim///
1712321369Sdim/// \param A
1713321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1714321369Sdim///    compared.
1715321369Sdim/// \param LA
1716321369Sdim///    An integer that specifies the length of the string in \a A.
1717321369Sdim/// \param B
1718321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1719321369Sdim///    compared.
1720321369Sdim/// \param LB
1721321369Sdim///    An integer that specifies the length of the string in \a B.
1722321369Sdim/// \param M
1723321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1724321369Sdim///    words, the type of comparison to perform, and the format of the return
1725321369Sdim///    value. \n
1726321369Sdim///    Bits [1:0]: Determine source data format. \n
1727321369Sdim///      00: 16 unsigned bytes \n
1728321369Sdim///      01: 8 unsigned words \n
1729321369Sdim///      10: 16 signed bytes \n
1730321369Sdim///      11: 8 signed words \n
1731321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1732321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1733321369Sdim///          the characters in \a A. \n
1734321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1735321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1736321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1737321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1738321369Sdim///          \a B for equality. \n
1739321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
1740321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1741321369Sdim///                mask of the comparison results. \n
1742321369Sdim///      00: No effect. \n
1743321369Sdim///      01: Negate the bit mask. \n
1744321369Sdim///      10: No effect. \n
1745321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1746321369Sdim///          to the size of \a A or \a B. \n
1747321369Sdim///    Bit [6]: Determines whether the result is zero-extended or expanded to 16
1748321369Sdim///             bytes. \n
1749321369Sdim///      0: The result is zero-extended to 16 bytes. \n
1750321369Sdim///      1: The result is expanded to 16 bytes (this expansion is performed by
1751321369Sdim///         repeating each bit 8 or 16 times). \n
1752321369Sdim/// \returns Returns a 128-bit integer vector representing the result mask of
1753321369Sdim///    the comparison.
1754205408Srdivacky#define _mm_cmpestrm(A, LA, B, LB, M) \
1755296417Sdim  (__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \
1756296417Sdim                                       (__v16qi)(__m128i)(B), (int)(LB), \
1757296417Sdim                                       (int)(M))
1758321369Sdim
1759341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1760321369Sdim///    data with explicitly defined lengths that is contained in source operands
1761321369Sdim///    \a A and \a B. Returns an integer representing the result index of the
1762321369Sdim///    comparison.
1763321369Sdim///
1764321369Sdim/// \headerfile <x86intrin.h>
1765321369Sdim///
1766321369Sdim/// \code
1767321369Sdim/// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M);
1768321369Sdim/// \endcode
1769321369Sdim///
1770321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
1771321369Sdim/// instruction.
1772321369Sdim///
1773321369Sdim/// \param A
1774321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1775321369Sdim///    compared.
1776321369Sdim/// \param LA
1777321369Sdim///    An integer that specifies the length of the string in \a A.
1778321369Sdim/// \param B
1779321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1780321369Sdim///    compared.
1781321369Sdim/// \param LB
1782321369Sdim///    An integer that specifies the length of the string in \a B.
1783321369Sdim/// \param M
1784321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1785321369Sdim///    words, the type of comparison to perform, and the format of the return
1786321369Sdim///    value. \n
1787321369Sdim///    Bits [1:0]: Determine source data format. \n
1788321369Sdim///      00: 16 unsigned bytes \n
1789321369Sdim///      01: 8 unsigned words \n
1790321369Sdim///      10: 16 signed bytes \n
1791321369Sdim///      11: 8 signed words \n
1792321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1793321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1794321369Sdim///          the characters in \a A. \n
1795321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1796321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1797321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1798321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1799321369Sdim///          \a B for equality. \n
1800321369Sdim///      11: Substring: Search B for substring matches of \a A. \n
1801321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1802321369Sdim///                mask of the comparison results. \n
1803321369Sdim///      00: No effect. \n
1804321369Sdim///      01: Negate the bit mask. \n
1805321369Sdim///      10: No effect. \n
1806321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1807321369Sdim///          to the size of \a A or \a B. \n
1808321369Sdim///    Bit [6]: Determines whether the index of the lowest set bit or the
1809321369Sdim///             highest set bit is returned. \n
1810321369Sdim///      0: The index of the least significant set bit. \n
1811321369Sdim///      1: The index of the most significant set bit. \n
1812321369Sdim/// \returns Returns an integer representing the result index of the comparison.
1813234353Sdim#define _mm_cmpestri(A, LA, B, LB, M) \
1814296417Sdim  (int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \
1815296417Sdim                                   (__v16qi)(__m128i)(B), (int)(LB), \
1816296417Sdim                                   (int)(M))
1817296417Sdim
1818205408Srdivacky/* SSE4.2 Packed Comparison Intrinsics and EFlag Reading.  */
1819341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1820321369Sdim///    data with implicitly defined lengths that is contained in source operands
1821321369Sdim///    \a A and \a B. Returns 1 if the bit mask is zero and the length of the
1822321369Sdim///    string in \a B is the maximum, otherwise, returns 0.
1823321369Sdim///
1824321369Sdim/// \headerfile <x86intrin.h>
1825321369Sdim///
1826321369Sdim/// \code
1827321369Sdim/// int _mm_cmpistra(__m128i A, __m128i B, const int M);
1828321369Sdim/// \endcode
1829321369Sdim///
1830321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1831321369Sdim/// instruction.
1832321369Sdim///
1833321369Sdim/// \param A
1834321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1835321369Sdim///    compared.
1836321369Sdim/// \param B
1837321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1838321369Sdim///    compared.
1839321369Sdim/// \param M
1840321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1841321369Sdim///    words and the type of comparison to perform. \n
1842321369Sdim///    Bits [1:0]: Determine source data format. \n
1843321369Sdim///      00: 16 unsigned bytes \n
1844321369Sdim///      01: 8 unsigned words \n
1845321369Sdim///      10: 16 signed bytes \n
1846321369Sdim///      11: 8 signed words \n
1847321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1848321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1849321369Sdim///          the characters in \a A. \n
1850321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1851321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1852321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1853321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1854321369Sdim///          \a B for equality. \n
1855321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
1856321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1857321369Sdim///                mask of the comparison results. \n
1858321369Sdim///      00: No effect. \n
1859321369Sdim///      01: Negate the bit mask. \n
1860321369Sdim///      10: No effect. \n
1861321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1862321369Sdim///          to the size of \a A or \a B. \n
1863321369Sdim/// \returns Returns 1 if the bit mask is zero and the length of the string in
1864321369Sdim///    \a B is the maximum; otherwise, returns 0.
1865234353Sdim#define _mm_cmpistra(A, B, M) \
1866296417Sdim  (int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \
1867296417Sdim                                    (__v16qi)(__m128i)(B), (int)(M))
1868321369Sdim
1869341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1870321369Sdim///    data with implicitly defined lengths that is contained in source operands
1871321369Sdim///    \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns
1872321369Sdim///    0.
1873321369Sdim///
1874321369Sdim/// \headerfile <x86intrin.h>
1875321369Sdim///
1876321369Sdim/// \code
1877321369Sdim/// int _mm_cmpistrc(__m128i A, __m128i B, const int M);
1878321369Sdim/// \endcode
1879321369Sdim///
1880321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1881321369Sdim/// instruction.
1882321369Sdim///
1883321369Sdim/// \param A
1884321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1885321369Sdim///    compared.
1886321369Sdim/// \param B
1887321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1888321369Sdim///    compared.
1889321369Sdim/// \param M
1890321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1891321369Sdim///    words and the type of comparison to perform. \n
1892321369Sdim///    Bits [1:0]: Determine source data format. \n
1893321369Sdim///      00: 16 unsigned bytes \n
1894321369Sdim///      01: 8 unsigned words \n
1895321369Sdim///      10: 16 signed bytes \n
1896321369Sdim///      11: 8 signed words \n
1897321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1898321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1899321369Sdim///          the characters in \a A. \n
1900321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1901321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1902321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1903321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1904321369Sdim///          \a B for equality. \n
1905321369Sdim///      11: Substring: Search B for substring matches of \a A. \n
1906321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1907321369Sdim///                mask of the comparison results. \n
1908321369Sdim///      00: No effect. \n
1909321369Sdim///      01: Negate the bit mask. \n
1910321369Sdim///      10: No effect. \n
1911321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1912321369Sdim///          to the size of \a A or \a B.
1913321369Sdim/// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0.
1914234353Sdim#define _mm_cmpistrc(A, B, M) \
1915296417Sdim  (int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \
1916296417Sdim                                    (__v16qi)(__m128i)(B), (int)(M))
1917321369Sdim
1918341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1919321369Sdim///    data with implicitly defined lengths that is contained in source operands
1920321369Sdim///    \a A and \a B. Returns bit 0 of the resulting bit mask.
1921321369Sdim///
1922321369Sdim/// \headerfile <x86intrin.h>
1923321369Sdim///
1924321369Sdim/// \code
1925321369Sdim/// int _mm_cmpistro(__m128i A, __m128i B, const int M);
1926321369Sdim/// \endcode
1927321369Sdim///
1928321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1929321369Sdim/// instruction.
1930321369Sdim///
1931321369Sdim/// \param A
1932321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1933321369Sdim///    compared.
1934321369Sdim/// \param B
1935321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1936321369Sdim///    compared.
1937321369Sdim/// \param M
1938321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1939321369Sdim///    words and the type of comparison to perform. \n
1940321369Sdim///    Bits [1:0]: Determine source data format. \n
1941321369Sdim///      00: 16 unsigned bytes \n
1942321369Sdim///      01: 8 unsigned words \n
1943321369Sdim///      10: 16 signed bytes \n
1944321369Sdim///      11: 8 signed words \n
1945321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1946321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1947321369Sdim///          the characters in \a A. \n
1948321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1949321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1950321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
1951321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
1952321369Sdim///          \a B for equality. \n
1953321369Sdim///      11: Substring: Search B for substring matches of \a A. \n
1954321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
1955321369Sdim///                mask of the comparison results. \n
1956321369Sdim///      00: No effect. \n
1957321369Sdim///      01: Negate the bit mask. \n
1958321369Sdim///      10: No effect. \n
1959321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
1960321369Sdim///          to the size of \a A or \a B. \n
1961321369Sdim/// \returns Returns bit 0 of the resulting bit mask.
1962234353Sdim#define _mm_cmpistro(A, B, M) \
1963296417Sdim  (int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \
1964296417Sdim                                    (__v16qi)(__m128i)(B), (int)(M))
1965321369Sdim
1966341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
1967321369Sdim///    data with implicitly defined lengths that is contained in source operands
1968321369Sdim///    \a A and \a B. Returns 1 if the length of the string in \a A is less than
1969321369Sdim///    the maximum, otherwise, returns 0.
1970321369Sdim///
1971321369Sdim/// \headerfile <x86intrin.h>
1972321369Sdim///
1973321369Sdim/// \code
1974321369Sdim/// int _mm_cmpistrs(__m128i A, __m128i B, const int M);
1975321369Sdim/// \endcode
1976321369Sdim///
1977321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1978321369Sdim/// instruction.
1979321369Sdim///
1980321369Sdim/// \param A
1981321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1982321369Sdim///    compared.
1983321369Sdim/// \param B
1984321369Sdim///    A 128-bit integer vector containing one of the source operands to be
1985321369Sdim///    compared.
1986321369Sdim/// \param M
1987321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
1988321369Sdim///    words and the type of comparison to perform. \n
1989321369Sdim///    Bits [1:0]: Determine source data format. \n
1990321369Sdim///      00: 16 unsigned bytes \n
1991321369Sdim///      01: 8 unsigned words \n
1992321369Sdim///      10: 16 signed bytes \n
1993321369Sdim///      11: 8 signed words \n
1994321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
1995321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
1996321369Sdim///          the characters in \a A. \n
1997321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
1998321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
1999321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2000321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2001321369Sdim///          \a B for equality. \n
2002321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2003321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
2004321369Sdim///                mask of the comparison results. \n
2005321369Sdim///      00: No effect. \n
2006321369Sdim///      01: Negate the bit mask. \n
2007321369Sdim///      10: No effect. \n
2008321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2009321369Sdim///          to the size of \a A or \a B. \n
2010321369Sdim/// \returns Returns 1 if the length of the string in \a A is less than the
2011321369Sdim///    maximum, otherwise, returns 0.
2012234353Sdim#define _mm_cmpistrs(A, B, M) \
2013296417Sdim  (int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \
2014296417Sdim                                    (__v16qi)(__m128i)(B), (int)(M))
2015321369Sdim
2016341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
2017321369Sdim///    data with implicitly defined lengths that is contained in source operands
2018321369Sdim///    \a A and \a B. Returns 1 if the length of the string in \a B is less than
2019321369Sdim///    the maximum, otherwise, returns 0.
2020321369Sdim///
2021321369Sdim/// \headerfile <x86intrin.h>
2022321369Sdim///
2023321369Sdim/// \code
2024321369Sdim/// int _mm_cmpistrz(__m128i A, __m128i B, const int M);
2025321369Sdim/// \endcode
2026321369Sdim///
2027321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
2028321369Sdim/// instruction.
2029321369Sdim///
2030321369Sdim/// \param A
2031321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2032321369Sdim///    compared.
2033321369Sdim/// \param B
2034321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2035321369Sdim///    compared.
2036321369Sdim/// \param M
2037321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
2038321369Sdim///    words and the type of comparison to perform. \n
2039321369Sdim///    Bits [1:0]: Determine source data format. \n
2040321369Sdim///      00: 16 unsigned bytes \n
2041321369Sdim///      01: 8 unsigned words \n
2042321369Sdim///      10: 16 signed bytes \n
2043321369Sdim///      11: 8 signed words \n
2044321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
2045321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
2046321369Sdim///          the characters in \a A. \n
2047321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
2048321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
2049321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2050321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2051321369Sdim///          \a B for equality. \n
2052321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2053321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
2054321369Sdim///                mask of the comparison results. \n
2055321369Sdim///      00: No effect. \n
2056321369Sdim///      01: Negate the bit mask. \n
2057321369Sdim///      10: No effect. \n
2058321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2059321369Sdim///          to the size of \a A or \a B.
2060321369Sdim/// \returns Returns 1 if the length of the string in \a B is less than the
2061321369Sdim///    maximum, otherwise, returns 0.
2062234353Sdim#define _mm_cmpistrz(A, B, M) \
2063296417Sdim  (int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \
2064296417Sdim                                    (__v16qi)(__m128i)(B), (int)(M))
2065205408Srdivacky
2066341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
2067321369Sdim///    data with explicitly defined lengths that is contained in source operands
2068321369Sdim///    \a A and \a B. Returns 1 if the bit mask is zero and the length of the
2069321369Sdim///    string in \a B is the maximum, otherwise, returns 0.
2070321369Sdim///
2071321369Sdim/// \headerfile <x86intrin.h>
2072321369Sdim///
2073321369Sdim/// \code
2074321369Sdim/// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M);
2075321369Sdim/// \endcode
2076321369Sdim///
2077321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2078321369Sdim/// instruction.
2079321369Sdim///
2080321369Sdim/// \param A
2081321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2082321369Sdim///    compared.
2083321369Sdim/// \param LA
2084321369Sdim///    An integer that specifies the length of the string in \a A.
2085321369Sdim/// \param B
2086321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2087321369Sdim///    compared.
2088321369Sdim/// \param LB
2089321369Sdim///    An integer that specifies the length of the string in \a B.
2090321369Sdim/// \param M
2091321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
2092321369Sdim///    words and the type of comparison to perform. \n
2093321369Sdim///    Bits [1:0]: Determine source data format. \n
2094321369Sdim///      00: 16 unsigned bytes \n
2095321369Sdim///      01: 8 unsigned words \n
2096321369Sdim///      10: 16 signed bytes \n
2097321369Sdim///      11: 8 signed words \n
2098321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
2099321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
2100321369Sdim///          the characters in \a A. \n
2101321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
2102321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
2103321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2104321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2105321369Sdim///          \a B for equality. \n
2106321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2107321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
2108321369Sdim///                mask of the comparison results. \n
2109321369Sdim///      00: No effect. \n
2110321369Sdim///      01: Negate the bit mask. \n
2111321369Sdim///      10: No effect. \n
2112321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2113321369Sdim///          to the size of \a A or \a B.
2114321369Sdim/// \returns Returns 1 if the bit mask is zero and the length of the string in
2115321369Sdim///    \a B is the maximum, otherwise, returns 0.
2116205408Srdivacky#define _mm_cmpestra(A, LA, B, LB, M) \
2117296417Sdim  (int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \
2118296417Sdim                                    (__v16qi)(__m128i)(B), (int)(LB), \
2119296417Sdim                                    (int)(M))
2120321369Sdim
2121341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
2122321369Sdim///    data with explicitly defined lengths that is contained in source operands
2123321369Sdim///    \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise,
2124321369Sdim///    returns 0.
2125321369Sdim///
2126321369Sdim/// \headerfile <x86intrin.h>
2127321369Sdim///
2128321369Sdim/// \code
2129321369Sdim/// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M);
2130321369Sdim/// \endcode
2131321369Sdim///
2132321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2133321369Sdim/// instruction.
2134321369Sdim///
2135321369Sdim/// \param A
2136321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2137321369Sdim///    compared.
2138321369Sdim/// \param LA
2139321369Sdim///    An integer that specifies the length of the string in \a A.
2140321369Sdim/// \param B
2141321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2142321369Sdim///    compared.
2143321369Sdim/// \param LB
2144321369Sdim///    An integer that specifies the length of the string in \a B.
2145321369Sdim/// \param M
2146321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
2147321369Sdim///    words and the type of comparison to perform. \n
2148321369Sdim///    Bits [1:0]: Determine source data format. \n
2149321369Sdim///      00: 16 unsigned bytes \n
2150321369Sdim///      01: 8 unsigned words \n
2151321369Sdim///      10: 16 signed bytes \n
2152321369Sdim///      11: 8 signed words \n
2153321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
2154321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
2155321369Sdim///          the characters in \a A. \n
2156321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
2157321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
2158321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2159321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2160321369Sdim///          \a B for equality. \n
2161321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2162321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
2163321369Sdim///                mask of the comparison results. \n
2164321369Sdim///      00: No effect. \n
2165321369Sdim///      01: Negate the bit mask. \n
2166321369Sdim///      10: No effect. \n
2167321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2168321369Sdim///          to the size of \a A or \a B. \n
2169321369Sdim/// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0.
2170205408Srdivacky#define _mm_cmpestrc(A, LA, B, LB, M) \
2171296417Sdim  (int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \
2172296417Sdim                                    (__v16qi)(__m128i)(B), (int)(LB), \
2173296417Sdim                                    (int)(M))
2174321369Sdim
2175341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
2176321369Sdim///    data with explicitly defined lengths that is contained in source operands
2177321369Sdim///    \a A and \a B. Returns bit 0 of the resulting bit mask.
2178321369Sdim///
2179321369Sdim/// \headerfile <x86intrin.h>
2180321369Sdim///
2181321369Sdim/// \code
2182321369Sdim/// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M);
2183321369Sdim/// \endcode
2184321369Sdim///
2185321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2186321369Sdim/// instruction.
2187321369Sdim///
2188321369Sdim/// \param A
2189321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2190321369Sdim///    compared.
2191321369Sdim/// \param LA
2192321369Sdim///    An integer that specifies the length of the string in \a A.
2193321369Sdim/// \param B
2194321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2195321369Sdim///    compared.
2196321369Sdim/// \param LB
2197321369Sdim///    An integer that specifies the length of the string in \a B.
2198321369Sdim/// \param M
2199321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
2200321369Sdim///    words and the type of comparison to perform. \n
2201321369Sdim///    Bits [1:0]: Determine source data format. \n
2202321369Sdim///      00: 16 unsigned bytes \n
2203321369Sdim///      01: 8 unsigned words \n
2204321369Sdim///      10: 16 signed bytes \n
2205321369Sdim///      11: 8 signed words \n
2206321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
2207321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
2208321369Sdim///          the characters in \a A. \n
2209321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
2210321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
2211321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2212321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2213321369Sdim///          \a B for equality. \n
2214321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2215321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
2216321369Sdim///                mask of the comparison results. \n
2217321369Sdim///      00: No effect. \n
2218321369Sdim///      01: Negate the bit mask. \n
2219321369Sdim///      10: No effect. \n
2220321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2221321369Sdim///          to the size of \a A or \a B.
2222321369Sdim/// \returns Returns bit 0 of the resulting bit mask.
2223205408Srdivacky#define _mm_cmpestro(A, LA, B, LB, M) \
2224296417Sdim  (int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \
2225296417Sdim                                    (__v16qi)(__m128i)(B), (int)(LB), \
2226296417Sdim                                    (int)(M))
2227321369Sdim
2228341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
2229321369Sdim///    data with explicitly defined lengths that is contained in source operands
2230321369Sdim///    \a A and \a B. Returns 1 if the length of the string in \a A is less than
2231321369Sdim///    the maximum, otherwise, returns 0.
2232321369Sdim///
2233321369Sdim/// \headerfile <x86intrin.h>
2234321369Sdim///
2235321369Sdim/// \code
2236321369Sdim/// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M);
2237321369Sdim/// \endcode
2238321369Sdim///
2239321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2240321369Sdim/// instruction.
2241321369Sdim///
2242321369Sdim/// \param A
2243321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2244321369Sdim///    compared.
2245321369Sdim/// \param LA
2246321369Sdim///    An integer that specifies the length of the string in \a A.
2247321369Sdim/// \param B
2248321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2249321369Sdim///    compared.
2250321369Sdim/// \param LB
2251321369Sdim///    An integer that specifies the length of the string in \a B.
2252321369Sdim/// \param M
2253321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
2254321369Sdim///    words and the type of comparison to perform. \n
2255321369Sdim///    Bits [1:0]: Determine source data format. \n
2256321369Sdim///      00: 16 unsigned bytes \n
2257321369Sdim///      01: 8 unsigned words \n
2258321369Sdim///      10: 16 signed bytes \n
2259321369Sdim///      11: 8 signed words \n
2260321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
2261321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
2262321369Sdim///          the characters in \a A. \n
2263321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
2264321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
2265321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2266321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2267321369Sdim///          \a B for equality. \n
2268321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2269321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement in the bit
2270321369Sdim///                mask of the comparison results. \n
2271321369Sdim///      00: No effect. \n
2272321369Sdim///      01: Negate the bit mask. \n
2273321369Sdim///      10: No effect. \n
2274321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2275321369Sdim///          to the size of \a A or \a B. \n
2276321369Sdim/// \returns Returns 1 if the length of the string in \a A is less than the
2277321369Sdim///    maximum, otherwise, returns 0.
2278205408Srdivacky#define _mm_cmpestrs(A, LA, B, LB, M) \
2279296417Sdim  (int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \
2280296417Sdim                                    (__v16qi)(__m128i)(B), (int)(LB), \
2281296417Sdim                                    (int)(M))
2282321369Sdim
2283341825Sdim/// Uses the immediate operand \a M to perform a comparison of string
2284321369Sdim///    data with explicitly defined lengths that is contained in source operands
2285321369Sdim///    \a A and \a B. Returns 1 if the length of the string in \a B is less than
2286321369Sdim///    the maximum, otherwise, returns 0.
2287321369Sdim///
2288321369Sdim/// \headerfile <x86intrin.h>
2289321369Sdim///
2290321369Sdim/// \code
2291321369Sdim/// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M);
2292321369Sdim/// \endcode
2293321369Sdim///
2294321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI </c> instruction.
2295321369Sdim///
2296321369Sdim/// \param A
2297321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2298321369Sdim///    compared.
2299321369Sdim/// \param LA
2300321369Sdim///    An integer that specifies the length of the string in \a A.
2301321369Sdim/// \param B
2302321369Sdim///    A 128-bit integer vector containing one of the source operands to be
2303321369Sdim///    compared.
2304321369Sdim/// \param LB
2305321369Sdim///    An integer that specifies the length of the string in \a B.
2306321369Sdim/// \param M
2307321369Sdim///    An 8-bit immediate operand specifying whether the characters are bytes or
2308321369Sdim///    words and the type of comparison to perform. \n
2309321369Sdim///    Bits [1:0]: Determine source data format. \n
2310321369Sdim///      00: 16 unsigned bytes  \n
2311321369Sdim///      01: 8 unsigned words \n
2312321369Sdim///      10: 16 signed bytes \n
2313321369Sdim///      11: 8 signed words \n
2314321369Sdim///    Bits [3:2]: Determine comparison type and aggregation method. \n
2315321369Sdim///      00: Subset: Each character in \a B is compared for equality with all
2316321369Sdim///          the characters in \a A. \n
2317321369Sdim///      01: Ranges: Each character in \a B is compared to \a A. The comparison
2318321369Sdim///          basis is greater than or equal for even-indexed elements in \a A,
2319321369Sdim///          and less than or equal for odd-indexed elements in \a A. \n
2320321369Sdim///      10: Match: Compare each pair of corresponding characters in \a A and
2321321369Sdim///          \a B for equality. \n
2322321369Sdim///      11: Substring: Search \a B for substring matches of \a A. \n
2323321369Sdim///    Bits [5:4]: Determine whether to perform a one's complement on the bit
2324321369Sdim///                mask of the comparison results. \n
2325321369Sdim///      00: No effect. \n
2326321369Sdim///      01: Negate the bit mask. \n
2327321369Sdim///      10: No effect. \n
2328321369Sdim///      11: Negate the bit mask only for bits with an index less than or equal
2329321369Sdim///          to the size of \a A or \a B.
2330321369Sdim/// \returns Returns 1 if the length of the string in \a B is less than the
2331321369Sdim///    maximum, otherwise, returns 0.
2332205408Srdivacky#define _mm_cmpestrz(A, LA, B, LB, M) \
2333296417Sdim  (int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \
2334296417Sdim                                    (__v16qi)(__m128i)(B), (int)(LB), \
2335296417Sdim                                    (int)(M))
2336205408Srdivacky
2337205408Srdivacky/* SSE4.2 Compare Packed Data -- Greater Than.  */
2338341825Sdim/// Compares each of the corresponding 64-bit values of the 128-bit
2339321369Sdim///    integer vectors to determine if the values in the first operand are
2340321369Sdim///    greater than those in the second operand.
2341321369Sdim///
2342321369Sdim/// \headerfile <x86intrin.h>
2343321369Sdim///
2344321369Sdim/// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction.
2345321369Sdim///
2346321369Sdim/// \param __V1
2347321369Sdim///    A 128-bit integer vector.
2348321369Sdim/// \param __V2
2349321369Sdim///    A 128-bit integer vector.
2350321369Sdim/// \returns A 128-bit integer vector containing the comparison results.
2351288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS
2352205408Srdivacky_mm_cmpgt_epi64(__m128i __V1, __m128i __V2)
2353205408Srdivacky{
2354234353Sdim  return (__m128i)((__v2di)__V1 > (__v2di)__V2);
2355205408Srdivacky}
2356205408Srdivacky
2357205408Srdivacky/* SSE4.2 Accumulate CRC32.  */
2358341825Sdim/// Adds the unsigned integer operand to the CRC-32C checksum of the
2359321369Sdim///    unsigned char operand.
2360321369Sdim///
2361321369Sdim/// \headerfile <x86intrin.h>
2362321369Sdim///
2363321369Sdim/// This intrinsic corresponds to the <c> CRC32B </c> instruction.
2364321369Sdim///
2365321369Sdim/// \param __C
2366321369Sdim///    An unsigned integer operand to add to the CRC-32C checksum of operand
2367321369Sdim///    \a  __D.
2368321369Sdim/// \param __D
2369321369Sdim///    An unsigned 8-bit integer operand used to compute the CRC-32C checksum.
2370321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of
2371321369Sdim///    operand \a __D.
2372288943Sdimstatic __inline__ unsigned int __DEFAULT_FN_ATTRS
2373205408Srdivacky_mm_crc32_u8(unsigned int __C, unsigned char __D)
2374205408Srdivacky{
2375205408Srdivacky  return __builtin_ia32_crc32qi(__C, __D);
2376205408Srdivacky}
2377205408Srdivacky
2378341825Sdim/// Adds the unsigned integer operand to the CRC-32C checksum of the
2379321369Sdim///    unsigned short operand.
2380321369Sdim///
2381321369Sdim/// \headerfile <x86intrin.h>
2382321369Sdim///
2383321369Sdim/// This intrinsic corresponds to the <c> CRC32W </c> instruction.
2384321369Sdim///
2385321369Sdim/// \param __C
2386321369Sdim///    An unsigned integer operand to add to the CRC-32C checksum of operand
2387321369Sdim///    \a __D.
2388321369Sdim/// \param __D
2389321369Sdim///    An unsigned 16-bit integer operand used to compute the CRC-32C checksum.
2390321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of
2391321369Sdim///    operand \a __D.
2392288943Sdimstatic __inline__ unsigned int __DEFAULT_FN_ATTRS
2393205408Srdivacky_mm_crc32_u16(unsigned int __C, unsigned short __D)
2394205408Srdivacky{
2395205408Srdivacky  return __builtin_ia32_crc32hi(__C, __D);
2396205408Srdivacky}
2397205408Srdivacky
2398341825Sdim/// Adds the first unsigned integer operand to the CRC-32C checksum of
2399321369Sdim///    the second unsigned integer operand.
2400321369Sdim///
2401321369Sdim/// \headerfile <x86intrin.h>
2402321369Sdim///
2403321369Sdim/// This intrinsic corresponds to the <c> CRC32L </c> instruction.
2404321369Sdim///
2405321369Sdim/// \param __C
2406321369Sdim///    An unsigned integer operand to add to the CRC-32C checksum of operand
2407321369Sdim///    \a __D.
2408321369Sdim/// \param __D
2409321369Sdim///    An unsigned 32-bit integer operand used to compute the CRC-32C checksum.
2410321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of
2411321369Sdim///    operand \a __D.
2412288943Sdimstatic __inline__ unsigned int __DEFAULT_FN_ATTRS
2413205408Srdivacky_mm_crc32_u32(unsigned int __C, unsigned int __D)
2414205408Srdivacky{
2415205408Srdivacky  return __builtin_ia32_crc32si(__C, __D);
2416205408Srdivacky}
2417205408Srdivacky
2418205408Srdivacky#ifdef __x86_64__
2419341825Sdim/// Adds the unsigned integer operand to the CRC-32C checksum of the
2420321369Sdim///    unsigned 64-bit integer operand.
2421321369Sdim///
2422321369Sdim/// \headerfile <x86intrin.h>
2423321369Sdim///
2424321369Sdim/// This intrinsic corresponds to the <c> CRC32Q </c> instruction.
2425321369Sdim///
2426321369Sdim/// \param __C
2427321369Sdim///    An unsigned integer operand to add to the CRC-32C checksum of operand
2428321369Sdim///    \a __D.
2429321369Sdim/// \param __D
2430321369Sdim///    An unsigned 64-bit integer operand used to compute the CRC-32C checksum.
2431321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of
2432321369Sdim///    operand \a __D.
2433288943Sdimstatic __inline__ unsigned long long __DEFAULT_FN_ATTRS
2434205408Srdivacky_mm_crc32_u64(unsigned long long __C, unsigned long long __D)
2435205408Srdivacky{
2436205408Srdivacky  return __builtin_ia32_crc32di(__C, __D);
2437205408Srdivacky}
2438205408Srdivacky#endif /* __x86_64__ */
2439205408Srdivacky
2440288943Sdim#undef __DEFAULT_FN_ATTRS
2441288943Sdim
2442234353Sdim#include <popcntintrin.h>
2443205408Srdivacky
2444341825Sdim#endif /* __SMMINTRIN_H */
2445