1 /*===---- smmintrin.h - SSE4 intrinsics ------------------------------------===
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===-----------------------------------------------------------------------===
13 #include <tmmintrin.h>
15 /* Define the default attributes for the functions in this file. */
16 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.1"), __min_vector_width__(128)))
18 /* SSE4 Rounding macros. */
19 #define _MM_FROUND_TO_NEAREST_INT 0x00
20 #define _MM_FROUND_TO_NEG_INF 0x01
21 #define _MM_FROUND_TO_POS_INF 0x02
22 #define _MM_FROUND_TO_ZERO 0x03
23 #define _MM_FROUND_CUR_DIRECTION 0x04
25 #define _MM_FROUND_RAISE_EXC 0x00
26 #define _MM_FROUND_NO_EXC 0x08
28 #define _MM_FROUND_NINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEAREST_INT)
29 #define _MM_FROUND_FLOOR (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEG_INF)
30 #define _MM_FROUND_CEIL (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_POS_INF)
31 #define _MM_FROUND_TRUNC (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_ZERO)
32 #define _MM_FROUND_RINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION)
33 #define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION)
35 /// Rounds up each element of the 128-bit vector of [4 x float] to an
36 /// integer and returns the rounded values in a 128-bit vector of
39 /// \headerfile <x86intrin.h>
42 /// __m128 _mm_ceil_ps(__m128 X);
45 /// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
48 /// A 128-bit vector of [4 x float] values to be rounded up.
49 /// \returns A 128-bit vector of [4 x float] containing the rounded values.
50 #define _mm_ceil_ps(X) _mm_round_ps((X), _MM_FROUND_CEIL)
52 /// Rounds up each element of the 128-bit vector of [2 x double] to an
53 /// integer and returns the rounded values in a 128-bit vector of
56 /// \headerfile <x86intrin.h>
59 /// __m128d _mm_ceil_pd(__m128d X);
62 /// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
65 /// A 128-bit vector of [2 x double] values to be rounded up.
66 /// \returns A 128-bit vector of [2 x double] containing the rounded values.
67 #define _mm_ceil_pd(X) _mm_round_pd((X), _MM_FROUND_CEIL)
69 /// Copies three upper elements of the first 128-bit vector operand to
70 /// the corresponding three upper elements of the 128-bit result vector of
71 /// [4 x float]. Rounds up the lowest element of the second 128-bit vector
72 /// operand to an integer and copies it to the lowest element of the 128-bit
73 /// result vector of [4 x float].
75 /// \headerfile <x86intrin.h>
78 /// __m128 _mm_ceil_ss(__m128 X, __m128 Y);
81 /// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
84 /// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
85 /// copied to the corresponding bits of the result.
87 /// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
88 /// rounded up to the nearest integer and copied to the corresponding bits
90 /// \returns A 128-bit vector of [4 x float] containing the copied and rounded
92 #define _mm_ceil_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_CEIL)
94 /// Copies the upper element of the first 128-bit vector operand to the
95 /// corresponding upper element of the 128-bit result vector of [2 x double].
96 /// Rounds up the lower element of the second 128-bit vector operand to an
97 /// integer and copies it to the lower element of the 128-bit result vector
100 /// \headerfile <x86intrin.h>
103 /// __m128d _mm_ceil_sd(__m128d X, __m128d Y);
106 /// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
109 /// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
110 /// copied to the corresponding bits of the result.
112 /// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
113 /// rounded up to the nearest integer and copied to the corresponding bits
115 /// \returns A 128-bit vector of [2 x double] containing the copied and rounded
117 #define _mm_ceil_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_CEIL)
119 /// Rounds down each element of the 128-bit vector of [4 x float] to an
120 /// an integer and returns the rounded values in a 128-bit vector of
123 /// \headerfile <x86intrin.h>
126 /// __m128 _mm_floor_ps(__m128 X);
129 /// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
132 /// A 128-bit vector of [4 x float] values to be rounded down.
133 /// \returns A 128-bit vector of [4 x float] containing the rounded values.
134 #define _mm_floor_ps(X) _mm_round_ps((X), _MM_FROUND_FLOOR)
136 /// Rounds down each element of the 128-bit vector of [2 x double] to an
137 /// integer and returns the rounded values in a 128-bit vector of
140 /// \headerfile <x86intrin.h>
143 /// __m128d _mm_floor_pd(__m128d X);
146 /// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
149 /// A 128-bit vector of [2 x double].
150 /// \returns A 128-bit vector of [2 x double] containing the rounded values.
151 #define _mm_floor_pd(X) _mm_round_pd((X), _MM_FROUND_FLOOR)
153 /// Copies three upper elements of the first 128-bit vector operand to
154 /// the corresponding three upper elements of the 128-bit result vector of
155 /// [4 x float]. Rounds down the lowest element of the second 128-bit vector
156 /// operand to an integer and copies it to the lowest element of the 128-bit
157 /// result vector of [4 x float].
159 /// \headerfile <x86intrin.h>
162 /// __m128 _mm_floor_ss(__m128 X, __m128 Y);
165 /// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
168 /// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
169 /// copied to the corresponding bits of the result.
171 /// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
172 /// rounded down to the nearest integer and copied to the corresponding bits
174 /// \returns A 128-bit vector of [4 x float] containing the copied and rounded
176 #define _mm_floor_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_FLOOR)
178 /// Copies the upper element of the first 128-bit vector operand to the
179 /// corresponding upper element of the 128-bit result vector of [2 x double].
180 /// Rounds down the lower element of the second 128-bit vector operand to an
181 /// integer and copies it to the lower element of the 128-bit result vector
184 /// \headerfile <x86intrin.h>
187 /// __m128d _mm_floor_sd(__m128d X, __m128d Y);
190 /// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
193 /// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
194 /// copied to the corresponding bits of the result.
196 /// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
197 /// rounded down to the nearest integer and copied to the corresponding bits
199 /// \returns A 128-bit vector of [2 x double] containing the copied and rounded
201 #define _mm_floor_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_FLOOR)
203 /// Rounds each element of the 128-bit vector of [4 x float] to an
204 /// integer value according to the rounding control specified by the second
205 /// argument and returns the rounded values in a 128-bit vector of
208 /// \headerfile <x86intrin.h>
211 /// __m128 _mm_round_ps(__m128 X, const int M);
214 /// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.
217 /// A 128-bit vector of [4 x float].
219 /// An integer value that specifies the rounding operation. \n
220 /// Bits [7:4] are reserved. \n
221 /// Bit [3] is a precision exception value: \n
222 /// 0: A normal PE exception is used \n
223 /// 1: The PE field is not updated \n
224 /// Bit [2] is the rounding control source: \n
225 /// 0: Use bits [1:0] of \a M \n
226 /// 1: Use the current MXCSR setting \n
227 /// Bits [1:0] contain the rounding control definition: \n
229 /// 01: Downward (toward negative infinity) \n
230 /// 10: Upward (toward positive infinity) \n
232 /// \returns A 128-bit vector of [4 x float] containing the rounded values.
233 #define _mm_round_ps(X, M) \
234 (__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M))
236 /// Copies three upper elements of the first 128-bit vector operand to
237 /// the corresponding three upper elements of the 128-bit result vector of
238 /// [4 x float]. Rounds the lowest element of the second 128-bit vector
239 /// operand to an integer value according to the rounding control specified
240 /// by the third argument and copies it to the lowest element of the 128-bit
241 /// result vector of [4 x float].
243 /// \headerfile <x86intrin.h>
246 /// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M);
249 /// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.
252 /// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
253 /// copied to the corresponding bits of the result.
255 /// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
256 /// rounded to the nearest integer using the specified rounding control and
257 /// copied to the corresponding bits of the result.
259 /// An integer value that specifies the rounding operation. \n
260 /// Bits [7:4] are reserved. \n
261 /// Bit [3] is a precision exception value: \n
262 /// 0: A normal PE exception is used \n
263 /// 1: The PE field is not updated \n
264 /// Bit [2] is the rounding control source: \n
265 /// 0: Use bits [1:0] of \a M \n
266 /// 1: Use the current MXCSR setting \n
267 /// Bits [1:0] contain the rounding control definition: \n
269 /// 01: Downward (toward negative infinity) \n
270 /// 10: Upward (toward positive infinity) \n
272 /// \returns A 128-bit vector of [4 x float] containing the copied and rounded
274 #define _mm_round_ss(X, Y, M) \
275 (__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), \
276 (__v4sf)(__m128)(Y), (M))
278 /// Rounds each element of the 128-bit vector of [2 x double] to an
279 /// integer value according to the rounding control specified by the second
280 /// argument and returns the rounded values in a 128-bit vector of
283 /// \headerfile <x86intrin.h>
286 /// __m128d _mm_round_pd(__m128d X, const int M);
289 /// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.
292 /// A 128-bit vector of [2 x double].
294 /// An integer value that specifies the rounding operation. \n
295 /// Bits [7:4] are reserved. \n
296 /// Bit [3] is a precision exception value: \n
297 /// 0: A normal PE exception is used \n
298 /// 1: The PE field is not updated \n
299 /// Bit [2] is the rounding control source: \n
300 /// 0: Use bits [1:0] of \a M \n
301 /// 1: Use the current MXCSR setting \n
302 /// Bits [1:0] contain the rounding control definition: \n
304 /// 01: Downward (toward negative infinity) \n
305 /// 10: Upward (toward positive infinity) \n
307 /// \returns A 128-bit vector of [2 x double] containing the rounded values.
308 #define _mm_round_pd(X, M) \
309 (__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M))
311 /// Copies the upper element of the first 128-bit vector operand to the
312 /// corresponding upper element of the 128-bit result vector of [2 x double].
313 /// Rounds the lower element of the second 128-bit vector operand to an
314 /// integer value according to the rounding control specified by the third
315 /// argument and copies it to the lower element of the 128-bit result vector
318 /// \headerfile <x86intrin.h>
321 /// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M);
324 /// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.
327 /// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
328 /// copied to the corresponding bits of the result.
330 /// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
331 /// rounded to the nearest integer using the specified rounding control and
332 /// copied to the corresponding bits of the result.
334 /// An integer value that specifies the rounding operation. \n
335 /// Bits [7:4] are reserved. \n
336 /// Bit [3] is a precision exception value: \n
337 /// 0: A normal PE exception is used \n
338 /// 1: The PE field is not updated \n
339 /// Bit [2] is the rounding control source: \n
340 /// 0: Use bits [1:0] of \a M \n
341 /// 1: Use the current MXCSR setting \n
342 /// Bits [1:0] contain the rounding control definition: \n
344 /// 01: Downward (toward negative infinity) \n
345 /// 10: Upward (toward positive infinity) \n
347 /// \returns A 128-bit vector of [2 x double] containing the copied and rounded
349 #define _mm_round_sd(X, Y, M) \
350 (__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), \
351 (__v2df)(__m128d)(Y), (M))
353 /* SSE4 Packed Blending Intrinsics. */
354 /// Returns a 128-bit vector of [2 x double] where the values are
355 /// selected from either the first or second operand as specified by the
356 /// third operand, the control mask.
358 /// \headerfile <x86intrin.h>
361 /// __m128d _mm_blend_pd(__m128d V1, __m128d V2, const int M);
364 /// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction.
367 /// A 128-bit vector of [2 x double].
369 /// A 128-bit vector of [2 x double].
371 /// An immediate integer operand, with mask bits [1:0] specifying how the
372 /// values are to be copied. The position of the mask bit corresponds to the
373 /// index of a copied value. When a mask bit is 0, the corresponding 64-bit
374 /// element in operand \a V1 is copied to the same position in the result.
375 /// When a mask bit is 1, the corresponding 64-bit element in operand \a V2
376 /// is copied to the same position in the result.
377 /// \returns A 128-bit vector of [2 x double] containing the copied values.
378 #define _mm_blend_pd(V1, V2, M) \
379 (__m128d) __builtin_ia32_blendpd ((__v2df)(__m128d)(V1), \
380 (__v2df)(__m128d)(V2), (int)(M))
382 /// Returns a 128-bit vector of [4 x float] where the values are selected
383 /// from either the first or second operand as specified by the third
384 /// operand, the control mask.
386 /// \headerfile <x86intrin.h>
389 /// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M);
392 /// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS </c> instruction.
395 /// A 128-bit vector of [4 x float].
397 /// A 128-bit vector of [4 x float].
399 /// An immediate integer operand, with mask bits [3:0] specifying how the
400 /// values are to be copied. The position of the mask bit corresponds to the
401 /// index of a copied value. When a mask bit is 0, the corresponding 32-bit
402 /// element in operand \a V1 is copied to the same position in the result.
403 /// When a mask bit is 1, the corresponding 32-bit element in operand \a V2
404 /// is copied to the same position in the result.
405 /// \returns A 128-bit vector of [4 x float] containing the copied values.
406 #define _mm_blend_ps(V1, V2, M) \
407 (__m128) __builtin_ia32_blendps ((__v4sf)(__m128)(V1), \
408 (__v4sf)(__m128)(V2), (int)(M))
410 /// Returns a 128-bit vector of [2 x double] where the values are
411 /// selected from either the first or second operand as specified by the
412 /// third operand, the control mask.
414 /// \headerfile <x86intrin.h>
416 /// This intrinsic corresponds to the <c> VBLENDVPD / BLENDVPD </c> instruction.
419 /// A 128-bit vector of [2 x double].
421 /// A 128-bit vector of [2 x double].
423 /// A 128-bit vector operand, with mask bits 127 and 63 specifying how the
424 /// values are to be copied. The position of the mask bit corresponds to the
425 /// most significant bit of a copied value. When a mask bit is 0, the
426 /// corresponding 64-bit element in operand \a __V1 is copied to the same
427 /// position in the result. When a mask bit is 1, the corresponding 64-bit
428 /// element in operand \a __V2 is copied to the same position in the result.
429 /// \returns A 128-bit vector of [2 x double] containing the copied values.
430 static __inline__ __m128d __DEFAULT_FN_ATTRS
431 _mm_blendv_pd (__m128d __V1, __m128d __V2, __m128d __M)
433 return (__m128d) __builtin_ia32_blendvpd ((__v2df)__V1, (__v2df)__V2,
437 /// Returns a 128-bit vector of [4 x float] where the values are
438 /// selected from either the first or second operand as specified by the
439 /// third operand, the control mask.
441 /// \headerfile <x86intrin.h>
443 /// This intrinsic corresponds to the <c> VBLENDVPS / BLENDVPS </c> instruction.
446 /// A 128-bit vector of [4 x float].
448 /// A 128-bit vector of [4 x float].
450 /// A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying
451 /// how the values are to be copied. The position of the mask bit corresponds
452 /// to the most significant bit of a copied value. When a mask bit is 0, the
453 /// corresponding 32-bit element in operand \a __V1 is copied to the same
454 /// position in the result. When a mask bit is 1, the corresponding 32-bit
455 /// element in operand \a __V2 is copied to the same position in the result.
456 /// \returns A 128-bit vector of [4 x float] containing the copied values.
457 static __inline__ __m128 __DEFAULT_FN_ATTRS
458 _mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M)
460 return (__m128) __builtin_ia32_blendvps ((__v4sf)__V1, (__v4sf)__V2,
464 /// Returns a 128-bit vector of [16 x i8] where the values are selected
465 /// from either of the first or second operand as specified by the third
466 /// operand, the control mask.
468 /// \headerfile <x86intrin.h>
470 /// This intrinsic corresponds to the <c> VPBLENDVB / PBLENDVB </c> instruction.
473 /// A 128-bit vector of [16 x i8].
475 /// A 128-bit vector of [16 x i8].
477 /// A 128-bit vector operand, with mask bits 127, 119, 111...7 specifying
478 /// how the values are to be copied. The position of the mask bit corresponds
479 /// to the most significant bit of a copied value. When a mask bit is 0, the
480 /// corresponding 8-bit element in operand \a __V1 is copied to the same
481 /// position in the result. When a mask bit is 1, the corresponding 8-bit
482 /// element in operand \a __V2 is copied to the same position in the result.
483 /// \returns A 128-bit vector of [16 x i8] containing the copied values.
484 static __inline__ __m128i __DEFAULT_FN_ATTRS
485 _mm_blendv_epi8 (__m128i __V1, __m128i __V2, __m128i __M)
487 return (__m128i) __builtin_ia32_pblendvb128 ((__v16qi)__V1, (__v16qi)__V2,
491 /// Returns a 128-bit vector of [8 x i16] where the values are selected
492 /// from either of the first or second operand as specified by the third
493 /// operand, the control mask.
495 /// \headerfile <x86intrin.h>
498 /// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M);
501 /// This intrinsic corresponds to the <c> VPBLENDW / PBLENDW </c> instruction.
504 /// A 128-bit vector of [8 x i16].
506 /// A 128-bit vector of [8 x i16].
508 /// An immediate integer operand, with mask bits [7:0] specifying how the
509 /// values are to be copied. The position of the mask bit corresponds to the
510 /// index of a copied value. When a mask bit is 0, the corresponding 16-bit
511 /// element in operand \a V1 is copied to the same position in the result.
512 /// When a mask bit is 1, the corresponding 16-bit element in operand \a V2
513 /// is copied to the same position in the result.
514 /// \returns A 128-bit vector of [8 x i16] containing the copied values.
515 #define _mm_blend_epi16(V1, V2, M) \
516 (__m128i) __builtin_ia32_pblendw128 ((__v8hi)(__m128i)(V1), \
517 (__v8hi)(__m128i)(V2), (int)(M))
519 /* SSE4 Dword Multiply Instructions. */
520 /// Multiples corresponding elements of two 128-bit vectors of [4 x i32]
521 /// and returns the lower 32 bits of the each product in a 128-bit vector of
524 /// \headerfile <x86intrin.h>
526 /// This intrinsic corresponds to the <c> VPMULLD / PMULLD </c> instruction.
529 /// A 128-bit integer vector.
531 /// A 128-bit integer vector.
532 /// \returns A 128-bit integer vector containing the products of both operands.
533 static __inline__ __m128i __DEFAULT_FN_ATTRS
534 _mm_mullo_epi32 (__m128i __V1, __m128i __V2)
536 return (__m128i) ((__v4su)__V1 * (__v4su)__V2);
539 /// Multiplies corresponding even-indexed elements of two 128-bit
540 /// vectors of [4 x i32] and returns a 128-bit vector of [2 x i64]
541 /// containing the products.
543 /// \headerfile <x86intrin.h>
545 /// This intrinsic corresponds to the <c> VPMULDQ / PMULDQ </c> instruction.
548 /// A 128-bit vector of [4 x i32].
550 /// A 128-bit vector of [4 x i32].
551 /// \returns A 128-bit vector of [2 x i64] containing the products of both
553 static __inline__ __m128i __DEFAULT_FN_ATTRS
554 _mm_mul_epi32 (__m128i __V1, __m128i __V2)
556 return (__m128i) __builtin_ia32_pmuldq128 ((__v4si)__V1, (__v4si)__V2);
559 /* SSE4 Floating Point Dot Product Instructions. */
560 /// Computes the dot product of the two 128-bit vectors of [4 x float]
561 /// and returns it in the elements of the 128-bit result vector of
564 /// The immediate integer operand controls which input elements
565 /// will contribute to the dot product, and where the final results are
568 /// \headerfile <x86intrin.h>
571 /// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M);
574 /// This intrinsic corresponds to the <c> VDPPS / DPPS </c> instruction.
577 /// A 128-bit vector of [4 x float].
579 /// A 128-bit vector of [4 x float].
581 /// An immediate integer operand. Mask bits [7:4] determine which elements
582 /// of the input vectors are used, with bit [4] corresponding to the lowest
583 /// element and bit [7] corresponding to the highest element of each [4 x
584 /// float] vector. If a bit is set, the corresponding elements from the two
585 /// input vectors are used as an input for dot product; otherwise that input
586 /// is treated as zero. Bits [3:0] determine which elements of the result
587 /// will receive a copy of the final dot product, with bit [0] corresponding
588 /// to the lowest element and bit [3] corresponding to the highest element of
589 /// each [4 x float] subvector. If a bit is set, the dot product is returned
590 /// in the corresponding element; otherwise that element is set to zero.
591 /// \returns A 128-bit vector of [4 x float] containing the dot product.
592 #define _mm_dp_ps(X, Y, M) \
593 (__m128) __builtin_ia32_dpps((__v4sf)(__m128)(X), \
594 (__v4sf)(__m128)(Y), (M))
596 /// Computes the dot product of the two 128-bit vectors of [2 x double]
597 /// and returns it in the elements of the 128-bit result vector of
600 /// The immediate integer operand controls which input
601 /// elements will contribute to the dot product, and where the final results
604 /// \headerfile <x86intrin.h>
607 /// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M);
610 /// This intrinsic corresponds to the <c> VDPPD / DPPD </c> instruction.
613 /// A 128-bit vector of [2 x double].
615 /// A 128-bit vector of [2 x double].
617 /// An immediate integer operand. Mask bits [5:4] determine which elements
618 /// of the input vectors are used, with bit [4] corresponding to the lowest
619 /// element and bit [5] corresponding to the highest element of each of [2 x
620 /// double] vector. If a bit is set, the corresponding elements from the two
621 /// input vectors are used as an input for dot product; otherwise that input
622 /// is treated as zero. Bits [1:0] determine which elements of the result
623 /// will receive a copy of the final dot product, with bit [0] corresponding
624 /// to the lowest element and bit [1] corresponding to the highest element of
625 /// each [2 x double] vector. If a bit is set, the dot product is returned in
626 /// the corresponding element; otherwise that element is set to zero.
627 #define _mm_dp_pd(X, Y, M) \
628 (__m128d) __builtin_ia32_dppd((__v2df)(__m128d)(X), \
629 (__v2df)(__m128d)(Y), (M))
631 /* SSE4 Streaming Load Hint Instruction. */
632 /// Loads integer values from a 128-bit aligned memory location to a
633 /// 128-bit integer vector.
635 /// \headerfile <x86intrin.h>
637 /// This intrinsic corresponds to the <c> VMOVNTDQA / MOVNTDQA </c> instruction.
640 /// A pointer to a 128-bit aligned memory location that contains the integer
642 /// \returns A 128-bit integer vector containing the data stored at the
643 /// specified memory location.
644 static __inline__ __m128i __DEFAULT_FN_ATTRS
645 _mm_stream_load_si128 (__m128i const *__V)
647 return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V);
650 /* SSE4 Packed Integer Min/Max Instructions. */
651 /// Compares the corresponding elements of two 128-bit vectors of
652 /// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser
653 /// of the two values.
655 /// \headerfile <x86intrin.h>
657 /// This intrinsic corresponds to the <c> VPMINSB / PMINSB </c> instruction.
660 /// A 128-bit vector of [16 x i8].
662 /// A 128-bit vector of [16 x i8]
663 /// \returns A 128-bit vector of [16 x i8] containing the lesser values.
664 static __inline__ __m128i __DEFAULT_FN_ATTRS
665 _mm_min_epi8 (__m128i __V1, __m128i __V2)
667 return (__m128i) __builtin_ia32_pminsb128 ((__v16qi) __V1, (__v16qi) __V2);
670 /// Compares the corresponding elements of two 128-bit vectors of
671 /// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the
672 /// greater value of the two.
674 /// \headerfile <x86intrin.h>
676 /// This intrinsic corresponds to the <c> VPMAXSB / PMAXSB </c> instruction.
679 /// A 128-bit vector of [16 x i8].
681 /// A 128-bit vector of [16 x i8].
682 /// \returns A 128-bit vector of [16 x i8] containing the greater values.
683 static __inline__ __m128i __DEFAULT_FN_ATTRS
684 _mm_max_epi8 (__m128i __V1, __m128i __V2)
686 return (__m128i) __builtin_ia32_pmaxsb128 ((__v16qi) __V1, (__v16qi) __V2);
689 /// Compares the corresponding elements of two 128-bit vectors of
690 /// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser
691 /// value of the two.
693 /// \headerfile <x86intrin.h>
695 /// This intrinsic corresponds to the <c> VPMINUW / PMINUW </c> instruction.
698 /// A 128-bit vector of [8 x u16].
700 /// A 128-bit vector of [8 x u16].
701 /// \returns A 128-bit vector of [8 x u16] containing the lesser values.
702 static __inline__ __m128i __DEFAULT_FN_ATTRS
703 _mm_min_epu16 (__m128i __V1, __m128i __V2)
705 return (__m128i) __builtin_ia32_pminuw128 ((__v8hi) __V1, (__v8hi) __V2);
708 /// Compares the corresponding elements of two 128-bit vectors of
709 /// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the
710 /// greater value of the two.
712 /// \headerfile <x86intrin.h>
714 /// This intrinsic corresponds to the <c> VPMAXUW / PMAXUW </c> instruction.
717 /// A 128-bit vector of [8 x u16].
719 /// A 128-bit vector of [8 x u16].
720 /// \returns A 128-bit vector of [8 x u16] containing the greater values.
721 static __inline__ __m128i __DEFAULT_FN_ATTRS
722 _mm_max_epu16 (__m128i __V1, __m128i __V2)
724 return (__m128i) __builtin_ia32_pmaxuw128 ((__v8hi) __V1, (__v8hi) __V2);
727 /// Compares the corresponding elements of two 128-bit vectors of
728 /// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser
729 /// value of the two.
731 /// \headerfile <x86intrin.h>
733 /// This intrinsic corresponds to the <c> VPMINSD / PMINSD </c> instruction.
736 /// A 128-bit vector of [4 x i32].
738 /// A 128-bit vector of [4 x i32].
739 /// \returns A 128-bit vector of [4 x i32] containing the lesser values.
740 static __inline__ __m128i __DEFAULT_FN_ATTRS
741 _mm_min_epi32 (__m128i __V1, __m128i __V2)
743 return (__m128i) __builtin_ia32_pminsd128 ((__v4si) __V1, (__v4si) __V2);
746 /// Compares the corresponding elements of two 128-bit vectors of
747 /// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the
748 /// greater value of the two.
750 /// \headerfile <x86intrin.h>
752 /// This intrinsic corresponds to the <c> VPMAXSD / PMAXSD </c> instruction.
755 /// A 128-bit vector of [4 x i32].
757 /// A 128-bit vector of [4 x i32].
758 /// \returns A 128-bit vector of [4 x i32] containing the greater values.
759 static __inline__ __m128i __DEFAULT_FN_ATTRS
760 _mm_max_epi32 (__m128i __V1, __m128i __V2)
762 return (__m128i) __builtin_ia32_pmaxsd128 ((__v4si) __V1, (__v4si) __V2);
765 /// Compares the corresponding elements of two 128-bit vectors of
766 /// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser
767 /// value of the two.
769 /// \headerfile <x86intrin.h>
771 /// This intrinsic corresponds to the <c> VPMINUD / PMINUD </c> instruction.
774 /// A 128-bit vector of [4 x u32].
776 /// A 128-bit vector of [4 x u32].
777 /// \returns A 128-bit vector of [4 x u32] containing the lesser values.
778 static __inline__ __m128i __DEFAULT_FN_ATTRS
779 _mm_min_epu32 (__m128i __V1, __m128i __V2)
781 return (__m128i) __builtin_ia32_pminud128((__v4si) __V1, (__v4si) __V2);
784 /// Compares the corresponding elements of two 128-bit vectors of
785 /// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the
786 /// greater value of the two.
788 /// \headerfile <x86intrin.h>
790 /// This intrinsic corresponds to the <c> VPMAXUD / PMAXUD </c> instruction.
793 /// A 128-bit vector of [4 x u32].
795 /// A 128-bit vector of [4 x u32].
796 /// \returns A 128-bit vector of [4 x u32] containing the greater values.
797 static __inline__ __m128i __DEFAULT_FN_ATTRS
798 _mm_max_epu32 (__m128i __V1, __m128i __V2)
800 return (__m128i) __builtin_ia32_pmaxud128((__v4si) __V1, (__v4si) __V2);
803 /* SSE4 Insertion and Extraction from XMM Register Instructions. */
804 /// Takes the first argument \a X and inserts an element from the second
805 /// argument \a Y as selected by the third argument \a N. That result then
806 /// has elements zeroed out also as selected by the third argument \a N. The
807 /// resulting 128-bit vector of [4 x float] is then returned.
809 /// \headerfile <x86intrin.h>
812 /// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N);
815 /// This intrinsic corresponds to the <c> VINSERTPS </c> instruction.
818 /// A 128-bit vector source operand of [4 x float]. With the exception of
819 /// those bits in the result copied from parameter \a Y and zeroed by bits
820 /// [3:0] of \a N, all bits from this parameter are copied to the result.
822 /// A 128-bit vector source operand of [4 x float]. One single-precision
823 /// floating-point element from this source, as determined by the immediate
824 /// parameter, is copied to the result.
826 /// Specifies which bits from operand \a Y will be copied, which bits in the
827 /// result they will be be copied to, and which bits in the result will be
828 /// cleared. The following assignments are made: \n
829 /// Bits [7:6] specify the bits to copy from operand \a Y: \n
830 /// 00: Selects bits [31:0] from operand \a Y. \n
831 /// 01: Selects bits [63:32] from operand \a Y. \n
832 /// 10: Selects bits [95:64] from operand \a Y. \n
833 /// 11: Selects bits [127:96] from operand \a Y. \n
834 /// Bits [5:4] specify the bits in the result to which the selected bits
835 /// from operand \a Y are copied: \n
836 /// 00: Copies the selected bits from \a Y to result bits [31:0]. \n
837 /// 01: Copies the selected bits from \a Y to result bits [63:32]. \n
838 /// 10: Copies the selected bits from \a Y to result bits [95:64]. \n
839 /// 11: Copies the selected bits from \a Y to result bits [127:96]. \n
840 /// Bits[3:0]: If any of these bits are set, the corresponding result
841 /// element is cleared.
842 /// \returns A 128-bit vector of [4 x float] containing the copied
843 /// single-precision floating point elements from the operands.
844 #define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))
846 /// Extracts a 32-bit integer from a 128-bit vector of [4 x float] and
847 /// returns it, using the immediate value parameter \a N as a selector.
849 /// \headerfile <x86intrin.h>
852 /// int _mm_extract_ps(__m128 X, const int N);
855 /// This intrinsic corresponds to the <c> VEXTRACTPS / EXTRACTPS </c>
859 /// A 128-bit vector of [4 x float].
861 /// An immediate value. Bits [1:0] determines which bits from the argument
862 /// \a X are extracted and returned: \n
863 /// 00: Bits [31:0] of parameter \a X are returned. \n
864 /// 01: Bits [63:32] of parameter \a X are returned. \n
865 /// 10: Bits [95:64] of parameter \a X are returned. \n
866 /// 11: Bits [127:96] of parameter \a X are returned.
867 /// \returns A 32-bit integer containing the extracted 32 bits of float data.
868 #define _mm_extract_ps(X, N) (__extension__ \
869 ({ union { int __i; float __f; } __t; \
870 __t.__f = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); \
873 /* Miscellaneous insert and extract macros. */
874 /* Extract a single-precision float from X at index N into D. */
875 #define _MM_EXTRACT_FLOAT(D, X, N) \
876 { (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); }
878 /* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create
879 an index suitable for _mm_insert_ps. */
880 #define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z))
882 /* Extract a float from X at index N into the first index of the return. */
883 #define _MM_PICK_OUT_PS(X, N) _mm_insert_ps (_mm_setzero_ps(), (X), \
884 _MM_MK_INSERTPS_NDX((N), 0, 0x0e))
886 /* Insert int into packed integer array at index. */
887 /// Constructs a 128-bit vector of [16 x i8] by first making a copy of
888 /// the 128-bit integer vector parameter, and then inserting the lower 8 bits
889 /// of an integer parameter \a I into an offset specified by the immediate
890 /// value parameter \a N.
892 /// \headerfile <x86intrin.h>
895 /// __m128i _mm_insert_epi8(__m128i X, int I, const int N);
898 /// This intrinsic corresponds to the <c> VPINSRB / PINSRB </c> instruction.
901 /// A 128-bit integer vector of [16 x i8]. This vector is copied to the
902 /// result and then one of the sixteen elements in the result vector is
903 /// replaced by the lower 8 bits of \a I.
905 /// An integer. The lower 8 bits of this operand are written to the result
906 /// beginning at the offset specified by \a N.
908 /// An immediate value. Bits [3:0] specify the bit offset in the result at
909 /// which the lower 8 bits of \a I are written. \n
910 /// 0000: Bits [7:0] of the result are used for insertion. \n
911 /// 0001: Bits [15:8] of the result are used for insertion. \n
912 /// 0010: Bits [23:16] of the result are used for insertion. \n
913 /// 0011: Bits [31:24] of the result are used for insertion. \n
914 /// 0100: Bits [39:32] of the result are used for insertion. \n
915 /// 0101: Bits [47:40] of the result are used for insertion. \n
916 /// 0110: Bits [55:48] of the result are used for insertion. \n
917 /// 0111: Bits [63:56] of the result are used for insertion. \n
918 /// 1000: Bits [71:64] of the result are used for insertion. \n
919 /// 1001: Bits [79:72] of the result are used for insertion. \n
920 /// 1010: Bits [87:80] of the result are used for insertion. \n
921 /// 1011: Bits [95:88] of the result are used for insertion. \n
922 /// 1100: Bits [103:96] of the result are used for insertion. \n
923 /// 1101: Bits [111:104] of the result are used for insertion. \n
924 /// 1110: Bits [119:112] of the result are used for insertion. \n
925 /// 1111: Bits [127:120] of the result are used for insertion.
926 /// \returns A 128-bit integer vector containing the constructed values.
927 #define _mm_insert_epi8(X, I, N) \
928 (__m128i)__builtin_ia32_vec_set_v16qi((__v16qi)(__m128i)(X), \
931 /// Constructs a 128-bit vector of [4 x i32] by first making a copy of
932 /// the 128-bit integer vector parameter, and then inserting the 32-bit
933 /// integer parameter \a I at the offset specified by the immediate value
936 /// \headerfile <x86intrin.h>
939 /// __m128i _mm_insert_epi32(__m128i X, int I, const int N);
942 /// This intrinsic corresponds to the <c> VPINSRD / PINSRD </c> instruction.
945 /// A 128-bit integer vector of [4 x i32]. This vector is copied to the
946 /// result and then one of the four elements in the result vector is
947 /// replaced by \a I.
949 /// A 32-bit integer that is written to the result beginning at the offset
950 /// specified by \a N.
952 /// An immediate value. Bits [1:0] specify the bit offset in the result at
953 /// which the integer \a I is written. \n
954 /// 00: Bits [31:0] of the result are used for insertion. \n
955 /// 01: Bits [63:32] of the result are used for insertion. \n
956 /// 10: Bits [95:64] of the result are used for insertion. \n
957 /// 11: Bits [127:96] of the result are used for insertion.
958 /// \returns A 128-bit integer vector containing the constructed values.
959 #define _mm_insert_epi32(X, I, N) \
960 (__m128i)__builtin_ia32_vec_set_v4si((__v4si)(__m128i)(X), \
964 /// Constructs a 128-bit vector of [2 x i64] by first making a copy of
965 /// the 128-bit integer vector parameter, and then inserting the 64-bit
966 /// integer parameter \a I, using the immediate value parameter \a N as an
967 /// insertion location selector.
969 /// \headerfile <x86intrin.h>
972 /// __m128i _mm_insert_epi64(__m128i X, long long I, const int N);
975 /// This intrinsic corresponds to the <c> VPINSRQ / PINSRQ </c> instruction.
978 /// A 128-bit integer vector of [2 x i64]. This vector is copied to the
979 /// result and then one of the two elements in the result vector is replaced
982 /// A 64-bit integer that is written to the result beginning at the offset
983 /// specified by \a N.
985 /// An immediate value. Bit [0] specifies the bit offset in the result at
986 /// which the integer \a I is written. \n
987 /// 0: Bits [63:0] of the result are used for insertion. \n
988 /// 1: Bits [127:64] of the result are used for insertion. \n
989 /// \returns A 128-bit integer vector containing the constructed values.
990 #define _mm_insert_epi64(X, I, N) \
991 (__m128i)__builtin_ia32_vec_set_v2di((__v2di)(__m128i)(X), \
992 (long long)(I), (int)(N))
993 #endif /* __x86_64__ */
995 /* Extract int from packed integer array at index. This returns the element
996 * as a zero extended value, so it is unsigned.
998 /// Extracts an 8-bit element from the 128-bit integer vector of
999 /// [16 x i8], using the immediate value parameter \a N as a selector.
1001 /// \headerfile <x86intrin.h>
1004 /// int _mm_extract_epi8(__m128i X, const int N);
1007 /// This intrinsic corresponds to the <c> VPEXTRB / PEXTRB </c> instruction.
1010 /// A 128-bit integer vector.
1012 /// An immediate value. Bits [3:0] specify which 8-bit vector element from
1013 /// the argument \a X to extract and copy to the result. \n
1014 /// 0000: Bits [7:0] of parameter \a X are extracted. \n
1015 /// 0001: Bits [15:8] of the parameter \a X are extracted. \n
1016 /// 0010: Bits [23:16] of the parameter \a X are extracted. \n
1017 /// 0011: Bits [31:24] of the parameter \a X are extracted. \n
1018 /// 0100: Bits [39:32] of the parameter \a X are extracted. \n
1019 /// 0101: Bits [47:40] of the parameter \a X are extracted. \n
1020 /// 0110: Bits [55:48] of the parameter \a X are extracted. \n
1021 /// 0111: Bits [63:56] of the parameter \a X are extracted. \n
1022 /// 1000: Bits [71:64] of the parameter \a X are extracted. \n
1023 /// 1001: Bits [79:72] of the parameter \a X are extracted. \n
1024 /// 1010: Bits [87:80] of the parameter \a X are extracted. \n
1025 /// 1011: Bits [95:88] of the parameter \a X are extracted. \n
1026 /// 1100: Bits [103:96] of the parameter \a X are extracted. \n
1027 /// 1101: Bits [111:104] of the parameter \a X are extracted. \n
1028 /// 1110: Bits [119:112] of the parameter \a X are extracted. \n
1029 /// 1111: Bits [127:120] of the parameter \a X are extracted.
1030 /// \returns An unsigned integer, whose lower 8 bits are selected from the
1031 /// 128-bit integer vector parameter and the remaining bits are assigned
1033 #define _mm_extract_epi8(X, N) \
1034 (int)(unsigned char)__builtin_ia32_vec_ext_v16qi((__v16qi)(__m128i)(X), \
1037 /// Extracts a 32-bit element from the 128-bit integer vector of
1038 /// [4 x i32], using the immediate value parameter \a N as a selector.
1040 /// \headerfile <x86intrin.h>
1043 /// int _mm_extract_epi32(__m128i X, const int N);
1046 /// This intrinsic corresponds to the <c> VPEXTRD / PEXTRD </c> instruction.
1049 /// A 128-bit integer vector.
1051 /// An immediate value. Bits [1:0] specify which 32-bit vector element from
1052 /// the argument \a X to extract and copy to the result. \n
1053 /// 00: Bits [31:0] of the parameter \a X are extracted. \n
1054 /// 01: Bits [63:32] of the parameter \a X are extracted. \n
1055 /// 10: Bits [95:64] of the parameter \a X are extracted. \n
1056 /// 11: Bits [127:96] of the parameter \a X are exracted.
1057 /// \returns An integer, whose lower 32 bits are selected from the 128-bit
1058 /// integer vector parameter and the remaining bits are assigned zeros.
1059 #define _mm_extract_epi32(X, N) \
1060 (int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N))
1063 /// Extracts a 64-bit element from the 128-bit integer vector of
1064 /// [2 x i64], using the immediate value parameter \a N as a selector.
1066 /// \headerfile <x86intrin.h>
1069 /// long long _mm_extract_epi64(__m128i X, const int N);
1072 /// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
1075 /// A 128-bit integer vector.
1077 /// An immediate value. Bit [0] specifies which 64-bit vector element from
1078 /// the argument \a X to return. \n
1079 /// 0: Bits [63:0] are returned. \n
1080 /// 1: Bits [127:64] are returned. \n
1081 /// \returns A 64-bit integer.
1082 #define _mm_extract_epi64(X, N) \
1083 (long long)__builtin_ia32_vec_ext_v2di((__v2di)(__m128i)(X), (int)(N))
1084 #endif /* __x86_64 */
1086 /* SSE4 128-bit Packed Integer Comparisons. */
1087 /// Tests whether the specified bits in a 128-bit integer vector are all
1090 /// \headerfile <x86intrin.h>
1092 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1095 /// A 128-bit integer vector containing the bits to be tested.
1097 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1098 /// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1099 static __inline__ int __DEFAULT_FN_ATTRS
1100 _mm_testz_si128(__m128i __M, __m128i __V)
1102 return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V);
1105 /// Tests whether the specified bits in a 128-bit integer vector are all
1108 /// \headerfile <x86intrin.h>
1110 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1113 /// A 128-bit integer vector containing the bits to be tested.
1115 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1116 /// \returns TRUE if the specified bits are all ones; FALSE otherwise.
1117 static __inline__ int __DEFAULT_FN_ATTRS
1118 _mm_testc_si128(__m128i __M, __m128i __V)
1120 return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V);
1123 /// Tests whether the specified bits in a 128-bit integer vector are
1124 /// neither all zeros nor all ones.
1126 /// \headerfile <x86intrin.h>
1128 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1131 /// A 128-bit integer vector containing the bits to be tested.
1133 /// A 128-bit integer vector selecting which bits to test in operand \a __M.
1134 /// \returns TRUE if the specified bits are neither all zeros nor all ones;
1135 /// FALSE otherwise.
1136 static __inline__ int __DEFAULT_FN_ATTRS
1137 _mm_testnzc_si128(__m128i __M, __m128i __V)
1139 return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V);
1142 /// Tests whether the specified bits in a 128-bit integer vector are all
1145 /// \headerfile <x86intrin.h>
1148 /// int _mm_test_all_ones(__m128i V);
1151 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1154 /// A 128-bit integer vector containing the bits to be tested.
1155 /// \returns TRUE if the bits specified in the operand are all set to 1; FALSE
1157 #define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V)))
1159 /// Tests whether the specified bits in a 128-bit integer vector are
1160 /// neither all zeros nor all ones.
1162 /// \headerfile <x86intrin.h>
1165 /// int _mm_test_mix_ones_zeros(__m128i M, __m128i V);
1168 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1171 /// A 128-bit integer vector containing the bits to be tested.
1173 /// A 128-bit integer vector selecting which bits to test in operand \a M.
1174 /// \returns TRUE if the specified bits are neither all zeros nor all ones;
1175 /// FALSE otherwise.
1176 #define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V))
1178 /// Tests whether the specified bits in a 128-bit integer vector are all
1181 /// \headerfile <x86intrin.h>
1184 /// int _mm_test_all_zeros(__m128i M, __m128i V);
1187 /// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.
1190 /// A 128-bit integer vector containing the bits to be tested.
1192 /// A 128-bit integer vector selecting which bits to test in operand \a M.
1193 /// \returns TRUE if the specified bits are all zeros; FALSE otherwise.
1194 #define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V))
1196 /* SSE4 64-bit Packed Integer Comparisons. */
1197 /// Compares each of the corresponding 64-bit values of the 128-bit
1198 /// integer vectors for equality.
1200 /// \headerfile <x86intrin.h>
1202 /// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction.
1205 /// A 128-bit integer vector.
1207 /// A 128-bit integer vector.
1208 /// \returns A 128-bit integer vector containing the comparison results.
1209 static __inline__ __m128i __DEFAULT_FN_ATTRS
1210 _mm_cmpeq_epi64(__m128i __V1, __m128i __V2)
1212 return (__m128i)((__v2di)__V1 == (__v2di)__V2);
1215 /* SSE4 Packed Integer Sign-Extension. */
1216 /// Sign-extends each of the lower eight 8-bit integer elements of a
1217 /// 128-bit vector of [16 x i8] to 16-bit values and returns them in a
1218 /// 128-bit vector of [8 x i16]. The upper eight elements of the input vector
1221 /// \headerfile <x86intrin.h>
1223 /// This intrinsic corresponds to the <c> VPMOVSXBW / PMOVSXBW </c> instruction.
1226 /// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are sign-
1227 /// extended to 16-bit values.
1228 /// \returns A 128-bit vector of [8 x i16] containing the sign-extended values.
1229 static __inline__ __m128i __DEFAULT_FN_ATTRS
1230 _mm_cvtepi8_epi16(__m128i __V)
1232 /* This function always performs a signed extension, but __v16qi is a char
1233 which may be signed or unsigned, so use __v16qs. */
1234 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1237 /// Sign-extends each of the lower four 8-bit integer elements of a
1238 /// 128-bit vector of [16 x i8] to 32-bit values and returns them in a
1239 /// 128-bit vector of [4 x i32]. The upper twelve elements of the input
1240 /// vector are unused.
1242 /// \headerfile <x86intrin.h>
1244 /// This intrinsic corresponds to the <c> VPMOVSXBD / PMOVSXBD </c> instruction.
1247 /// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
1248 /// sign-extended to 32-bit values.
1249 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1250 static __inline__ __m128i __DEFAULT_FN_ATTRS
1251 _mm_cvtepi8_epi32(__m128i __V)
1253 /* This function always performs a signed extension, but __v16qi is a char
1254 which may be signed or unsigned, so use __v16qs. */
1255 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si);
1258 /// Sign-extends each of the lower two 8-bit integer elements of a
1259 /// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1260 /// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1261 /// vector are unused.
1263 /// \headerfile <x86intrin.h>
1265 /// This intrinsic corresponds to the <c> VPMOVSXBQ / PMOVSXBQ </c> instruction.
1268 /// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
1269 /// sign-extended to 64-bit values.
1270 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1271 static __inline__ __m128i __DEFAULT_FN_ATTRS
1272 _mm_cvtepi8_epi64(__m128i __V)
1274 /* This function always performs a signed extension, but __v16qi is a char
1275 which may be signed or unsigned, so use __v16qs. */
1276 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di);
1279 /// Sign-extends each of the lower four 16-bit integer elements of a
1280 /// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1281 /// a 128-bit vector of [4 x i32]. The upper four elements of the input
1282 /// vector are unused.
1284 /// \headerfile <x86intrin.h>
1286 /// This intrinsic corresponds to the <c> VPMOVSXWD / PMOVSXWD </c> instruction.
1289 /// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
1290 /// sign-extended to 32-bit values.
1291 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
1292 static __inline__ __m128i __DEFAULT_FN_ATTRS
1293 _mm_cvtepi16_epi32(__m128i __V)
1295 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si);
1298 /// Sign-extends each of the lower two 16-bit integer elements of a
1299 /// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1300 /// a 128-bit vector of [2 x i64]. The upper six elements of the input
1301 /// vector are unused.
1303 /// \headerfile <x86intrin.h>
1305 /// This intrinsic corresponds to the <c> VPMOVSXWQ / PMOVSXWQ </c> instruction.
1308 /// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
1309 /// sign-extended to 64-bit values.
1310 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1311 static __inline__ __m128i __DEFAULT_FN_ATTRS
1312 _mm_cvtepi16_epi64(__m128i __V)
1314 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di);
1317 /// Sign-extends each of the lower two 32-bit integer elements of a
1318 /// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1319 /// a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1322 /// \headerfile <x86intrin.h>
1324 /// This intrinsic corresponds to the <c> VPMOVSXDQ / PMOVSXDQ </c> instruction.
1327 /// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
1328 /// sign-extended to 64-bit values.
1329 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
1330 static __inline__ __m128i __DEFAULT_FN_ATTRS
1331 _mm_cvtepi32_epi64(__m128i __V)
1333 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di);
1336 /* SSE4 Packed Integer Zero-Extension. */
1337 /// Zero-extends each of the lower eight 8-bit integer elements of a
1338 /// 128-bit vector of [16 x i8] to 16-bit values and returns them in a
1339 /// 128-bit vector of [8 x i16]. The upper eight elements of the input vector
1342 /// \headerfile <x86intrin.h>
1344 /// This intrinsic corresponds to the <c> VPMOVZXBW / PMOVZXBW </c> instruction.
1347 /// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are
1348 /// zero-extended to 16-bit values.
1349 /// \returns A 128-bit vector of [8 x i16] containing the zero-extended values.
1350 static __inline__ __m128i __DEFAULT_FN_ATTRS
1351 _mm_cvtepu8_epi16(__m128i __V)
1353 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi);
1356 /// Zero-extends each of the lower four 8-bit integer elements of a
1357 /// 128-bit vector of [16 x i8] to 32-bit values and returns them in a
1358 /// 128-bit vector of [4 x i32]. The upper twelve elements of the input
1359 /// vector are unused.
1361 /// \headerfile <x86intrin.h>
1363 /// This intrinsic corresponds to the <c> VPMOVZXBD / PMOVZXBD </c> instruction.
1366 /// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
1367 /// zero-extended to 32-bit values.
1368 /// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1369 static __inline__ __m128i __DEFAULT_FN_ATTRS
1370 _mm_cvtepu8_epi32(__m128i __V)
1372 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si);
1375 /// Zero-extends each of the lower two 8-bit integer elements of a
1376 /// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in
1377 /// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input
1378 /// vector are unused.
1380 /// \headerfile <x86intrin.h>
1382 /// This intrinsic corresponds to the <c> VPMOVZXBQ / PMOVZXBQ </c> instruction.
1385 /// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
1386 /// zero-extended to 64-bit values.
1387 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1388 static __inline__ __m128i __DEFAULT_FN_ATTRS
1389 _mm_cvtepu8_epi64(__m128i __V)
1391 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di);
1394 /// Zero-extends each of the lower four 16-bit integer elements of a
1395 /// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in
1396 /// a 128-bit vector of [4 x i32]. The upper four elements of the input
1397 /// vector are unused.
1399 /// \headerfile <x86intrin.h>
1401 /// This intrinsic corresponds to the <c> VPMOVZXWD / PMOVZXWD </c> instruction.
1404 /// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
1405 /// zero-extended to 32-bit values.
1406 /// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.
1407 static __inline__ __m128i __DEFAULT_FN_ATTRS
1408 _mm_cvtepu16_epi32(__m128i __V)
1410 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si);
1413 /// Zero-extends each of the lower two 16-bit integer elements of a
1414 /// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in
1415 /// a 128-bit vector of [2 x i64]. The upper six elements of the input vector
1418 /// \headerfile <x86intrin.h>
1420 /// This intrinsic corresponds to the <c> VPMOVZXWQ / PMOVZXWQ </c> instruction.
1423 /// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
1424 /// zero-extended to 64-bit values.
1425 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1426 static __inline__ __m128i __DEFAULT_FN_ATTRS
1427 _mm_cvtepu16_epi64(__m128i __V)
1429 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di);
1432 /// Zero-extends each of the lower two 32-bit integer elements of a
1433 /// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in
1434 /// a 128-bit vector of [2 x i64]. The upper two elements of the input vector
1437 /// \headerfile <x86intrin.h>
1439 /// This intrinsic corresponds to the <c> VPMOVZXDQ / PMOVZXDQ </c> instruction.
1442 /// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
1443 /// zero-extended to 64-bit values.
1444 /// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.
1445 static __inline__ __m128i __DEFAULT_FN_ATTRS
1446 _mm_cvtepu32_epi64(__m128i __V)
1448 return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di);
1451 /* SSE4 Pack with Unsigned Saturation. */
1452 /// Converts 32-bit signed integers from both 128-bit integer vector
1453 /// operands into 16-bit unsigned integers, and returns the packed result.
1454 /// Values greater than 0xFFFF are saturated to 0xFFFF. Values less than
1455 /// 0x0000 are saturated to 0x0000.
1457 /// \headerfile <x86intrin.h>
1459 /// This intrinsic corresponds to the <c> VPACKUSDW / PACKUSDW </c> instruction.
1462 /// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1463 /// signed integer and is converted to a 16-bit unsigned integer with
1464 /// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1465 /// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1466 /// are written to the lower 64 bits of the result.
1468 /// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a
1469 /// signed integer and is converted to a 16-bit unsigned integer with
1470 /// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values
1471 /// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values
1472 /// are written to the higher 64 bits of the result.
1473 /// \returns A 128-bit vector of [8 x i16] containing the converted values.
1474 static __inline__ __m128i __DEFAULT_FN_ATTRS
1475 _mm_packus_epi32(__m128i __V1, __m128i __V2)
1477 return (__m128i) __builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2);
1480 /* SSE4 Multiple Packed Sums of Absolute Difference. */
1481 /// Subtracts 8-bit unsigned integer values and computes the absolute
1482 /// values of the differences to the corresponding bits in the destination.
1483 /// Then sums of the absolute differences are returned according to the bit
1484 /// fields in the immediate operand.
1486 /// \headerfile <x86intrin.h>
1489 /// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M);
1492 /// This intrinsic corresponds to the <c> VMPSADBW / MPSADBW </c> instruction.
1495 /// A 128-bit vector of [16 x i8].
1497 /// A 128-bit vector of [16 x i8].
1499 /// An 8-bit immediate operand specifying how the absolute differences are to
1500 /// be calculated, according to the following algorithm:
1502 /// // M2 represents bit 2 of the immediate operand
1503 /// // M10 represents bits [1:0] of the immediate operand
1506 /// for (k = 0; k < 8; k = k + 1) {
1507 /// d0 = abs(X[i + k + 0] - Y[j + 0]);
1508 /// d1 = abs(X[i + k + 1] - Y[j + 1]);
1509 /// d2 = abs(X[i + k + 2] - Y[j + 2]);
1510 /// d3 = abs(X[i + k + 3] - Y[j + 3]);
1511 /// r[k] = d0 + d1 + d2 + d3;
1514 /// \returns A 128-bit integer vector containing the sums of the sets of
1515 /// absolute differences between both operands.
1516 #define _mm_mpsadbw_epu8(X, Y, M) \
1517 (__m128i) __builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \
1518 (__v16qi)(__m128i)(Y), (M))
1520 /// Finds the minimum unsigned 16-bit element in the input 128-bit
1521 /// vector of [8 x u16] and returns it and along with its index.
1523 /// \headerfile <x86intrin.h>
1525 /// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c>
1529 /// A 128-bit vector of [8 x u16].
1530 /// \returns A 128-bit value where bits [15:0] contain the minimum value found
1531 /// in parameter \a __V, bits [18:16] contain the index of the minimum value
1532 /// and the remaining bits are set to 0.
1533 static __inline__ __m128i __DEFAULT_FN_ATTRS
1534 _mm_minpos_epu16(__m128i __V)
1536 return (__m128i) __builtin_ia32_phminposuw128((__v8hi)__V);
1539 /* Handle the sse4.2 definitions here. */
1541 /* These definitions are normally in nmmintrin.h, but gcc puts them in here
1542 so we'll do the same. */
1544 #undef __DEFAULT_FN_ATTRS
1545 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))
1547 /* These specify the type of data that we're comparing. */
1548 #define _SIDD_UBYTE_OPS 0x00
1549 #define _SIDD_UWORD_OPS 0x01
1550 #define _SIDD_SBYTE_OPS 0x02
1551 #define _SIDD_SWORD_OPS 0x03
1553 /* These specify the type of comparison operation. */
1554 #define _SIDD_CMP_EQUAL_ANY 0x00
1555 #define _SIDD_CMP_RANGES 0x04
1556 #define _SIDD_CMP_EQUAL_EACH 0x08
1557 #define _SIDD_CMP_EQUAL_ORDERED 0x0c
1559 /* These macros specify the polarity of the operation. */
1560 #define _SIDD_POSITIVE_POLARITY 0x00
1561 #define _SIDD_NEGATIVE_POLARITY 0x10
1562 #define _SIDD_MASKED_POSITIVE_POLARITY 0x20
1563 #define _SIDD_MASKED_NEGATIVE_POLARITY 0x30
1565 /* These macros are used in _mm_cmpXstri() to specify the return. */
1566 #define _SIDD_LEAST_SIGNIFICANT 0x00
1567 #define _SIDD_MOST_SIGNIFICANT 0x40
1569 /* These macros are used in _mm_cmpXstri() to specify the return. */
1570 #define _SIDD_BIT_MASK 0x00
1571 #define _SIDD_UNIT_MASK 0x40
1573 /* SSE4.2 Packed Comparison Intrinsics. */
1574 /// Uses the immediate operand \a M to perform a comparison of string
1575 /// data with implicitly defined lengths that is contained in source operands
1576 /// \a A and \a B. Returns a 128-bit integer vector representing the result
1577 /// mask of the comparison.
1579 /// \headerfile <x86intrin.h>
1582 /// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M);
1585 /// This intrinsic corresponds to the <c> VPCMPISTRM / PCMPISTRM </c>
1589 /// A 128-bit integer vector containing one of the source operands to be
1592 /// A 128-bit integer vector containing one of the source operands to be
1595 /// An 8-bit immediate operand specifying whether the characters are bytes or
1596 /// words, the type of comparison to perform, and the format of the return
1598 /// Bits [1:0]: Determine source data format. \n
1599 /// 00: 16 unsigned bytes \n
1600 /// 01: 8 unsigned words \n
1601 /// 10: 16 signed bytes \n
1602 /// 11: 8 signed words \n
1603 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1604 /// 00: Subset: Each character in \a B is compared for equality with all
1605 /// the characters in \a A. \n
1606 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1607 /// basis is greater than or equal for even-indexed elements in \a A,
1608 /// and less than or equal for odd-indexed elements in \a A. \n
1609 /// 10: Match: Compare each pair of corresponding characters in \a A and
1610 /// \a B for equality. \n
1611 /// 11: Substring: Search \a B for substring matches of \a A. \n
1612 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1613 /// mask of the comparison results. \n
1614 /// 00: No effect. \n
1615 /// 01: Negate the bit mask. \n
1616 /// 10: No effect. \n
1617 /// 11: Negate the bit mask only for bits with an index less than or equal
1618 /// to the size of \a A or \a B. \n
1619 /// Bit [6]: Determines whether the result is zero-extended or expanded to 16
1621 /// 0: The result is zero-extended to 16 bytes. \n
1622 /// 1: The result is expanded to 16 bytes (this expansion is performed by
1623 /// repeating each bit 8 or 16 times).
1624 /// \returns Returns a 128-bit integer vector representing the result mask of
1626 #define _mm_cmpistrm(A, B, M) \
1627 (__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \
1628 (__v16qi)(__m128i)(B), (int)(M))
1630 /// Uses the immediate operand \a M to perform a comparison of string
1631 /// data with implicitly defined lengths that is contained in source operands
1632 /// \a A and \a B. Returns an integer representing the result index of the
1635 /// \headerfile <x86intrin.h>
1638 /// int _mm_cmpistri(__m128i A, __m128i B, const int M);
1641 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1645 /// A 128-bit integer vector containing one of the source operands to be
1648 /// A 128-bit integer vector containing one of the source operands to be
1651 /// An 8-bit immediate operand specifying whether the characters are bytes or
1652 /// words, the type of comparison to perform, and the format of the return
1654 /// Bits [1:0]: Determine source data format. \n
1655 /// 00: 16 unsigned bytes \n
1656 /// 01: 8 unsigned words \n
1657 /// 10: 16 signed bytes \n
1658 /// 11: 8 signed words \n
1659 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1660 /// 00: Subset: Each character in \a B is compared for equality with all
1661 /// the characters in \a A. \n
1662 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1663 /// basis is greater than or equal for even-indexed elements in \a A,
1664 /// and less than or equal for odd-indexed elements in \a A. \n
1665 /// 10: Match: Compare each pair of corresponding characters in \a A and
1666 /// \a B for equality. \n
1667 /// 11: Substring: Search B for substring matches of \a A. \n
1668 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1669 /// mask of the comparison results. \n
1670 /// 00: No effect. \n
1671 /// 01: Negate the bit mask. \n
1672 /// 10: No effect. \n
1673 /// 11: Negate the bit mask only for bits with an index less than or equal
1674 /// to the size of \a A or \a B. \n
1675 /// Bit [6]: Determines whether the index of the lowest set bit or the
1676 /// highest set bit is returned. \n
1677 /// 0: The index of the least significant set bit. \n
1678 /// 1: The index of the most significant set bit. \n
1679 /// \returns Returns an integer representing the result index of the comparison.
1680 #define _mm_cmpistri(A, B, M) \
1681 (int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \
1682 (__v16qi)(__m128i)(B), (int)(M))
1684 /// Uses the immediate operand \a M to perform a comparison of string
1685 /// data with explicitly defined lengths that is contained in source operands
1686 /// \a A and \a B. Returns a 128-bit integer vector representing the result
1687 /// mask of the comparison.
1689 /// \headerfile <x86intrin.h>
1692 /// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M);
1695 /// This intrinsic corresponds to the <c> VPCMPESTRM / PCMPESTRM </c>
1699 /// A 128-bit integer vector containing one of the source operands to be
1702 /// An integer that specifies the length of the string in \a A.
1704 /// A 128-bit integer vector containing one of the source operands to be
1707 /// An integer that specifies the length of the string in \a B.
1709 /// An 8-bit immediate operand specifying whether the characters are bytes or
1710 /// words, the type of comparison to perform, and the format of the return
1712 /// Bits [1:0]: Determine source data format. \n
1713 /// 00: 16 unsigned bytes \n
1714 /// 01: 8 unsigned words \n
1715 /// 10: 16 signed bytes \n
1716 /// 11: 8 signed words \n
1717 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1718 /// 00: Subset: Each character in \a B is compared for equality with all
1719 /// the characters in \a A. \n
1720 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1721 /// basis is greater than or equal for even-indexed elements in \a A,
1722 /// and less than or equal for odd-indexed elements in \a A. \n
1723 /// 10: Match: Compare each pair of corresponding characters in \a A and
1724 /// \a B for equality. \n
1725 /// 11: Substring: Search \a B for substring matches of \a A. \n
1726 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1727 /// mask of the comparison results. \n
1728 /// 00: No effect. \n
1729 /// 01: Negate the bit mask. \n
1730 /// 10: No effect. \n
1731 /// 11: Negate the bit mask only for bits with an index less than or equal
1732 /// to the size of \a A or \a B. \n
1733 /// Bit [6]: Determines whether the result is zero-extended or expanded to 16
1735 /// 0: The result is zero-extended to 16 bytes. \n
1736 /// 1: The result is expanded to 16 bytes (this expansion is performed by
1737 /// repeating each bit 8 or 16 times). \n
1738 /// \returns Returns a 128-bit integer vector representing the result mask of
1740 #define _mm_cmpestrm(A, LA, B, LB, M) \
1741 (__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \
1742 (__v16qi)(__m128i)(B), (int)(LB), \
1745 /// Uses the immediate operand \a M to perform a comparison of string
1746 /// data with explicitly defined lengths that is contained in source operands
1747 /// \a A and \a B. Returns an integer representing the result index of the
1750 /// \headerfile <x86intrin.h>
1753 /// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M);
1756 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
1760 /// A 128-bit integer vector containing one of the source operands to be
1763 /// An integer that specifies the length of the string in \a A.
1765 /// A 128-bit integer vector containing one of the source operands to be
1768 /// An integer that specifies the length of the string in \a B.
1770 /// An 8-bit immediate operand specifying whether the characters are bytes or
1771 /// words, the type of comparison to perform, and the format of the return
1773 /// Bits [1:0]: Determine source data format. \n
1774 /// 00: 16 unsigned bytes \n
1775 /// 01: 8 unsigned words \n
1776 /// 10: 16 signed bytes \n
1777 /// 11: 8 signed words \n
1778 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1779 /// 00: Subset: Each character in \a B is compared for equality with all
1780 /// the characters in \a A. \n
1781 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1782 /// basis is greater than or equal for even-indexed elements in \a A,
1783 /// and less than or equal for odd-indexed elements in \a A. \n
1784 /// 10: Match: Compare each pair of corresponding characters in \a A and
1785 /// \a B for equality. \n
1786 /// 11: Substring: Search B for substring matches of \a A. \n
1787 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1788 /// mask of the comparison results. \n
1789 /// 00: No effect. \n
1790 /// 01: Negate the bit mask. \n
1791 /// 10: No effect. \n
1792 /// 11: Negate the bit mask only for bits with an index less than or equal
1793 /// to the size of \a A or \a B. \n
1794 /// Bit [6]: Determines whether the index of the lowest set bit or the
1795 /// highest set bit is returned. \n
1796 /// 0: The index of the least significant set bit. \n
1797 /// 1: The index of the most significant set bit. \n
1798 /// \returns Returns an integer representing the result index of the comparison.
1799 #define _mm_cmpestri(A, LA, B, LB, M) \
1800 (int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \
1801 (__v16qi)(__m128i)(B), (int)(LB), \
1804 /* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */
1805 /// Uses the immediate operand \a M to perform a comparison of string
1806 /// data with implicitly defined lengths that is contained in source operands
1807 /// \a A and \a B. Returns 1 if the bit mask is zero and the length of the
1808 /// string in \a B is the maximum, otherwise, returns 0.
1810 /// \headerfile <x86intrin.h>
1813 /// int _mm_cmpistra(__m128i A, __m128i B, const int M);
1816 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1820 /// A 128-bit integer vector containing one of the source operands to be
1823 /// A 128-bit integer vector containing one of the source operands to be
1826 /// An 8-bit immediate operand specifying whether the characters are bytes or
1827 /// words and the type of comparison to perform. \n
1828 /// Bits [1:0]: Determine source data format. \n
1829 /// 00: 16 unsigned bytes \n
1830 /// 01: 8 unsigned words \n
1831 /// 10: 16 signed bytes \n
1832 /// 11: 8 signed words \n
1833 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1834 /// 00: Subset: Each character in \a B is compared for equality with all
1835 /// the characters in \a A. \n
1836 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1837 /// basis is greater than or equal for even-indexed elements in \a A,
1838 /// and less than or equal for odd-indexed elements in \a A. \n
1839 /// 10: Match: Compare each pair of corresponding characters in \a A and
1840 /// \a B for equality. \n
1841 /// 11: Substring: Search \a B for substring matches of \a A. \n
1842 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1843 /// mask of the comparison results. \n
1844 /// 00: No effect. \n
1845 /// 01: Negate the bit mask. \n
1846 /// 10: No effect. \n
1847 /// 11: Negate the bit mask only for bits with an index less than or equal
1848 /// to the size of \a A or \a B. \n
1849 /// \returns Returns 1 if the bit mask is zero and the length of the string in
1850 /// \a B is the maximum; otherwise, returns 0.
1851 #define _mm_cmpistra(A, B, M) \
1852 (int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \
1853 (__v16qi)(__m128i)(B), (int)(M))
1855 /// Uses the immediate operand \a M to perform a comparison of string
1856 /// data with implicitly defined lengths that is contained in source operands
1857 /// \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns
1860 /// \headerfile <x86intrin.h>
1863 /// int _mm_cmpistrc(__m128i A, __m128i B, const int M);
1866 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1870 /// A 128-bit integer vector containing one of the source operands to be
1873 /// A 128-bit integer vector containing one of the source operands to be
1876 /// An 8-bit immediate operand specifying whether the characters are bytes or
1877 /// words and the type of comparison to perform. \n
1878 /// Bits [1:0]: Determine source data format. \n
1879 /// 00: 16 unsigned bytes \n
1880 /// 01: 8 unsigned words \n
1881 /// 10: 16 signed bytes \n
1882 /// 11: 8 signed words \n
1883 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1884 /// 00: Subset: Each character in \a B is compared for equality with all
1885 /// the characters in \a A. \n
1886 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1887 /// basis is greater than or equal for even-indexed elements in \a A,
1888 /// and less than or equal for odd-indexed elements in \a A. \n
1889 /// 10: Match: Compare each pair of corresponding characters in \a A and
1890 /// \a B for equality. \n
1891 /// 11: Substring: Search B for substring matches of \a A. \n
1892 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1893 /// mask of the comparison results. \n
1894 /// 00: No effect. \n
1895 /// 01: Negate the bit mask. \n
1896 /// 10: No effect. \n
1897 /// 11: Negate the bit mask only for bits with an index less than or equal
1898 /// to the size of \a A or \a B.
1899 /// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0.
1900 #define _mm_cmpistrc(A, B, M) \
1901 (int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \
1902 (__v16qi)(__m128i)(B), (int)(M))
1904 /// Uses the immediate operand \a M to perform a comparison of string
1905 /// data with implicitly defined lengths that is contained in source operands
1906 /// \a A and \a B. Returns bit 0 of the resulting bit mask.
1908 /// \headerfile <x86intrin.h>
1911 /// int _mm_cmpistro(__m128i A, __m128i B, const int M);
1914 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1918 /// A 128-bit integer vector containing one of the source operands to be
1921 /// A 128-bit integer vector containing one of the source operands to be
1924 /// An 8-bit immediate operand specifying whether the characters are bytes or
1925 /// words and the type of comparison to perform. \n
1926 /// Bits [1:0]: Determine source data format. \n
1927 /// 00: 16 unsigned bytes \n
1928 /// 01: 8 unsigned words \n
1929 /// 10: 16 signed bytes \n
1930 /// 11: 8 signed words \n
1931 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1932 /// 00: Subset: Each character in \a B is compared for equality with all
1933 /// the characters in \a A. \n
1934 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1935 /// basis is greater than or equal for even-indexed elements in \a A,
1936 /// and less than or equal for odd-indexed elements in \a A. \n
1937 /// 10: Match: Compare each pair of corresponding characters in \a A and
1938 /// \a B for equality. \n
1939 /// 11: Substring: Search B for substring matches of \a A. \n
1940 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1941 /// mask of the comparison results. \n
1942 /// 00: No effect. \n
1943 /// 01: Negate the bit mask. \n
1944 /// 10: No effect. \n
1945 /// 11: Negate the bit mask only for bits with an index less than or equal
1946 /// to the size of \a A or \a B. \n
1947 /// \returns Returns bit 0 of the resulting bit mask.
1948 #define _mm_cmpistro(A, B, M) \
1949 (int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \
1950 (__v16qi)(__m128i)(B), (int)(M))
1952 /// Uses the immediate operand \a M to perform a comparison of string
1953 /// data with implicitly defined lengths that is contained in source operands
1954 /// \a A and \a B. Returns 1 if the length of the string in \a A is less than
1955 /// the maximum, otherwise, returns 0.
1957 /// \headerfile <x86intrin.h>
1960 /// int _mm_cmpistrs(__m128i A, __m128i B, const int M);
1963 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
1967 /// A 128-bit integer vector containing one of the source operands to be
1970 /// A 128-bit integer vector containing one of the source operands to be
1973 /// An 8-bit immediate operand specifying whether the characters are bytes or
1974 /// words and the type of comparison to perform. \n
1975 /// Bits [1:0]: Determine source data format. \n
1976 /// 00: 16 unsigned bytes \n
1977 /// 01: 8 unsigned words \n
1978 /// 10: 16 signed bytes \n
1979 /// 11: 8 signed words \n
1980 /// Bits [3:2]: Determine comparison type and aggregation method. \n
1981 /// 00: Subset: Each character in \a B is compared for equality with all
1982 /// the characters in \a A. \n
1983 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
1984 /// basis is greater than or equal for even-indexed elements in \a A,
1985 /// and less than or equal for odd-indexed elements in \a A. \n
1986 /// 10: Match: Compare each pair of corresponding characters in \a A and
1987 /// \a B for equality. \n
1988 /// 11: Substring: Search \a B for substring matches of \a A. \n
1989 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
1990 /// mask of the comparison results. \n
1991 /// 00: No effect. \n
1992 /// 01: Negate the bit mask. \n
1993 /// 10: No effect. \n
1994 /// 11: Negate the bit mask only for bits with an index less than or equal
1995 /// to the size of \a A or \a B. \n
1996 /// \returns Returns 1 if the length of the string in \a A is less than the
1997 /// maximum, otherwise, returns 0.
1998 #define _mm_cmpistrs(A, B, M) \
1999 (int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \
2000 (__v16qi)(__m128i)(B), (int)(M))
2002 /// Uses the immediate operand \a M to perform a comparison of string
2003 /// data with implicitly defined lengths that is contained in source operands
2004 /// \a A and \a B. Returns 1 if the length of the string in \a B is less than
2005 /// the maximum, otherwise, returns 0.
2007 /// \headerfile <x86intrin.h>
2010 /// int _mm_cmpistrz(__m128i A, __m128i B, const int M);
2013 /// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>
2017 /// A 128-bit integer vector containing one of the source operands to be
2020 /// A 128-bit integer vector containing one of the source operands to be
2023 /// An 8-bit immediate operand specifying whether the characters are bytes or
2024 /// words and the type of comparison to perform. \n
2025 /// Bits [1:0]: Determine source data format. \n
2026 /// 00: 16 unsigned bytes \n
2027 /// 01: 8 unsigned words \n
2028 /// 10: 16 signed bytes \n
2029 /// 11: 8 signed words \n
2030 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2031 /// 00: Subset: Each character in \a B is compared for equality with all
2032 /// the characters in \a A. \n
2033 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2034 /// basis is greater than or equal for even-indexed elements in \a A,
2035 /// and less than or equal for odd-indexed elements in \a A. \n
2036 /// 10: Match: Compare each pair of corresponding characters in \a A and
2037 /// \a B for equality. \n
2038 /// 11: Substring: Search \a B for substring matches of \a A. \n
2039 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2040 /// mask of the comparison results. \n
2041 /// 00: No effect. \n
2042 /// 01: Negate the bit mask. \n
2043 /// 10: No effect. \n
2044 /// 11: Negate the bit mask only for bits with an index less than or equal
2045 /// to the size of \a A or \a B.
2046 /// \returns Returns 1 if the length of the string in \a B is less than the
2047 /// maximum, otherwise, returns 0.
2048 #define _mm_cmpistrz(A, B, M) \
2049 (int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \
2050 (__v16qi)(__m128i)(B), (int)(M))
2052 /// Uses the immediate operand \a M to perform a comparison of string
2053 /// data with explicitly defined lengths that is contained in source operands
2054 /// \a A and \a B. Returns 1 if the bit mask is zero and the length of the
2055 /// string in \a B is the maximum, otherwise, returns 0.
2057 /// \headerfile <x86intrin.h>
2060 /// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M);
2063 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2067 /// A 128-bit integer vector containing one of the source operands to be
2070 /// An integer that specifies the length of the string in \a A.
2072 /// A 128-bit integer vector containing one of the source operands to be
2075 /// An integer that specifies the length of the string in \a B.
2077 /// An 8-bit immediate operand specifying whether the characters are bytes or
2078 /// words and the type of comparison to perform. \n
2079 /// Bits [1:0]: Determine source data format. \n
2080 /// 00: 16 unsigned bytes \n
2081 /// 01: 8 unsigned words \n
2082 /// 10: 16 signed bytes \n
2083 /// 11: 8 signed words \n
2084 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2085 /// 00: Subset: Each character in \a B is compared for equality with all
2086 /// the characters in \a A. \n
2087 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2088 /// basis is greater than or equal for even-indexed elements in \a A,
2089 /// and less than or equal for odd-indexed elements in \a A. \n
2090 /// 10: Match: Compare each pair of corresponding characters in \a A and
2091 /// \a B for equality. \n
2092 /// 11: Substring: Search \a B for substring matches of \a A. \n
2093 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2094 /// mask of the comparison results. \n
2095 /// 00: No effect. \n
2096 /// 01: Negate the bit mask. \n
2097 /// 10: No effect. \n
2098 /// 11: Negate the bit mask only for bits with an index less than or equal
2099 /// to the size of \a A or \a B.
2100 /// \returns Returns 1 if the bit mask is zero and the length of the string in
2101 /// \a B is the maximum, otherwise, returns 0.
2102 #define _mm_cmpestra(A, LA, B, LB, M) \
2103 (int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \
2104 (__v16qi)(__m128i)(B), (int)(LB), \
2107 /// Uses the immediate operand \a M to perform a comparison of string
2108 /// data with explicitly defined lengths that is contained in source operands
2109 /// \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise,
2112 /// \headerfile <x86intrin.h>
2115 /// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M);
2118 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2122 /// A 128-bit integer vector containing one of the source operands to be
2125 /// An integer that specifies the length of the string in \a A.
2127 /// A 128-bit integer vector containing one of the source operands to be
2130 /// An integer that specifies the length of the string in \a B.
2132 /// An 8-bit immediate operand specifying whether the characters are bytes or
2133 /// words and the type of comparison to perform. \n
2134 /// Bits [1:0]: Determine source data format. \n
2135 /// 00: 16 unsigned bytes \n
2136 /// 01: 8 unsigned words \n
2137 /// 10: 16 signed bytes \n
2138 /// 11: 8 signed words \n
2139 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2140 /// 00: Subset: Each character in \a B is compared for equality with all
2141 /// the characters in \a A. \n
2142 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2143 /// basis is greater than or equal for even-indexed elements in \a A,
2144 /// and less than or equal for odd-indexed elements in \a A. \n
2145 /// 10: Match: Compare each pair of corresponding characters in \a A and
2146 /// \a B for equality. \n
2147 /// 11: Substring: Search \a B for substring matches of \a A. \n
2148 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2149 /// mask of the comparison results. \n
2150 /// 00: No effect. \n
2151 /// 01: Negate the bit mask. \n
2152 /// 10: No effect. \n
2153 /// 11: Negate the bit mask only for bits with an index less than or equal
2154 /// to the size of \a A or \a B. \n
2155 /// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0.
2156 #define _mm_cmpestrc(A, LA, B, LB, M) \
2157 (int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \
2158 (__v16qi)(__m128i)(B), (int)(LB), \
2161 /// Uses the immediate operand \a M to perform a comparison of string
2162 /// data with explicitly defined lengths that is contained in source operands
2163 /// \a A and \a B. Returns bit 0 of the resulting bit mask.
2165 /// \headerfile <x86intrin.h>
2168 /// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M);
2171 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2175 /// A 128-bit integer vector containing one of the source operands to be
2178 /// An integer that specifies the length of the string in \a A.
2180 /// A 128-bit integer vector containing one of the source operands to be
2183 /// An integer that specifies the length of the string in \a B.
2185 /// An 8-bit immediate operand specifying whether the characters are bytes or
2186 /// words and the type of comparison to perform. \n
2187 /// Bits [1:0]: Determine source data format. \n
2188 /// 00: 16 unsigned bytes \n
2189 /// 01: 8 unsigned words \n
2190 /// 10: 16 signed bytes \n
2191 /// 11: 8 signed words \n
2192 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2193 /// 00: Subset: Each character in \a B is compared for equality with all
2194 /// the characters in \a A. \n
2195 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2196 /// basis is greater than or equal for even-indexed elements in \a A,
2197 /// and less than or equal for odd-indexed elements in \a A. \n
2198 /// 10: Match: Compare each pair of corresponding characters in \a A and
2199 /// \a B for equality. \n
2200 /// 11: Substring: Search \a B for substring matches of \a A. \n
2201 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2202 /// mask of the comparison results. \n
2203 /// 00: No effect. \n
2204 /// 01: Negate the bit mask. \n
2205 /// 10: No effect. \n
2206 /// 11: Negate the bit mask only for bits with an index less than or equal
2207 /// to the size of \a A or \a B.
2208 /// \returns Returns bit 0 of the resulting bit mask.
2209 #define _mm_cmpestro(A, LA, B, LB, M) \
2210 (int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \
2211 (__v16qi)(__m128i)(B), (int)(LB), \
2214 /// Uses the immediate operand \a M to perform a comparison of string
2215 /// data with explicitly defined lengths that is contained in source operands
2216 /// \a A and \a B. Returns 1 if the length of the string in \a A is less than
2217 /// the maximum, otherwise, returns 0.
2219 /// \headerfile <x86intrin.h>
2222 /// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M);
2225 /// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>
2229 /// A 128-bit integer vector containing one of the source operands to be
2232 /// An integer that specifies the length of the string in \a A.
2234 /// A 128-bit integer vector containing one of the source operands to be
2237 /// An integer that specifies the length of the string in \a B.
2239 /// An 8-bit immediate operand specifying whether the characters are bytes or
2240 /// words and the type of comparison to perform. \n
2241 /// Bits [1:0]: Determine source data format. \n
2242 /// 00: 16 unsigned bytes \n
2243 /// 01: 8 unsigned words \n
2244 /// 10: 16 signed bytes \n
2245 /// 11: 8 signed words \n
2246 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2247 /// 00: Subset: Each character in \a B is compared for equality with all
2248 /// the characters in \a A. \n
2249 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2250 /// basis is greater than or equal for even-indexed elements in \a A,
2251 /// and less than or equal for odd-indexed elements in \a A. \n
2252 /// 10: Match: Compare each pair of corresponding characters in \a A and
2253 /// \a B for equality. \n
2254 /// 11: Substring: Search \a B for substring matches of \a A. \n
2255 /// Bits [5:4]: Determine whether to perform a one's complement in the bit
2256 /// mask of the comparison results. \n
2257 /// 00: No effect. \n
2258 /// 01: Negate the bit mask. \n
2259 /// 10: No effect. \n
2260 /// 11: Negate the bit mask only for bits with an index less than or equal
2261 /// to the size of \a A or \a B. \n
2262 /// \returns Returns 1 if the length of the string in \a A is less than the
2263 /// maximum, otherwise, returns 0.
2264 #define _mm_cmpestrs(A, LA, B, LB, M) \
2265 (int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \
2266 (__v16qi)(__m128i)(B), (int)(LB), \
2269 /// Uses the immediate operand \a M to perform a comparison of string
2270 /// data with explicitly defined lengths that is contained in source operands
2271 /// \a A and \a B. Returns 1 if the length of the string in \a B is less than
2272 /// the maximum, otherwise, returns 0.
2274 /// \headerfile <x86intrin.h>
2277 /// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M);
2280 /// This intrinsic corresponds to the <c> VPCMPESTRI </c> instruction.
2283 /// A 128-bit integer vector containing one of the source operands to be
2286 /// An integer that specifies the length of the string in \a A.
2288 /// A 128-bit integer vector containing one of the source operands to be
2291 /// An integer that specifies the length of the string in \a B.
2293 /// An 8-bit immediate operand specifying whether the characters are bytes or
2294 /// words and the type of comparison to perform. \n
2295 /// Bits [1:0]: Determine source data format. \n
2296 /// 00: 16 unsigned bytes \n
2297 /// 01: 8 unsigned words \n
2298 /// 10: 16 signed bytes \n
2299 /// 11: 8 signed words \n
2300 /// Bits [3:2]: Determine comparison type and aggregation method. \n
2301 /// 00: Subset: Each character in \a B is compared for equality with all
2302 /// the characters in \a A. \n
2303 /// 01: Ranges: Each character in \a B is compared to \a A. The comparison
2304 /// basis is greater than or equal for even-indexed elements in \a A,
2305 /// and less than or equal for odd-indexed elements in \a A. \n
2306 /// 10: Match: Compare each pair of corresponding characters in \a A and
2307 /// \a B for equality. \n
2308 /// 11: Substring: Search \a B for substring matches of \a A. \n
2309 /// Bits [5:4]: Determine whether to perform a one's complement on the bit
2310 /// mask of the comparison results. \n
2311 /// 00: No effect. \n
2312 /// 01: Negate the bit mask. \n
2313 /// 10: No effect. \n
2314 /// 11: Negate the bit mask only for bits with an index less than or equal
2315 /// to the size of \a A or \a B.
2316 /// \returns Returns 1 if the length of the string in \a B is less than the
2317 /// maximum, otherwise, returns 0.
2318 #define _mm_cmpestrz(A, LA, B, LB, M) \
2319 (int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \
2320 (__v16qi)(__m128i)(B), (int)(LB), \
2323 /* SSE4.2 Compare Packed Data -- Greater Than. */
2324 /// Compares each of the corresponding 64-bit values of the 128-bit
2325 /// integer vectors to determine if the values in the first operand are
2326 /// greater than those in the second operand.
2328 /// \headerfile <x86intrin.h>
2330 /// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction.
2333 /// A 128-bit integer vector.
2335 /// A 128-bit integer vector.
2336 /// \returns A 128-bit integer vector containing the comparison results.
2337 static __inline__ __m128i __DEFAULT_FN_ATTRS
2338 _mm_cmpgt_epi64(__m128i __V1, __m128i __V2)
2340 return (__m128i)((__v2di)__V1 > (__v2di)__V2);
2343 /* SSE4.2 Accumulate CRC32. */
2344 /// Adds the unsigned integer operand to the CRC-32C checksum of the
2345 /// unsigned char operand.
2347 /// \headerfile <x86intrin.h>
2349 /// This intrinsic corresponds to the <c> CRC32B </c> instruction.
2352 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2355 /// An unsigned 8-bit integer operand used to compute the CRC-32C checksum.
2356 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2358 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2359 _mm_crc32_u8(unsigned int __C, unsigned char __D)
2361 return __builtin_ia32_crc32qi(__C, __D);
2364 /// Adds the unsigned integer operand to the CRC-32C checksum of the
2365 /// unsigned short operand.
2367 /// \headerfile <x86intrin.h>
2369 /// This intrinsic corresponds to the <c> CRC32W </c> instruction.
2372 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2375 /// An unsigned 16-bit integer operand used to compute the CRC-32C checksum.
2376 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2378 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2379 _mm_crc32_u16(unsigned int __C, unsigned short __D)
2381 return __builtin_ia32_crc32hi(__C, __D);
2384 /// Adds the first unsigned integer operand to the CRC-32C checksum of
2385 /// the second unsigned integer operand.
2387 /// \headerfile <x86intrin.h>
2389 /// This intrinsic corresponds to the <c> CRC32L </c> instruction.
2392 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2395 /// An unsigned 32-bit integer operand used to compute the CRC-32C checksum.
2396 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2398 static __inline__ unsigned int __DEFAULT_FN_ATTRS
2399 _mm_crc32_u32(unsigned int __C, unsigned int __D)
2401 return __builtin_ia32_crc32si(__C, __D);
2405 /// Adds the unsigned integer operand to the CRC-32C checksum of the
2406 /// unsigned 64-bit integer operand.
2408 /// \headerfile <x86intrin.h>
2410 /// This intrinsic corresponds to the <c> CRC32Q </c> instruction.
2413 /// An unsigned integer operand to add to the CRC-32C checksum of operand
2416 /// An unsigned 64-bit integer operand used to compute the CRC-32C checksum.
2417 /// \returns The result of adding operand \a __C to the CRC-32C checksum of
2419 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
2420 _mm_crc32_u64(unsigned long long __C, unsigned long long __D)
2422 return __builtin_ia32_crc32di(__C, __D);
2424 #endif /* __x86_64__ */
2426 #undef __DEFAULT_FN_ATTRS
2428 #include <popcntintrin.h>
2430 #endif /* __SMMINTRIN_H */