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"), __min_vector_width__(128)))
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 /// 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 /// 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 /// 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 /// 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 /// 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 /// 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 /// 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 /// 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 /// 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) \
248 (__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M))
250 /// 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) \
289 (__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), \
290 (__v4sf)(__m128)(Y), (M))
292 /// 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) \
323 (__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M))
325 /// 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) \
364 (__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), \
365 (__v2df)(__m128d)(Y), (M))
367 /* SSE4 Packed Blending Intrinsics. */
368 /// 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) \
393 (__m128d) __builtin_ia32_blendpd ((__v2df)(__m128d)(V1), \
394 (__v2df)(__m128d)(V2), (int)(M))
396 /// Returns a 128-bit vector of [4 x float] where the values are selected
397 /// from either the first or second operand as specified by the third
398 /// operand, the control mask.
400 /// \headerfile <x86intrin.h>
403 /// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M);
406 /// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS </c> instruction.
409 /// A 128-bit vector of [4 x float].
411 /// A 128-bit vector of [4 x float].
413 /// An immediate integer operand, with mask bits [3:0] specifying how the
414 /// values are to be copied. The position of the mask bit corresponds to the
415 /// index of a copied value. When a mask bit is 0, the corresponding 32-bit
416 /// element in operand \a V1 is copied to the same position in the result.
417 /// When a mask bit is 1, the corresponding 32-bit element in operand \a V2
418 /// is copied to the same position in the result.
419 /// \returns A 128-bit vector of [4 x float] containing the copied values.
420 #define _mm_blend_ps(V1, V2, M) \
421 (__m128) __builtin_ia32_blendps ((__v4sf)(__m128)(V1), \
422 (__v4sf)(__m128)(V2), (int)(M))
424 /// Returns a 128-bit vector of [2 x double] where the values are
425 /// selected from either the first or second operand as specified by the
426 /// third operand, the control mask.
428 /// \headerfile <x86intrin.h>
430 /// This intrinsic corresponds to the <c> VBLENDVPD / BLENDVPD </c> instruction.
433 /// A 128-bit vector of [2 x double].
435 /// A 128-bit vector of [2 x double].
437 /// A 128-bit vector operand, with mask bits 127 and 63 specifying how the
438 /// values are to be copied. The position of the mask bit corresponds to the
439 /// most significant bit of a copied value. When a mask bit is 0, the
440 /// corresponding 64-bit element in operand \a __V1 is copied to the same
441 /// position in the result. When a mask bit is 1, the corresponding 64-bit
442 /// element in operand \a __V2 is copied to the same position in the result.
443 /// \returns A 128-bit vector of [2 x double] containing the copied values.
444 static __inline__ __m128d __DEFAULT_FN_ATTRS
445 _mm_blendv_pd (__m128d __V1, __m128d __V2, __m128d __M)
447 return (__m128d) __builtin_ia32_blendvpd ((__v2df)__V1, (__v2df)__V2,
451 /// Returns a 128-bit vector of [4 x float] where the values are
452 /// selected from either the first or second operand as specified by the
453 /// third operand, the control mask.
455 /// \headerfile <x86intrin.h>
457 /// This intrinsic corresponds to the <c> VBLENDVPS / BLENDVPS </c> instruction.
460 /// A 128-bit vector of [4 x float].
462 /// A 128-bit vector of [4 x float].
464 /// A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying
465 /// how the values are to be copied. The position of the mask bit corresponds
466 /// to the most significant bit of a copied value. When a mask bit is 0, the
467 /// corresponding 32-bit element in operand \a __V1 is copied to the same
468 /// position in the result. When a mask bit is 1, the corresponding 32-bit
469 /// element in operand \a __V2 is copied to the same position in the result.
470 /// \returns A 128-bit vector of [4 x float] containing the copied values.
471 static __inline__ __m128 __DEFAULT_FN_ATTRS
472 _mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M)
474 return (__m128) __builtin_ia32_blendvps ((__v4sf)__V1, (__v4sf)__V2,
478 /// Returns a 128-bit vector of [16 x i8] where the values are selected
479 /// from either of the first or second operand as specified by the third
480 /// operand, the control mask.
482 /// \headerfile <x86intrin.h>
484 /// This intrinsic corresponds to the <c> VPBLENDVB / PBLENDVB </c> instruction.
487 /// A 128-bit vector of [16 x i8].
489 /// A 128-bit vector of [16 x i8].
491 /// A 128-bit vector operand, with mask bits 127, 119, 111...7 specifying
492 /// how the values are to be copied. The position of the mask bit corresponds
493 /// to the most significant bit of a copied value. When a mask bit is 0, the
494 /// corresponding 8-bit element in operand \a __V1 is copied to the same
495 /// position in the result. When a mask bit is 1, the corresponding 8-bit
496 /// element in operand \a __V2 is copied to the same position in the result.
497 /// \returns A 128-bit vector of [16 x i8] containing the copied values.
498 static __inline__ __m128i __DEFAULT_FN_ATTRS
499 _mm_blendv_epi8 (__m128i __V1, __m128i __V2, __m128i __M)
501 return (__m128i) __builtin_ia32_pblendvb128 ((__v16qi)__V1, (__v16qi)__V2,
505 /// Returns a 128-bit vector of [8 x i16] where the values are selected
506 /// from either of the first or second operand as specified by the third
507 /// operand, the control mask.
509 /// \headerfile <x86intrin.h>
512 /// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M);
515 /// This intrinsic corresponds to the <c> VPBLENDW / PBLENDW </c> instruction.
518 /// A 128-bit vector of [8 x i16].
520 /// A 128-bit vector of [8 x i16].
522 /// An immediate integer operand, with mask bits [7:0] specifying how the
523 /// values are to be copied. The position of the mask bit corresponds to the
524 /// index of a copied value. When a mask bit is 0, the corresponding 16-bit
525 /// element in operand \a V1 is copied to the same position in the result.
526 /// When a mask bit is 1, the corresponding 16-bit element in operand \a V2
527 /// is copied to the same position in the result.
528 /// \returns A 128-bit vector of [8 x i16] containing the copied values.
529 #define _mm_blend_epi16(V1, V2, M) \
530 (__m128i) __builtin_ia32_pblendw128 ((__v8hi)(__m128i)(V1), \
531 (__v8hi)(__m128i)(V2), (int)(M))
533 /* SSE4 Dword Multiply Instructions. */
534 /// Multiples corresponding elements of two 128-bit vectors of [4 x i32]
535 /// and returns the lower 32 bits of the each product in a 128-bit vector of
538 /// \headerfile <x86intrin.h>
540 /// This intrinsic corresponds to the <c> VPMULLD / PMULLD </c> instruction.
543 /// A 128-bit integer vector.
545 /// A 128-bit integer vector.
546 /// \returns A 128-bit integer vector containing the products of both operands.
547 static __inline__ __m128i __DEFAULT_FN_ATTRS
548 _mm_mullo_epi32 (__m128i __V1, __m128i __V2)
550 return (__m128i) ((__v4su)__V1 * (__v4su)__V2);
553 /// Multiplies corresponding even-indexed elements of two 128-bit
554 /// vectors of [4 x i32] and returns a 128-bit vector of [2 x i64]
555 /// containing the products.
557 /// \headerfile <x86intrin.h>
559 /// This intrinsic corresponds to the <c> VPMULDQ / PMULDQ </c> instruction.
562 /// A 128-bit vector of [4 x i32].
564 /// A 128-bit vector of [4 x i32].
565 /// \returns A 128-bit vector of [2 x i64] containing the products of both
567 static __inline__ __m128i __DEFAULT_FN_ATTRS
568 _mm_mul_epi32 (__m128i __V1, __m128i __V2)
570 return (__m128i) __builtin_ia32_pmuldq128 ((__v4si)__V1, (__v4si)__V2);
573 /* SSE4 Floating Point Dot Product Instructions. */
574 /// Computes the dot product of the two 128-bit vectors of [4 x float]
575 /// and returns it in the elements of the 128-bit result vector of
578 /// The immediate integer operand controls which input elements
579 /// will contribute to the dot product, and where the final results are
582 /// \headerfile <x86intrin.h>
585 /// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M);
588 /// This intrinsic corresponds to the <c> VDPPS / DPPS </c> instruction.
591 /// A 128-bit vector of [4 x float].
593 /// A 128-bit vector of [4 x float].
595 /// An immediate integer operand. Mask bits [7:4] determine which elements
596 /// of the input vectors are used, with bit [4] corresponding to the lowest
597 /// element and bit [7] corresponding to the highest element of each [4 x
598 /// float] vector. If a bit is set, the corresponding elements from the two
599 /// input vectors are used as an input for dot product; otherwise that input
600 /// is treated as zero. Bits [3:0] determine which elements of the result
601 /// will receive a copy of the final dot product, with bit [0] corresponding
602 /// to the lowest element and bit [3] corresponding to the highest element of
603 /// each [4 x float] subvector. If a bit is set, the dot product is returned
604 /// in the corresponding element; otherwise that element is set to zero.
605 /// \returns A 128-bit vector of [4 x float] containing the dot product.
606 #define _mm_dp_ps(X, Y, M) \
607 (__m128) __builtin_ia32_dpps((__v4sf)(__m128)(X), \
608 (__v4sf)(__m128)(Y), (M))
610 /// Computes the dot product of the two 128-bit vectors of [2 x double]
611 /// and returns it in the elements of the 128-bit result vector of
614 /// The immediate integer operand controls which input
615 /// elements will contribute to the dot product, and where the final results
618 /// \headerfile <x86intrin.h>
621 /// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M);
624 /// This intrinsic corresponds to the <c> VDPPD / DPPD </c> instruction.
627 /// A 128-bit vector of [2 x double].
629 /// A 128-bit vector of [2 x double].
631 /// An immediate integer operand. Mask bits [5:4] determine which elements
632 /// of the input vectors are used, with bit [4] corresponding to the lowest
633 /// element and bit [5] corresponding to the highest element of each of [2 x
634 /// double] vector. If a bit is set, the corresponding elements from the two
635 /// input vectors are used as an input for dot product; otherwise that input
636 /// is treated as zero. Bits [1:0] determine which elements of the result
637 /// will receive a copy of the final dot product, with bit [0] corresponding
638 /// to the lowest element and bit [1] corresponding to the highest element of
639 /// each [2 x double] vector. If a bit is set, the dot product is returned in
640 /// the corresponding element; otherwise that element is set to zero.
641 #define _mm_dp_pd(X, Y, M) \
642 (__m128d) __builtin_ia32_dppd((__v2df)(__m128d)(X), \
643 (__v2df)(__m128d)(Y), (M))
645 /* SSE4 Streaming Load Hint Instruction. */
646 /// Loads integer values from a 128-bit aligned memory location to a
647 /// 128-bit integer vector.
649 /// \headerfile <x86intrin.h>
651 /// This intrinsic corresponds to the <c> VMOVNTDQA / MOVNTDQA </c> instruction.
654 /// A pointer to a 128-bit aligned memory location that contains the integer
656 /// \returns A 128-bit integer vector containing the data stored at the
657 /// specified memory location.
658 static __inline__ __m128i __DEFAULT_FN_ATTRS
659 _mm_stream_load_si128 (__m128i const *__V)
661 return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V);
664 /* SSE4 Packed Integer Min/Max Instructions. */
665 /// Compares the corresponding elements of two 128-bit vectors of
666 /// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser
667 /// of the two values.
669 /// \headerfile <x86intrin.h>
671 /// This intrinsic corresponds to the <c> VPMINSB / PMINSB </c> instruction.
674 /// A 128-bit vector of [16 x i8].
676 /// A 128-bit vector of [16 x i8]
677 /// \returns A 128-bit vector of [16 x i8] containing the lesser values.
678 static __inline__ __m128i __DEFAULT_FN_ATTRS
679 _mm_min_epi8 (__m128i __V1, __m128i __V2)
681 return (__m128i) __builtin_ia32_pminsb128 ((__v16qi) __V1, (__v16qi) __V2);
684 /// Compares the corresponding elements of two 128-bit vectors of
685 /// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the
686 /// greater value of the two.
688 /// \headerfile <x86intrin.h>
690 /// This intrinsic corresponds to the <c> VPMAXSB / PMAXSB </c> instruction.
693 /// A 128-bit vector of [16 x i8].
695 /// A 128-bit vector of [16 x i8].
696 /// \returns A 128-bit vector of [16 x i8] containing the greater values.
697 static __inline__ __m128i __DEFAULT_FN_ATTRS
698 _mm_max_epi8 (__m128i __V1, __m128i __V2)
700 return (__m128i) __builtin_ia32_pmaxsb128 ((__v16qi) __V1, (__v16qi) __V2);
703 /// Compares the corresponding elements of two 128-bit vectors of
704 /// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser
705 /// value of the two.
707 /// \headerfile <x86intrin.h>
709 /// This intrinsic corresponds to the <c> VPMINUW / PMINUW </c> instruction.
712 /// A 128-bit vector of [8 x u16].
714 /// A 128-bit vector of [8 x u16].
715 /// \returns A 128-bit vector of [8 x u16] containing the lesser values.
716 static __inline__ __m128i __DEFAULT_FN_ATTRS
717 _mm_min_epu16 (__m128i __V1, __m128i __V2)
719 return (__m128i) __builtin_ia32_pminuw128 ((__v8hi) __V1, (__v8hi) __V2);
722 /// Compares the corresponding elements of two 128-bit vectors of
723 /// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the
724 /// greater value of the two.
726 /// \headerfile <x86intrin.h>
728 /// This intrinsic corresponds to the <c> VPMAXUW / PMAXUW </c> instruction.
731 /// A 128-bit vector of [8 x u16].
733 /// A 128-bit vector of [8 x u16].
734 /// \returns A 128-bit vector of [8 x u16] containing the greater values.
735 static __inline__ __m128i __DEFAULT_FN_ATTRS
736 _mm_max_epu16 (__m128i __V1, __m128i __V2)
738 return (__m128i) __builtin_ia32_pmaxuw128 ((__v8hi) __V1, (__v8hi) __V2);
741 /// Compares the corresponding elements of two 128-bit vectors of
742 /// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser
743 /// value of the two.
745 /// \headerfile <x86intrin.h>
747 /// This intrinsic corresponds to the <c> VPMINSD / PMINSD </c> instruction.
750 /// A 128-bit vector of [4 x i32].
752 /// A 128-bit vector of [4 x i32].
753 /// \returns A 128-bit vector of [4 x i32] containing the lesser values.
754 static __inline__ __m128i __DEFAULT_FN_ATTRS
755 _mm_min_epi32 (__m128i __V1, __m128i __V2)
757 return (__m128i) __builtin_ia32_pminsd128 ((__v4si) __V1, (__v4si) __V2);
760 /// Compares the corresponding elements of two 128-bit vectors of
761 /// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the
762 /// greater value of the two.
764 /// \headerfile <x86intrin.h>
766 /// This intrinsic corresponds to the <c> VPMAXSD / PMAXSD </c> instruction.
769 /// A 128-bit vector of [4 x i32].
771 /// A 128-bit vector of [4 x i32].
772 /// \returns A 128-bit vector of [4 x i32] containing the greater values.
773 static __inline__ __m128i __DEFAULT_FN_ATTRS
774 _mm_max_epi32 (__m128i __V1, __m128i __V2)
776 return (__m128i) __builtin_ia32_pmaxsd128 ((__v4si) __V1, (__v4si) __V2);
779 /// Compares the corresponding elements of two 128-bit vectors of
780 /// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser
781 /// value of the two.
783 /// \headerfile <x86intrin.h>
785 /// This intrinsic corresponds to the <c> VPMINUD / PMINUD </c> instruction.
788 /// A 128-bit vector of [4 x u32].
790 /// A 128-bit vector of [4 x u32].
791 /// \returns A 128-bit vector of [4 x u32] containing the lesser values.
792 static __inline__ __m128i __DEFAULT_FN_ATTRS
793 _mm_min_epu32 (__m128i __V1, __m128i __V2)
795 return (__m128i) __builtin_ia32_pminud128((__v4si) __V1, (__v4si) __V2);
798 /// Compares the corresponding elements of two 128-bit vectors of
799 /// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the
800 /// greater value of the two.
802 /// \headerfile <x86intrin.h>
804 /// This intrinsic corresponds to the <c> VPMAXUD / PMAXUD </c> instruction.
807 /// A 128-bit vector of [4 x u32].
809 /// A 128-bit vector of [4 x u32].
810 /// \returns A 128-bit vector of [4 x u32] containing the greater values.
811 static __inline__ __m128i __DEFAULT_FN_ATTRS
812 _mm_max_epu32 (__m128i __V1, __m128i __V2)
814 return (__m128i) __builtin_ia32_pmaxud128((__v4si) __V1, (__v4si) __V2);
817 /* SSE4 Insertion and Extraction from XMM Register Instructions. */
818 /// Takes the first argument \a X and inserts an element from the second
819 /// argument \a Y as selected by the third argument \a N. That result then
820 /// has elements zeroed out also as selected by the third argument \a N. The
821 /// resulting 128-bit vector of [4 x float] is then returned.
823 /// \headerfile <x86intrin.h>
826 /// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N);
829 /// This intrinsic corresponds to the <c> VINSERTPS </c> instruction.
832 /// A 128-bit vector source operand of [4 x float]. With the exception of
833 /// those bits in the result copied from parameter \a Y and zeroed by bits
834 /// [3:0] of \a N, all bits from this parameter are copied to the result.
836 /// A 128-bit vector source operand of [4 x float]. One single-precision
837 /// floating-point element from this source, as determined by the immediate
838 /// parameter, is copied to the result.
840 /// Specifies which bits from operand \a Y will be copied, which bits in the
841 /// result they will be be copied to, and which bits in the result will be
842 /// cleared. The following assignments are made: \n
843 /// Bits [7:6] specify the bits to copy from operand \a Y: \n
844 /// 00: Selects bits [31:0] from operand \a Y. \n
845 /// 01: Selects bits [63:32] from operand \a Y. \n
846 /// 10: Selects bits [95:64] from operand \a Y. \n
847 /// 11: Selects bits [127:96] from operand \a Y. \n
848 /// Bits [5:4] specify the bits in the result to which the selected bits
849 /// from operand \a Y are copied: \n
850 /// 00: Copies the selected bits from \a Y to result bits [31:0]. \n
851 /// 01: Copies the selected bits from \a Y to result bits [63:32]. \n
852 /// 10: Copies the selected bits from \a Y to result bits [95:64]. \n
853 /// 11: Copies the selected bits from \a Y to result bits [127:96]. \n
854 /// Bits[3:0]: If any of these bits are set, the corresponding result
855 /// element is cleared.
856 /// \returns A 128-bit vector of [4 x float] containing the copied
857 /// single-precision floating point elements from the operands.
858 #define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))
860 /// Extracts a 32-bit integer from a 128-bit vector of [4 x float] and
861 /// returns it, using the immediate value parameter \a N as a selector.
863 /// \headerfile <x86intrin.h>
866 /// int _mm_extract_ps(__m128 X, const int N);
869 /// This intrinsic corresponds to the <c> VEXTRACTPS / EXTRACTPS </c>
873 /// A 128-bit vector of [4 x float].
875 /// An immediate value. Bits [1:0] determines which bits from the argument
876 /// \a X are extracted and returned: \n
877 /// 00: Bits [31:0] of parameter \a X are returned. \n
878 /// 01: Bits [63:32] of parameter \a X are returned. \n
879 /// 10: Bits [95:64] of parameter \a X are returned. \n
880 /// 11: Bits [127:96] of parameter \a X are returned.
881 /// \returns A 32-bit integer containing the extracted 32 bits of float data.
882 #define _mm_extract_ps(X, N) (__extension__ \
883 ({ union { int __i; float __f; } __t; \
884 __t.__f = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); \
887 /* Miscellaneous insert and extract macros. */
888 /* Extract a single-precision float from X at index N into D. */
889 #define _MM_EXTRACT_FLOAT(D, X, N) \
890 { (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); }
892 /* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create
893 an index suitable for _mm_insert_ps. */
894 #define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z))
896 /* Extract a float from X at index N into the first index of the return. */
897 #define _MM_PICK_OUT_PS(X, N) _mm_insert_ps (_mm_setzero_ps(), (X), \
898 _MM_MK_INSERTPS_NDX((N), 0, 0x0e))
900 /* Insert int into packed integer array at index. */
901 /// Constructs a 128-bit vector of [16 x i8] by first making a copy of
902 /// the 128-bit integer vector parameter, and then inserting the lower 8 bits
903 /// of an integer parameter \a I into an offset specified by the immediate
904 /// value parameter \a N.
906 /// \headerfile <x86intrin.h>
909 /// __m128i _mm_insert_epi8(__m128i X, int I, const int N);
912 /// This intrinsic corresponds to the <c> VPINSRB / PINSRB </c> instruction.
915 /// A 128-bit integer vector of [16 x i8]. This vector is copied to the
916 /// result and then one of the sixteen elements in the result vector is
917 /// replaced by the lower 8 bits of \a I.
919 /// An integer. The lower 8 bits of this operand are written to the result
920 /// beginning at the offset specified by \a N.
922 /// An immediate value. Bits [3:0] specify the bit offset in the result at
923 /// which the lower 8 bits of \a I are written. \n
924 /// 0000: Bits [7:0] of the result are used for insertion. \n
925 /// 0001: Bits [15:8] of the result are used for insertion. \n
926 /// 0010: Bits [23:16] of the result are used for insertion. \n
927 /// 0011: Bits [31:24] of the result are used for insertion. \n
928 /// 0100: Bits [39:32] of the result are used for insertion. \n
929 /// 0101: Bits [47:40] of the result are used for insertion. \n
930 /// 0110: Bits [55:48] of the result are used for insertion. \n
931 /// 0111: Bits [63:56] of the result are used for insertion. \n
932 /// 1000: Bits [71:64] of the result are used for insertion. \n
933 /// 1001: Bits [79:72] of the result are used for insertion. \n
934 /// 1010: Bits [87:80] of the result are used for insertion. \n
935 /// 1011: Bits [95:88] of the result are used for insertion. \n
936 /// 1100: Bits [103:96] of the result are used for insertion. \n
937 /// 1101: Bits [111:104] of the result are used for insertion. \n
938 /// 1110: Bits [119:112] of the result are used for insertion. \n
939 /// 1111: Bits [127:120] of the result are used for insertion.
940 /// \returns A 128-bit integer vector containing the constructed values.
941 #define _mm_insert_epi8(X, I, N) \
942 (__m128i)__builtin_ia32_vec_set_v16qi((__v16qi)(__m128i)(X), \
945 /// Constructs a 128-bit vector of [4 x i32] by first making a copy of
946 /// the 128-bit integer vector parameter, and then inserting the 32-bit
947 /// integer parameter \a I at the offset specified by the immediate value
950 /// \headerfile <x86intrin.h>
953 /// __m128i _mm_insert_epi32(__m128i X, int I, const int N);
956 /// This intrinsic corresponds to the <c> VPINSRD / PINSRD </c> instruction.
959 /// A 128-bit integer vector of [4 x i32]. This vector is copied to the
960 /// result and then one of the four elements in the result vector is
961 /// replaced by \a I.
963 /// A 32-bit integer that is written to the result beginning at the offset
964 /// specified by \a N.
966 /// An immediate value. Bits [1:0] specify the bit offset in the result at
967 /// which the integer \a I is written. \n
968 /// 00: Bits [31:0] of the result are used for insertion. \n
969 /// 01: Bits [63:32] of the result are used for insertion. \n
970 /// 10: Bits [95:64] of the result are used for insertion. \n
971 /// 11: Bits [127:96] of the result are used for insertion.
972 /// \returns A 128-bit integer vector containing the constructed values.
973 #define _mm_insert_epi32(X, I, N) \
974 (__m128i)__builtin_ia32_vec_set_v4si((__v4si)(__m128i)(X), \
978 /// Constructs a 128-bit vector of [2 x i64] by first making a copy of
979 /// the 128-bit integer vector parameter, and then inserting the 64-bit
980 /// integer parameter \a I, using the immediate value parameter \a N as an
981 /// insertion location selector.
983 /// \headerfile <x86intrin.h>
986 /// __m128i _mm_insert_epi64(__m128i X, long long I, const int N);
989 /// This intrinsic corresponds to the <c> VPINSRQ / PINSRQ </c> instruction.
992 /// A 128-bit integer vector of [2 x i64]. This vector is copied to the
993 /// result and then one of the two elements in the result vector is replaced
996 /// A 64-bit integer that is written to the result beginning at the offset
997 /// specified by \a N.
999 /// An immediate value. Bit [0] specifies the bit offset in the result at
1000 /// which the integer \a I is written. \n
1001 /// 0: Bits [63:0] of the result are used for insertion. \n
1002 /// 1: Bits [127:64] of the result are used for insertion. \n
1003 /// \returns A 128-bit integer vector containing the constructed values.
1004 #define _mm_insert_epi64(X, I, N) \
1005 (__m128i)__builtin_ia32_vec_set_v2di((__v2di)(__m128i)(X), \
1006 (long long)(I), (int)(N))
1007 #endif /* __x86_64__ */
1009 /* Extract int from packed integer array at index. This returns the element
1010 * as a zero extended value, so it is unsigned.
1012 /// Extracts an 8-bit element from the 128-bit integer vector of
1013 /// [16 x i8], using the immediate value parameter \a N as a selector.
1015 /// \headerfile <x86intrin.h>
1018 /// int _mm_extract_epi8(__m128i X, const int N);
1021 /// This intrinsic corresponds to the <c> VPEXTRB / PEXTRB </c> instruction.
1024 /// A 128-bit integer vector.
1026 /// An immediate value. Bits [3:0] specify which 8-bit vector element from
1027 /// the argument \a X to extract and copy to the result. \n
1028 /// 0000: Bits [7:0] of parameter \a X are extracted. \n
1029 /// 0001: Bits [15:8] of the parameter \a X are extracted. \n
1030 /// 0010: Bits [23:16] of the parameter \a X are extracted. \n
1031 /// 0011: Bits [31:24] of the parameter \a X are extracted. \n
1032 /// 0100: Bits [39:32] of the parameter \a X are extracted. \n
1033 /// 0101: Bits [47:40] of the parameter \a X are extracted. \n
1034 /// 0110: Bits [55:48] of the parameter \a X are extracted. \n
1035 /// 0111: Bits [63:56] of the parameter \a X are extracted. \n
1036 /// 1000: Bits [71:64] of the parameter \a X are extracted. \n
1037 /// 1001: Bits [79:72] of the parameter \a X are extracted. \n
1038 /// 1010: Bits [87:80] of the parameter \a X are extracted. \n
1039 /// 1011: Bits [95:88] of the parameter \a X are extracted. \n
1040 /// 1100: Bits [103:96] of the parameter \a X are extracted. \n
1041 /// 1101: Bits [111:104] of the parameter \a X are extracted. \n
1042 /// 1110: Bits [119:112] of the parameter \a X are extracted. \n
1043 /// 1111: Bits [127:120] of the parameter \a X are extracted.
1044 /// \returns An unsigned integer, whose lower 8 bits are selected from the
1045 /// 128-bit integer vector parameter and the remaining bits are assigned
1047 #define _mm_extract_epi8(X, N) \
1048 (int)(unsigned char)__builtin_ia32_vec_ext_v16qi((__v16qi)(__m128i)(X), \
1051 /// Extracts a 32-bit element from the 128-bit integer vector of
1052 /// [4 x i32], using the immediate value parameter \a N as a selector.
1054 /// \headerfile <x86intrin.h>
1057 /// int _mm_extract_epi32(__m128i X, const int N);
1060 /// This intrinsic corresponds to the <c> VPEXTRD / PEXTRD </c> instruction.
1063 /// A 128-bit integer vector.
1065 /// An immediate value. Bits [1:0] specify which 32-bit vector element from
1066 /// the argument \a X to extract and copy to the result. \n
1067 /// 00: Bits [31:0] of the parameter \a X are extracted. \n
1068 /// 01: Bits [63:32] of the parameter \a X are extracted. \n
1069 /// 10: Bits [95:64] of the parameter \a X are extracted. \n
1070 /// 11: Bits [127:96] of the parameter \a X are exracted.
1071 /// \returns An integer, whose lower 32 bits are selected from the 128-bit
1072 /// integer vector parameter and the remaining bits are assigned zeros.
1073 #define _mm_extract_epi32(X, N) \
1074 (int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N))
1077 /// Extracts a 64-bit element from the 128-bit integer vector of
1078 /// [2 x i64], using the immediate value parameter \a N as a selector.
1080 /// \headerfile <x86intrin.h>
1083 /// long long _mm_extract_epi64(__m128i X, const int N);
1086 /// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
1089 /// A 128-bit integer vector.
1091 /// An immediate value. Bit [0] specifies which 64-bit vector element from
1092 /// the argument \a X to return. \n
1093 /// 0: Bits [63:0] are returned. \n
1094 /// 1: Bits [127:64] are returned. \n
1095 /// \returns A 64-bit integer.
1096 #define _mm_extract_epi64(X, N) \
1097 (long long)__builtin_ia32_vec_ext_v2di((__v2di)(__m128i)(X), (int)(N))
1098 #endif /* __x86_64 */
1100 /* SSE4 128-bit Packed Integer Comparisons. */
1101 /// Tests whether the specified bits in a 128-bit integer vector are all
1104 /// \headerfile <x86intrin.h>
1106 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1109 /// A 128-bit integer vector containing the bits to be tested.
1111 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1112 /// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1113 static __inline__ int __DEFAULT_FN_ATTRS
1114 _mm_testz_si128(__m128i __M, __m128i __V)
1116 return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V);
1119 /// Tests whether the specified bits in a 128-bit integer vector are all
1122 /// \headerfile <x86intrin.h>
1124 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1127 /// A 128-bit integer vector containing the bits to be tested.
1129 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1130 /// \returns TRUE if the specified bits are all ones; FALSE otherwise.
1131 static __inline__ int __DEFAULT_FN_ATTRS
1132 _mm_testc_si128(__m128i __M, __m128i __V)
1134 return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V);
1137 /// Tests whether the specified bits in a 128-bit integer vector are
1138 /// neither all zeros nor all ones.
1140 /// \headerfile <x86intrin.h>
1142 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1145 /// A 128-bit integer vector containing the bits to be tested.
1147 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1148 /// \returns TRUE if the specified bits are neither all zeros nor all ones;
1149 /// FALSE otherwise.
1150 static __inline__ int __DEFAULT_FN_ATTRS
1151 _mm_testnzc_si128(__m128i __M, __m128i __V)
1153 return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V);
1156 /// Tests whether the specified bits in a 128-bit integer vector are all
1159 /// \headerfile <x86intrin.h>
1162 /// int _mm_test_all_ones(__m128i V);
1165 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1168 /// A 128-bit integer vector containing the bits to be tested.
1169 /// \returns TRUE if the bits specified in the operand are all set to 1; FALSE
1171 #define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V)))
1173 /// Tests whether the specified bits in a 128-bit integer vector are
1174 /// neither all zeros nor all ones.
1176 /// \headerfile <x86intrin.h>
1179 /// int _mm_test_mix_ones_zeros(__m128i M, __m128i V);
1182 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1185 /// A 128-bit integer vector containing the bits to be tested.
1187 /// A 128-bit integer vector selecting which bits to test in operand \a M.
1188 /// \returns TRUE if the specified bits are neither all zeros nor all ones;
1189 /// FALSE otherwise.
1190 #define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V))
1192 /// Tests whether the specified bits in a 128-bit integer vector are all
1195 /// \headerfile <x86intrin.h>
1198 /// int _mm_test_all_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 all zeros; FALSE otherwise.
1208 #define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V))
1210 /* SSE4 64-bit Packed Integer Comparisons. */
1211 /// Compares each of the corresponding 64-bit values of the 128-bit
1212 /// integer vectors for equality.
1214 /// \headerfile <x86intrin.h>
1216 /// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction.
1219 /// A 128-bit integer vector.
1221 /// A 128-bit integer vector.
1222 /// \returns A 128-bit integer vector containing the comparison results.
1223 static __inline__ __m128i __DEFAULT_FN_ATTRS
1224 _mm_cmpeq_epi64(__m128i __V1, __m128i __V2)
1226 return (__m128i)((__v2di)__V1 == (__v2di)__V2);
1229 /* SSE4 Packed Integer Sign-Extension. */
1230 /// Sign-extends each of the lower eight 8-bit integer elements of a
1231 /// 128-bit vector of [16 x i8] to 16-bit values and returns them in a
1232 /// 128-bit vector of [8 x i16]. The upper eight elements of the input vector
1235 /// \headerfile <x86intrin.h>
1237 /// This intrinsic corresponds to the <c> VPMOVSXBW / PMOVSXBW </c> instruction.
1240 /// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are sign-
1241 /// extended to 16-bit values.
1242 /// \returns A 128-bit vector of [8 x i16] containing the sign-extended values.
1243 static __inline__ __m128i __DEFAULT_FN_ATTRS
1244 _mm_cvtepi8_epi16(__m128i __V)
1246 /* This function always performs a signed extension, but __v16qi is a char
1247 which may be signed or unsigned, so use __v16qs. */
1248 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1251 /// Sign-extends each of the lower four 8-bit integer elements of a
1252 /// 128-bit vector of [16 x i8] to 32-bit values and returns them in a
1253 /// 128-bit vector of [4 x i32]. The upper twelve elements of the input
1254 /// vector are unused.
1256 /// \headerfile <x86intrin.h>
1258 /// This intrinsic corresponds to the <c> VPMOVSXBD / PMOVSXBD </c> instruction.
1261 /// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
1262 /// sign-extended to 32-bit values.
1263 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1264 static __inline__ __m128i __DEFAULT_FN_ATTRS
1265 _mm_cvtepi8_epi32(__m128i __V)
1267 /* This function always performs a signed extension, but __v16qi is a char
1268 which may be signed or unsigned, so use __v16qs. */
1269 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si);
1272 /// Sign-extends each of the lower two 8-bit integer elements of a
1273 /// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1274 /// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1275 /// vector are unused.
1277 /// \headerfile <x86intrin.h>
1279 /// This intrinsic corresponds to the <c> VPMOVSXBQ / PMOVSXBQ </c> instruction.
1282 /// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
1283 /// sign-extended to 64-bit values.
1284 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1285 static __inline__ __m128i __DEFAULT_FN_ATTRS
1286 _mm_cvtepi8_epi64(__m128i __V)
1288 /* This function always performs a signed extension, but __v16qi is a char
1289 which may be signed or unsigned, so use __v16qs. */
1290 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di);
1293 /// Sign-extends each of the lower four 16-bit integer elements of a
1294 /// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1295 /// a 128-bit vector of [4 x i32]. The upper four elements of the input
1296 /// vector are unused.
1298 /// \headerfile <x86intrin.h>
1300 /// This intrinsic corresponds to the <c> VPMOVSXWD / PMOVSXWD </c> instruction.
1303 /// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
1304 /// sign-extended to 32-bit values.
1305 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1306 static __inline__ __m128i __DEFAULT_FN_ATTRS
1307 _mm_cvtepi16_epi32(__m128i __V)
1309 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si);
1312 /// Sign-extends each of the lower two 16-bit integer elements of a
1313 /// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1314 /// a 128-bit vector of [2 x i64]. The upper six elements of the input
1315 /// vector are unused.
1317 /// \headerfile <x86intrin.h>
1319 /// This intrinsic corresponds to the <c> VPMOVSXWQ / PMOVSXWQ </c> instruction.
1322 /// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
1323 /// sign-extended to 64-bit values.
1324 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1325 static __inline__ __m128i __DEFAULT_FN_ATTRS
1326 _mm_cvtepi16_epi64(__m128i __V)
1328 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di);
1331 /// Sign-extends each of the lower two 32-bit integer elements of a
1332 /// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1333 /// a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1336 /// \headerfile <x86intrin.h>
1338 /// This intrinsic corresponds to the <c> VPMOVSXDQ / PMOVSXDQ </c> instruction.
1341 /// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
1342 /// sign-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_cvtepi32_epi64(__m128i __V)
1347 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di);
1350 /* SSE4 Packed Integer Zero-Extension. */
1351 /// Zero-extends each of the lower eight 8-bit integer elements of a
1352 /// 128-bit vector of [16 x i8] to 16-bit values and returns them in a
1353 /// 128-bit vector of [8 x i16]. The upper eight elements of the input vector
1356 /// \headerfile <x86intrin.h>
1358 /// This intrinsic corresponds to the <c> VPMOVZXBW / PMOVZXBW </c> instruction.
1361 /// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are
1362 /// zero-extended to 16-bit values.
1363 /// \returns A 128-bit vector of [8 x i16] containing the zero-extended values.
1364 static __inline__ __m128i __DEFAULT_FN_ATTRS
1365 _mm_cvtepu8_epi16(__m128i __V)
1367 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1370 /// Zero-extends each of the lower four 8-bit integer elements of a
1371 /// 128-bit vector of [16 x i8] to 32-bit values and returns them in a
1372 /// 128-bit vector of [4 x i32]. The upper twelve elements of the input
1373 /// vector are unused.
1375 /// \headerfile <x86intrin.h>
1377 /// This intrinsic corresponds to the <c> VPMOVZXBD / PMOVZXBD </c> instruction.
1380 /// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
1381 /// zero-extended to 32-bit values.
1382 /// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1383 static __inline__ __m128i __DEFAULT_FN_ATTRS
1384 _mm_cvtepu8_epi32(__m128i __V)
1386 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si);
1389 /// Zero-extends each of the lower two 8-bit integer elements of a
1390 /// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1391 /// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1392 /// vector are unused.
1394 /// \headerfile <x86intrin.h>
1396 /// This intrinsic corresponds to the <c> VPMOVZXBQ / PMOVZXBQ </c> instruction.
1399 /// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
1400 /// zero-extended to 64-bit values.
1401 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1402 static __inline__ __m128i __DEFAULT_FN_ATTRS
1403 _mm_cvtepu8_epi64(__m128i __V)
1405 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di);
1408 /// Zero-extends each of the lower four 16-bit integer elements of a
1409 /// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1410 /// a 128-bit vector of [4 x i32]. The upper four elements of the input
1411 /// vector are unused.
1413 /// \headerfile <x86intrin.h>
1415 /// This intrinsic corresponds to the <c> VPMOVZXWD / PMOVZXWD </c> instruction.
1418 /// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
1419 /// zero-extended to 32-bit values.
1420 /// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1421 static __inline__ __m128i __DEFAULT_FN_ATTRS
1422 _mm_cvtepu16_epi32(__m128i __V)
1424 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si);
1427 /// Zero-extends each of the lower two 16-bit integer elements of a
1428 /// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1429 /// a 128-bit vector of [2 x i64]. The upper six elements of the input vector
1432 /// \headerfile <x86intrin.h>
1434 /// This intrinsic corresponds to the <c> VPMOVZXWQ / PMOVZXWQ </c> instruction.
1437 /// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
1438 /// zero-extended to 64-bit values.
1439 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1440 static __inline__ __m128i __DEFAULT_FN_ATTRS
1441 _mm_cvtepu16_epi64(__m128i __V)
1443 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di);
1446 /// Zero-extends each of the lower two 32-bit integer elements of a
1447 /// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1448 /// a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1451 /// \headerfile <x86intrin.h>
1453 /// This intrinsic corresponds to the <c> VPMOVZXDQ / PMOVZXDQ </c> instruction.
1456 /// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
1457 /// zero-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_cvtepu32_epi64(__m128i __V)
1462 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di);
1465 /* SSE4 Pack with Unsigned Saturation. */
1466 /// Converts 32-bit signed integers from both 128-bit integer vector
1467 /// operands into 16-bit unsigned integers, and returns the packed result.
1468 /// Values greater than 0xFFFF are saturated to 0xFFFF. Values less than
1469 /// 0x0000 are saturated to 0x0000.
1471 /// \headerfile <x86intrin.h>
1473 /// This intrinsic corresponds to the <c> VPACKUSDW / PACKUSDW </c> instruction.
1476 /// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1477 /// signed integer and is converted to a 16-bit unsigned integer with
1478 /// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1479 /// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1480 /// are written to the lower 64 bits of the result.
1482 /// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1483 /// signed integer and is converted to a 16-bit unsigned integer with
1484 /// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1485 /// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1486 /// are written to the higher 64 bits of the result.
1487 /// \returns A 128-bit vector of [8 x i16] containing the converted values.
1488 static __inline__ __m128i __DEFAULT_FN_ATTRS
1489 _mm_packus_epi32(__m128i __V1, __m128i __V2)
1491 return (__m128i) __builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2);
1494 /* SSE4 Multiple Packed Sums of Absolute Difference. */
1495 /// Subtracts 8-bit unsigned integer values and computes the absolute
1496 /// values of the differences to the corresponding bits in the destination.
1497 /// Then sums of the absolute differences are returned according to the bit
1498 /// fields in the immediate operand.
1500 /// \headerfile <x86intrin.h>
1503 /// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M);
1506 /// This intrinsic corresponds to the <c> VMPSADBW / MPSADBW </c> instruction.
1509 /// A 128-bit vector of [16 x i8].
1511 /// A 128-bit vector of [16 x i8].
1513 /// An 8-bit immediate operand specifying how the absolute differences are to
1514 /// be calculated, according to the following algorithm:
1516 /// // M2 represents bit 2 of the immediate operand
1517 /// // M10 represents bits [1:0] of the immediate operand
1520 /// for (k = 0; k < 8; k = k + 1) {
1521 /// d0 = abs(X[i + k + 0] - Y[j + 0]);
1522 /// d1 = abs(X[i + k + 1] - Y[j + 1]);
1523 /// d2 = abs(X[i + k + 2] - Y[j + 2]);
1524 /// d3 = abs(X[i + k + 3] - Y[j + 3]);
1525 /// r[k] = d0 + d1 + d2 + d3;
1528 /// \returns A 128-bit integer vector containing the sums of the sets of
1529 /// absolute differences between both operands.
1530 #define _mm_mpsadbw_epu8(X, Y, M) \
1531 (__m128i) __builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \
1532 (__v16qi)(__m128i)(Y), (M))
1534 /// Finds the minimum unsigned 16-bit element in the input 128-bit
1535 /// vector of [8 x u16] and returns it and along with its index.
1537 /// \headerfile <x86intrin.h>
1539 /// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c>
1543 /// A 128-bit vector of [8 x u16].
1544 /// \returns A 128-bit value where bits [15:0] contain the minimum value found
1545 /// in parameter \a __V, bits [18:16] contain the index of the minimum value
1546 /// and the remaining bits are set to 0.
1547 static __inline__ __m128i __DEFAULT_FN_ATTRS
1548 _mm_minpos_epu16(__m128i __V)
1550 return (__m128i) __builtin_ia32_phminposuw128((__v8hi)__V);
1553 /* Handle the sse4.2 definitions here. */
1555 /* These definitions are normally in nmmintrin.h, but gcc puts them in here
1556 so we'll do the same. */
1558 #undef __DEFAULT_FN_ATTRS
1559 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))
1561 /* These specify the type of data that we're comparing. */
1562 #define _SIDD_UBYTE_OPS 0x00
1563 #define _SIDD_UWORD_OPS 0x01
1564 #define _SIDD_SBYTE_OPS 0x02
1565 #define _SIDD_SWORD_OPS 0x03
1567 /* These specify the type of comparison operation. */
1568 #define _SIDD_CMP_EQUAL_ANY 0x00
1569 #define _SIDD_CMP_RANGES 0x04
1570 #define _SIDD_CMP_EQUAL_EACH 0x08
1571 #define _SIDD_CMP_EQUAL_ORDERED 0x0c
1573 /* These macros specify the polarity of the operation. */
1574 #define _SIDD_POSITIVE_POLARITY 0x00
1575 #define _SIDD_NEGATIVE_POLARITY 0x10
1576 #define _SIDD_MASKED_POSITIVE_POLARITY 0x20
1577 #define _SIDD_MASKED_NEGATIVE_POLARITY 0x30
1579 /* These macros are used in _mm_cmpXstri() to specify the return. */
1580 #define _SIDD_LEAST_SIGNIFICANT 0x00
1581 #define _SIDD_MOST_SIGNIFICANT 0x40
1583 /* These macros are used in _mm_cmpXstri() to specify the return. */
1584 #define _SIDD_BIT_MASK 0x00
1585 #define _SIDD_UNIT_MASK 0x40
1587 /* SSE4.2 Packed Comparison Intrinsics. */
1588 /// Uses the immediate operand \a M to perform a comparison of string
1589 /// data with implicitly defined lengths that is contained in source operands
1590 /// \a A and \a B. Returns a 128-bit integer vector representing the result
1591 /// mask of the comparison.
1593 /// \headerfile <x86intrin.h>
1596 /// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M);
1599 /// This intrinsic corresponds to the <c> VPCMPISTRM / PCMPISTRM </c>
1603 /// A 128-bit integer vector containing one of the source operands to be
1606 /// A 128-bit integer vector containing one of the source operands to be
1609 /// An 8-bit immediate operand specifying whether the characters are bytes or
1610 /// words, the type of comparison to perform, and the format of the return
1612 /// Bits [1:0]: Determine source data format. \n
1613 /// 00: 16 unsigned bytes \n
1614 /// 01: 8 unsigned words \n
1615 /// 10: 16 signed bytes \n
1616 /// 11: 8 signed words \n
1617 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1618 /// 00: Subset: Each character in \a B is compared for equality with all
1619 /// the characters in \a A. \n
1620 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1621 /// basis is greater than or equal for even-indexed elements in \a A,
1622 /// and less than or equal for odd-indexed elements in \a A. \n
1623 /// 10: Match: Compare each pair of corresponding characters in \a A and
1624 /// \a B for equality. \n
1625 /// 11: Substring: Search \a B for substring matches of \a A. \n
1626 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1627 /// mask of the comparison results. \n
1628 /// 00: No effect. \n
1629 /// 01: Negate the bit mask. \n
1630 /// 10: No effect. \n
1631 /// 11: Negate the bit mask only for bits with an index less than or equal
1632 /// to the size of \a A or \a B. \n
1633 /// Bit [6]: Determines whether the result is zero-extended or expanded to 16
1635 /// 0: The result is zero-extended to 16 bytes. \n
1636 /// 1: The result is expanded to 16 bytes (this expansion is performed by
1637 /// repeating each bit 8 or 16 times).
1638 /// \returns Returns a 128-bit integer vector representing the result mask of
1640 #define _mm_cmpistrm(A, B, M) \
1641 (__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \
1642 (__v16qi)(__m128i)(B), (int)(M))
1644 /// Uses the immediate operand \a M to perform a comparison of string
1645 /// data with implicitly defined lengths that is contained in source operands
1646 /// \a A and \a B. Returns an integer representing the result index of the
1649 /// \headerfile <x86intrin.h>
1652 /// int _mm_cmpistri(__m128i A, __m128i B, const int M);
1655 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1659 /// A 128-bit integer vector containing one of the source operands to be
1662 /// A 128-bit integer vector containing one of the source operands to be
1665 /// An 8-bit immediate operand specifying whether the characters are bytes or
1666 /// words, the type of comparison to perform, and the format of the return
1668 /// Bits [1:0]: Determine source data format. \n
1669 /// 00: 16 unsigned bytes \n
1670 /// 01: 8 unsigned words \n
1671 /// 10: 16 signed bytes \n
1672 /// 11: 8 signed words \n
1673 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1674 /// 00: Subset: Each character in \a B is compared for equality with all
1675 /// the characters in \a A. \n
1676 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1677 /// basis is greater than or equal for even-indexed elements in \a A,
1678 /// and less than or equal for odd-indexed elements in \a A. \n
1679 /// 10: Match: Compare each pair of corresponding characters in \a A and
1680 /// \a B for equality. \n
1681 /// 11: Substring: Search B for substring matches of \a A. \n
1682 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1683 /// mask of the comparison results. \n
1684 /// 00: No effect. \n
1685 /// 01: Negate the bit mask. \n
1686 /// 10: No effect. \n
1687 /// 11: Negate the bit mask only for bits with an index less than or equal
1688 /// to the size of \a A or \a B. \n
1689 /// Bit [6]: Determines whether the index of the lowest set bit or the
1690 /// highest set bit is returned. \n
1691 /// 0: The index of the least significant set bit. \n
1692 /// 1: The index of the most significant set bit. \n
1693 /// \returns Returns an integer representing the result index of the comparison.
1694 #define _mm_cmpistri(A, B, M) \
1695 (int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \
1696 (__v16qi)(__m128i)(B), (int)(M))
1698 /// Uses the immediate operand \a M to perform a comparison of string
1699 /// data with explicitly defined lengths that is contained in source operands
1700 /// \a A and \a B. Returns a 128-bit integer vector representing the result
1701 /// mask of the comparison.
1703 /// \headerfile <x86intrin.h>
1706 /// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M);
1709 /// This intrinsic corresponds to the <c> VPCMPESTRM / PCMPESTRM </c>
1713 /// A 128-bit integer vector containing one of the source operands to be
1716 /// An integer that specifies the length of the string in \a A.
1718 /// A 128-bit integer vector containing one of the source operands to be
1721 /// An integer that specifies the length of the string in \a B.
1723 /// An 8-bit immediate operand specifying whether the characters are bytes or
1724 /// words, the type of comparison to perform, and the format of the return
1726 /// Bits [1:0]: Determine source data format. \n
1727 /// 00: 16 unsigned bytes \n
1728 /// 01: 8 unsigned words \n
1729 /// 10: 16 signed bytes \n
1730 /// 11: 8 signed words \n
1731 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1732 /// 00: Subset: Each character in \a B is compared for equality with all
1733 /// the characters in \a A. \n
1734 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1735 /// basis is greater than or equal for even-indexed elements in \a A,
1736 /// and less than or equal for odd-indexed elements in \a A. \n
1737 /// 10: Match: Compare each pair of corresponding characters in \a A and
1738 /// \a B for equality. \n
1739 /// 11: Substring: Search \a B for substring matches of \a A. \n
1740 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1741 /// mask of the comparison results. \n
1742 /// 00: No effect. \n
1743 /// 01: Negate the bit mask. \n
1744 /// 10: No effect. \n
1745 /// 11: Negate the bit mask only for bits with an index less than or equal
1746 /// to the size of \a A or \a B. \n
1747 /// Bit [6]: Determines whether the result is zero-extended or expanded to 16
1749 /// 0: The result is zero-extended to 16 bytes. \n
1750 /// 1: The result is expanded to 16 bytes (this expansion is performed by
1751 /// repeating each bit 8 or 16 times). \n
1752 /// \returns Returns a 128-bit integer vector representing the result mask of
1754 #define _mm_cmpestrm(A, LA, B, LB, M) \
1755 (__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \
1756 (__v16qi)(__m128i)(B), (int)(LB), \
1759 /// Uses the immediate operand \a M to perform a comparison of string
1760 /// data with explicitly defined lengths that is contained in source operands
1761 /// \a A and \a B. Returns an integer representing the result index of the
1764 /// \headerfile <x86intrin.h>
1767 /// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M);
1770 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
1774 /// A 128-bit integer vector containing one of the source operands to be
1777 /// An integer that specifies the length of the string in \a A.
1779 /// A 128-bit integer vector containing one of the source operands to be
1782 /// An integer that specifies the length of the string in \a B.
1784 /// An 8-bit immediate operand specifying whether the characters are bytes or
1785 /// words, the type of comparison to perform, and the format of the return
1787 /// Bits [1:0]: Determine source data format. \n
1788 /// 00: 16 unsigned bytes \n
1789 /// 01: 8 unsigned words \n
1790 /// 10: 16 signed bytes \n
1791 /// 11: 8 signed words \n
1792 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1793 /// 00: Subset: Each character in \a B is compared for equality with all
1794 /// the characters in \a A. \n
1795 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1796 /// basis is greater than or equal for even-indexed elements in \a A,
1797 /// and less than or equal for odd-indexed elements in \a A. \n
1798 /// 10: Match: Compare each pair of corresponding characters in \a A and
1799 /// \a B for equality. \n
1800 /// 11: Substring: Search B for substring matches of \a A. \n
1801 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1802 /// mask of the comparison results. \n
1803 /// 00: No effect. \n
1804 /// 01: Negate the bit mask. \n
1805 /// 10: No effect. \n
1806 /// 11: Negate the bit mask only for bits with an index less than or equal
1807 /// to the size of \a A or \a B. \n
1808 /// Bit [6]: Determines whether the index of the lowest set bit or the
1809 /// highest set bit is returned. \n
1810 /// 0: The index of the least significant set bit. \n
1811 /// 1: The index of the most significant set bit. \n
1812 /// \returns Returns an integer representing the result index of the comparison.
1813 #define _mm_cmpestri(A, LA, B, LB, M) \
1814 (int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \
1815 (__v16qi)(__m128i)(B), (int)(LB), \
1818 /* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */
1819 /// Uses the immediate operand \a M to perform a comparison of string
1820 /// data with implicitly defined lengths that is contained in source operands
1821 /// \a A and \a B. Returns 1 if the bit mask is zero and the length of the
1822 /// string in \a B is the maximum, otherwise, returns 0.
1824 /// \headerfile <x86intrin.h>
1827 /// int _mm_cmpistra(__m128i A, __m128i B, const int M);
1830 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1834 /// A 128-bit integer vector containing one of the source operands to be
1837 /// A 128-bit integer vector containing one of the source operands to be
1840 /// An 8-bit immediate operand specifying whether the characters are bytes or
1841 /// words and the type of comparison to perform. \n
1842 /// Bits [1:0]: Determine source data format. \n
1843 /// 00: 16 unsigned bytes \n
1844 /// 01: 8 unsigned words \n
1845 /// 10: 16 signed bytes \n
1846 /// 11: 8 signed words \n
1847 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1848 /// 00: Subset: Each character in \a B is compared for equality with all
1849 /// the characters in \a A. \n
1850 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1851 /// basis is greater than or equal for even-indexed elements in \a A,
1852 /// and less than or equal for odd-indexed elements in \a A. \n
1853 /// 10: Match: Compare each pair of corresponding characters in \a A and
1854 /// \a B for equality. \n
1855 /// 11: Substring: Search \a B for substring matches of \a A. \n
1856 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1857 /// mask of the comparison results. \n
1858 /// 00: No effect. \n
1859 /// 01: Negate the bit mask. \n
1860 /// 10: No effect. \n
1861 /// 11: Negate the bit mask only for bits with an index less than or equal
1862 /// to the size of \a A or \a B. \n
1863 /// \returns Returns 1 if the bit mask is zero and the length of the string in
1864 /// \a B is the maximum; otherwise, returns 0.
1865 #define _mm_cmpistra(A, B, M) \
1866 (int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \
1867 (__v16qi)(__m128i)(B), (int)(M))
1869 /// Uses the immediate operand \a M to perform a comparison of string
1870 /// data with implicitly defined lengths that is contained in source operands
1871 /// \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns
1874 /// \headerfile <x86intrin.h>
1877 /// int _mm_cmpistrc(__m128i A, __m128i B, const int M);
1880 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1884 /// A 128-bit integer vector containing one of the source operands to be
1887 /// A 128-bit integer vector containing one of the source operands to be
1890 /// An 8-bit immediate operand specifying whether the characters are bytes or
1891 /// words and the type of comparison to perform. \n
1892 /// Bits [1:0]: Determine source data format. \n
1893 /// 00: 16 unsigned bytes \n
1894 /// 01: 8 unsigned words \n
1895 /// 10: 16 signed bytes \n
1896 /// 11: 8 signed words \n
1897 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1898 /// 00: Subset: Each character in \a B is compared for equality with all
1899 /// the characters in \a A. \n
1900 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1901 /// basis is greater than or equal for even-indexed elements in \a A,
1902 /// and less than or equal for odd-indexed elements in \a A. \n
1903 /// 10: Match: Compare each pair of corresponding characters in \a A and
1904 /// \a B for equality. \n
1905 /// 11: Substring: Search B for substring matches of \a A. \n
1906 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1907 /// mask of the comparison results. \n
1908 /// 00: No effect. \n
1909 /// 01: Negate the bit mask. \n
1910 /// 10: No effect. \n
1911 /// 11: Negate the bit mask only for bits with an index less than or equal
1912 /// to the size of \a A or \a B.
1913 /// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0.
1914 #define _mm_cmpistrc(A, B, M) \
1915 (int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \
1916 (__v16qi)(__m128i)(B), (int)(M))
1918 /// Uses the immediate operand \a M to perform a comparison of string
1919 /// data with implicitly defined lengths that is contained in source operands
1920 /// \a A and \a B. Returns bit 0 of the resulting bit mask.
1922 /// \headerfile <x86intrin.h>
1925 /// int _mm_cmpistro(__m128i A, __m128i B, const int M);
1928 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1932 /// A 128-bit integer vector containing one of the source operands to be
1935 /// A 128-bit integer vector containing one of the source operands to be
1938 /// An 8-bit immediate operand specifying whether the characters are bytes or
1939 /// words and the type of comparison to perform. \n
1940 /// Bits [1:0]: Determine source data format. \n
1941 /// 00: 16 unsigned bytes \n
1942 /// 01: 8 unsigned words \n
1943 /// 10: 16 signed bytes \n
1944 /// 11: 8 signed words \n
1945 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1946 /// 00: Subset: Each character in \a B is compared for equality with all
1947 /// the characters in \a A. \n
1948 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1949 /// basis is greater than or equal for even-indexed elements in \a A,
1950 /// and less than or equal for odd-indexed elements in \a A. \n
1951 /// 10: Match: Compare each pair of corresponding characters in \a A and
1952 /// \a B for equality. \n
1953 /// 11: Substring: Search B for substring matches of \a A. \n
1954 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1955 /// mask of the comparison results. \n
1956 /// 00: No effect. \n
1957 /// 01: Negate the bit mask. \n
1958 /// 10: No effect. \n
1959 /// 11: Negate the bit mask only for bits with an index less than or equal
1960 /// to the size of \a A or \a B. \n
1961 /// \returns Returns bit 0 of the resulting bit mask.
1962 #define _mm_cmpistro(A, B, M) \
1963 (int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \
1964 (__v16qi)(__m128i)(B), (int)(M))
1966 /// Uses the immediate operand \a M to perform a comparison of string
1967 /// data with implicitly defined lengths that is contained in source operands
1968 /// \a A and \a B. Returns 1 if the length of the string in \a A is less than
1969 /// the maximum, otherwise, returns 0.
1971 /// \headerfile <x86intrin.h>
1974 /// int _mm_cmpistrs(__m128i A, __m128i B, const int M);
1977 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1981 /// A 128-bit integer vector containing one of the source operands to be
1984 /// A 128-bit integer vector containing one of the source operands to be
1987 /// An 8-bit immediate operand specifying whether the characters are bytes or
1988 /// words and the type of comparison to perform. \n
1989 /// Bits [1:0]: Determine source data format. \n
1990 /// 00: 16 unsigned bytes \n
1991 /// 01: 8 unsigned words \n
1992 /// 10: 16 signed bytes \n
1993 /// 11: 8 signed words \n
1994 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1995 /// 00: Subset: Each character in \a B is compared for equality with all
1996 /// the characters in \a A. \n
1997 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1998 /// basis is greater than or equal for even-indexed elements in \a A,
1999 /// and less than or equal for odd-indexed elements in \a A. \n
2000 /// 10: Match: Compare each pair of corresponding characters in \a A and
2001 /// \a B for equality. \n
2002 /// 11: Substring: Search \a B for substring matches of \a A. \n
2003 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2004 /// mask of the comparison results. \n
2005 /// 00: No effect. \n
2006 /// 01: Negate the bit mask. \n
2007 /// 10: No effect. \n
2008 /// 11: Negate the bit mask only for bits with an index less than or equal
2009 /// to the size of \a A or \a B. \n
2010 /// \returns Returns 1 if the length of the string in \a A is less than the
2011 /// maximum, otherwise, returns 0.
2012 #define _mm_cmpistrs(A, B, M) \
2013 (int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \
2014 (__v16qi)(__m128i)(B), (int)(M))
2016 /// Uses the immediate operand \a M to perform a comparison of string
2017 /// data with implicitly defined lengths that is contained in source operands
2018 /// \a A and \a B. Returns 1 if the length of the string in \a B is less than
2019 /// the maximum, otherwise, returns 0.
2021 /// \headerfile <x86intrin.h>
2024 /// int _mm_cmpistrz(__m128i A, __m128i B, const int M);
2027 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
2031 /// A 128-bit integer vector containing one of the source operands to be
2034 /// A 128-bit integer vector containing one of the source operands to be
2037 /// An 8-bit immediate operand specifying whether the characters are bytes or
2038 /// words and the type of comparison to perform. \n
2039 /// Bits [1:0]: Determine source data format. \n
2040 /// 00: 16 unsigned bytes \n
2041 /// 01: 8 unsigned words \n
2042 /// 10: 16 signed bytes \n
2043 /// 11: 8 signed words \n
2044 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2045 /// 00: Subset: Each character in \a B is compared for equality with all
2046 /// the characters in \a A. \n
2047 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2048 /// basis is greater than or equal for even-indexed elements in \a A,
2049 /// and less than or equal for odd-indexed elements in \a A. \n
2050 /// 10: Match: Compare each pair of corresponding characters in \a A and
2051 /// \a B for equality. \n
2052 /// 11: Substring: Search \a B for substring matches of \a A. \n
2053 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2054 /// mask of the comparison results. \n
2055 /// 00: No effect. \n
2056 /// 01: Negate the bit mask. \n
2057 /// 10: No effect. \n
2058 /// 11: Negate the bit mask only for bits with an index less than or equal
2059 /// to the size of \a A or \a B.
2060 /// \returns Returns 1 if the length of the string in \a B is less than the
2061 /// maximum, otherwise, returns 0.
2062 #define _mm_cmpistrz(A, B, M) \
2063 (int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \
2064 (__v16qi)(__m128i)(B), (int)(M))
2066 /// Uses the immediate operand \a M to perform a comparison of string
2067 /// data with explicitly defined lengths that is contained in source operands
2068 /// \a A and \a B. Returns 1 if the bit mask is zero and the length of the
2069 /// string in \a B is the maximum, otherwise, returns 0.
2071 /// \headerfile <x86intrin.h>
2074 /// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M);
2077 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2081 /// A 128-bit integer vector containing one of the source operands to be
2084 /// An integer that specifies the length of the string in \a A.
2086 /// A 128-bit integer vector containing one of the source operands to be
2089 /// An integer that specifies the length of the string in \a B.
2091 /// An 8-bit immediate operand specifying whether the characters are bytes or
2092 /// words and the type of comparison to perform. \n
2093 /// Bits [1:0]: Determine source data format. \n
2094 /// 00: 16 unsigned bytes \n
2095 /// 01: 8 unsigned words \n
2096 /// 10: 16 signed bytes \n
2097 /// 11: 8 signed words \n
2098 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2099 /// 00: Subset: Each character in \a B is compared for equality with all
2100 /// the characters in \a A. \n
2101 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2102 /// basis is greater than or equal for even-indexed elements in \a A,
2103 /// and less than or equal for odd-indexed elements in \a A. \n
2104 /// 10: Match: Compare each pair of corresponding characters in \a A and
2105 /// \a B for equality. \n
2106 /// 11: Substring: Search \a B for substring matches of \a A. \n
2107 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2108 /// mask of the comparison results. \n
2109 /// 00: No effect. \n
2110 /// 01: Negate the bit mask. \n
2111 /// 10: No effect. \n
2112 /// 11: Negate the bit mask only for bits with an index less than or equal
2113 /// to the size of \a A or \a B.
2114 /// \returns Returns 1 if the bit mask is zero and the length of the string in
2115 /// \a B is the maximum, otherwise, returns 0.
2116 #define _mm_cmpestra(A, LA, B, LB, M) \
2117 (int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \
2118 (__v16qi)(__m128i)(B), (int)(LB), \
2121 /// Uses the immediate operand \a M to perform a comparison of string
2122 /// data with explicitly defined lengths that is contained in source operands
2123 /// \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise,
2126 /// \headerfile <x86intrin.h>
2129 /// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M);
2132 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2136 /// A 128-bit integer vector containing one of the source operands to be
2139 /// An integer that specifies the length of the string in \a A.
2141 /// A 128-bit integer vector containing one of the source operands to be
2144 /// An integer that specifies the length of the string in \a B.
2146 /// An 8-bit immediate operand specifying whether the characters are bytes or
2147 /// words and the type of comparison to perform. \n
2148 /// Bits [1:0]: Determine source data format. \n
2149 /// 00: 16 unsigned bytes \n
2150 /// 01: 8 unsigned words \n
2151 /// 10: 16 signed bytes \n
2152 /// 11: 8 signed words \n
2153 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2154 /// 00: Subset: Each character in \a B is compared for equality with all
2155 /// the characters in \a A. \n
2156 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2157 /// basis is greater than or equal for even-indexed elements in \a A,
2158 /// and less than or equal for odd-indexed elements in \a A. \n
2159 /// 10: Match: Compare each pair of corresponding characters in \a A and
2160 /// \a B for equality. \n
2161 /// 11: Substring: Search \a B for substring matches of \a A. \n
2162 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2163 /// mask of the comparison results. \n
2164 /// 00: No effect. \n
2165 /// 01: Negate the bit mask. \n
2166 /// 10: No effect. \n
2167 /// 11: Negate the bit mask only for bits with an index less than or equal
2168 /// to the size of \a A or \a B. \n
2169 /// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0.
2170 #define _mm_cmpestrc(A, LA, B, LB, M) \
2171 (int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \
2172 (__v16qi)(__m128i)(B), (int)(LB), \
2175 /// Uses the immediate operand \a M to perform a comparison of string
2176 /// data with explicitly defined lengths that is contained in source operands
2177 /// \a A and \a B. Returns bit 0 of the resulting bit mask.
2179 /// \headerfile <x86intrin.h>
2182 /// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M);
2185 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2189 /// A 128-bit integer vector containing one of the source operands to be
2192 /// An integer that specifies the length of the string in \a A.
2194 /// A 128-bit integer vector containing one of the source operands to be
2197 /// An integer that specifies the length of the string in \a B.
2199 /// An 8-bit immediate operand specifying whether the characters are bytes or
2200 /// words and the type of comparison to perform. \n
2201 /// Bits [1:0]: Determine source data format. \n
2202 /// 00: 16 unsigned bytes \n
2203 /// 01: 8 unsigned words \n
2204 /// 10: 16 signed bytes \n
2205 /// 11: 8 signed words \n
2206 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2207 /// 00: Subset: Each character in \a B is compared for equality with all
2208 /// the characters in \a A. \n
2209 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2210 /// basis is greater than or equal for even-indexed elements in \a A,
2211 /// and less than or equal for odd-indexed elements in \a A. \n
2212 /// 10: Match: Compare each pair of corresponding characters in \a A and
2213 /// \a B for equality. \n
2214 /// 11: Substring: Search \a B for substring matches of \a A. \n
2215 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2216 /// mask of the comparison results. \n
2217 /// 00: No effect. \n
2218 /// 01: Negate the bit mask. \n
2219 /// 10: No effect. \n
2220 /// 11: Negate the bit mask only for bits with an index less than or equal
2221 /// to the size of \a A or \a B.
2222 /// \returns Returns bit 0 of the resulting bit mask.
2223 #define _mm_cmpestro(A, LA, B, LB, M) \
2224 (int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \
2225 (__v16qi)(__m128i)(B), (int)(LB), \
2228 /// Uses the immediate operand \a M to perform a comparison of string
2229 /// data with explicitly defined lengths that is contained in source operands
2230 /// \a A and \a B. Returns 1 if the length of the string in \a A is less than
2231 /// the maximum, otherwise, returns 0.
2233 /// \headerfile <x86intrin.h>
2236 /// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M);
2239 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2243 /// A 128-bit integer vector containing one of the source operands to be
2246 /// An integer that specifies the length of the string in \a A.
2248 /// A 128-bit integer vector containing one of the source operands to be
2251 /// An integer that specifies the length of the string in \a B.
2253 /// An 8-bit immediate operand specifying whether the characters are bytes or
2254 /// words and the type of comparison to perform. \n
2255 /// Bits [1:0]: Determine source data format. \n
2256 /// 00: 16 unsigned bytes \n
2257 /// 01: 8 unsigned words \n
2258 /// 10: 16 signed bytes \n
2259 /// 11: 8 signed words \n
2260 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2261 /// 00: Subset: Each character in \a B is compared for equality with all
2262 /// the characters in \a A. \n
2263 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2264 /// basis is greater than or equal for even-indexed elements in \a A,
2265 /// and less than or equal for odd-indexed elements in \a A. \n
2266 /// 10: Match: Compare each pair of corresponding characters in \a A and
2267 /// \a B for equality. \n
2268 /// 11: Substring: Search \a B for substring matches of \a A. \n
2269 /// Bits [5:4]: Determine whether to perform a one's complement in the bit
2270 /// mask of the comparison results. \n
2271 /// 00: No effect. \n
2272 /// 01: Negate the bit mask. \n
2273 /// 10: No effect. \n
2274 /// 11: Negate the bit mask only for bits with an index less than or equal
2275 /// to the size of \a A or \a B. \n
2276 /// \returns Returns 1 if the length of the string in \a A is less than the
2277 /// maximum, otherwise, returns 0.
2278 #define _mm_cmpestrs(A, LA, B, LB, M) \
2279 (int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \
2280 (__v16qi)(__m128i)(B), (int)(LB), \
2283 /// Uses the immediate operand \a M to perform a comparison of string
2284 /// data with explicitly defined lengths that is contained in source operands
2285 /// \a A and \a B. Returns 1 if the length of the string in \a B is less than
2286 /// the maximum, otherwise, returns 0.
2288 /// \headerfile <x86intrin.h>
2291 /// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M);
2294 /// This intrinsic corresponds to the <c> VPCMPESTRI </c> instruction.
2297 /// A 128-bit integer vector containing one of the source operands to be
2300 /// An integer that specifies the length of the string in \a A.
2302 /// A 128-bit integer vector containing one of the source operands to be
2305 /// An integer that specifies the length of the string in \a B.
2307 /// An 8-bit immediate operand specifying whether the characters are bytes or
2308 /// words and the type of comparison to perform. \n
2309 /// Bits [1:0]: Determine source data format. \n
2310 /// 00: 16 unsigned bytes \n
2311 /// 01: 8 unsigned words \n
2312 /// 10: 16 signed bytes \n
2313 /// 11: 8 signed words \n
2314 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2315 /// 00: Subset: Each character in \a B is compared for equality with all
2316 /// the characters in \a A. \n
2317 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2318 /// basis is greater than or equal for even-indexed elements in \a A,
2319 /// and less than or equal for odd-indexed elements in \a A. \n
2320 /// 10: Match: Compare each pair of corresponding characters in \a A and
2321 /// \a B for equality. \n
2322 /// 11: Substring: Search \a B for substring matches of \a A. \n
2323 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2324 /// mask of the comparison results. \n
2325 /// 00: No effect. \n
2326 /// 01: Negate the bit mask. \n
2327 /// 10: No effect. \n
2328 /// 11: Negate the bit mask only for bits with an index less than or equal
2329 /// to the size of \a A or \a B.
2330 /// \returns Returns 1 if the length of the string in \a B is less than the
2331 /// maximum, otherwise, returns 0.
2332 #define _mm_cmpestrz(A, LA, B, LB, M) \
2333 (int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \
2334 (__v16qi)(__m128i)(B), (int)(LB), \
2337 /* SSE4.2 Compare Packed Data -- Greater Than. */
2338 /// Compares each of the corresponding 64-bit values of the 128-bit
2339 /// integer vectors to determine if the values in the first operand are
2340 /// greater than those in the second operand.
2342 /// \headerfile <x86intrin.h>
2344 /// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction.
2347 /// A 128-bit integer vector.
2349 /// A 128-bit integer vector.
2350 /// \returns A 128-bit integer vector containing the comparison results.
2351 static __inline__ __m128i __DEFAULT_FN_ATTRS
2352 _mm_cmpgt_epi64(__m128i __V1, __m128i __V2)
2354 return (__m128i)((__v2di)__V1 > (__v2di)__V2);
2357 /* SSE4.2 Accumulate CRC32. */
2358 /// Adds the unsigned integer operand to the CRC-32C checksum of the
2359 /// unsigned char operand.
2361 /// \headerfile <x86intrin.h>
2363 /// This intrinsic corresponds to the <c> CRC32B </c> instruction.
2366 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2369 /// An unsigned 8-bit integer operand used to compute the CRC-32C checksum.
2370 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2372 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2373 _mm_crc32_u8(unsigned int __C, unsigned char __D)
2375 return __builtin_ia32_crc32qi(__C, __D);
2378 /// Adds the unsigned integer operand to the CRC-32C checksum of the
2379 /// unsigned short operand.
2381 /// \headerfile <x86intrin.h>
2383 /// This intrinsic corresponds to the <c> CRC32W </c> instruction.
2386 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2389 /// An unsigned 16-bit integer operand used to compute the CRC-32C checksum.
2390 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2392 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2393 _mm_crc32_u16(unsigned int __C, unsigned short __D)
2395 return __builtin_ia32_crc32hi(__C, __D);
2398 /// Adds the first unsigned integer operand to the CRC-32C checksum of
2399 /// the second unsigned integer operand.
2401 /// \headerfile <x86intrin.h>
2403 /// This intrinsic corresponds to the <c> CRC32L </c> instruction.
2406 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2409 /// An unsigned 32-bit integer operand used to compute the CRC-32C checksum.
2410 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2412 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2413 _mm_crc32_u32(unsigned int __C, unsigned int __D)
2415 return __builtin_ia32_crc32si(__C, __D);
2419 /// Adds the unsigned integer operand to the CRC-32C checksum of the
2420 /// unsigned 64-bit integer operand.
2422 /// \headerfile <x86intrin.h>
2424 /// This intrinsic corresponds to the <c> CRC32Q </c> instruction.
2427 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2430 /// An unsigned 64-bit integer operand used to compute the CRC-32C checksum.
2431 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2433 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
2434 _mm_crc32_u64(unsigned long long __C, unsigned long long __D)
2436 return __builtin_ia32_crc32di(__C, __D);
2438 #endif /* __x86_64__ */
2440 #undef __DEFAULT_FN_ATTRS
2442 #include <popcntintrin.h>
2444 #endif /* __SMMINTRIN_H */