1 /*===---- smmintrin.h - SSE4 intrinsics ------------------------------------===
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 *===-----------------------------------------------------------------------===
27 #include <tmmintrin.h>
29 /* Define the default attributes for the functions in this file. */
30 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.1")))
32 /* SSE4 Rounding macros. */
33 #define _MM_FROUND_TO_NEAREST_INT 0x00
34 #define _MM_FROUND_TO_NEG_INF 0x01
35 #define _MM_FROUND_TO_POS_INF 0x02
36 #define _MM_FROUND_TO_ZERO 0x03
37 #define _MM_FROUND_CUR_DIRECTION 0x04
39 #define _MM_FROUND_RAISE_EXC 0x00
40 #define _MM_FROUND_NO_EXC 0x08
42 #define _MM_FROUND_NINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEAREST_INT)
43 #define _MM_FROUND_FLOOR (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEG_INF)
44 #define _MM_FROUND_CEIL (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_POS_INF)
45 #define _MM_FROUND_TRUNC (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_ZERO)
46 #define _MM_FROUND_RINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION)
47 #define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION)
49 /// \brief Rounds up each element of the 128-bit vector of [4 x float] to an
50 /// integer and returns the rounded values in a 128-bit vector of
53 /// \headerfile <x86intrin.h>
56 /// __m128 _mm_ceil_ps(__m128 X);
59 /// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
62 /// A 128-bit vector of [4 x float] values to be rounded up.
63 /// \returns A 128-bit vector of [4 x float] containing the rounded values.
64 #define _mm_ceil_ps(X) _mm_round_ps((X), _MM_FROUND_CEIL)
66 /// \brief Rounds up each element of the 128-bit vector of [2 x double] to an
67 /// integer and returns the rounded values in a 128-bit vector of
70 /// \headerfile <x86intrin.h>
73 /// __m128d _mm_ceil_pd(__m128d X);
76 /// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
79 /// A 128-bit vector of [2 x double] values to be rounded up.
80 /// \returns A 128-bit vector of [2 x double] containing the rounded values.
81 #define _mm_ceil_pd(X) _mm_round_pd((X), _MM_FROUND_CEIL)
83 /// \brief Copies three upper elements of the first 128-bit vector operand to
84 /// the corresponding three upper elements of the 128-bit result vector of
85 /// [4 x float]. Rounds up the lowest element of the second 128-bit vector
86 /// operand to an integer and copies it to the lowest element of the 128-bit
87 /// result vector of [4 x float].
89 /// \headerfile <x86intrin.h>
92 /// __m128 _mm_ceil_ss(__m128 X, __m128 Y);
95 /// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
98 /// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
99 /// copied to the corresponding bits of the result.
101 /// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
102 /// rounded up to the nearest integer and copied to the corresponding bits
104 /// \returns A 128-bit vector of [4 x float] containing the copied and rounded
106 #define _mm_ceil_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_CEIL)
108 /// \brief Copies the upper element of the first 128-bit vector operand to the
109 /// corresponding upper element of the 128-bit result vector of [2 x double].
110 /// Rounds up the lower element of the second 128-bit vector operand to an
111 /// integer and copies it to the lower element of the 128-bit result vector
114 /// \headerfile <x86intrin.h>
117 /// __m128d _mm_ceil_sd(__m128d X, __m128d Y);
120 /// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
123 /// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
124 /// copied to the corresponding bits of the result.
126 /// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
127 /// rounded up to the nearest integer and copied to the corresponding bits
129 /// \returns A 128-bit vector of [2 x double] containing the copied and rounded
131 #define _mm_ceil_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_CEIL)
133 /// \brief Rounds down each element of the 128-bit vector of [4 x float] to an
134 /// an integer and returns the rounded values in a 128-bit vector of
137 /// \headerfile <x86intrin.h>
140 /// __m128 _mm_floor_ps(__m128 X);
143 /// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
146 /// A 128-bit vector of [4 x float] values to be rounded down.
147 /// \returns A 128-bit vector of [4 x float] containing the rounded values.
148 #define _mm_floor_ps(X) _mm_round_ps((X), _MM_FROUND_FLOOR)
150 /// \brief Rounds down each element of the 128-bit vector of [2 x double] to an
151 /// integer and returns the rounded values in a 128-bit vector of
154 /// \headerfile <x86intrin.h>
157 /// __m128d _mm_floor_pd(__m128d X);
160 /// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
163 /// A 128-bit vector of [2 x double].
164 /// \returns A 128-bit vector of [2 x double] containing the rounded values.
165 #define _mm_floor_pd(X) _mm_round_pd((X), _MM_FROUND_FLOOR)
167 /// \brief Copies three upper elements of the first 128-bit vector operand to
168 /// the corresponding three upper elements of the 128-bit result vector of
169 /// [4 x float]. Rounds down the lowest element of the second 128-bit vector
170 /// operand to an integer and copies it to the lowest element of the 128-bit
171 /// result vector of [4 x float].
173 /// \headerfile <x86intrin.h>
176 /// __m128 _mm_floor_ss(__m128 X, __m128 Y);
179 /// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
182 /// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
183 /// copied to the corresponding bits of the result.
185 /// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
186 /// rounded down to the nearest integer and copied to the corresponding bits
188 /// \returns A 128-bit vector of [4 x float] containing the copied and rounded
190 #define _mm_floor_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_FLOOR)
192 /// \brief Copies the upper element of the first 128-bit vector operand to the
193 /// corresponding upper element of the 128-bit result vector of [2 x double].
194 /// Rounds down the lower element of the second 128-bit vector operand to an
195 /// integer and copies it to the lower element of the 128-bit result vector
198 /// \headerfile <x86intrin.h>
201 /// __m128d _mm_floor_sd(__m128d X, __m128d Y);
204 /// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
207 /// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
208 /// copied to the corresponding bits of the result.
210 /// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
211 /// rounded down to the nearest integer and copied to the corresponding bits
213 /// \returns A 128-bit vector of [2 x double] containing the copied and rounded
215 #define _mm_floor_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_FLOOR)
217 /// \brief Rounds each element of the 128-bit vector of [4 x float] to an
218 /// integer value according to the rounding control specified by the second
219 /// argument and returns the rounded values in a 128-bit vector of
222 /// \headerfile <x86intrin.h>
225 /// __m128 _mm_round_ps(__m128 X, const int M);
228 /// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
231 /// A 128-bit vector of [4 x float].
233 /// An integer value that specifies the rounding operation. \n
234 /// Bits [7:4] are reserved. \n
235 /// Bit [3] is a precision exception value: \n
236 /// 0: A normal PE exception is used \n
237 /// 1: The PE field is not updated \n
238 /// Bit [2] is the rounding control source: \n
239 /// 0: Use bits [1:0] of \a M \n
240 /// 1: Use the current MXCSR setting \n
241 /// Bits [1:0] contain the rounding control definition: \n
243 /// 01: Downward (toward negative infinity) \n
244 /// 10: Upward (toward positive infinity) \n
246 /// \returns A 128-bit vector of [4 x float] containing the rounded values.
247 #define _mm_round_ps(X, M) __extension__ ({ \
248 (__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M)); })
250 /// \brief Copies three upper elements of the first 128-bit vector operand to
251 /// the corresponding three upper elements of the 128-bit result vector of
252 /// [4 x float]. Rounds the lowest element of the second 128-bit vector
253 /// operand to an integer value according to the rounding control specified
254 /// by the third argument and copies it to the lowest element of the 128-bit
255 /// result vector of [4 x float].
257 /// \headerfile <x86intrin.h>
260 /// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M);
263 /// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
266 /// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
267 /// copied to the corresponding bits of the result.
269 /// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
270 /// rounded to the nearest integer using the specified rounding control and
271 /// copied to the corresponding bits of the result.
273 /// An integer value that specifies the rounding operation. \n
274 /// Bits [7:4] are reserved. \n
275 /// Bit [3] is a precision exception value: \n
276 /// 0: A normal PE exception is used \n
277 /// 1: The PE field is not updated \n
278 /// Bit [2] is the rounding control source: \n
279 /// 0: Use bits [1:0] of \a M \n
280 /// 1: Use the current MXCSR setting \n
281 /// Bits [1:0] contain the rounding control definition: \n
283 /// 01: Downward (toward negative infinity) \n
284 /// 10: Upward (toward positive infinity) \n
286 /// \returns A 128-bit vector of [4 x float] containing the copied and rounded
288 #define _mm_round_ss(X, Y, M) __extension__ ({ \
289 (__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), \
290 (__v4sf)(__m128)(Y), (M)); })
292 /// \brief Rounds each element of the 128-bit vector of [2 x double] to an
293 /// integer value according to the rounding control specified by the second
294 /// argument and returns the rounded values in a 128-bit vector of
297 /// \headerfile <x86intrin.h>
300 /// __m128d _mm_round_pd(__m128d X, const int M);
303 /// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
306 /// A 128-bit vector of [2 x double].
308 /// An integer value that specifies the rounding operation. \n
309 /// Bits [7:4] are reserved. \n
310 /// Bit [3] is a precision exception value: \n
311 /// 0: A normal PE exception is used \n
312 /// 1: The PE field is not updated \n
313 /// Bit [2] is the rounding control source: \n
314 /// 0: Use bits [1:0] of \a M \n
315 /// 1: Use the current MXCSR setting \n
316 /// Bits [1:0] contain the rounding control definition: \n
318 /// 01: Downward (toward negative infinity) \n
319 /// 10: Upward (toward positive infinity) \n
321 /// \returns A 128-bit vector of [2 x double] containing the rounded values.
322 #define _mm_round_pd(X, M) __extension__ ({ \
323 (__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M)); })
325 /// \brief Copies the upper element of the first 128-bit vector operand to the
326 /// corresponding upper element of the 128-bit result vector of [2 x double].
327 /// Rounds the lower element of the second 128-bit vector operand to an
328 /// integer value according to the rounding control specified by the third
329 /// argument and copies it to the lower element of the 128-bit result vector
332 /// \headerfile <x86intrin.h>
335 /// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M);
338 /// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
341 /// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
342 /// copied to the corresponding bits of the result.
344 /// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
345 /// rounded to the nearest integer using the specified rounding control and
346 /// copied to the corresponding bits of the result.
348 /// An integer value that specifies the rounding operation. \n
349 /// Bits [7:4] are reserved. \n
350 /// Bit [3] is a precision exception value: \n
351 /// 0: A normal PE exception is used \n
352 /// 1: The PE field is not updated \n
353 /// Bit [2] is the rounding control source: \n
354 /// 0: Use bits [1:0] of \a M \n
355 /// 1: Use the current MXCSR setting \n
356 /// Bits [1:0] contain the rounding control definition: \n
358 /// 01: Downward (toward negative infinity) \n
359 /// 10: Upward (toward positive infinity) \n
361 /// \returns A 128-bit vector of [2 x double] containing the copied and rounded
363 #define _mm_round_sd(X, Y, M) __extension__ ({ \
364 (__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), \
365 (__v2df)(__m128d)(Y), (M)); })
367 /* SSE4 Packed Blending Intrinsics. */
368 /// \brief Returns a 128-bit vector of [2 x double] where the values are
369 /// selected from either the first or second operand as specified by the
370 /// third operand, the control mask.
372 /// \headerfile <x86intrin.h>
375 /// __m128d _mm_blend_pd(__m128d V1, __m128d V2, const int M);
378 /// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction.
381 /// A 128-bit vector of [2 x double].
383 /// A 128-bit vector of [2 x double].
385 /// An immediate integer operand, with mask bits [1:0] specifying how the
386 /// values are to be copied. The position of the mask bit corresponds to the
387 /// index of a copied value. When a mask bit is 0, the corresponding 64-bit
388 /// element in operand \a V1 is copied to the same position in the result.
389 /// When a mask bit is 1, the corresponding 64-bit element in operand \a V2
390 /// is copied to the same position in the result.
391 /// \returns A 128-bit vector of [2 x double] containing the copied values.
392 #define _mm_blend_pd(V1, V2, M) __extension__ ({ \
393 (__m128d)__builtin_shufflevector((__v2df)(__m128d)(V1), \
394 (__v2df)(__m128d)(V2), \
395 (((M) & 0x01) ? 2 : 0), \
396 (((M) & 0x02) ? 3 : 1)); })
398 /// \brief Returns a 128-bit vector of [4 x float] where the values are selected
399 /// from either the first or second operand as specified by the third
400 /// operand, the control mask.
402 /// \headerfile <x86intrin.h>
405 /// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M);
408 /// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS </c> instruction.
411 /// A 128-bit vector of [4 x float].
413 /// A 128-bit vector of [4 x float].
415 /// An immediate integer operand, with mask bits [3:0] specifying how the
416 /// values are to be copied. The position of the mask bit corresponds to the
417 /// index of a copied value. When a mask bit is 0, the corresponding 32-bit
418 /// element in operand \a V1 is copied to the same position in the result.
419 /// When a mask bit is 1, the corresponding 32-bit element in operand \a V2
420 /// is copied to the same position in the result.
421 /// \returns A 128-bit vector of [4 x float] containing the copied values.
422 #define _mm_blend_ps(V1, V2, M) __extension__ ({ \
423 (__m128)__builtin_shufflevector((__v4sf)(__m128)(V1), (__v4sf)(__m128)(V2), \
424 (((M) & 0x01) ? 4 : 0), \
425 (((M) & 0x02) ? 5 : 1), \
426 (((M) & 0x04) ? 6 : 2), \
427 (((M) & 0x08) ? 7 : 3)); })
429 /// \brief Returns a 128-bit vector of [2 x double] where the values are
430 /// selected from either the first or second operand as specified by the
431 /// third operand, the control mask.
433 /// \headerfile <x86intrin.h>
435 /// This intrinsic corresponds to the <c> VBLENDVPD / BLENDVPD </c> instruction.
438 /// A 128-bit vector of [2 x double].
440 /// A 128-bit vector of [2 x double].
442 /// A 128-bit vector operand, with mask bits 127 and 63 specifying how the
443 /// values are to be copied. The position of the mask bit corresponds to the
444 /// most significant bit of a copied value. When a mask bit is 0, the
445 /// corresponding 64-bit element in operand \a __V1 is copied to the same
446 /// position in the result. When a mask bit is 1, the corresponding 64-bit
447 /// element in operand \a __V2 is copied to the same position in the result.
448 /// \returns A 128-bit vector of [2 x double] containing the copied values.
449 static __inline__ __m128d __DEFAULT_FN_ATTRS
450 _mm_blendv_pd (__m128d __V1, __m128d __V2, __m128d __M)
452 return (__m128d) __builtin_ia32_blendvpd ((__v2df)__V1, (__v2df)__V2,
456 /// \brief Returns a 128-bit vector of [4 x float] where the values are
457 /// selected from either the first or second operand as specified by the
458 /// third operand, the control mask.
460 /// \headerfile <x86intrin.h>
462 /// This intrinsic corresponds to the <c> VBLENDVPS / BLENDVPS </c> instruction.
465 /// A 128-bit vector of [4 x float].
467 /// A 128-bit vector of [4 x float].
469 /// A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying
470 /// how the values are to be copied. The position of the mask bit corresponds
471 /// to the most significant bit of a copied value. When a mask bit is 0, the
472 /// corresponding 32-bit element in operand \a __V1 is copied to the same
473 /// position in the result. When a mask bit is 1, the corresponding 32-bit
474 /// element in operand \a __V2 is copied to the same position in the result.
475 /// \returns A 128-bit vector of [4 x float] containing the copied values.
476 static __inline__ __m128 __DEFAULT_FN_ATTRS
477 _mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M)
479 return (__m128) __builtin_ia32_blendvps ((__v4sf)__V1, (__v4sf)__V2,
483 /// \brief Returns a 128-bit vector of [16 x i8] where the values are selected
484 /// from either of the first or second operand as specified by the third
485 /// operand, the control mask.
487 /// \headerfile <x86intrin.h>
489 /// This intrinsic corresponds to the <c> VPBLENDVB / PBLENDVB </c> instruction.
492 /// A 128-bit vector of [16 x i8].
494 /// A 128-bit vector of [16 x i8].
496 /// A 128-bit vector operand, with mask bits 127, 119, 111 ... 7 specifying
497 /// how the values are to be copied. The position of the mask bit corresponds
498 /// to the most significant bit of a copied value. When a mask bit is 0, the
499 /// corresponding 8-bit element in operand \a __V1 is copied to the same
500 /// position in the result. When a mask bit is 1, the corresponding 8-bit
501 /// element in operand \a __V2 is copied to the same position in the result.
502 /// \returns A 128-bit vector of [16 x i8] containing the copied values.
503 static __inline__ __m128i __DEFAULT_FN_ATTRS
504 _mm_blendv_epi8 (__m128i __V1, __m128i __V2, __m128i __M)
506 return (__m128i) __builtin_ia32_pblendvb128 ((__v16qi)__V1, (__v16qi)__V2,
510 /// \brief Returns a 128-bit vector of [8 x i16] where the values are selected
511 /// from either of the first or second operand as specified by the third
512 /// operand, the control mask.
514 /// \headerfile <x86intrin.h>
517 /// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M);
520 /// This intrinsic corresponds to the <c> VPBLENDW / PBLENDW </c> instruction.
523 /// A 128-bit vector of [8 x i16].
525 /// A 128-bit vector of [8 x i16].
527 /// An immediate integer operand, with mask bits [7:0] specifying how the
528 /// values are to be copied. The position of the mask bit corresponds to the
529 /// index of a copied value. When a mask bit is 0, the corresponding 16-bit
530 /// element in operand \a V1 is copied to the same position in the result.
531 /// When a mask bit is 1, the corresponding 16-bit element in operand \a V2
532 /// is copied to the same position in the result.
533 /// \returns A 128-bit vector of [8 x i16] containing the copied values.
534 #define _mm_blend_epi16(V1, V2, M) __extension__ ({ \
535 (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(V1), \
536 (__v8hi)(__m128i)(V2), \
537 (((M) & 0x01) ? 8 : 0), \
538 (((M) & 0x02) ? 9 : 1), \
539 (((M) & 0x04) ? 10 : 2), \
540 (((M) & 0x08) ? 11 : 3), \
541 (((M) & 0x10) ? 12 : 4), \
542 (((M) & 0x20) ? 13 : 5), \
543 (((M) & 0x40) ? 14 : 6), \
544 (((M) & 0x80) ? 15 : 7)); })
546 /* SSE4 Dword Multiply Instructions. */
547 /// \brief Multiples corresponding elements of two 128-bit vectors of [4 x i32]
548 /// and returns the lower 32 bits of the each product in a 128-bit vector of
551 /// \headerfile <x86intrin.h>
553 /// This intrinsic corresponds to the <c> VPMULLD / PMULLD </c> instruction.
556 /// A 128-bit integer vector.
558 /// A 128-bit integer vector.
559 /// \returns A 128-bit integer vector containing the products of both operands.
560 static __inline__ __m128i __DEFAULT_FN_ATTRS
561 _mm_mullo_epi32 (__m128i __V1, __m128i __V2)
563 return (__m128i) ((__v4su)__V1 * (__v4su)__V2);
566 /// \brief Multiplies corresponding even-indexed elements of two 128-bit
567 /// vectors of [4 x i32] and returns a 128-bit vector of [2 x i64]
568 /// containing the products.
570 /// \headerfile <x86intrin.h>
572 /// This intrinsic corresponds to the <c> VPMULDQ / PMULDQ </c> instruction.
575 /// A 128-bit vector of [4 x i32].
577 /// A 128-bit vector of [4 x i32].
578 /// \returns A 128-bit vector of [2 x i64] containing the products of both
580 static __inline__ __m128i __DEFAULT_FN_ATTRS
581 _mm_mul_epi32 (__m128i __V1, __m128i __V2)
583 return (__m128i) __builtin_ia32_pmuldq128 ((__v4si)__V1, (__v4si)__V2);
586 /* SSE4 Floating Point Dot Product Instructions. */
587 /// \brief Computes the dot product of the two 128-bit vectors of [4 x float]
588 /// and returns it in the elements of the 128-bit result vector of
591 /// The immediate integer operand controls which input elements
592 /// will contribute to the dot product, and where the final results are
595 /// \headerfile <x86intrin.h>
598 /// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M);
601 /// This intrinsic corresponds to the <c> VDPPS / DPPS </c> instruction.
604 /// A 128-bit vector of [4 x float].
606 /// A 128-bit vector of [4 x float].
608 /// An immediate integer operand. Mask bits [7:4] determine which elements
609 /// of the input vectors are used, with bit [4] corresponding to the lowest
610 /// element and bit [7] corresponding to the highest element of each [4 x
611 /// float] vector. If a bit is set, the corresponding elements from the two
612 /// input vectors are used as an input for dot product; otherwise that input
613 /// is treated as zero. Bits [3:0] determine which elements of the result
614 /// will receive a copy of the final dot product, with bit [0] corresponding
615 /// to the lowest element and bit [3] corresponding to the highest element of
616 /// each [4 x float] subvector. If a bit is set, the dot product is returned
617 /// in the corresponding element; otherwise that element is set to zero.
618 /// \returns A 128-bit vector of [4 x float] containing the dot product.
619 #define _mm_dp_ps(X, Y, M) __extension__ ({ \
620 (__m128) __builtin_ia32_dpps((__v4sf)(__m128)(X), \
621 (__v4sf)(__m128)(Y), (M)); })
623 /// \brief Computes the dot product of the two 128-bit vectors of [2 x double]
624 /// and returns it in the elements of the 128-bit result vector of
627 /// The immediate integer operand controls which input
628 /// elements will contribute to the dot product, and where the final results
631 /// \headerfile <x86intrin.h>
634 /// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M);
637 /// This intrinsic corresponds to the <c> VDPPD / DPPD </c> instruction.
640 /// A 128-bit vector of [2 x double].
642 /// A 128-bit vector of [2 x double].
644 /// An immediate integer operand. Mask bits [5:4] determine which elements
645 /// of the input vectors are used, with bit [4] corresponding to the lowest
646 /// element and bit [5] corresponding to the highest element of each of [2 x
647 /// double] vector. If a bit is set, the corresponding elements from the two
648 /// input vectors are used as an input for dot product; otherwise that input
649 /// is treated as zero. Bits [1:0] determine which elements of the result
650 /// will receive a copy of the final dot product, with bit [0] corresponding
651 /// to the lowest element and bit [3] corresponding to the highest element of
652 /// each [2 x double] vector. If a bit is set, the dot product is returned in
653 /// the corresponding element; otherwise that element is set to zero.
654 #define _mm_dp_pd(X, Y, M) __extension__ ({\
655 (__m128d) __builtin_ia32_dppd((__v2df)(__m128d)(X), \
656 (__v2df)(__m128d)(Y), (M)); })
658 /* SSE4 Streaming Load Hint Instruction. */
659 /// \brief Loads integer values from a 128-bit aligned memory location to a
660 /// 128-bit integer vector.
662 /// \headerfile <x86intrin.h>
664 /// This intrinsic corresponds to the <c> VMOVNTDQA / MOVNTDQA </c> instruction.
667 /// A pointer to a 128-bit aligned memory location that contains the integer
669 /// \returns A 128-bit integer vector containing the data stored at the
670 /// specified memory location.
671 static __inline__ __m128i __DEFAULT_FN_ATTRS
672 _mm_stream_load_si128 (__m128i const *__V)
674 return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V);
677 /* SSE4 Packed Integer Min/Max Instructions. */
678 /// \brief Compares the corresponding elements of two 128-bit vectors of
679 /// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser
680 /// of the two values.
682 /// \headerfile <x86intrin.h>
684 /// This intrinsic corresponds to the <c> VPMINSB / PMINSB </c> instruction.
687 /// A 128-bit vector of [16 x i8].
689 /// A 128-bit vector of [16 x i8]
690 /// \returns A 128-bit vector of [16 x i8] containing the lesser values.
691 static __inline__ __m128i __DEFAULT_FN_ATTRS
692 _mm_min_epi8 (__m128i __V1, __m128i __V2)
694 return (__m128i) __builtin_ia32_pminsb128 ((__v16qi) __V1, (__v16qi) __V2);
697 /// \brief Compares the corresponding elements of two 128-bit vectors of
698 /// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the
699 /// greater value of the two.
701 /// \headerfile <x86intrin.h>
703 /// This intrinsic corresponds to the <c> VPMAXSB / PMAXSB </c> instruction.
706 /// A 128-bit vector of [16 x i8].
708 /// A 128-bit vector of [16 x i8].
709 /// \returns A 128-bit vector of [16 x i8] containing the greater values.
710 static __inline__ __m128i __DEFAULT_FN_ATTRS
711 _mm_max_epi8 (__m128i __V1, __m128i __V2)
713 return (__m128i) __builtin_ia32_pmaxsb128 ((__v16qi) __V1, (__v16qi) __V2);
716 /// \brief Compares the corresponding elements of two 128-bit vectors of
717 /// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser
718 /// value of the two.
720 /// \headerfile <x86intrin.h>
722 /// This intrinsic corresponds to the <c> VPMINUW / PMINUW </c> instruction.
725 /// A 128-bit vector of [8 x u16].
727 /// A 128-bit vector of [8 x u16].
728 /// \returns A 128-bit vector of [8 x u16] containing the lesser values.
729 static __inline__ __m128i __DEFAULT_FN_ATTRS
730 _mm_min_epu16 (__m128i __V1, __m128i __V2)
732 return (__m128i) __builtin_ia32_pminuw128 ((__v8hi) __V1, (__v8hi) __V2);
735 /// \brief Compares the corresponding elements of two 128-bit vectors of
736 /// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the
737 /// greater value of the two.
739 /// \headerfile <x86intrin.h>
741 /// This intrinsic corresponds to the <c> VPMAXUW / PMAXUW </c> instruction.
744 /// A 128-bit vector of [8 x u16].
746 /// A 128-bit vector of [8 x u16].
747 /// \returns A 128-bit vector of [8 x u16] containing the greater values.
748 static __inline__ __m128i __DEFAULT_FN_ATTRS
749 _mm_max_epu16 (__m128i __V1, __m128i __V2)
751 return (__m128i) __builtin_ia32_pmaxuw128 ((__v8hi) __V1, (__v8hi) __V2);
754 /// \brief Compares the corresponding elements of two 128-bit vectors of
755 /// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser
756 /// value of the two.
758 /// \headerfile <x86intrin.h>
760 /// This intrinsic corresponds to the <c> VPMINSD / PMINSD </c> instruction.
763 /// A 128-bit vector of [4 x i32].
765 /// A 128-bit vector of [4 x i32].
766 /// \returns A 128-bit vector of [4 x i32] containing the lesser values.
767 static __inline__ __m128i __DEFAULT_FN_ATTRS
768 _mm_min_epi32 (__m128i __V1, __m128i __V2)
770 return (__m128i) __builtin_ia32_pminsd128 ((__v4si) __V1, (__v4si) __V2);
773 /// \brief Compares the corresponding elements of two 128-bit vectors of
774 /// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the
775 /// greater value of the two.
777 /// \headerfile <x86intrin.h>
779 /// This intrinsic corresponds to the <c> VPMAXSD / PMAXSD </c> instruction.
782 /// A 128-bit vector of [4 x i32].
784 /// A 128-bit vector of [4 x i32].
785 /// \returns A 128-bit vector of [4 x i32] containing the greater values.
786 static __inline__ __m128i __DEFAULT_FN_ATTRS
787 _mm_max_epi32 (__m128i __V1, __m128i __V2)
789 return (__m128i) __builtin_ia32_pmaxsd128 ((__v4si) __V1, (__v4si) __V2);
792 /// \brief Compares the corresponding elements of two 128-bit vectors of
793 /// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser
794 /// value of the two.
796 /// \headerfile <x86intrin.h>
798 /// This intrinsic corresponds to the <c> VPMINUD / PMINUD </c> instruction.
801 /// A 128-bit vector of [4 x u32].
803 /// A 128-bit vector of [4 x u32].
804 /// \returns A 128-bit vector of [4 x u32] containing the lesser values.
805 static __inline__ __m128i __DEFAULT_FN_ATTRS
806 _mm_min_epu32 (__m128i __V1, __m128i __V2)
808 return (__m128i) __builtin_ia32_pminud128((__v4si) __V1, (__v4si) __V2);
811 /// \brief Compares the corresponding elements of two 128-bit vectors of
812 /// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the
813 /// greater value of the two.
815 /// \headerfile <x86intrin.h>
817 /// This intrinsic corresponds to the <c> VPMAXUD / PMAXUD </c> instruction.
820 /// A 128-bit vector of [4 x u32].
822 /// A 128-bit vector of [4 x u32].
823 /// \returns A 128-bit vector of [4 x u32] containing the greater values.
824 static __inline__ __m128i __DEFAULT_FN_ATTRS
825 _mm_max_epu32 (__m128i __V1, __m128i __V2)
827 return (__m128i) __builtin_ia32_pmaxud128((__v4si) __V1, (__v4si) __V2);
830 /* SSE4 Insertion and Extraction from XMM Register Instructions. */
831 /// \brief Takes the first argument \a X and inserts an element from the second
832 /// argument \a Y as selected by the third argument \a N. That result then
833 /// has elements zeroed out also as selected by the third argument \a N. The
834 /// resulting 128-bit vector of [4 x float] is then returned.
836 /// \headerfile <x86intrin.h>
839 /// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N);
842 /// This intrinsic corresponds to the <c> VINSERTPS </c> instruction.
845 /// A 128-bit vector source operand of [4 x float]. With the exception of
846 /// those bits in the result copied from parameter \a Y and zeroed by bits
847 /// [3:0] of \a N, all bits from this parameter are copied to the result.
849 /// A 128-bit vector source operand of [4 x float]. One single-precision
850 /// floating-point element from this source, as determined by the immediate
851 /// parameter, is copied to the result.
853 /// Specifies which bits from operand \a Y will be copied, which bits in the
854 /// result they will be be copied to, and which bits in the result will be
855 /// cleared. The following assignments are made: \n
856 /// Bits [7:6] specify the bits to copy from operand \a Y: \n
857 /// 00: Selects bits [31:0] from operand \a Y. \n
858 /// 01: Selects bits [63:32] from operand \a Y. \n
859 /// 10: Selects bits [95:64] from operand \a Y. \n
860 /// 11: Selects bits [127:96] from operand \a Y. \n
861 /// Bits [5:4] specify the bits in the result to which the selected bits
862 /// from operand \a Y are copied: \n
863 /// 00: Copies the selected bits from \a Y to result bits [31:0]. \n
864 /// 01: Copies the selected bits from \a Y to result bits [63:32]. \n
865 /// 10: Copies the selected bits from \a Y to result bits [95:64]. \n
866 /// 11: Copies the selected bits from \a Y to result bits [127:96]. \n
867 /// Bits[3:0]: If any of these bits are set, the corresponding result
868 /// element is cleared.
869 /// \returns A 128-bit vector of [4 x float] containing the copied single-
870 /// precision floating point elements from the operands.
871 #define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))
873 /// \brief Extracts a 32-bit integer from a 128-bit vector of [4 x float] and
874 /// returns it, using the immediate value parameter \a N as a selector.
876 /// \headerfile <x86intrin.h>
879 /// int _mm_extract_ps(__m128 X, const int N);
882 /// This intrinsic corresponds to the <c> VEXTRACTPS / EXTRACTPS </c>
886 /// A 128-bit vector of [4 x float].
888 /// An immediate value. Bits [1:0] determines which bits from the argument
889 /// \a X are extracted and returned: \n
890 /// 00: Bits [31:0] of parameter \a X are returned. \n
891 /// 01: Bits [63:32] of parameter \a X are returned. \n
892 /// 10: Bits [95:64] of parameter \a X are returned. \n
893 /// 11: Bits [127:96] of parameter \a X are returned.
894 /// \returns A 32-bit integer containing the extracted 32 bits of float data.
895 #define _mm_extract_ps(X, N) (__extension__ \
896 ({ union { int __i; float __f; } __t; \
897 __v4sf __a = (__v4sf)(__m128)(X); \
898 __t.__f = __a[(N) & 3]; \
901 /* Miscellaneous insert and extract macros. */
902 /* Extract a single-precision float from X at index N into D. */
903 #define _MM_EXTRACT_FLOAT(D, X, N) (__extension__ ({ __v4sf __a = (__v4sf)(X); \
906 /* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create
907 an index suitable for _mm_insert_ps. */
908 #define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z))
910 /* Extract a float from X at index N into the first index of the return. */
911 #define _MM_PICK_OUT_PS(X, N) _mm_insert_ps (_mm_setzero_ps(), (X), \
912 _MM_MK_INSERTPS_NDX((N), 0, 0x0e))
914 /* Insert int into packed integer array at index. */
915 /// \brief Constructs a 128-bit vector of [16 x i8] by first making a copy of
916 /// the 128-bit integer vector parameter, and then inserting the lower 8 bits
917 /// of an integer parameter \a I into an offset specified by the immediate
918 /// value parameter \a N.
920 /// \headerfile <x86intrin.h>
923 /// __m128i _mm_insert_epi8(__m128i X, int I, const int N);
926 /// This intrinsic corresponds to the <c> VPINSRB / PINSRB </c> instruction.
929 /// A 128-bit integer vector of [16 x i8]. This vector is copied to the
930 /// result and then one of the sixteen elements in the result vector is
931 /// replaced by the lower 8 bits of \a I.
933 /// An integer. The lower 8 bits of this operand are written to the result
934 /// beginning at the offset specified by \a N.
936 /// An immediate value. Bits [3:0] specify the bit offset in the result at
937 /// which the lower 8 bits of \a I are written. \n
938 /// 0000: Bits [7:0] of the result are used for insertion. \n
939 /// 0001: Bits [15:8] of the result are used for insertion. \n
940 /// 0010: Bits [23:16] of the result are used for insertion. \n
941 /// 0011: Bits [31:24] of the result are used for insertion. \n
942 /// 0100: Bits [39:32] of the result are used for insertion. \n
943 /// 0101: Bits [47:40] of the result are used for insertion. \n
944 /// 0110: Bits [55:48] of the result are used for insertion. \n
945 /// 0111: Bits [63:56] of the result are used for insertion. \n
946 /// 1000: Bits [71:64] of the result are used for insertion. \n
947 /// 1001: Bits [79:72] of the result are used for insertion. \n
948 /// 1010: Bits [87:80] of the result are used for insertion. \n
949 /// 1011: Bits [95:88] of the result are used for insertion. \n
950 /// 1100: Bits [103:96] of the result are used for insertion. \n
951 /// 1101: Bits [111:104] of the result are used for insertion. \n
952 /// 1110: Bits [119:112] of the result are used for insertion. \n
953 /// 1111: Bits [127:120] of the result are used for insertion.
954 /// \returns A 128-bit integer vector containing the constructed values.
955 #define _mm_insert_epi8(X, I, N) (__extension__ \
956 ({ __v16qi __a = (__v16qi)(__m128i)(X); \
957 __a[(N) & 15] = (I); \
960 /// \brief Constructs a 128-bit vector of [4 x i32] by first making a copy of
961 /// the 128-bit integer vector parameter, and then inserting the 32-bit
962 /// integer parameter \a I at the offset specified by the immediate value
965 /// \headerfile <x86intrin.h>
968 /// __m128i _mm_insert_epi32(__m128i X, int I, const int N);
971 /// This intrinsic corresponds to the <c> VPINSRD / PINSRD </c> instruction.
974 /// A 128-bit integer vector of [4 x i32]. This vector is copied to the
975 /// result and then one of the four elements in the result vector is
976 /// replaced by \a I.
978 /// A 32-bit integer that is written to the result beginning at the offset
979 /// specified by \a N.
981 /// An immediate value. Bits [1:0] specify the bit offset in the result at
982 /// which the integer \a I is written. \n
983 /// 00: Bits [31:0] of the result are used for insertion. \n
984 /// 01: Bits [63:32] of the result are used for insertion. \n
985 /// 10: Bits [95:64] of the result are used for insertion. \n
986 /// 11: Bits [127:96] of the result are used for insertion.
987 /// \returns A 128-bit integer vector containing the constructed values.
988 #define _mm_insert_epi32(X, I, N) (__extension__ \
989 ({ __v4si __a = (__v4si)(__m128i)(X); \
990 __a[(N) & 3] = (I); \
994 /// \brief Constructs a 128-bit vector of [2 x i64] by first making a copy of
995 /// the 128-bit integer vector parameter, and then inserting the 64-bit
996 /// integer parameter \a I, using the immediate value parameter \a N as an
997 /// insertion location selector.
999 /// \headerfile <x86intrin.h>
1002 /// __m128i _mm_insert_epi64(__m128i X, long long I, const int N);
1005 /// This intrinsic corresponds to the <c> VPINSRQ / PINSRQ </c> instruction.
1008 /// A 128-bit integer vector of [2 x i64]. This vector is copied to the
1009 /// result and then one of the two elements in the result vector is replaced
1012 /// A 64-bit integer that is written to the result beginning at the offset
1013 /// specified by \a N.
1015 /// An immediate value. Bit [0] specifies the bit offset in the result at
1016 /// which the integer \a I is written. \n
1017 /// 0: Bits [63:0] of the result are used for insertion. \n
1018 /// 1: Bits [127:64] of the result are used for insertion. \n
1019 /// \returns A 128-bit integer vector containing the constructed values.
1020 #define _mm_insert_epi64(X, I, N) (__extension__ \
1021 ({ __v2di __a = (__v2di)(__m128i)(X); \
1022 __a[(N) & 1] = (I); \
1024 #endif /* __x86_64__ */
1026 /* Extract int from packed integer array at index. This returns the element
1027 * as a zero extended value, so it is unsigned.
1029 /// \brief Extracts an 8-bit element from the 128-bit integer vector of
1030 /// [16 x i8], using the immediate value parameter \a N as a selector.
1032 /// \headerfile <x86intrin.h>
1035 /// int _mm_extract_epi8(__m128i X, const int N);
1038 /// This intrinsic corresponds to the <c> VPEXTRB / PEXTRB </c> instruction.
1041 /// A 128-bit integer vector.
1043 /// An immediate value. Bits [3:0] specify which 8-bit vector element from
1044 /// the argument \a X to extract and copy to the result. \n
1045 /// 0000: Bits [7:0] of parameter \a X are extracted. \n
1046 /// 0001: Bits [15:8] of the parameter \a X are extracted. \n
1047 /// 0010: Bits [23:16] of the parameter \a X are extracted. \n
1048 /// 0011: Bits [31:24] of the parameter \a X are extracted. \n
1049 /// 0100: Bits [39:32] of the parameter \a X are extracted. \n
1050 /// 0101: Bits [47:40] of the parameter \a X are extracted. \n
1051 /// 0110: Bits [55:48] of the parameter \a X are extracted. \n
1052 /// 0111: Bits [63:56] of the parameter \a X are extracted. \n
1053 /// 1000: Bits [71:64] of the parameter \a X are extracted. \n
1054 /// 1001: Bits [79:72] of the parameter \a X are extracted. \n
1055 /// 1010: Bits [87:80] of the parameter \a X are extracted. \n
1056 /// 1011: Bits [95:88] of the parameter \a X are extracted. \n
1057 /// 1100: Bits [103:96] of the parameter \a X are extracted. \n
1058 /// 1101: Bits [111:104] of the parameter \a X are extracted. \n
1059 /// 1110: Bits [119:112] of the parameter \a X are extracted. \n
1060 /// 1111: Bits [127:120] of the parameter \a X are extracted.
1061 /// \returns An unsigned integer, whose lower 8 bits are selected from the
1062 /// 128-bit integer vector parameter and the remaining bits are assigned
1064 #define _mm_extract_epi8(X, N) (__extension__ \
1065 ({ __v16qi __a = (__v16qi)(__m128i)(X); \
1066 (int)(unsigned char) __a[(N) & 15];}))
1068 /// \brief Extracts a 32-bit element from the 128-bit integer vector of
1069 /// [4 x i32], using the immediate value parameter \a N as a selector.
1071 /// \headerfile <x86intrin.h>
1074 /// int _mm_extract_epi32(__m128i X, const int N);
1077 /// This intrinsic corresponds to the <c> VPEXTRD / PEXTRD </c> instruction.
1080 /// A 128-bit integer vector.
1082 /// An immediate value. Bits [1:0] specify which 32-bit vector element from
1083 /// the argument \a X to extract and copy to the result. \n
1084 /// 00: Bits [31:0] of the parameter \a X are extracted. \n
1085 /// 01: Bits [63:32] of the parameter \a X are extracted. \n
1086 /// 10: Bits [95:64] of the parameter \a X are extracted. \n
1087 /// 11: Bits [127:96] of the parameter \a X are exracted.
1088 /// \returns An integer, whose lower 32 bits are selected from the 128-bit
1089 /// integer vector parameter and the remaining bits are assigned zeros.
1090 #define _mm_extract_epi32(X, N) (__extension__ \
1091 ({ __v4si __a = (__v4si)(__m128i)(X); \
1092 (int)__a[(N) & 3];}))
1095 /// \brief Extracts a 64-bit element from the 128-bit integer vector of
1096 /// [2 x i64], using the immediate value parameter \a N as a selector.
1098 /// \headerfile <x86intrin.h>
1101 /// long long _mm_extract_epi64(__m128i X, const int N);
1104 /// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
1107 /// A 128-bit integer vector.
1109 /// An immediate value. Bit [0] specifies which 64-bit vector element from
1110 /// the argument \a X to return. \n
1111 /// 0: Bits [63:0] are returned. \n
1112 /// 1: Bits [127:64] are returned. \n
1113 /// \returns A 64-bit integer.
1114 #define _mm_extract_epi64(X, N) (__extension__ \
1115 ({ __v2di __a = (__v2di)(__m128i)(X); \
1116 (long long)__a[(N) & 1];}))
1117 #endif /* __x86_64 */
1119 /* SSE4 128-bit Packed Integer Comparisons. */
1120 /// \brief Tests whether the specified bits in a 128-bit integer vector are all
1123 /// \headerfile <x86intrin.h>
1125 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1128 /// A 128-bit integer vector containing the bits to be tested.
1130 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1131 /// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1132 static __inline__ int __DEFAULT_FN_ATTRS
1133 _mm_testz_si128(__m128i __M, __m128i __V)
1135 return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V);
1138 /// \brief Tests whether the specified bits in a 128-bit integer vector are all
1141 /// \headerfile <x86intrin.h>
1143 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1146 /// A 128-bit integer vector containing the bits to be tested.
1148 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1149 /// \returns TRUE if the specified bits are all ones; FALSE otherwise.
1150 static __inline__ int __DEFAULT_FN_ATTRS
1151 _mm_testc_si128(__m128i __M, __m128i __V)
1153 return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V);
1156 /// \brief Tests whether the specified bits in a 128-bit integer vector are
1157 /// neither all zeros nor all ones.
1159 /// \headerfile <x86intrin.h>
1161 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1164 /// A 128-bit integer vector containing the bits to be tested.
1166 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1167 /// \returns TRUE if the specified bits are neither all zeros nor all ones;
1168 /// FALSE otherwise.
1169 static __inline__ int __DEFAULT_FN_ATTRS
1170 _mm_testnzc_si128(__m128i __M, __m128i __V)
1172 return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V);
1175 /// \brief Tests whether the specified bits in a 128-bit integer vector are all
1178 /// \headerfile <x86intrin.h>
1181 /// int _mm_test_all_ones(__m128i V);
1184 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1187 /// A 128-bit integer vector containing the bits to be tested.
1188 /// \returns TRUE if the bits specified in the operand are all set to 1; FALSE
1190 #define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V)))
1192 /// \brief Tests whether the specified bits in a 128-bit integer vector are
1193 /// neither all zeros nor all ones.
1195 /// \headerfile <x86intrin.h>
1198 /// int _mm_test_mix_ones_zeros(__m128i M, __m128i V);
1201 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1204 /// A 128-bit integer vector containing the bits to be tested.
1206 /// A 128-bit integer vector selecting which bits to test in operand \a M.
1207 /// \returns TRUE if the specified bits are neither all zeros nor all ones;
1208 /// FALSE otherwise.
1209 #define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V))
1211 /// \brief Tests whether the specified bits in a 128-bit integer vector are all
1214 /// \headerfile <x86intrin.h>
1217 /// int _mm_test_all_zeros(__m128i M, __m128i V);
1220 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1223 /// A 128-bit integer vector containing the bits to be tested.
1225 /// A 128-bit integer vector selecting which bits to test in operand \a M.
1226 /// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1227 #define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V))
1229 /* SSE4 64-bit Packed Integer Comparisons. */
1230 /// \brief Compares each of the corresponding 64-bit values of the 128-bit
1231 /// integer vectors for equality.
1233 /// \headerfile <x86intrin.h>
1235 /// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction.
1238 /// A 128-bit integer vector.
1240 /// A 128-bit integer vector.
1241 /// \returns A 128-bit integer vector containing the comparison results.
1242 static __inline__ __m128i __DEFAULT_FN_ATTRS
1243 _mm_cmpeq_epi64(__m128i __V1, __m128i __V2)
1245 return (__m128i)((__v2di)__V1 == (__v2di)__V2);
1248 /* SSE4 Packed Integer Sign-Extension. */
1249 /// \brief Sign-extends each of the lower eight 8-bit integer elements of a
1250 /// 128-bit vector of [16 x i8] to 16-bit values and returns them in a
1251 /// 128-bit vector of [8 x i16]. The upper eight elements of the input vector
1254 /// \headerfile <x86intrin.h>
1256 /// This intrinsic corresponds to the <c> VPMOVSXBW / PMOVSXBW </c> instruction.
1259 /// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are sign-
1260 /// extended to 16-bit values.
1261 /// \returns A 128-bit vector of [8 x i16] containing the sign-extended values.
1262 static __inline__ __m128i __DEFAULT_FN_ATTRS
1263 _mm_cvtepi8_epi16(__m128i __V)
1265 /* This function always performs a signed extension, but __v16qi is a char
1266 which may be signed or unsigned, so use __v16qs. */
1267 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1270 /// \brief Sign-extends each of the lower four 8-bit integer elements of a
1271 /// 128-bit vector of [16 x i8] to 32-bit values and returns them in a
1272 /// 128-bit vector of [4 x i32]. The upper twelve elements of the input
1273 /// vector are unused.
1275 /// \headerfile <x86intrin.h>
1277 /// This intrinsic corresponds to the <c> VPMOVSXBD / PMOVSXBD </c> instruction.
1280 /// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are sign-
1281 /// extended to 32-bit values.
1282 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1283 static __inline__ __m128i __DEFAULT_FN_ATTRS
1284 _mm_cvtepi8_epi32(__m128i __V)
1286 /* This function always performs a signed extension, but __v16qi is a char
1287 which may be signed or unsigned, so use __v16qs. */
1288 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si);
1291 /// \brief Sign-extends each of the lower two 8-bit integer elements of a
1292 /// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1293 /// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1294 /// vector are unused.
1296 /// \headerfile <x86intrin.h>
1298 /// This intrinsic corresponds to the <c> VPMOVSXBQ / PMOVSXBQ </c> instruction.
1301 /// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are sign-
1302 /// extended to 64-bit values.
1303 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1304 static __inline__ __m128i __DEFAULT_FN_ATTRS
1305 _mm_cvtepi8_epi64(__m128i __V)
1307 /* This function always performs a signed extension, but __v16qi is a char
1308 which may be signed or unsigned, so use __v16qs. */
1309 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di);
1312 /// \brief Sign-extends each of the lower four 16-bit integer elements of a
1313 /// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1314 /// a 128-bit vector of [4 x i32]. The upper four elements of the input
1315 /// vector are unused.
1317 /// \headerfile <x86intrin.h>
1319 /// This intrinsic corresponds to the <c> VPMOVSXWD / PMOVSXWD </c> instruction.
1322 /// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are sign-
1323 /// extended to 32-bit values.
1324 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1325 static __inline__ __m128i __DEFAULT_FN_ATTRS
1326 _mm_cvtepi16_epi32(__m128i __V)
1328 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si);
1331 /// \brief Sign-extends each of the lower two 16-bit integer elements of a
1332 /// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1333 /// a 128-bit vector of [2 x i64]. The upper six elements of the input
1334 /// vector are unused.
1336 /// \headerfile <x86intrin.h>
1338 /// This intrinsic corresponds to the <c> VPMOVSXWQ / PMOVSXWQ </c> instruction.
1341 /// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are sign-
1342 /// extended to 64-bit values.
1343 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1344 static __inline__ __m128i __DEFAULT_FN_ATTRS
1345 _mm_cvtepi16_epi64(__m128i __V)
1347 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di);
1350 /// \brief Sign-extends each of the lower two 32-bit integer elements of a
1351 /// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1352 /// a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1355 /// \headerfile <x86intrin.h>
1357 /// This intrinsic corresponds to the <c> VPMOVSXDQ / PMOVSXDQ </c> instruction.
1360 /// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are sign-
1361 /// extended to 64-bit values.
1362 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1363 static __inline__ __m128i __DEFAULT_FN_ATTRS
1364 _mm_cvtepi32_epi64(__m128i __V)
1366 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di);
1369 /* SSE4 Packed Integer Zero-Extension. */
1370 /// \brief Zero-extends each of the lower eight 8-bit integer elements of a
1371 /// 128-bit vector of [16 x i8] to 16-bit values and returns them in a
1372 /// 128-bit vector of [8 x i16]. The upper eight elements of the input vector
1375 /// \headerfile <x86intrin.h>
1377 /// This intrinsic corresponds to the <c> VPMOVZXBW / PMOVZXBW </c> instruction.
1380 /// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are zero-
1381 /// extended to 16-bit values.
1382 /// \returns A 128-bit vector of [8 x i16] containing the zero-extended values.
1383 static __inline__ __m128i __DEFAULT_FN_ATTRS
1384 _mm_cvtepu8_epi16(__m128i __V)
1386 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1389 /// \brief Zero-extends each of the lower four 8-bit integer elements of a
1390 /// 128-bit vector of [16 x i8] to 32-bit values and returns them in a
1391 /// 128-bit vector of [4 x i32]. The upper twelve elements of the input
1392 /// vector are unused.
1394 /// \headerfile <x86intrin.h>
1396 /// This intrinsic corresponds to the <c> VPMOVZXBD / PMOVZXBD </c> instruction.
1399 /// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are zero-
1400 /// extended to 32-bit values.
1401 /// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1402 static __inline__ __m128i __DEFAULT_FN_ATTRS
1403 _mm_cvtepu8_epi32(__m128i __V)
1405 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si);
1408 /// \brief Zero-extends each of the lower two 8-bit integer elements of a
1409 /// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1410 /// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1411 /// vector are unused.
1413 /// \headerfile <x86intrin.h>
1415 /// This intrinsic corresponds to the <c> VPMOVZXBQ / PMOVZXBQ </c> instruction.
1418 /// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are zero-
1419 /// extended to 64-bit values.
1420 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1421 static __inline__ __m128i __DEFAULT_FN_ATTRS
1422 _mm_cvtepu8_epi64(__m128i __V)
1424 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di);
1427 /// \brief Zero-extends each of the lower four 16-bit integer elements of a
1428 /// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1429 /// a 128-bit vector of [4 x i32]. The upper four elements of the input
1430 /// vector are unused.
1432 /// \headerfile <x86intrin.h>
1434 /// This intrinsic corresponds to the <c> VPMOVZXWD / PMOVZXWD </c> instruction.
1437 /// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are zero-
1438 /// extended to 32-bit values.
1439 /// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1440 static __inline__ __m128i __DEFAULT_FN_ATTRS
1441 _mm_cvtepu16_epi32(__m128i __V)
1443 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si);
1446 /// \brief Zero-extends each of the lower two 16-bit integer elements of a
1447 /// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1448 /// a 128-bit vector of [2 x i64]. The upper six elements of the input vector
1451 /// \headerfile <x86intrin.h>
1453 /// This intrinsic corresponds to the <c> VPMOVZXWQ / PMOVZXWQ </c> instruction.
1456 /// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are zero-
1457 /// extended to 64-bit values.
1458 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1459 static __inline__ __m128i __DEFAULT_FN_ATTRS
1460 _mm_cvtepu16_epi64(__m128i __V)
1462 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di);
1465 /// \brief Zero-extends each of the lower two 32-bit integer elements of a
1466 /// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1467 /// a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1470 /// \headerfile <x86intrin.h>
1472 /// This intrinsic corresponds to the <c> VPMOVZXDQ / PMOVZXDQ </c> instruction.
1475 /// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are zero-
1476 /// extended to 64-bit values.
1477 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1478 static __inline__ __m128i __DEFAULT_FN_ATTRS
1479 _mm_cvtepu32_epi64(__m128i __V)
1481 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di);
1484 /* SSE4 Pack with Unsigned Saturation. */
1485 /// \brief Converts 32-bit signed integers from both 128-bit integer vector
1486 /// operands into 16-bit unsigned integers, and returns the packed result.
1487 /// Values greater than 0xFFFF are saturated to 0xFFFF. Values less than
1488 /// 0x0000 are saturated to 0x0000.
1490 /// \headerfile <x86intrin.h>
1492 /// This intrinsic corresponds to the <c> VPACKUSDW / PACKUSDW </c> instruction.
1495 /// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1496 /// signed integer and is converted to a 16-bit unsigned integer with
1497 /// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1498 /// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1499 /// are written to the lower 64 bits of the result.
1501 /// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1502 /// signed integer and is converted to a 16-bit unsigned integer with
1503 /// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1504 /// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1505 /// are written to the higher 64 bits of the result.
1506 /// \returns A 128-bit vector of [8 x i16] containing the converted values.
1507 static __inline__ __m128i __DEFAULT_FN_ATTRS
1508 _mm_packus_epi32(__m128i __V1, __m128i __V2)
1510 return (__m128i) __builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2);
1513 /* SSE4 Multiple Packed Sums of Absolute Difference. */
1514 /// \brief Subtracts 8-bit unsigned integer values and computes the absolute
1515 /// values of the differences to the corresponding bits in the destination.
1516 /// Then sums of the absolute differences are returned according to the bit
1517 /// fields in the immediate operand.
1519 /// \headerfile <x86intrin.h>
1522 /// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M);
1525 /// This intrinsic corresponds to the <c> VMPSADBW / MPSADBW </c> instruction.
1528 /// A 128-bit vector of [16 x i8].
1530 /// A 128-bit vector of [16 x i8].
1532 /// An 8-bit immediate operand specifying how the absolute differences are to
1533 /// be calculated, according to the following algorithm:
1535 /// // M2 represents bit 2 of the immediate operand
1536 /// // M10 represents bits [1:0] of the immediate operand
1539 /// for (k = 0; k < 8; k = k + 1) {
1540 /// d0 = abs(X[i + k + 0] - Y[j + 0])
1541 /// d1 = abs(X[i + k + 1] - Y[j + 1])
1542 /// d2 = abs(X[i + k + 2] - Y[j + 2])
1543 /// d3 = abs(X[i + k + 3] - Y[j + 3])
1544 /// r[k] = d0 + d1 + d2 + d3
1547 /// \returns A 128-bit integer vector containing the sums of the sets of
1548 /// absolute differences between both operands.
1549 #define _mm_mpsadbw_epu8(X, Y, M) __extension__ ({ \
1550 (__m128i) __builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \
1551 (__v16qi)(__m128i)(Y), (M)); })
1553 /// \brief Finds the minimum unsigned 16-bit element in the input 128-bit
1554 /// vector of [8 x u16] and returns it and along with its index.
1556 /// \headerfile <x86intrin.h>
1558 /// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c>
1562 /// A 128-bit vector of [8 x u16].
1563 /// \returns A 128-bit value where bits [15:0] contain the minimum value found
1564 /// in parameter \a __V, bits [18:16] contain the index of the minimum value
1565 /// and the remaining bits are set to 0.
1566 static __inline__ __m128i __DEFAULT_FN_ATTRS
1567 _mm_minpos_epu16(__m128i __V)
1569 return (__m128i) __builtin_ia32_phminposuw128((__v8hi)__V);
1572 /* Handle the sse4.2 definitions here. */
1574 /* These definitions are normally in nmmintrin.h, but gcc puts them in here
1575 so we'll do the same. */
1577 #undef __DEFAULT_FN_ATTRS
1578 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))
1580 /* These specify the type of data that we're comparing. */
1581 #define _SIDD_UBYTE_OPS 0x00
1582 #define _SIDD_UWORD_OPS 0x01
1583 #define _SIDD_SBYTE_OPS 0x02
1584 #define _SIDD_SWORD_OPS 0x03
1586 /* These specify the type of comparison operation. */
1587 #define _SIDD_CMP_EQUAL_ANY 0x00
1588 #define _SIDD_CMP_RANGES 0x04
1589 #define _SIDD_CMP_EQUAL_EACH 0x08
1590 #define _SIDD_CMP_EQUAL_ORDERED 0x0c
1592 /* These macros specify the polarity of the operation. */
1593 #define _SIDD_POSITIVE_POLARITY 0x00
1594 #define _SIDD_NEGATIVE_POLARITY 0x10
1595 #define _SIDD_MASKED_POSITIVE_POLARITY 0x20
1596 #define _SIDD_MASKED_NEGATIVE_POLARITY 0x30
1598 /* These macros are used in _mm_cmpXstri() to specify the return. */
1599 #define _SIDD_LEAST_SIGNIFICANT 0x00
1600 #define _SIDD_MOST_SIGNIFICANT 0x40
1602 /* These macros are used in _mm_cmpXstri() to specify the return. */
1603 #define _SIDD_BIT_MASK 0x00
1604 #define _SIDD_UNIT_MASK 0x40
1606 /* SSE4.2 Packed Comparison Intrinsics. */
1607 /// \brief Uses the immediate operand \a M to perform a comparison of string
1608 /// data with implicitly defined lengths that is contained in source operands
1609 /// \a A and \a B. Returns a 128-bit integer vector representing the result
1610 /// mask of the comparison.
1612 /// \headerfile <x86intrin.h>
1615 /// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M);
1618 /// This intrinsic corresponds to the <c> VPCMPISTRM / PCMPISTRM </c>
1622 /// A 128-bit integer vector containing one of the source operands to be
1625 /// A 128-bit integer vector containing one of the source operands to be
1628 /// An 8-bit immediate operand specifying whether the characters are bytes or
1629 /// words, the type of comparison to perform, and the format of the return
1631 /// Bits [1:0]: Determine source data format. \n
1632 /// 00: 16 unsigned bytes \n
1633 /// 01: 8 unsigned words \n
1634 /// 10: 16 signed bytes \n
1635 /// 11: 8 signed words \n
1636 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1637 /// 00: Subset: Each character in \a B is compared for equality with all
1638 /// the characters in \a A. \n
1639 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1640 /// basis is greater than or equal for even-indexed elements in \a A,
1641 /// and less than or equal for odd-indexed elements in \a A. \n
1642 /// 10: Match: Compare each pair of corresponding characters in \a A and
1643 /// \a B for equality. \n
1644 /// 11: Substring: Search \a B for substring matches of \a A. \n
1645 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1646 /// mask of the comparison results. \n
1647 /// 00: No effect. \n
1648 /// 01: Negate the bit mask. \n
1649 /// 10: No effect. \n
1650 /// 11: Negate the bit mask only for bits with an index less than or equal
1651 /// to the size of \a A or \a B. \n
1652 /// Bit [6]: Determines whether the result is zero-extended or expanded to 16
1654 /// 0: The result is zero-extended to 16 bytes. \n
1655 /// 1: The result is expanded to 16 bytes (this expansion is performed by
1656 /// repeating each bit 8 or 16 times).
1657 /// \returns Returns a 128-bit integer vector representing the result mask of
1659 #define _mm_cmpistrm(A, B, M) \
1660 (__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \
1661 (__v16qi)(__m128i)(B), (int)(M))
1663 /// \brief Uses the immediate operand \a M to perform a comparison of string
1664 /// data with implicitly defined lengths that is contained in source operands
1665 /// \a A and \a B. Returns an integer representing the result index of the
1668 /// \headerfile <x86intrin.h>
1671 /// int _mm_cmpistri(__m128i A, __m128i B, const int M);
1674 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1678 /// A 128-bit integer vector containing one of the source operands to be
1681 /// A 128-bit integer vector containing one of the source operands to be
1684 /// An 8-bit immediate operand specifying whether the characters are bytes or
1685 /// words, the type of comparison to perform, and the format of the return
1687 /// Bits [1:0]: Determine source data format. \n
1688 /// 00: 16 unsigned bytes \n
1689 /// 01: 8 unsigned words \n
1690 /// 10: 16 signed bytes \n
1691 /// 11: 8 signed words \n
1692 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1693 /// 00: Subset: Each character in \a B is compared for equality with all
1694 /// the characters in \a A. \n
1695 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1696 /// basis is greater than or equal for even-indexed elements in \a A,
1697 /// and less than or equal for odd-indexed elements in \a A. \n
1698 /// 10: Match: Compare each pair of corresponding characters in \a A and
1699 /// \a B for equality. \n
1700 /// 11: Substring: Search B for substring matches of \a A. \n
1701 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1702 /// mask of the comparison results. \n
1703 /// 00: No effect. \n
1704 /// 01: Negate the bit mask. \n
1705 /// 10: No effect. \n
1706 /// 11: Negate the bit mask only for bits with an index less than or equal
1707 /// to the size of \a A or \a B. \n
1708 /// Bit [6]: Determines whether the index of the lowest set bit or the
1709 /// highest set bit is returned. \n
1710 /// 0: The index of the least significant set bit. \n
1711 /// 1: The index of the most significant set bit. \n
1712 /// \returns Returns an integer representing the result index of the comparison.
1713 #define _mm_cmpistri(A, B, M) \
1714 (int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \
1715 (__v16qi)(__m128i)(B), (int)(M))
1717 /// \brief Uses the immediate operand \a M to perform a comparison of string
1718 /// data with explicitly defined lengths that is contained in source operands
1719 /// \a A and \a B. Returns a 128-bit integer vector representing the result
1720 /// mask of the comparison.
1722 /// \headerfile <x86intrin.h>
1725 /// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M);
1728 /// This intrinsic corresponds to the <c> VPCMPESTRM / PCMPESTRM </c>
1732 /// A 128-bit integer vector containing one of the source operands to be
1735 /// An integer that specifies the length of the string in \a A.
1737 /// A 128-bit integer vector containing one of the source operands to be
1740 /// An integer that specifies the length of the string in \a B.
1742 /// An 8-bit immediate operand specifying whether the characters are bytes or
1743 /// words, the type of comparison to perform, and the format of the return
1745 /// Bits [1:0]: Determine source data format. \n
1746 /// 00: 16 unsigned bytes \n
1747 /// 01: 8 unsigned words \n
1748 /// 10: 16 signed bytes \n
1749 /// 11: 8 signed words \n
1750 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1751 /// 00: Subset: Each character in \a B is compared for equality with all
1752 /// the characters in \a A. \n
1753 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1754 /// basis is greater than or equal for even-indexed elements in \a A,
1755 /// and less than or equal for odd-indexed elements in \a A. \n
1756 /// 10: Match: Compare each pair of corresponding characters in \a A and
1757 /// \a B for equality. \n
1758 /// 11: Substring: Search \a B for substring matches of \a A. \n
1759 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1760 /// mask of the comparison results. \n
1761 /// 00: No effect. \n
1762 /// 01: Negate the bit mask. \n
1763 /// 10: No effect. \n
1764 /// 11: Negate the bit mask only for bits with an index less than or equal
1765 /// to the size of \a A or \a B. \n
1766 /// Bit [6]: Determines whether the result is zero-extended or expanded to 16
1768 /// 0: The result is zero-extended to 16 bytes. \n
1769 /// 1: The result is expanded to 16 bytes (this expansion is performed by
1770 /// repeating each bit 8 or 16 times). \n
1771 /// \returns Returns a 128-bit integer vector representing the result mask of
1773 #define _mm_cmpestrm(A, LA, B, LB, M) \
1774 (__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \
1775 (__v16qi)(__m128i)(B), (int)(LB), \
1778 /// \brief Uses the immediate operand \a M to perform a comparison of string
1779 /// data with explicitly defined lengths that is contained in source operands
1780 /// \a A and \a B. Returns an integer representing the result index of the
1783 /// \headerfile <x86intrin.h>
1786 /// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M);
1789 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
1793 /// A 128-bit integer vector containing one of the source operands to be
1796 /// An integer that specifies the length of the string in \a A.
1798 /// A 128-bit integer vector containing one of the source operands to be
1801 /// An integer that specifies the length of the string in \a B.
1803 /// An 8-bit immediate operand specifying whether the characters are bytes or
1804 /// words, the type of comparison to perform, and the format of the return
1806 /// Bits [1:0]: Determine source data format. \n
1807 /// 00: 16 unsigned bytes \n
1808 /// 01: 8 unsigned words \n
1809 /// 10: 16 signed bytes \n
1810 /// 11: 8 signed words \n
1811 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1812 /// 00: Subset: Each character in \a B is compared for equality with all
1813 /// the characters in \a A. \n
1814 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1815 /// basis is greater than or equal for even-indexed elements in \a A,
1816 /// and less than or equal for odd-indexed elements in \a A. \n
1817 /// 10: Match: Compare each pair of corresponding characters in \a A and
1818 /// \a B for equality. \n
1819 /// 11: Substring: Search B for substring matches of \a A. \n
1820 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1821 /// mask of the comparison results. \n
1822 /// 00: No effect. \n
1823 /// 01: Negate the bit mask. \n
1824 /// 10: No effect. \n
1825 /// 11: Negate the bit mask only for bits with an index less than or equal
1826 /// to the size of \a A or \a B. \n
1827 /// Bit [6]: Determines whether the index of the lowest set bit or the
1828 /// highest set bit is returned. \n
1829 /// 0: The index of the least significant set bit. \n
1830 /// 1: The index of the most significant set bit. \n
1831 /// \returns Returns an integer representing the result index of the comparison.
1832 #define _mm_cmpestri(A, LA, B, LB, M) \
1833 (int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \
1834 (__v16qi)(__m128i)(B), (int)(LB), \
1837 /* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */
1838 /// \brief Uses the immediate operand \a M to perform a comparison of string
1839 /// data with implicitly defined lengths that is contained in source operands
1840 /// \a A and \a B. Returns 1 if the bit mask is zero and the length of the
1841 /// string in \a B is the maximum, otherwise, returns 0.
1843 /// \headerfile <x86intrin.h>
1846 /// int _mm_cmpistra(__m128i A, __m128i B, const int M);
1849 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1853 /// A 128-bit integer vector containing one of the source operands to be
1856 /// A 128-bit integer vector containing one of the source operands to be
1859 /// An 8-bit immediate operand specifying whether the characters are bytes or
1860 /// words and the type of comparison to perform. \n
1861 /// Bits [1:0]: Determine source data format. \n
1862 /// 00: 16 unsigned bytes \n
1863 /// 01: 8 unsigned words \n
1864 /// 10: 16 signed bytes \n
1865 /// 11: 8 signed words \n
1866 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1867 /// 00: Subset: Each character in \a B is compared for equality with all
1868 /// the characters in \a A. \n
1869 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1870 /// basis is greater than or equal for even-indexed elements in \a A,
1871 /// and less than or equal for odd-indexed elements in \a A. \n
1872 /// 10: Match: Compare each pair of corresponding characters in \a A and
1873 /// \a B for equality. \n
1874 /// 11: Substring: Search \a B for substring matches of \a A. \n
1875 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1876 /// mask of the comparison results. \n
1877 /// 00: No effect. \n
1878 /// 01: Negate the bit mask. \n
1879 /// 10: No effect. \n
1880 /// 11: Negate the bit mask only for bits with an index less than or equal
1881 /// to the size of \a A or \a B. \n
1882 /// \returns Returns 1 if the bit mask is zero and the length of the string in
1883 /// \a B is the maximum; otherwise, returns 0.
1884 #define _mm_cmpistra(A, B, M) \
1885 (int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \
1886 (__v16qi)(__m128i)(B), (int)(M))
1888 /// \brief Uses the immediate operand \a M to perform a comparison of string
1889 /// data with implicitly defined lengths that is contained in source operands
1890 /// \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns
1893 /// \headerfile <x86intrin.h>
1896 /// int _mm_cmpistrc(__m128i A, __m128i B, const int M);
1899 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1903 /// A 128-bit integer vector containing one of the source operands to be
1906 /// A 128-bit integer vector containing one of the source operands to be
1909 /// An 8-bit immediate operand specifying whether the characters are bytes or
1910 /// words and the type of comparison to perform. \n
1911 /// Bits [1:0]: Determine source data format. \n
1912 /// 00: 16 unsigned bytes \n
1913 /// 01: 8 unsigned words \n
1914 /// 10: 16 signed bytes \n
1915 /// 11: 8 signed words \n
1916 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1917 /// 00: Subset: Each character in \a B is compared for equality with all
1918 /// the characters in \a A. \n
1919 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1920 /// basis is greater than or equal for even-indexed elements in \a A,
1921 /// and less than or equal for odd-indexed elements in \a A. \n
1922 /// 10: Match: Compare each pair of corresponding characters in \a A and
1923 /// \a B for equality. \n
1924 /// 11: Substring: Search B for substring matches of \a A. \n
1925 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1926 /// mask of the comparison results. \n
1927 /// 00: No effect. \n
1928 /// 01: Negate the bit mask. \n
1929 /// 10: No effect. \n
1930 /// 11: Negate the bit mask only for bits with an index less than or equal
1931 /// to the size of \a A or \a B.
1932 /// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0.
1933 #define _mm_cmpistrc(A, B, M) \
1934 (int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \
1935 (__v16qi)(__m128i)(B), (int)(M))
1937 /// \brief Uses the immediate operand \a M to perform a comparison of string
1938 /// data with implicitly defined lengths that is contained in source operands
1939 /// \a A and \a B. Returns bit 0 of the resulting bit mask.
1941 /// \headerfile <x86intrin.h>
1944 /// int _mm_cmpistro(__m128i A, __m128i B, const int M);
1947 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1951 /// A 128-bit integer vector containing one of the source operands to be
1954 /// A 128-bit integer vector containing one of the source operands to be
1957 /// An 8-bit immediate operand specifying whether the characters are bytes or
1958 /// words and the type of comparison to perform. \n
1959 /// Bits [1:0]: Determine source data format. \n
1960 /// 00: 16 unsigned bytes \n
1961 /// 01: 8 unsigned words \n
1962 /// 10: 16 signed bytes \n
1963 /// 11: 8 signed words \n
1964 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1965 /// 00: Subset: Each character in \a B is compared for equality with all
1966 /// the characters in \a A. \n
1967 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1968 /// basis is greater than or equal for even-indexed elements in \a A,
1969 /// and less than or equal for odd-indexed elements in \a A. \n
1970 /// 10: Match: Compare each pair of corresponding characters in \a A and
1971 /// \a B for equality. \n
1972 /// 11: Substring: Search B for substring matches of \a A. \n
1973 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1974 /// mask of the comparison results. \n
1975 /// 00: No effect. \n
1976 /// 01: Negate the bit mask. \n
1977 /// 10: No effect. \n
1978 /// 11: Negate the bit mask only for bits with an index less than or equal
1979 /// to the size of \a A or \a B. \n
1980 /// \returns Returns bit 0 of the resulting bit mask.
1981 #define _mm_cmpistro(A, B, M) \
1982 (int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \
1983 (__v16qi)(__m128i)(B), (int)(M))
1985 /// \brief Uses the immediate operand \a M to perform a comparison of string
1986 /// data with implicitly defined lengths that is contained in source operands
1987 /// \a A and \a B. Returns 1 if the length of the string in \a A is less than
1988 /// the maximum, otherwise, returns 0.
1990 /// \headerfile <x86intrin.h>
1993 /// int _mm_cmpistrs(__m128i A, __m128i B, const int M);
1996 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
2000 /// A 128-bit integer vector containing one of the source operands to be
2003 /// A 128-bit integer vector containing one of the source operands to be
2006 /// An 8-bit immediate operand specifying whether the characters are bytes or
2007 /// words and the type of comparison to perform. \n
2008 /// Bits [1:0]: Determine source data format. \n
2009 /// 00: 16 unsigned bytes \n
2010 /// 01: 8 unsigned words \n
2011 /// 10: 16 signed bytes \n
2012 /// 11: 8 signed words \n
2013 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2014 /// 00: Subset: Each character in \a B is compared for equality with all
2015 /// the characters in \a A. \n
2016 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2017 /// basis is greater than or equal for even-indexed elements in \a A,
2018 /// and less than or equal for odd-indexed elements in \a A. \n
2019 /// 10: Match: Compare each pair of corresponding characters in \a A and
2020 /// \a B for equality. \n
2021 /// 11: Substring: Search \a B for substring matches of \a A. \n
2022 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2023 /// mask of the comparison results. \n
2024 /// 00: No effect. \n
2025 /// 01: Negate the bit mask. \n
2026 /// 10: No effect. \n
2027 /// 11: Negate the bit mask only for bits with an index less than or equal
2028 /// to the size of \a A or \a B. \n
2029 /// \returns Returns 1 if the length of the string in \a A is less than the
2030 /// maximum, otherwise, returns 0.
2031 #define _mm_cmpistrs(A, B, M) \
2032 (int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \
2033 (__v16qi)(__m128i)(B), (int)(M))
2035 /// \brief Uses the immediate operand \a M to perform a comparison of string
2036 /// data with implicitly defined lengths that is contained in source operands
2037 /// \a A and \a B. Returns 1 if the length of the string in \a B is less than
2038 /// the maximum, otherwise, returns 0.
2040 /// \headerfile <x86intrin.h>
2043 /// int _mm_cmpistrz(__m128i A, __m128i B, const int M);
2046 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
2050 /// A 128-bit integer vector containing one of the source operands to be
2053 /// A 128-bit integer vector containing one of the source operands to be
2056 /// An 8-bit immediate operand specifying whether the characters are bytes or
2057 /// words and the type of comparison to perform. \n
2058 /// Bits [1:0]: Determine source data format. \n
2059 /// 00: 16 unsigned bytes \n
2060 /// 01: 8 unsigned words \n
2061 /// 10: 16 signed bytes \n
2062 /// 11: 8 signed words \n
2063 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2064 /// 00: Subset: Each character in \a B is compared for equality with all
2065 /// the characters in \a A. \n
2066 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2067 /// basis is greater than or equal for even-indexed elements in \a A,
2068 /// and less than or equal for odd-indexed elements in \a A. \n
2069 /// 10: Match: Compare each pair of corresponding characters in \a A and
2070 /// \a B for equality. \n
2071 /// 11: Substring: Search \a B for substring matches of \a A. \n
2072 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2073 /// mask of the comparison results. \n
2074 /// 00: No effect. \n
2075 /// 01: Negate the bit mask. \n
2076 /// 10: No effect. \n
2077 /// 11: Negate the bit mask only for bits with an index less than or equal
2078 /// to the size of \a A or \a B.
2079 /// \returns Returns 1 if the length of the string in \a B is less than the
2080 /// maximum, otherwise, returns 0.
2081 #define _mm_cmpistrz(A, B, M) \
2082 (int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \
2083 (__v16qi)(__m128i)(B), (int)(M))
2085 /// \brief Uses the immediate operand \a M to perform a comparison of string
2086 /// data with explicitly defined lengths that is contained in source operands
2087 /// \a A and \a B. Returns 1 if the bit mask is zero and the length of the
2088 /// string in \a B is the maximum, otherwise, returns 0.
2090 /// \headerfile <x86intrin.h>
2093 /// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M);
2096 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2100 /// A 128-bit integer vector containing one of the source operands to be
2103 /// An integer that specifies the length of the string in \a A.
2105 /// A 128-bit integer vector containing one of the source operands to be
2108 /// An integer that specifies the length of the string in \a B.
2110 /// An 8-bit immediate operand specifying whether the characters are bytes or
2111 /// words and the type of comparison to perform. \n
2112 /// Bits [1:0]: Determine source data format. \n
2113 /// 00: 16 unsigned bytes \n
2114 /// 01: 8 unsigned words \n
2115 /// 10: 16 signed bytes \n
2116 /// 11: 8 signed words \n
2117 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2118 /// 00: Subset: Each character in \a B is compared for equality with all
2119 /// the characters in \a A. \n
2120 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2121 /// basis is greater than or equal for even-indexed elements in \a A,
2122 /// and less than or equal for odd-indexed elements in \a A. \n
2123 /// 10: Match: Compare each pair of corresponding characters in \a A and
2124 /// \a B for equality. \n
2125 /// 11: Substring: Search \a B for substring matches of \a A. \n
2126 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2127 /// mask of the comparison results. \n
2128 /// 00: No effect. \n
2129 /// 01: Negate the bit mask. \n
2130 /// 10: No effect. \n
2131 /// 11: Negate the bit mask only for bits with an index less than or equal
2132 /// to the size of \a A or \a B.
2133 /// \returns Returns 1 if the bit mask is zero and the length of the string in
2134 /// \a B is the maximum, otherwise, returns 0.
2135 #define _mm_cmpestra(A, LA, B, LB, M) \
2136 (int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \
2137 (__v16qi)(__m128i)(B), (int)(LB), \
2140 /// \brief Uses the immediate operand \a M to perform a comparison of string
2141 /// data with explicitly defined lengths that is contained in source operands
2142 /// \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise,
2145 /// \headerfile <x86intrin.h>
2148 /// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M);
2151 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2155 /// A 128-bit integer vector containing one of the source operands to be
2158 /// An integer that specifies the length of the string in \a A.
2160 /// A 128-bit integer vector containing one of the source operands to be
2163 /// An integer that specifies the length of the string in \a B.
2165 /// An 8-bit immediate operand specifying whether the characters are bytes or
2166 /// words and the type of comparison to perform. \n
2167 /// Bits [1:0]: Determine source data format. \n
2168 /// 00: 16 unsigned bytes \n
2169 /// 01: 8 unsigned words \n
2170 /// 10: 16 signed bytes \n
2171 /// 11: 8 signed words \n
2172 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2173 /// 00: Subset: Each character in \a B is compared for equality with all
2174 /// the characters in \a A. \n
2175 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2176 /// basis is greater than or equal for even-indexed elements in \a A,
2177 /// and less than or equal for odd-indexed elements in \a A. \n
2178 /// 10: Match: Compare each pair of corresponding characters in \a A and
2179 /// \a B for equality. \n
2180 /// 11: Substring: Search \a B for substring matches of \a A. \n
2181 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2182 /// mask of the comparison results. \n
2183 /// 00: No effect. \n
2184 /// 01: Negate the bit mask. \n
2185 /// 10: No effect. \n
2186 /// 11: Negate the bit mask only for bits with an index less than or equal
2187 /// to the size of \a A or \a B. \n
2188 /// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0.
2189 #define _mm_cmpestrc(A, LA, B, LB, M) \
2190 (int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \
2191 (__v16qi)(__m128i)(B), (int)(LB), \
2194 /// \brief Uses the immediate operand \a M to perform a comparison of string
2195 /// data with explicitly defined lengths that is contained in source operands
2196 /// \a A and \a B. Returns bit 0 of the resulting bit mask.
2198 /// \headerfile <x86intrin.h>
2201 /// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M);
2204 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2208 /// A 128-bit integer vector containing one of the source operands to be
2211 /// An integer that specifies the length of the string in \a A.
2213 /// A 128-bit integer vector containing one of the source operands to be
2216 /// An integer that specifies the length of the string in \a B.
2218 /// An 8-bit immediate operand specifying whether the characters are bytes or
2219 /// words and the type of comparison to perform. \n
2220 /// Bits [1:0]: Determine source data format. \n
2221 /// 00: 16 unsigned bytes \n
2222 /// 01: 8 unsigned words \n
2223 /// 10: 16 signed bytes \n
2224 /// 11: 8 signed words \n
2225 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2226 /// 00: Subset: Each character in \a B is compared for equality with all
2227 /// the characters in \a A. \n
2228 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2229 /// basis is greater than or equal for even-indexed elements in \a A,
2230 /// and less than or equal for odd-indexed elements in \a A. \n
2231 /// 10: Match: Compare each pair of corresponding characters in \a A and
2232 /// \a B for equality. \n
2233 /// 11: Substring: Search \a B for substring matches of \a A. \n
2234 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2235 /// mask of the comparison results. \n
2236 /// 00: No effect. \n
2237 /// 01: Negate the bit mask. \n
2238 /// 10: No effect. \n
2239 /// 11: Negate the bit mask only for bits with an index less than or equal
2240 /// to the size of \a A or \a B.
2241 /// \returns Returns bit 0 of the resulting bit mask.
2242 #define _mm_cmpestro(A, LA, B, LB, M) \
2243 (int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \
2244 (__v16qi)(__m128i)(B), (int)(LB), \
2247 /// \brief Uses the immediate operand \a M to perform a comparison of string
2248 /// data with explicitly defined lengths that is contained in source operands
2249 /// \a A and \a B. Returns 1 if the length of the string in \a A is less than
2250 /// the maximum, otherwise, returns 0.
2252 /// \headerfile <x86intrin.h>
2255 /// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M);
2258 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2262 /// A 128-bit integer vector containing one of the source operands to be
2265 /// An integer that specifies the length of the string in \a A.
2267 /// A 128-bit integer vector containing one of the source operands to be
2270 /// An integer that specifies the length of the string in \a B.
2272 /// An 8-bit immediate operand specifying whether the characters are bytes or
2273 /// words and the type of comparison to perform. \n
2274 /// Bits [1:0]: Determine source data format. \n
2275 /// 00: 16 unsigned bytes \n
2276 /// 01: 8 unsigned words \n
2277 /// 10: 16 signed bytes \n
2278 /// 11: 8 signed words \n
2279 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2280 /// 00: Subset: Each character in \a B is compared for equality with all
2281 /// the characters in \a A. \n
2282 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2283 /// basis is greater than or equal for even-indexed elements in \a A,
2284 /// and less than or equal for odd-indexed elements in \a A. \n
2285 /// 10: Match: Compare each pair of corresponding characters in \a A and
2286 /// \a B for equality. \n
2287 /// 11: Substring: Search \a B for substring matches of \a A. \n
2288 /// Bits [5:4]: Determine whether to perform a one's complement in the bit
2289 /// mask of the comparison results. \n
2290 /// 00: No effect. \n
2291 /// 01: Negate the bit mask. \n
2292 /// 10: No effect. \n
2293 /// 11: Negate the bit mask only for bits with an index less than or equal
2294 /// to the size of \a A or \a B. \n
2295 /// \returns Returns 1 if the length of the string in \a A is less than the
2296 /// maximum, otherwise, returns 0.
2297 #define _mm_cmpestrs(A, LA, B, LB, M) \
2298 (int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \
2299 (__v16qi)(__m128i)(B), (int)(LB), \
2302 /// \brief Uses the immediate operand \a M to perform a comparison of string
2303 /// data with explicitly defined lengths that is contained in source operands
2304 /// \a A and \a B. Returns 1 if the length of the string in \a B is less than
2305 /// the maximum, otherwise, returns 0.
2307 /// \headerfile <x86intrin.h>
2310 /// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M);
2313 /// This intrinsic corresponds to the <c> VPCMPESTRI </c> instruction.
2316 /// A 128-bit integer vector containing one of the source operands to be
2319 /// An integer that specifies the length of the string in \a A.
2321 /// A 128-bit integer vector containing one of the source operands to be
2324 /// An integer that specifies the length of the string in \a B.
2326 /// An 8-bit immediate operand specifying whether the characters are bytes or
2327 /// words and the type of comparison to perform. \n
2328 /// Bits [1:0]: Determine source data format. \n
2329 /// 00: 16 unsigned bytes \n
2330 /// 01: 8 unsigned words \n
2331 /// 10: 16 signed bytes \n
2332 /// 11: 8 signed words \n
2333 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2334 /// 00: Subset: Each character in \a B is compared for equality with all
2335 /// the characters in \a A. \n
2336 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2337 /// basis is greater than or equal for even-indexed elements in \a A,
2338 /// and less than or equal for odd-indexed elements in \a A. \n
2339 /// 10: Match: Compare each pair of corresponding characters in \a A and
2340 /// \a B for equality. \n
2341 /// 11: Substring: Search \a B for substring matches of \a A. \n
2342 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2343 /// mask of the comparison results. \n
2344 /// 00: No effect. \n
2345 /// 01: Negate the bit mask. \n
2346 /// 10: No effect. \n
2347 /// 11: Negate the bit mask only for bits with an index less than or equal
2348 /// to the size of \a A or \a B.
2349 /// \returns Returns 1 if the length of the string in \a B is less than the
2350 /// maximum, otherwise, returns 0.
2351 #define _mm_cmpestrz(A, LA, B, LB, M) \
2352 (int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \
2353 (__v16qi)(__m128i)(B), (int)(LB), \
2356 /* SSE4.2 Compare Packed Data -- Greater Than. */
2357 /// \brief Compares each of the corresponding 64-bit values of the 128-bit
2358 /// integer vectors to determine if the values in the first operand are
2359 /// greater than those in the second operand.
2361 /// \headerfile <x86intrin.h>
2363 /// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction.
2366 /// A 128-bit integer vector.
2368 /// A 128-bit integer vector.
2369 /// \returns A 128-bit integer vector containing the comparison results.
2370 static __inline__ __m128i __DEFAULT_FN_ATTRS
2371 _mm_cmpgt_epi64(__m128i __V1, __m128i __V2)
2373 return (__m128i)((__v2di)__V1 > (__v2di)__V2);
2376 /* SSE4.2 Accumulate CRC32. */
2377 /// \brief Adds the unsigned integer operand to the CRC-32C checksum of the
2378 /// unsigned char operand.
2380 /// \headerfile <x86intrin.h>
2382 /// This intrinsic corresponds to the <c> CRC32B </c> instruction.
2385 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2388 /// An unsigned 8-bit integer operand used to compute the CRC-32C checksum.
2389 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2391 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2392 _mm_crc32_u8(unsigned int __C, unsigned char __D)
2394 return __builtin_ia32_crc32qi(__C, __D);
2397 /// \brief Adds the unsigned integer operand to the CRC-32C checksum of the
2398 /// unsigned short operand.
2400 /// \headerfile <x86intrin.h>
2402 /// This intrinsic corresponds to the <c> CRC32W </c> instruction.
2405 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2408 /// An unsigned 16-bit integer operand used to compute the CRC-32C checksum.
2409 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2411 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2412 _mm_crc32_u16(unsigned int __C, unsigned short __D)
2414 return __builtin_ia32_crc32hi(__C, __D);
2417 /// \brief Adds the first unsigned integer operand to the CRC-32C checksum of
2418 /// the second unsigned integer operand.
2420 /// \headerfile <x86intrin.h>
2422 /// This intrinsic corresponds to the <c> CRC32L </c> instruction.
2425 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2428 /// An unsigned 32-bit integer operand used to compute the CRC-32C checksum.
2429 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2431 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2432 _mm_crc32_u32(unsigned int __C, unsigned int __D)
2434 return __builtin_ia32_crc32si(__C, __D);
2438 /// \brief Adds the unsigned integer operand to the CRC-32C checksum of the
2439 /// unsigned 64-bit integer operand.
2441 /// \headerfile <x86intrin.h>
2443 /// This intrinsic corresponds to the <c> CRC32Q </c> instruction.
2446 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2449 /// An unsigned 64-bit integer operand used to compute the CRC-32C checksum.
2450 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2452 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
2453 _mm_crc32_u64(unsigned long long __C, unsigned long long __D)
2455 return __builtin_ia32_crc32di(__C, __D);
2457 #endif /* __x86_64__ */
2459 #undef __DEFAULT_FN_ATTRS
2462 #include <popcntintrin.h>
2465 #endif /* _SMMINTRIN_H */