2353 lines · c
1/*===---- smmintrin.h - SSE4 intrinsics ------------------------------------===2 *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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#ifndef __SMMINTRIN_H11#define __SMMINTRIN_H12 13#if !defined(__i386__) && !defined(__x86_64__)14#error "This header is only meant to be used on x86 and x64 architecture"15#endif16 17#include <tmmintrin.h>18 19/* Define the default attributes for the functions in this file. */20#define __DEFAULT_FN_ATTRS \21 __attribute__((__always_inline__, __nodebug__, __target__("sse4.1"), \22 __min_vector_width__(128)))23 24#if defined(__cplusplus) && (__cplusplus >= 201103L)25#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr26#else27#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS28#endif29 30/* SSE4 Rounding macros. */31#define _MM_FROUND_TO_NEAREST_INT 0x0032#define _MM_FROUND_TO_NEG_INF 0x0133#define _MM_FROUND_TO_POS_INF 0x0234#define _MM_FROUND_TO_ZERO 0x0335#define _MM_FROUND_CUR_DIRECTION 0x0436 37#define _MM_FROUND_RAISE_EXC 0x0038#define _MM_FROUND_NO_EXC 0x0839 40#define _MM_FROUND_NINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEAREST_INT)41#define _MM_FROUND_FLOOR (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEG_INF)42#define _MM_FROUND_CEIL (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_POS_INF)43#define _MM_FROUND_TRUNC (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_ZERO)44#define _MM_FROUND_RINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION)45#define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION)46 47/// Rounds up each element of the 128-bit vector of [4 x float] to an48/// integer and returns the rounded values in a 128-bit vector of49/// [4 x float].50///51/// \headerfile <x86intrin.h>52///53/// \code54/// __m128 _mm_ceil_ps(__m128 X);55/// \endcode56///57/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.58///59/// \param X60/// A 128-bit vector of [4 x float] values to be rounded up.61/// \returns A 128-bit vector of [4 x float] containing the rounded values.62#define _mm_ceil_ps(X) _mm_round_ps((X), _MM_FROUND_CEIL)63 64/// Rounds up each element of the 128-bit vector of [2 x double] to an65/// integer and returns the rounded values in a 128-bit vector of66/// [2 x double].67///68/// \headerfile <x86intrin.h>69///70/// \code71/// __m128d _mm_ceil_pd(__m128d X);72/// \endcode73///74/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.75///76/// \param X77/// A 128-bit vector of [2 x double] values to be rounded up.78/// \returns A 128-bit vector of [2 x double] containing the rounded values.79#define _mm_ceil_pd(X) _mm_round_pd((X), _MM_FROUND_CEIL)80 81/// Copies three upper elements of the first 128-bit vector operand to82/// the corresponding three upper elements of the 128-bit result vector of83/// [4 x float]. Rounds up the lowest element of the second 128-bit vector84/// operand to an integer and copies it to the lowest element of the 128-bit85/// result vector of [4 x float].86///87/// \headerfile <x86intrin.h>88///89/// \code90/// __m128 _mm_ceil_ss(__m128 X, __m128 Y);91/// \endcode92///93/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.94///95/// \param X96/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are97/// copied to the corresponding bits of the result.98/// \param Y99/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is100/// rounded up to the nearest integer and copied to the corresponding bits101/// of the result.102/// \returns A 128-bit vector of [4 x float] containing the copied and rounded103/// values.104#define _mm_ceil_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_CEIL)105 106/// Copies the upper element of the first 128-bit vector operand to the107/// corresponding upper element of the 128-bit result vector of [2 x double].108/// Rounds up the lower element of the second 128-bit vector operand to an109/// integer and copies it to the lower element of the 128-bit result vector110/// of [2 x double].111///112/// \headerfile <x86intrin.h>113///114/// \code115/// __m128d _mm_ceil_sd(__m128d X, __m128d Y);116/// \endcode117///118/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.119///120/// \param X121/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is122/// copied to the corresponding bits of the result.123/// \param Y124/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is125/// rounded up to the nearest integer and copied to the corresponding bits126/// of the result.127/// \returns A 128-bit vector of [2 x double] containing the copied and rounded128/// values.129#define _mm_ceil_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_CEIL)130 131/// Rounds down each element of the 128-bit vector of [4 x float] to an132/// an integer and returns the rounded values in a 128-bit vector of133/// [4 x float].134///135/// \headerfile <x86intrin.h>136///137/// \code138/// __m128 _mm_floor_ps(__m128 X);139/// \endcode140///141/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.142///143/// \param X144/// A 128-bit vector of [4 x float] values to be rounded down.145/// \returns A 128-bit vector of [4 x float] containing the rounded values.146#define _mm_floor_ps(X) _mm_round_ps((X), _MM_FROUND_FLOOR)147 148/// Rounds down each element of the 128-bit vector of [2 x double] to an149/// integer and returns the rounded values in a 128-bit vector of150/// [2 x double].151///152/// \headerfile <x86intrin.h>153///154/// \code155/// __m128d _mm_floor_pd(__m128d X);156/// \endcode157///158/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.159///160/// \param X161/// A 128-bit vector of [2 x double].162/// \returns A 128-bit vector of [2 x double] containing the rounded values.163#define _mm_floor_pd(X) _mm_round_pd((X), _MM_FROUND_FLOOR)164 165/// Copies three upper elements of the first 128-bit vector operand to166/// the corresponding three upper elements of the 128-bit result vector of167/// [4 x float]. Rounds down the lowest element of the second 128-bit vector168/// operand to an integer and copies it to the lowest element of the 128-bit169/// result vector of [4 x float].170///171/// \headerfile <x86intrin.h>172///173/// \code174/// __m128 _mm_floor_ss(__m128 X, __m128 Y);175/// \endcode176///177/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.178///179/// \param X180/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are181/// copied to the corresponding bits of the result.182/// \param Y183/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is184/// rounded down to the nearest integer and copied to the corresponding bits185/// of the result.186/// \returns A 128-bit vector of [4 x float] containing the copied and rounded187/// values.188#define _mm_floor_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_FLOOR)189 190/// Copies the upper element of the first 128-bit vector operand to the191/// corresponding upper element of the 128-bit result vector of [2 x double].192/// Rounds down the lower element of the second 128-bit vector operand to an193/// integer and copies it to the lower element of the 128-bit result vector194/// of [2 x double].195///196/// \headerfile <x86intrin.h>197///198/// \code199/// __m128d _mm_floor_sd(__m128d X, __m128d Y);200/// \endcode201///202/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.203///204/// \param X205/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is206/// copied to the corresponding bits of the result.207/// \param Y208/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is209/// rounded down to the nearest integer and copied to the corresponding bits210/// of the result.211/// \returns A 128-bit vector of [2 x double] containing the copied and rounded212/// values.213#define _mm_floor_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_FLOOR)214 215/// Rounds each element of the 128-bit vector of [4 x float] to an216/// integer value according to the rounding control specified by the second217/// argument and returns the rounded values in a 128-bit vector of218/// [4 x float].219///220/// \headerfile <x86intrin.h>221///222/// \code223/// __m128 _mm_round_ps(__m128 X, const int M);224/// \endcode225///226/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction.227///228/// \param X229/// A 128-bit vector of [4 x float].230/// \param M231/// An integer value that specifies the rounding operation. \n232/// Bits [7:4] are reserved. \n233/// Bit [3] is a precision exception value: \n234/// 0: A normal PE exception is used \n235/// 1: The PE field is not updated \n236/// Bit [2] is the rounding control source: \n237/// 0: Use bits [1:0] of \a M \n238/// 1: Use the current MXCSR setting \n239/// Bits [1:0] contain the rounding control definition: \n240/// 00: Nearest \n241/// 01: Downward (toward negative infinity) \n242/// 10: Upward (toward positive infinity) \n243/// 11: Truncated244/// \returns A 128-bit vector of [4 x float] containing the rounded values.245#define _mm_round_ps(X, M) \246 ((__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M)))247 248/// Copies three upper elements of the first 128-bit vector operand to249/// the corresponding three upper elements of the 128-bit result vector of250/// [4 x float]. Rounds the lowest element of the second 128-bit vector251/// operand to an integer value according to the rounding control specified252/// by the third argument and copies it to the lowest element of the 128-bit253/// result vector of [4 x float].254///255/// \headerfile <x86intrin.h>256///257/// \code258/// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M);259/// \endcode260///261/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction.262///263/// \param X264/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are265/// copied to the corresponding bits of the result.266/// \param Y267/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is268/// rounded to the nearest integer using the specified rounding control and269/// copied to the corresponding bits of the result.270/// \param M271/// An integer value that specifies the rounding operation. \n272/// Bits [7:4] are reserved. \n273/// Bit [3] is a precision exception value: \n274/// 0: A normal PE exception is used \n275/// 1: The PE field is not updated \n276/// Bit [2] is the rounding control source: \n277/// 0: Use bits [1:0] of \a M \n278/// 1: Use the current MXCSR setting \n279/// Bits [1:0] contain the rounding control definition: \n280/// 00: Nearest \n281/// 01: Downward (toward negative infinity) \n282/// 10: Upward (toward positive infinity) \n283/// 11: Truncated284/// \returns A 128-bit vector of [4 x float] containing the copied and rounded285/// values.286#define _mm_round_ss(X, Y, M) \287 ((__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), (__v4sf)(__m128)(Y), \288 (M)))289 290/// Rounds each element of the 128-bit vector of [2 x double] to an291/// integer value according to the rounding control specified by the second292/// argument and returns the rounded values in a 128-bit vector of293/// [2 x double].294///295/// \headerfile <x86intrin.h>296///297/// \code298/// __m128d _mm_round_pd(__m128d X, const int M);299/// \endcode300///301/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction.302///303/// \param X304/// A 128-bit vector of [2 x double].305/// \param M306/// An integer value that specifies the rounding operation. \n307/// Bits [7:4] are reserved. \n308/// Bit [3] is a precision exception value: \n309/// 0: A normal PE exception is used \n310/// 1: The PE field is not updated \n311/// Bit [2] is the rounding control source: \n312/// 0: Use bits [1:0] of \a M \n313/// 1: Use the current MXCSR setting \n314/// Bits [1:0] contain the rounding control definition: \n315/// 00: Nearest \n316/// 01: Downward (toward negative infinity) \n317/// 10: Upward (toward positive infinity) \n318/// 11: Truncated319/// \returns A 128-bit vector of [2 x double] containing the rounded values.320#define _mm_round_pd(X, M) \321 ((__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M)))322 323/// Copies the upper element of the first 128-bit vector operand to the324/// corresponding upper element of the 128-bit result vector of [2 x double].325/// Rounds the lower element of the second 128-bit vector operand to an326/// integer value according to the rounding control specified by the third327/// argument and copies it to the lower element of the 128-bit result vector328/// of [2 x double].329///330/// \headerfile <x86intrin.h>331///332/// \code333/// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M);334/// \endcode335///336/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction.337///338/// \param X339/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is340/// copied to the corresponding bits of the result.341/// \param Y342/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is343/// rounded to the nearest integer using the specified rounding control and344/// copied to the corresponding bits of the result.345/// \param M346/// An integer value that specifies the rounding operation. \n347/// Bits [7:4] are reserved. \n348/// Bit [3] is a precision exception value: \n349/// 0: A normal PE exception is used \n350/// 1: The PE field is not updated \n351/// Bit [2] is the rounding control source: \n352/// 0: Use bits [1:0] of \a M \n353/// 1: Use the current MXCSR setting \n354/// Bits [1:0] contain the rounding control definition: \n355/// 00: Nearest \n356/// 01: Downward (toward negative infinity) \n357/// 10: Upward (toward positive infinity) \n358/// 11: Truncated359/// \returns A 128-bit vector of [2 x double] containing the copied and rounded360/// values.361#define _mm_round_sd(X, Y, M) \362 ((__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), (__v2df)(__m128d)(Y), \363 (M)))364 365/* SSE4 Packed Blending Intrinsics. */366/// Returns a 128-bit vector of [2 x double] where the values are367/// selected from either the first or second operand as specified by the368/// third operand, the control mask.369///370/// \headerfile <x86intrin.h>371///372/// \code373/// __m128d _mm_blend_pd(__m128d V1, __m128d V2, const int M);374/// \endcode375///376/// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction.377///378/// \param V1379/// A 128-bit vector of [2 x double].380/// \param V2381/// A 128-bit vector of [2 x double].382/// \param M383/// An immediate integer operand, with mask bits [1:0] specifying how the384/// values are to be copied. The position of the mask bit corresponds to the385/// index of a copied value. When a mask bit is 0, the corresponding 64-bit386/// element in operand \a V1 is copied to the same position in the result.387/// When a mask bit is 1, the corresponding 64-bit element in operand \a V2388/// is copied to the same position in the result.389/// \returns A 128-bit vector of [2 x double] containing the copied values.390#define _mm_blend_pd(V1, V2, M) \391 ((__m128d)__builtin_ia32_blendpd((__v2df)(__m128d)(V1), \392 (__v2df)(__m128d)(V2), (int)(M)))393 394/// Returns a 128-bit vector of [4 x float] where the values are selected395/// from either the first or second operand as specified by the third396/// operand, the control mask.397///398/// \headerfile <x86intrin.h>399///400/// \code401/// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M);402/// \endcode403///404/// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS </c> instruction.405///406/// \param V1407/// A 128-bit vector of [4 x float].408/// \param V2409/// A 128-bit vector of [4 x float].410/// \param M411/// An immediate integer operand, with mask bits [3:0] specifying how the412/// values are to be copied. The position of the mask bit corresponds to the413/// index of a copied value. When a mask bit is 0, the corresponding 32-bit414/// element in operand \a V1 is copied to the same position in the result.415/// When a mask bit is 1, the corresponding 32-bit element in operand \a V2416/// is copied to the same position in the result.417/// \returns A 128-bit vector of [4 x float] containing the copied values.418#define _mm_blend_ps(V1, V2, M) \419 ((__m128)__builtin_ia32_blendps((__v4sf)(__m128)(V1), (__v4sf)(__m128)(V2), \420 (int)(M)))421 422/// Returns a 128-bit vector of [2 x double] where the values are423/// selected from either the first or second operand as specified by the424/// third operand, the control mask.425///426/// \headerfile <x86intrin.h>427///428/// This intrinsic corresponds to the <c> VBLENDVPD / BLENDVPD </c> instruction.429///430/// \param __V1431/// A 128-bit vector of [2 x double].432/// \param __V2433/// A 128-bit vector of [2 x double].434/// \param __M435/// A 128-bit vector operand, with mask bits 127 and 63 specifying how the436/// values are to be copied. The position of the mask bit corresponds to the437/// most significant bit of a copied value. When a mask bit is 0, the438/// corresponding 64-bit element in operand \a __V1 is copied to the same439/// position in the result. When a mask bit is 1, the corresponding 64-bit440/// element in operand \a __V2 is copied to the same position in the result.441/// \returns A 128-bit vector of [2 x double] containing the copied values.442static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR443_mm_blendv_pd(__m128d __V1, __m128d __V2, __m128d __M) {444 return (__m128d)__builtin_ia32_blendvpd((__v2df)__V1, (__v2df)__V2,445 (__v2df)__M);446}447 448/// Returns a 128-bit vector of [4 x float] where the values are449/// selected from either the first or second operand as specified by the450/// third operand, the control mask.451///452/// \headerfile <x86intrin.h>453///454/// This intrinsic corresponds to the <c> VBLENDVPS / BLENDVPS </c> instruction.455///456/// \param __V1457/// A 128-bit vector of [4 x float].458/// \param __V2459/// A 128-bit vector of [4 x float].460/// \param __M461/// A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying462/// how the values are to be copied. The position of the mask bit corresponds463/// to the most significant bit of a copied value. When a mask bit is 0, the464/// corresponding 32-bit element in operand \a __V1 is copied to the same465/// position in the result. When a mask bit is 1, the corresponding 32-bit466/// element in operand \a __V2 is copied to the same position in the result.467/// \returns A 128-bit vector of [4 x float] containing the copied values.468static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR469_mm_blendv_ps(__m128 __V1, __m128 __V2, __m128 __M) {470 return (__m128)__builtin_ia32_blendvps((__v4sf)__V1, (__v4sf)__V2,471 (__v4sf)__M);472}473 474/// Returns a 128-bit vector of [16 x i8] where the values are selected475/// from either of the first or second operand as specified by the third476/// operand, the control mask.477///478/// \headerfile <x86intrin.h>479///480/// This intrinsic corresponds to the <c> VPBLENDVB / PBLENDVB </c> instruction.481///482/// \param __V1483/// A 128-bit vector of [16 x i8].484/// \param __V2485/// A 128-bit vector of [16 x i8].486/// \param __M487/// A 128-bit vector operand, with mask bits 127, 119, 111...7 specifying488/// how the values are to be copied. The position of the mask bit corresponds489/// to the most significant bit of a copied value. When a mask bit is 0, the490/// corresponding 8-bit element in operand \a __V1 is copied to the same491/// position in the result. When a mask bit is 1, the corresponding 8-bit492/// element in operand \a __V2 is copied to the same position in the result.493/// \returns A 128-bit vector of [16 x i8] containing the copied values.494static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR495_mm_blendv_epi8(__m128i __V1, __m128i __V2, __m128i __M) {496 return (__m128i)__builtin_ia32_pblendvb128((__v16qi)__V1, (__v16qi)__V2,497 (__v16qi)__M);498}499 500/// Returns a 128-bit vector of [8 x i16] where the values are selected501/// from either of the first or second operand as specified by the third502/// operand, the control mask.503///504/// \headerfile <x86intrin.h>505///506/// \code507/// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M);508/// \endcode509///510/// This intrinsic corresponds to the <c> VPBLENDW / PBLENDW </c> instruction.511///512/// \param V1513/// A 128-bit vector of [8 x i16].514/// \param V2515/// A 128-bit vector of [8 x i16].516/// \param M517/// An immediate integer operand, with mask bits [7:0] specifying how the518/// values are to be copied. The position of the mask bit corresponds to the519/// index of a copied value. When a mask bit is 0, the corresponding 16-bit520/// element in operand \a V1 is copied to the same position in the result.521/// When a mask bit is 1, the corresponding 16-bit element in operand \a V2522/// is copied to the same position in the result.523/// \returns A 128-bit vector of [8 x i16] containing the copied values.524#define _mm_blend_epi16(V1, V2, M) \525 ((__m128i)__builtin_ia32_pblendw128((__v8hi)(__m128i)(V1), \526 (__v8hi)(__m128i)(V2), (int)(M)))527 528/* SSE4 Dword Multiply Instructions. */529/// Multiples corresponding elements of two 128-bit vectors of [4 x i32]530/// and returns the lower 32 bits of the each product in a 128-bit vector of531/// [4 x i32].532///533/// \headerfile <x86intrin.h>534///535/// This intrinsic corresponds to the <c> VPMULLD / PMULLD </c> instruction.536///537/// \param __V1538/// A 128-bit integer vector.539/// \param __V2540/// A 128-bit integer vector.541/// \returns A 128-bit integer vector containing the products of both operands.542static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR543_mm_mullo_epi32(__m128i __V1, __m128i __V2) {544 return (__m128i)((__v4su)__V1 * (__v4su)__V2);545}546 547/// Multiplies corresponding even-indexed elements of two 128-bit548/// vectors of [4 x i32] and returns a 128-bit vector of [2 x i64]549/// containing the products.550///551/// \headerfile <x86intrin.h>552///553/// This intrinsic corresponds to the <c> VPMULDQ / PMULDQ </c> instruction.554///555/// \param __V1556/// A 128-bit vector of [4 x i32].557/// \param __V2558/// A 128-bit vector of [4 x i32].559/// \returns A 128-bit vector of [2 x i64] containing the products of both560/// operands.561static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR562_mm_mul_epi32(__m128i __V1, __m128i __V2) {563 return (__m128i)__builtin_ia32_pmuldq128((__v4si)__V1, (__v4si)__V2);564}565 566/* SSE4 Floating Point Dot Product Instructions. */567/// Computes the dot product of the two 128-bit vectors of [4 x float]568/// and returns it in the elements of the 128-bit result vector of569/// [4 x float].570///571/// The immediate integer operand controls which input elements572/// will contribute to the dot product, and where the final results are573/// returned.574///575/// \headerfile <x86intrin.h>576///577/// \code578/// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M);579/// \endcode580///581/// This intrinsic corresponds to the <c> VDPPS / DPPS </c> instruction.582///583/// \param X584/// A 128-bit vector of [4 x float].585/// \param Y586/// A 128-bit vector of [4 x float].587/// \param M588/// An immediate integer operand. Mask bits [7:4] determine which elements589/// of the input vectors are used, with bit [4] corresponding to the lowest590/// element and bit [7] corresponding to the highest element of each [4 x591/// float] vector. If a bit is set, the corresponding elements from the two592/// input vectors are used as an input for dot product; otherwise that input593/// is treated as zero. Bits [3:0] determine which elements of the result594/// will receive a copy of the final dot product, with bit [0] corresponding595/// to the lowest element and bit [3] corresponding to the highest element of596/// each [4 x float] subvector. If a bit is set, the dot product is returned597/// in the corresponding element; otherwise that element is set to zero.598/// \returns A 128-bit vector of [4 x float] containing the dot product.599#define _mm_dp_ps(X, Y, M) \600 ((__m128)__builtin_ia32_dpps((__v4sf)(__m128)(X), (__v4sf)(__m128)(Y), (M)))601 602/// Computes the dot product of the two 128-bit vectors of [2 x double]603/// and returns it in the elements of the 128-bit result vector of604/// [2 x double].605///606/// The immediate integer operand controls which input607/// elements will contribute to the dot product, and where the final results608/// are returned.609///610/// \headerfile <x86intrin.h>611///612/// \code613/// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M);614/// \endcode615///616/// This intrinsic corresponds to the <c> VDPPD / DPPD </c> instruction.617///618/// \param X619/// A 128-bit vector of [2 x double].620/// \param Y621/// A 128-bit vector of [2 x double].622/// \param M623/// An immediate integer operand. Mask bits [5:4] determine which elements624/// of the input vectors are used, with bit [4] corresponding to the lowest625/// element and bit [5] corresponding to the highest element of each of [2 x626/// double] vector. If a bit is set, the corresponding elements from the two627/// input vectors are used as an input for dot product; otherwise that input628/// is treated as zero. Bits [1:0] determine which elements of the result629/// will receive a copy of the final dot product, with bit [0] corresponding630/// to the lowest element and bit [1] corresponding to the highest element of631/// each [2 x double] vector. If a bit is set, the dot product is returned in632/// the corresponding element; otherwise that element is set to zero.633#define _mm_dp_pd(X, Y, M) \634 ((__m128d)__builtin_ia32_dppd((__v2df)(__m128d)(X), (__v2df)(__m128d)(Y), \635 (M)))636 637/* SSE4 Streaming Load Hint Instruction. */638/// Loads integer values from a 128-bit aligned memory location to a639/// 128-bit integer vector.640///641/// \headerfile <x86intrin.h>642///643/// This intrinsic corresponds to the <c> VMOVNTDQA / MOVNTDQA </c> instruction.644///645/// \param __V646/// A pointer to a 128-bit aligned memory location that contains the integer647/// values.648/// \returns A 128-bit integer vector containing the data stored at the649/// specified memory location.650static __inline__ __m128i __DEFAULT_FN_ATTRS651_mm_stream_load_si128(const void *__V) {652 return (__m128i)__builtin_nontemporal_load((const __v2di *)__V);653}654 655/* SSE4 Packed Integer Min/Max Instructions. */656/// Compares the corresponding elements of two 128-bit vectors of657/// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser658/// of the two values.659///660/// \headerfile <x86intrin.h>661///662/// This intrinsic corresponds to the <c> VPMINSB / PMINSB </c> instruction.663///664/// \param __V1665/// A 128-bit vector of [16 x i8].666/// \param __V2667/// A 128-bit vector of [16 x i8]668/// \returns A 128-bit vector of [16 x i8] containing the lesser values.669static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR670_mm_min_epi8(__m128i __V1, __m128i __V2) {671 return (__m128i)__builtin_elementwise_min((__v16qs)__V1, (__v16qs)__V2);672}673 674/// Compares the corresponding elements of two 128-bit vectors of675/// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the676/// greater value of the two.677///678/// \headerfile <x86intrin.h>679///680/// This intrinsic corresponds to the <c> VPMAXSB / PMAXSB </c> instruction.681///682/// \param __V1683/// A 128-bit vector of [16 x i8].684/// \param __V2685/// A 128-bit vector of [16 x i8].686/// \returns A 128-bit vector of [16 x i8] containing the greater values.687static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR688_mm_max_epi8(__m128i __V1, __m128i __V2) {689 return (__m128i)__builtin_elementwise_max((__v16qs)__V1, (__v16qs)__V2);690}691 692/// Compares the corresponding elements of two 128-bit vectors of693/// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser694/// value of the two.695///696/// \headerfile <x86intrin.h>697///698/// This intrinsic corresponds to the <c> VPMINUW / PMINUW </c> instruction.699///700/// \param __V1701/// A 128-bit vector of [8 x u16].702/// \param __V2703/// A 128-bit vector of [8 x u16].704/// \returns A 128-bit vector of [8 x u16] containing the lesser values.705static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR706_mm_min_epu16(__m128i __V1, __m128i __V2) {707 return (__m128i)__builtin_elementwise_min((__v8hu)__V1, (__v8hu)__V2);708}709 710/// Compares the corresponding elements of two 128-bit vectors of711/// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the712/// greater value of the two.713///714/// \headerfile <x86intrin.h>715///716/// This intrinsic corresponds to the <c> VPMAXUW / PMAXUW </c> instruction.717///718/// \param __V1719/// A 128-bit vector of [8 x u16].720/// \param __V2721/// A 128-bit vector of [8 x u16].722/// \returns A 128-bit vector of [8 x u16] containing the greater values.723static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR724_mm_max_epu16(__m128i __V1, __m128i __V2) {725 return (__m128i)__builtin_elementwise_max((__v8hu)__V1, (__v8hu)__V2);726}727 728/// Compares the corresponding elements of two 128-bit vectors of729/// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser730/// value of the two.731///732/// \headerfile <x86intrin.h>733///734/// This intrinsic corresponds to the <c> VPMINSD / PMINSD </c> instruction.735///736/// \param __V1737/// A 128-bit vector of [4 x i32].738/// \param __V2739/// A 128-bit vector of [4 x i32].740/// \returns A 128-bit vector of [4 x i32] containing the lesser values.741static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR742_mm_min_epi32(__m128i __V1, __m128i __V2) {743 return (__m128i)__builtin_elementwise_min((__v4si)__V1, (__v4si)__V2);744}745 746/// Compares the corresponding elements of two 128-bit vectors of747/// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the748/// greater value of the two.749///750/// \headerfile <x86intrin.h>751///752/// This intrinsic corresponds to the <c> VPMAXSD / PMAXSD </c> instruction.753///754/// \param __V1755/// A 128-bit vector of [4 x i32].756/// \param __V2757/// A 128-bit vector of [4 x i32].758/// \returns A 128-bit vector of [4 x i32] containing the greater values.759static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR760_mm_max_epi32(__m128i __V1, __m128i __V2) {761 return (__m128i)__builtin_elementwise_max((__v4si)__V1, (__v4si)__V2);762}763 764/// Compares the corresponding elements of two 128-bit vectors of765/// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser766/// value of the two.767///768/// \headerfile <x86intrin.h>769///770/// This intrinsic corresponds to the <c> VPMINUD / PMINUD </c> instruction.771///772/// \param __V1773/// A 128-bit vector of [4 x u32].774/// \param __V2775/// A 128-bit vector of [4 x u32].776/// \returns A 128-bit vector of [4 x u32] containing the lesser values.777static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR778_mm_min_epu32(__m128i __V1, __m128i __V2) {779 return (__m128i)__builtin_elementwise_min((__v4su)__V1, (__v4su)__V2);780}781 782/// Compares the corresponding elements of two 128-bit vectors of783/// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the784/// greater value of the two.785///786/// \headerfile <x86intrin.h>787///788/// This intrinsic corresponds to the <c> VPMAXUD / PMAXUD </c> instruction.789///790/// \param __V1791/// A 128-bit vector of [4 x u32].792/// \param __V2793/// A 128-bit vector of [4 x u32].794/// \returns A 128-bit vector of [4 x u32] containing the greater values.795static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR796_mm_max_epu32(__m128i __V1, __m128i __V2) {797 return (__m128i)__builtin_elementwise_max((__v4su)__V1, (__v4su)__V2);798}799 800/* SSE4 Insertion and Extraction from XMM Register Instructions. */801/// Takes the first argument \a X and inserts an element from the second802/// argument \a Y as selected by the third argument \a N. That result then803/// has elements zeroed out also as selected by the third argument \a N. The804/// resulting 128-bit vector of [4 x float] is then returned.805///806/// \headerfile <x86intrin.h>807///808/// \code809/// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N);810/// \endcode811///812/// This intrinsic corresponds to the <c> VINSERTPS </c> instruction.813///814/// \param X815/// A 128-bit vector source operand of [4 x float]. With the exception of816/// those bits in the result copied from parameter \a Y and zeroed by bits817/// [3:0] of \a N, all bits from this parameter are copied to the result.818/// \param Y819/// A 128-bit vector source operand of [4 x float]. One single-precision820/// floating-point element from this source, as determined by the immediate821/// parameter, is copied to the result.822/// \param N823/// Specifies which bits from operand \a Y will be copied, which bits in the824/// result they will be copied to, and which bits in the result will be825/// cleared. The following assignments are made: \n826/// Bits [7:6] specify the bits to copy from operand \a Y: \n827/// 00: Selects bits [31:0] from operand \a Y. \n828/// 01: Selects bits [63:32] from operand \a Y. \n829/// 10: Selects bits [95:64] from operand \a Y. \n830/// 11: Selects bits [127:96] from operand \a Y. \n831/// Bits [5:4] specify the bits in the result to which the selected bits832/// from operand \a Y are copied: \n833/// 00: Copies the selected bits from \a Y to result bits [31:0]. \n834/// 01: Copies the selected bits from \a Y to result bits [63:32]. \n835/// 10: Copies the selected bits from \a Y to result bits [95:64]. \n836/// 11: Copies the selected bits from \a Y to result bits [127:96]. \n837/// Bits[3:0]: If any of these bits are set, the corresponding result838/// element is cleared.839/// \returns A 128-bit vector of [4 x float] containing the copied840/// single-precision floating point elements from the operands.841#define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N))842 843/// Extracts a 32-bit integer from a 128-bit vector of [4 x float] and844/// returns it, using the immediate value parameter \a N as a selector.845///846/// \headerfile <x86intrin.h>847///848/// \code849/// int _mm_extract_ps(__m128 X, const int N);850/// \endcode851///852/// This intrinsic corresponds to the <c> VEXTRACTPS / EXTRACTPS </c>853/// instruction.854///855/// \param X856/// A 128-bit vector of [4 x float].857/// \param N858/// An immediate value. Bits [1:0] determines which bits from the argument859/// \a X are extracted and returned: \n860/// 00: Bits [31:0] of parameter \a X are returned. \n861/// 01: Bits [63:32] of parameter \a X are returned. \n862/// 10: Bits [95:64] of parameter \a X are returned. \n863/// 11: Bits [127:96] of parameter \a X are returned.864/// \returns A 32-bit integer containing the extracted 32 bits of float data.865#define _mm_extract_ps(X, N) \866 __builtin_bit_cast( \867 int, __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)))868 869/* Miscellaneous insert and extract macros. */870/* Extract a single-precision float from X at index N into D. */871#define _MM_EXTRACT_FLOAT(D, X, N) \872 do { \873 (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); \874 } while (0)875 876/* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create877 an index suitable for _mm_insert_ps. */878#define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z))879 880/* Extract a float from X at index N into the first index of the return. */881#define _MM_PICK_OUT_PS(X, N) \882 _mm_insert_ps(_mm_setzero_ps(), (X), _MM_MK_INSERTPS_NDX((N), 0, 0x0e))883 884/* Insert int into packed integer array at index. */885/// Constructs a 128-bit vector of [16 x i8] by first making a copy of886/// the 128-bit integer vector parameter, and then inserting the lower 8 bits887/// of an integer parameter \a I into an offset specified by the immediate888/// value parameter \a N.889///890/// \headerfile <x86intrin.h>891///892/// \code893/// __m128i _mm_insert_epi8(__m128i X, int I, const int N);894/// \endcode895///896/// This intrinsic corresponds to the <c> VPINSRB / PINSRB </c> instruction.897///898/// \param X899/// A 128-bit integer vector of [16 x i8]. This vector is copied to the900/// result and then one of the sixteen elements in the result vector is901/// replaced by the lower 8 bits of \a I.902/// \param I903/// An integer. The lower 8 bits of this operand are written to the result904/// beginning at the offset specified by \a N.905/// \param N906/// An immediate value. Bits [3:0] specify the bit offset in the result at907/// which the lower 8 bits of \a I are written. \n908/// 0000: Bits [7:0] of the result are used for insertion. \n909/// 0001: Bits [15:8] of the result are used for insertion. \n910/// 0010: Bits [23:16] of the result are used for insertion. \n911/// 0011: Bits [31:24] of the result are used for insertion. \n912/// 0100: Bits [39:32] of the result are used for insertion. \n913/// 0101: Bits [47:40] of the result are used for insertion. \n914/// 0110: Bits [55:48] of the result are used for insertion. \n915/// 0111: Bits [63:56] of the result are used for insertion. \n916/// 1000: Bits [71:64] of the result are used for insertion. \n917/// 1001: Bits [79:72] of the result are used for insertion. \n918/// 1010: Bits [87:80] of the result are used for insertion. \n919/// 1011: Bits [95:88] of the result are used for insertion. \n920/// 1100: Bits [103:96] of the result are used for insertion. \n921/// 1101: Bits [111:104] of the result are used for insertion. \n922/// 1110: Bits [119:112] of the result are used for insertion. \n923/// 1111: Bits [127:120] of the result are used for insertion.924/// \returns A 128-bit integer vector containing the constructed values.925#define _mm_insert_epi8(X, I, N) \926 ((__m128i)__builtin_ia32_vec_set_v16qi((__v16qi)(__m128i)(X), (int)(I), \927 (int)(N)))928 929/// Constructs a 128-bit vector of [4 x i32] by first making a copy of930/// the 128-bit integer vector parameter, and then inserting the 32-bit931/// integer parameter \a I at the offset specified by the immediate value932/// parameter \a N.933///934/// \headerfile <x86intrin.h>935///936/// \code937/// __m128i _mm_insert_epi32(__m128i X, int I, const int N);938/// \endcode939///940/// This intrinsic corresponds to the <c> VPINSRD / PINSRD </c> instruction.941///942/// \param X943/// A 128-bit integer vector of [4 x i32]. This vector is copied to the944/// result and then one of the four elements in the result vector is945/// replaced by \a I.946/// \param I947/// A 32-bit integer that is written to the result beginning at the offset948/// specified by \a N.949/// \param N950/// An immediate value. Bits [1:0] specify the bit offset in the result at951/// which the integer \a I is written. \n952/// 00: Bits [31:0] of the result are used for insertion. \n953/// 01: Bits [63:32] of the result are used for insertion. \n954/// 10: Bits [95:64] of the result are used for insertion. \n955/// 11: Bits [127:96] of the result are used for insertion.956/// \returns A 128-bit integer vector containing the constructed values.957#define _mm_insert_epi32(X, I, N) \958 ((__m128i)__builtin_ia32_vec_set_v4si((__v4si)(__m128i)(X), (int)(I), \959 (int)(N)))960 961#ifdef __x86_64__962/// Constructs a 128-bit vector of [2 x i64] by first making a copy of963/// the 128-bit integer vector parameter, and then inserting the 64-bit964/// integer parameter \a I, using the immediate value parameter \a N as an965/// insertion location selector.966///967/// \headerfile <x86intrin.h>968///969/// \code970/// __m128i _mm_insert_epi64(__m128i X, long long I, const int N);971/// \endcode972///973/// This intrinsic corresponds to the <c> VPINSRQ / PINSRQ </c> instruction.974///975/// \param X976/// A 128-bit integer vector of [2 x i64]. This vector is copied to the977/// result and then one of the two elements in the result vector is replaced978/// by \a I.979/// \param I980/// A 64-bit integer that is written to the result beginning at the offset981/// specified by \a N.982/// \param N983/// An immediate value. Bit [0] specifies the bit offset in the result at984/// which the integer \a I is written. \n985/// 0: Bits [63:0] of the result are used for insertion. \n986/// 1: Bits [127:64] of the result are used for insertion. \n987/// \returns A 128-bit integer vector containing the constructed values.988#define _mm_insert_epi64(X, I, N) \989 ((__m128i)__builtin_ia32_vec_set_v2di((__v2di)(__m128i)(X), (long long)(I), \990 (int)(N)))991#endif /* __x86_64__ */992 993/* Extract int from packed integer array at index. This returns the element994 * as a zero extended value, so it is unsigned.995 */996/// Extracts an 8-bit element from the 128-bit integer vector of997/// [16 x i8], using the immediate value parameter \a N as a selector.998///999/// \headerfile <x86intrin.h>1000///1001/// \code1002/// int _mm_extract_epi8(__m128i X, const int N);1003/// \endcode1004///1005/// This intrinsic corresponds to the <c> VPEXTRB / PEXTRB </c> instruction.1006///1007/// \param X1008/// A 128-bit integer vector.1009/// \param N1010/// An immediate value. Bits [3:0] specify which 8-bit vector element from1011/// the argument \a X to extract and copy to the result. \n1012/// 0000: Bits [7:0] of parameter \a X are extracted. \n1013/// 0001: Bits [15:8] of the parameter \a X are extracted. \n1014/// 0010: Bits [23:16] of the parameter \a X are extracted. \n1015/// 0011: Bits [31:24] of the parameter \a X are extracted. \n1016/// 0100: Bits [39:32] of the parameter \a X are extracted. \n1017/// 0101: Bits [47:40] of the parameter \a X are extracted. \n1018/// 0110: Bits [55:48] of the parameter \a X are extracted. \n1019/// 0111: Bits [63:56] of the parameter \a X are extracted. \n1020/// 1000: Bits [71:64] of the parameter \a X are extracted. \n1021/// 1001: Bits [79:72] of the parameter \a X are extracted. \n1022/// 1010: Bits [87:80] of the parameter \a X are extracted. \n1023/// 1011: Bits [95:88] of the parameter \a X are extracted. \n1024/// 1100: Bits [103:96] of the parameter \a X are extracted. \n1025/// 1101: Bits [111:104] of the parameter \a X are extracted. \n1026/// 1110: Bits [119:112] of the parameter \a X are extracted. \n1027/// 1111: Bits [127:120] of the parameter \a X are extracted.1028/// \returns An unsigned integer, whose lower 8 bits are selected from the1029/// 128-bit integer vector parameter and the remaining bits are assigned1030/// zeros.1031#define _mm_extract_epi8(X, N) \1032 ((int)(unsigned char)__builtin_ia32_vec_ext_v16qi((__v16qi)(__m128i)(X), \1033 (int)(N)))1034 1035/// Extracts a 32-bit element from the 128-bit integer vector of1036/// [4 x i32], using the immediate value parameter \a N as a selector.1037///1038/// \headerfile <x86intrin.h>1039///1040/// \code1041/// int _mm_extract_epi32(__m128i X, const int N);1042/// \endcode1043///1044/// This intrinsic corresponds to the <c> VPEXTRD / PEXTRD </c> instruction.1045///1046/// \param X1047/// A 128-bit integer vector.1048/// \param N1049/// An immediate value. Bits [1:0] specify which 32-bit vector element from1050/// the argument \a X to extract and copy to the result. \n1051/// 00: Bits [31:0] of the parameter \a X are extracted. \n1052/// 01: Bits [63:32] of the parameter \a X are extracted. \n1053/// 10: Bits [95:64] of the parameter \a X are extracted. \n1054/// 11: Bits [127:96] of the parameter \a X are exracted.1055/// \returns An integer, whose lower 32 bits are selected from the 128-bit1056/// integer vector parameter and the remaining bits are assigned zeros.1057#define _mm_extract_epi32(X, N) \1058 ((int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N)))1059 1060/// Extracts a 64-bit element from the 128-bit integer vector of1061/// [2 x i64], using the immediate value parameter \a N as a selector.1062///1063/// \headerfile <x86intrin.h>1064///1065/// \code1066/// long long _mm_extract_epi64(__m128i X, const int N);1067/// \endcode1068///1069/// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction1070/// in 64-bit mode.1071///1072/// \param X1073/// A 128-bit integer vector.1074/// \param N1075/// An immediate value. Bit [0] specifies which 64-bit vector element from1076/// the argument \a X to return. \n1077/// 0: Bits [63:0] are returned. \n1078/// 1: Bits [127:64] are returned. \n1079/// \returns A 64-bit integer.1080#define _mm_extract_epi64(X, N) \1081 ((long long)__builtin_ia32_vec_ext_v2di((__v2di)(__m128i)(X), (int)(N)))1082 1083/* SSE4 128-bit Packed Integer Comparisons. */1084/// Tests whether the specified bits in a 128-bit integer vector are all1085/// zeros.1086///1087/// \headerfile <x86intrin.h>1088///1089/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.1090///1091/// \param __M1092/// A 128-bit integer vector containing the bits to be tested.1093/// \param __V1094/// A 128-bit integer vector selecting which bits to test in operand \a __M.1095/// \returns TRUE if the specified bits are all zeros; FALSE otherwise.1096static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR1097_mm_testz_si128(__m128i __M, __m128i __V) {1098 return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V);1099}1100 1101/// Tests whether the specified bits in a 128-bit integer vector are all1102/// ones.1103///1104/// \headerfile <x86intrin.h>1105///1106/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.1107///1108/// \param __M1109/// A 128-bit integer vector containing the bits to be tested.1110/// \param __V1111/// A 128-bit integer vector selecting which bits to test in operand \a __M.1112/// \returns TRUE if the specified bits are all ones; FALSE otherwise.1113static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR1114_mm_testc_si128(__m128i __M, __m128i __V) {1115 return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V);1116}1117 1118/// Tests whether the specified bits in a 128-bit integer vector are1119/// neither all zeros nor all ones.1120///1121/// \headerfile <x86intrin.h>1122///1123/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.1124///1125/// \param __M1126/// A 128-bit integer vector containing the bits to be tested.1127/// \param __V1128/// A 128-bit integer vector selecting which bits to test in operand \a __M.1129/// \returns TRUE if the specified bits are neither all zeros nor all ones;1130/// FALSE otherwise.1131static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR1132_mm_testnzc_si128(__m128i __M, __m128i __V) {1133 return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V);1134}1135 1136/// Tests whether the specified bits in a 128-bit integer vector are all1137/// ones.1138///1139/// \headerfile <x86intrin.h>1140///1141/// \code1142/// int _mm_test_all_ones(__m128i V);1143/// \endcode1144///1145/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.1146///1147/// \param V1148/// A 128-bit integer vector containing the bits to be tested.1149/// \returns TRUE if the bits specified in the operand are all set to 1; FALSE1150/// otherwise.1151#define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_set1_epi32(-1))1152 1153/// Tests whether the specified bits in a 128-bit integer vector are1154/// neither all zeros nor all ones.1155///1156/// \headerfile <x86intrin.h>1157///1158/// \code1159/// int _mm_test_mix_ones_zeros(__m128i M, __m128i V);1160/// \endcode1161///1162/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.1163///1164/// \param M1165/// A 128-bit integer vector containing the bits to be tested.1166/// \param V1167/// A 128-bit integer vector selecting which bits to test in operand \a M.1168/// \returns TRUE if the specified bits are neither all zeros nor all ones;1169/// FALSE otherwise.1170#define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V))1171 1172/// Tests whether the specified bits in a 128-bit integer vector are all1173/// zeros.1174///1175/// \headerfile <x86intrin.h>1176///1177/// \code1178/// int _mm_test_all_zeros(__m128i M, __m128i V);1179/// \endcode1180///1181/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction.1182///1183/// \param M1184/// A 128-bit integer vector containing the bits to be tested.1185/// \param V1186/// A 128-bit integer vector selecting which bits to test in operand \a M.1187/// \returns TRUE if the specified bits are all zeros; FALSE otherwise.1188#define _mm_test_all_zeros(M, V) _mm_testz_si128((M), (V))1189 1190/* SSE4 64-bit Packed Integer Comparisons. */1191/// Compares each of the corresponding 64-bit values of the 128-bit1192/// integer vectors for equality.1193///1194/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.1195///1196/// \headerfile <x86intrin.h>1197///1198/// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction.1199///1200/// \param __V11201/// A 128-bit integer vector.1202/// \param __V21203/// A 128-bit integer vector.1204/// \returns A 128-bit integer vector containing the comparison results.1205static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1206_mm_cmpeq_epi64(__m128i __V1, __m128i __V2) {1207 return (__m128i)((__v2di)__V1 == (__v2di)__V2);1208}1209 1210/* SSE4 Packed Integer Sign-Extension. */1211/// Sign-extends each of the lower eight 8-bit integer elements of a1212/// 128-bit vector of [16 x i8] to 16-bit values and returns them in a1213/// 128-bit vector of [8 x i16]. The upper eight elements of the input vector1214/// are unused.1215///1216/// \headerfile <x86intrin.h>1217///1218/// This intrinsic corresponds to the <c> VPMOVSXBW / PMOVSXBW </c> instruction.1219///1220/// \param __V1221/// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are1222/// sign-extended to 16-bit values.1223/// \returns A 128-bit vector of [8 x i16] containing the sign-extended values.1224static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1225_mm_cvtepi8_epi16(__m128i __V) {1226 /* This function always performs a signed extension, but __v16qi is a char1227 which may be signed or unsigned, so use __v16qs. */1228 return (__m128i) __builtin_convertvector(1229 __builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6,1230 7),1231 __v8hi);1232}1233 1234/// Sign-extends each of the lower four 8-bit integer elements of a1235/// 128-bit vector of [16 x i8] to 32-bit values and returns them in a1236/// 128-bit vector of [4 x i32]. The upper twelve elements of the input1237/// vector are unused.1238///1239/// \headerfile <x86intrin.h>1240///1241/// This intrinsic corresponds to the <c> VPMOVSXBD / PMOVSXBD </c> instruction.1242///1243/// \param __V1244/// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are1245/// sign-extended to 32-bit values.1246/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.1247static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1248_mm_cvtepi8_epi32(__m128i __V) {1249 /* This function always performs a signed extension, but __v16qi is a char1250 which may be signed or unsigned, so use __v16qs. */1251 return (__m128i) __builtin_convertvector(1252 __builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si);1253}1254 1255/// Sign-extends each of the lower two 8-bit integer elements of a1256/// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in1257/// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input1258/// vector are unused.1259///1260/// \headerfile <x86intrin.h>1261///1262/// This intrinsic corresponds to the <c> VPMOVSXBQ / PMOVSXBQ </c> instruction.1263///1264/// \param __V1265/// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are1266/// sign-extended to 64-bit values.1267/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.1268static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1269_mm_cvtepi8_epi64(__m128i __V) {1270 /* This function always performs a signed extension, but __v16qi is a char1271 which may be signed or unsigned, so use __v16qs. */1272 return (__m128i) __builtin_convertvector(1273 __builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di);1274}1275 1276/// Sign-extends each of the lower four 16-bit integer elements of a1277/// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in1278/// a 128-bit vector of [4 x i32]. The upper four elements of the input1279/// vector are unused.1280///1281/// \headerfile <x86intrin.h>1282///1283/// This intrinsic corresponds to the <c> VPMOVSXWD / PMOVSXWD </c> instruction.1284///1285/// \param __V1286/// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are1287/// sign-extended to 32-bit values.1288/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.1289static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1290_mm_cvtepi16_epi32(__m128i __V) {1291 return (__m128i) __builtin_convertvector(1292 __builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si);1293}1294 1295/// Sign-extends each of the lower two 16-bit integer elements of a1296/// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in1297/// a 128-bit vector of [2 x i64]. The upper six elements of the input1298/// vector are unused.1299///1300/// \headerfile <x86intrin.h>1301///1302/// This intrinsic corresponds to the <c> VPMOVSXWQ / PMOVSXWQ </c> instruction.1303///1304/// \param __V1305/// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are1306/// sign-extended to 64-bit values.1307/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.1308static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1309_mm_cvtepi16_epi64(__m128i __V) {1310 return (__m128i) __builtin_convertvector(1311 __builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di);1312}1313 1314/// Sign-extends each of the lower two 32-bit integer elements of a1315/// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in1316/// a 128-bit vector of [2 x i64]. The upper two elements of the input vector1317/// are unused.1318///1319/// \headerfile <x86intrin.h>1320///1321/// This intrinsic corresponds to the <c> VPMOVSXDQ / PMOVSXDQ </c> instruction.1322///1323/// \param __V1324/// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are1325/// sign-extended to 64-bit values.1326/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.1327static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1328_mm_cvtepi32_epi64(__m128i __V) {1329 return (__m128i) __builtin_convertvector(1330 __builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di);1331}1332 1333/* SSE4 Packed Integer Zero-Extension. */1334/// Zero-extends each of the lower eight 8-bit integer elements of a1335/// 128-bit vector of [16 x i8] to 16-bit values and returns them in a1336/// 128-bit vector of [8 x i16]. The upper eight elements of the input vector1337/// are unused.1338///1339/// \headerfile <x86intrin.h>1340///1341/// This intrinsic corresponds to the <c> VPMOVZXBW / PMOVZXBW </c> instruction.1342///1343/// \param __V1344/// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are1345/// zero-extended to 16-bit values.1346/// \returns A 128-bit vector of [8 x i16] containing the zero-extended values.1347static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1348_mm_cvtepu8_epi16(__m128i __V) {1349 return (__m128i) __builtin_convertvector(1350 __builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6,1351 7),1352 __v8hi);1353}1354 1355/// Zero-extends each of the lower four 8-bit integer elements of a1356/// 128-bit vector of [16 x i8] to 32-bit values and returns them in a1357/// 128-bit vector of [4 x i32]. The upper twelve elements of the input1358/// vector are unused.1359///1360/// \headerfile <x86intrin.h>1361///1362/// This intrinsic corresponds to the <c> VPMOVZXBD / PMOVZXBD </c> instruction.1363///1364/// \param __V1365/// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are1366/// zero-extended to 32-bit values.1367/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.1368static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1369_mm_cvtepu8_epi32(__m128i __V) {1370 return (__m128i) __builtin_convertvector(1371 __builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si);1372}1373 1374/// Zero-extends each of the lower two 8-bit integer elements of a1375/// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in1376/// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input1377/// vector are unused.1378///1379/// \headerfile <x86intrin.h>1380///1381/// This intrinsic corresponds to the <c> VPMOVZXBQ / PMOVZXBQ </c> instruction.1382///1383/// \param __V1384/// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are1385/// zero-extended to 64-bit values.1386/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.1387static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1388_mm_cvtepu8_epi64(__m128i __V) {1389 return (__m128i) __builtin_convertvector(1390 __builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di);1391}1392 1393/// Zero-extends each of the lower four 16-bit integer elements of a1394/// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in1395/// a 128-bit vector of [4 x i32]. The upper four elements of the input1396/// vector are unused.1397///1398/// \headerfile <x86intrin.h>1399///1400/// This intrinsic corresponds to the <c> VPMOVZXWD / PMOVZXWD </c> instruction.1401///1402/// \param __V1403/// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are1404/// zero-extended to 32-bit values.1405/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values.1406static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1407_mm_cvtepu16_epi32(__m128i __V) {1408 return (__m128i) __builtin_convertvector(1409 __builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si);1410}1411 1412/// Zero-extends each of the lower two 16-bit integer elements of a1413/// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in1414/// a 128-bit vector of [2 x i64]. The upper six elements of the input vector1415/// are unused.1416///1417/// \headerfile <x86intrin.h>1418///1419/// This intrinsic corresponds to the <c> VPMOVZXWQ / PMOVZXWQ </c> instruction.1420///1421/// \param __V1422/// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are1423/// zero-extended to 64-bit values.1424/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.1425static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1426_mm_cvtepu16_epi64(__m128i __V) {1427 return (__m128i) __builtin_convertvector(1428 __builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di);1429}1430 1431/// Zero-extends each of the lower two 32-bit integer elements of a1432/// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in1433/// a 128-bit vector of [2 x i64]. The upper two elements of the input vector1434/// are unused.1435///1436/// \headerfile <x86intrin.h>1437///1438/// This intrinsic corresponds to the <c> VPMOVZXDQ / PMOVZXDQ </c> instruction.1439///1440/// \param __V1441/// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are1442/// zero-extended to 64-bit values.1443/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values.1444static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1445_mm_cvtepu32_epi64(__m128i __V) {1446 return (__m128i) __builtin_convertvector(1447 __builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di);1448}1449 1450/* SSE4 Pack with Unsigned Saturation. */1451/// Converts, with saturation, 32-bit signed integers from both 128-bit integer1452/// vector operands into 16-bit unsigned integers, and returns the packed1453/// result.1454///1455/// Values greater than 0xFFFF are saturated to 0xFFFF. Values less than1456/// 0x0000 are saturated to 0x0000.1457///1458/// \headerfile <x86intrin.h>1459///1460/// This intrinsic corresponds to the <c> VPACKUSDW / PACKUSDW </c> instruction.1461///1462/// \param __V11463/// A 128-bit vector of [4 x i32]. The converted [4 x i16] values are1464/// written to the lower 64 bits of the result.1465/// \param __V21466/// A 128-bit vector of [4 x i32]. The converted [4 x i16] values are1467/// written to the higher 64 bits of the result.1468/// \returns A 128-bit vector of [8 x i16] containing the converted values.1469static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1470_mm_packus_epi32(__m128i __V1, __m128i __V2) {1471 return (__m128i)__builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2);1472}1473 1474/* SSE4 Multiple Packed Sums of Absolute Difference. */1475/// Subtracts 8-bit unsigned integer values and computes the absolute1476/// values of the differences to the corresponding bits in the destination.1477/// Then sums of the absolute differences are returned according to the bit1478/// fields in the immediate operand.1479///1480/// \headerfile <x86intrin.h>1481///1482/// \code1483/// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M);1484/// \endcode1485///1486/// This intrinsic corresponds to the <c> VMPSADBW / MPSADBW </c> instruction.1487///1488/// \param X1489/// A 128-bit vector of [16 x i8].1490/// \param Y1491/// A 128-bit vector of [16 x i8].1492/// \param M1493/// An 8-bit immediate operand specifying how the absolute differences are to1494/// be calculated, according to the following algorithm:1495/// \code1496/// // M2 represents bit 2 of the immediate operand1497/// // M10 represents bits [1:0] of the immediate operand1498/// i = M2 * 4;1499/// j = M10 * 4;1500/// for (k = 0; k < 8; k = k + 1) {1501/// d0 = abs(X[i + k + 0] - Y[j + 0]);1502/// d1 = abs(X[i + k + 1] - Y[j + 1]);1503/// d2 = abs(X[i + k + 2] - Y[j + 2]);1504/// d3 = abs(X[i + k + 3] - Y[j + 3]);1505/// r[k] = d0 + d1 + d2 + d3;1506/// }1507/// \endcode1508/// \returns A 128-bit integer vector containing the sums of the sets of1509/// absolute differences between both operands.1510#define _mm_mpsadbw_epu8(X, Y, M) \1511 ((__m128i)__builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \1512 (__v16qi)(__m128i)(Y), (M)))1513 1514/// Finds the minimum unsigned 16-bit element in the input 128-bit1515/// vector of [8 x u16] and returns it and along with its index.1516///1517/// \headerfile <x86intrin.h>1518///1519/// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c>1520/// instruction.1521///1522/// \param __V1523/// A 128-bit vector of [8 x u16].1524/// \returns A 128-bit value where bits [15:0] contain the minimum value found1525/// in parameter \a __V, bits [18:16] contain the index of the minimum value1526/// and the remaining bits are set to 0.1527static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR1528_mm_minpos_epu16(__m128i __V) {1529 return (__m128i)__builtin_ia32_phminposuw128((__v8hi)__V);1530}1531 1532/* Handle the sse4.2 definitions here. */1533 1534/* These definitions are normally in nmmintrin.h, but gcc puts them in here1535 so we'll do the same. */1536 1537#undef __DEFAULT_FN_ATTRS1538#undef __DEFAULT_FN_ATTRS_CONSTEXPR1539#define __DEFAULT_FN_ATTRS \1540 __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))1541 1542#if defined(__cplusplus) && (__cplusplus >= 201103L)1543#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr1544#else1545#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS1546#endif1547 1548/* These specify the type of data that we're comparing. */1549#define _SIDD_UBYTE_OPS 0x001550#define _SIDD_UWORD_OPS 0x011551#define _SIDD_SBYTE_OPS 0x021552#define _SIDD_SWORD_OPS 0x031553 1554/* These specify the type of comparison operation. */1555#define _SIDD_CMP_EQUAL_ANY 0x001556#define _SIDD_CMP_RANGES 0x041557#define _SIDD_CMP_EQUAL_EACH 0x081558#define _SIDD_CMP_EQUAL_ORDERED 0x0c1559 1560/* These macros specify the polarity of the operation. */1561#define _SIDD_POSITIVE_POLARITY 0x001562#define _SIDD_NEGATIVE_POLARITY 0x101563#define _SIDD_MASKED_POSITIVE_POLARITY 0x201564#define _SIDD_MASKED_NEGATIVE_POLARITY 0x301565 1566/* These macros are used in _mm_cmpXstri() to specify the return. */1567#define _SIDD_LEAST_SIGNIFICANT 0x001568#define _SIDD_MOST_SIGNIFICANT 0x401569 1570/* These macros are used in _mm_cmpXstri() to specify the return. */1571#define _SIDD_BIT_MASK 0x001572#define _SIDD_UNIT_MASK 0x401573 1574/* SSE4.2 Packed Comparison Intrinsics. */1575/// Uses the immediate operand \a M to perform a comparison of string1576/// data with implicitly defined lengths that is contained in source operands1577/// \a A and \a B. Returns a 128-bit integer vector representing the result1578/// mask of the comparison.1579///1580/// \headerfile <x86intrin.h>1581///1582/// \code1583/// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M);1584/// \endcode1585///1586/// This intrinsic corresponds to the <c> VPCMPISTRM / PCMPISTRM </c>1587/// instruction.1588///1589/// \param A1590/// A 128-bit integer vector containing one of the source operands to be1591/// compared.1592/// \param B1593/// A 128-bit integer vector containing one of the source operands to be1594/// compared.1595/// \param M1596/// An 8-bit immediate operand specifying whether the characters are bytes or1597/// words, the type of comparison to perform, and the format of the return1598/// value. \n1599/// Bits [1:0]: Determine source data format. \n1600/// 00: 16 unsigned bytes \n1601/// 01: 8 unsigned words \n1602/// 10: 16 signed bytes \n1603/// 11: 8 signed words \n1604/// Bits [3:2]: Determine comparison type and aggregation method. \n1605/// 00: Subset: Each character in \a B is compared for equality with all1606/// the characters in \a A. \n1607/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1608/// basis is greater than or equal for even-indexed elements in \a A,1609/// and less than or equal for odd-indexed elements in \a A. \n1610/// 10: Match: Compare each pair of corresponding characters in \a A and1611/// \a B for equality. \n1612/// 11: Substring: Search \a B for substring matches of \a A. \n1613/// Bits [5:4]: Determine whether to perform a one's complement on the bit1614/// mask of the comparison results. \n1615/// 00: No effect. \n1616/// 01: Negate the bit mask. \n1617/// 10: No effect. \n1618/// 11: Negate the bit mask only for bits with an index less than or equal1619/// to the size of \a A or \a B. \n1620/// Bit [6]: Determines whether the result is zero-extended or expanded to 161621/// bytes. \n1622/// 0: The result is zero-extended to 16 bytes. \n1623/// 1: The result is expanded to 16 bytes (this expansion is performed by1624/// repeating each bit 8 or 16 times).1625/// \returns Returns a 128-bit integer vector representing the result mask of1626/// the comparison.1627#define _mm_cmpistrm(A, B, M) \1628 ((__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \1629 (__v16qi)(__m128i)(B), (int)(M)))1630 1631/// Uses the immediate operand \a M to perform a comparison of string1632/// data with implicitly defined lengths that is contained in source operands1633/// \a A and \a B. Returns an integer representing the result index of the1634/// comparison.1635///1636/// \headerfile <x86intrin.h>1637///1638/// \code1639/// int _mm_cmpistri(__m128i A, __m128i B, const int M);1640/// \endcode1641///1642/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>1643/// instruction.1644///1645/// \param A1646/// A 128-bit integer vector containing one of the source operands to be1647/// compared.1648/// \param B1649/// A 128-bit integer vector containing one of the source operands to be1650/// compared.1651/// \param M1652/// An 8-bit immediate operand specifying whether the characters are bytes or1653/// words, the type of comparison to perform, and the format of the return1654/// value. \n1655/// Bits [1:0]: Determine source data format. \n1656/// 00: 16 unsigned bytes \n1657/// 01: 8 unsigned words \n1658/// 10: 16 signed bytes \n1659/// 11: 8 signed words \n1660/// Bits [3:2]: Determine comparison type and aggregation method. \n1661/// 00: Subset: Each character in \a B is compared for equality with all1662/// the characters in \a A. \n1663/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1664/// basis is greater than or equal for even-indexed elements in \a A,1665/// and less than or equal for odd-indexed elements in \a A. \n1666/// 10: Match: Compare each pair of corresponding characters in \a A and1667/// \a B for equality. \n1668/// 11: Substring: Search B for substring matches of \a A. \n1669/// Bits [5:4]: Determine whether to perform a one's complement on the bit1670/// mask of the comparison results. \n1671/// 00: No effect. \n1672/// 01: Negate the bit mask. \n1673/// 10: No effect. \n1674/// 11: Negate the bit mask only for bits with an index less than or equal1675/// to the size of \a A or \a B. \n1676/// Bit [6]: Determines whether the index of the lowest set bit or the1677/// highest set bit is returned. \n1678/// 0: The index of the least significant set bit. \n1679/// 1: The index of the most significant set bit. \n1680/// \returns Returns an integer representing the result index of the comparison.1681#define _mm_cmpistri(A, B, M) \1682 ((int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \1683 (__v16qi)(__m128i)(B), (int)(M)))1684 1685/// Uses the immediate operand \a M to perform a comparison of string1686/// data with explicitly defined lengths that is contained in source operands1687/// \a A and \a B. Returns a 128-bit integer vector representing the result1688/// mask of the comparison.1689///1690/// \headerfile <x86intrin.h>1691///1692/// \code1693/// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M);1694/// \endcode1695///1696/// This intrinsic corresponds to the <c> VPCMPESTRM / PCMPESTRM </c>1697/// instruction.1698///1699/// \param A1700/// A 128-bit integer vector containing one of the source operands to be1701/// compared.1702/// \param LA1703/// An integer that specifies the length of the string in \a A.1704/// \param B1705/// A 128-bit integer vector containing one of the source operands to be1706/// compared.1707/// \param LB1708/// An integer that specifies the length of the string in \a B.1709/// \param M1710/// An 8-bit immediate operand specifying whether the characters are bytes or1711/// words, the type of comparison to perform, and the format of the return1712/// value. \n1713/// Bits [1:0]: Determine source data format. \n1714/// 00: 16 unsigned bytes \n1715/// 01: 8 unsigned words \n1716/// 10: 16 signed bytes \n1717/// 11: 8 signed words \n1718/// Bits [3:2]: Determine comparison type and aggregation method. \n1719/// 00: Subset: Each character in \a B is compared for equality with all1720/// the characters in \a A. \n1721/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1722/// basis is greater than or equal for even-indexed elements in \a A,1723/// and less than or equal for odd-indexed elements in \a A. \n1724/// 10: Match: Compare each pair of corresponding characters in \a A and1725/// \a B for equality. \n1726/// 11: Substring: Search \a B for substring matches of \a A. \n1727/// Bits [5:4]: Determine whether to perform a one's complement on the bit1728/// mask of the comparison results. \n1729/// 00: No effect. \n1730/// 01: Negate the bit mask. \n1731/// 10: No effect. \n1732/// 11: Negate the bit mask only for bits with an index less than or equal1733/// to the size of \a A or \a B. \n1734/// Bit [6]: Determines whether the result is zero-extended or expanded to 161735/// bytes. \n1736/// 0: The result is zero-extended to 16 bytes. \n1737/// 1: The result is expanded to 16 bytes (this expansion is performed by1738/// repeating each bit 8 or 16 times). \n1739/// \returns Returns a 128-bit integer vector representing the result mask of1740/// the comparison.1741#define _mm_cmpestrm(A, LA, B, LB, M) \1742 ((__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \1743 (__v16qi)(__m128i)(B), (int)(LB), \1744 (int)(M)))1745 1746/// Uses the immediate operand \a M to perform a comparison of string1747/// data with explicitly defined lengths that is contained in source operands1748/// \a A and \a B. Returns an integer representing the result index of the1749/// comparison.1750///1751/// \headerfile <x86intrin.h>1752///1753/// \code1754/// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M);1755/// \endcode1756///1757/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>1758/// instruction.1759///1760/// \param A1761/// A 128-bit integer vector containing one of the source operands to be1762/// compared.1763/// \param LA1764/// An integer that specifies the length of the string in \a A.1765/// \param B1766/// A 128-bit integer vector containing one of the source operands to be1767/// compared.1768/// \param LB1769/// An integer that specifies the length of the string in \a B.1770/// \param M1771/// An 8-bit immediate operand specifying whether the characters are bytes or1772/// words, the type of comparison to perform, and the format of the return1773/// value. \n1774/// Bits [1:0]: Determine source data format. \n1775/// 00: 16 unsigned bytes \n1776/// 01: 8 unsigned words \n1777/// 10: 16 signed bytes \n1778/// 11: 8 signed words \n1779/// Bits [3:2]: Determine comparison type and aggregation method. \n1780/// 00: Subset: Each character in \a B is compared for equality with all1781/// the characters in \a A. \n1782/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1783/// basis is greater than or equal for even-indexed elements in \a A,1784/// and less than or equal for odd-indexed elements in \a A. \n1785/// 10: Match: Compare each pair of corresponding characters in \a A and1786/// \a B for equality. \n1787/// 11: Substring: Search B for substring matches of \a A. \n1788/// Bits [5:4]: Determine whether to perform a one's complement on the bit1789/// mask of the comparison results. \n1790/// 00: No effect. \n1791/// 01: Negate the bit mask. \n1792/// 10: No effect. \n1793/// 11: Negate the bit mask only for bits with an index less than or equal1794/// to the size of \a A or \a B. \n1795/// Bit [6]: Determines whether the index of the lowest set bit or the1796/// highest set bit is returned. \n1797/// 0: The index of the least significant set bit. \n1798/// 1: The index of the most significant set bit. \n1799/// \returns Returns an integer representing the result index of the comparison.1800#define _mm_cmpestri(A, LA, B, LB, M) \1801 ((int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \1802 (__v16qi)(__m128i)(B), (int)(LB), \1803 (int)(M)))1804 1805/* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */1806/// Uses the immediate operand \a M to perform a comparison of string1807/// data with implicitly defined lengths that is contained in source operands1808/// \a A and \a B. Returns 1 if the bit mask is zero and the length of the1809/// string in \a B is the maximum, otherwise, returns 0.1810///1811/// \headerfile <x86intrin.h>1812///1813/// \code1814/// int _mm_cmpistra(__m128i A, __m128i B, const int M);1815/// \endcode1816///1817/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>1818/// instruction.1819///1820/// \param A1821/// A 128-bit integer vector containing one of the source operands to be1822/// compared.1823/// \param B1824/// A 128-bit integer vector containing one of the source operands to be1825/// compared.1826/// \param M1827/// An 8-bit immediate operand specifying whether the characters are bytes or1828/// words and the type of comparison to perform. \n1829/// Bits [1:0]: Determine source data format. \n1830/// 00: 16 unsigned bytes \n1831/// 01: 8 unsigned words \n1832/// 10: 16 signed bytes \n1833/// 11: 8 signed words \n1834/// Bits [3:2]: Determine comparison type and aggregation method. \n1835/// 00: Subset: Each character in \a B is compared for equality with all1836/// the characters in \a A. \n1837/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1838/// basis is greater than or equal for even-indexed elements in \a A,1839/// and less than or equal for odd-indexed elements in \a A. \n1840/// 10: Match: Compare each pair of corresponding characters in \a A and1841/// \a B for equality. \n1842/// 11: Substring: Search \a B for substring matches of \a A. \n1843/// Bits [5:4]: Determine whether to perform a one's complement on the bit1844/// mask of the comparison results. \n1845/// 00: No effect. \n1846/// 01: Negate the bit mask. \n1847/// 10: No effect. \n1848/// 11: Negate the bit mask only for bits with an index less than or equal1849/// to the size of \a A or \a B. \n1850/// \returns Returns 1 if the bit mask is zero and the length of the string in1851/// \a B is the maximum; otherwise, returns 0.1852#define _mm_cmpistra(A, B, M) \1853 ((int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \1854 (__v16qi)(__m128i)(B), (int)(M)))1855 1856/// Uses the immediate operand \a M to perform a comparison of string1857/// data with implicitly defined lengths that is contained in source operands1858/// \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns1859/// 0.1860///1861/// \headerfile <x86intrin.h>1862///1863/// \code1864/// int _mm_cmpistrc(__m128i A, __m128i B, const int M);1865/// \endcode1866///1867/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>1868/// instruction.1869///1870/// \param A1871/// A 128-bit integer vector containing one of the source operands to be1872/// compared.1873/// \param B1874/// A 128-bit integer vector containing one of the source operands to be1875/// compared.1876/// \param M1877/// An 8-bit immediate operand specifying whether the characters are bytes or1878/// words and the type of comparison to perform. \n1879/// Bits [1:0]: Determine source data format. \n1880/// 00: 16 unsigned bytes \n1881/// 01: 8 unsigned words \n1882/// 10: 16 signed bytes \n1883/// 11: 8 signed words \n1884/// Bits [3:2]: Determine comparison type and aggregation method. \n1885/// 00: Subset: Each character in \a B is compared for equality with all1886/// the characters in \a A. \n1887/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1888/// basis is greater than or equal for even-indexed elements in \a A,1889/// and less than or equal for odd-indexed elements in \a A. \n1890/// 10: Match: Compare each pair of corresponding characters in \a A and1891/// \a B for equality. \n1892/// 11: Substring: Search B for substring matches of \a A. \n1893/// Bits [5:4]: Determine whether to perform a one's complement on the bit1894/// mask of the comparison results. \n1895/// 00: No effect. \n1896/// 01: Negate the bit mask. \n1897/// 10: No effect. \n1898/// 11: Negate the bit mask only for bits with an index less than or equal1899/// to the size of \a A or \a B.1900/// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0.1901#define _mm_cmpistrc(A, B, M) \1902 ((int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \1903 (__v16qi)(__m128i)(B), (int)(M)))1904 1905/// Uses the immediate operand \a M to perform a comparison of string1906/// data with implicitly defined lengths that is contained in source operands1907/// \a A and \a B. Returns bit 0 of the resulting bit mask.1908///1909/// \headerfile <x86intrin.h>1910///1911/// \code1912/// int _mm_cmpistro(__m128i A, __m128i B, const int M);1913/// \endcode1914///1915/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>1916/// instruction.1917///1918/// \param A1919/// A 128-bit integer vector containing one of the source operands to be1920/// compared.1921/// \param B1922/// A 128-bit integer vector containing one of the source operands to be1923/// compared.1924/// \param M1925/// An 8-bit immediate operand specifying whether the characters are bytes or1926/// words and the type of comparison to perform. \n1927/// Bits [1:0]: Determine source data format. \n1928/// 00: 16 unsigned bytes \n1929/// 01: 8 unsigned words \n1930/// 10: 16 signed bytes \n1931/// 11: 8 signed words \n1932/// Bits [3:2]: Determine comparison type and aggregation method. \n1933/// 00: Subset: Each character in \a B is compared for equality with all1934/// the characters in \a A. \n1935/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1936/// basis is greater than or equal for even-indexed elements in \a A,1937/// and less than or equal for odd-indexed elements in \a A. \n1938/// 10: Match: Compare each pair of corresponding characters in \a A and1939/// \a B for equality. \n1940/// 11: Substring: Search B for substring matches of \a A. \n1941/// Bits [5:4]: Determine whether to perform a one's complement on the bit1942/// mask of the comparison results. \n1943/// 00: No effect. \n1944/// 01: Negate the bit mask. \n1945/// 10: No effect. \n1946/// 11: Negate the bit mask only for bits with an index less than or equal1947/// to the size of \a A or \a B. \n1948/// \returns Returns bit 0 of the resulting bit mask.1949#define _mm_cmpistro(A, B, M) \1950 ((int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \1951 (__v16qi)(__m128i)(B), (int)(M)))1952 1953/// Uses the immediate operand \a M to perform a comparison of string1954/// data with implicitly defined lengths that is contained in source operands1955/// \a A and \a B. Returns 1 if the length of the string in \a A is less than1956/// the maximum, otherwise, returns 0.1957///1958/// \headerfile <x86intrin.h>1959///1960/// \code1961/// int _mm_cmpistrs(__m128i A, __m128i B, const int M);1962/// \endcode1963///1964/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>1965/// instruction.1966///1967/// \param A1968/// A 128-bit integer vector containing one of the source operands to be1969/// compared.1970/// \param B1971/// A 128-bit integer vector containing one of the source operands to be1972/// compared.1973/// \param M1974/// An 8-bit immediate operand specifying whether the characters are bytes or1975/// words and the type of comparison to perform. \n1976/// Bits [1:0]: Determine source data format. \n1977/// 00: 16 unsigned bytes \n1978/// 01: 8 unsigned words \n1979/// 10: 16 signed bytes \n1980/// 11: 8 signed words \n1981/// Bits [3:2]: Determine comparison type and aggregation method. \n1982/// 00: Subset: Each character in \a B is compared for equality with all1983/// the characters in \a A. \n1984/// 01: Ranges: Each character in \a B is compared to \a A. The comparison1985/// basis is greater than or equal for even-indexed elements in \a A,1986/// and less than or equal for odd-indexed elements in \a A. \n1987/// 10: Match: Compare each pair of corresponding characters in \a A and1988/// \a B for equality. \n1989/// 11: Substring: Search \a B for substring matches of \a A. \n1990/// Bits [5:4]: Determine whether to perform a one's complement on the bit1991/// mask of the comparison results. \n1992/// 00: No effect. \n1993/// 01: Negate the bit mask. \n1994/// 10: No effect. \n1995/// 11: Negate the bit mask only for bits with an index less than or equal1996/// to the size of \a A or \a B. \n1997/// \returns Returns 1 if the length of the string in \a A is less than the1998/// maximum, otherwise, returns 0.1999#define _mm_cmpistrs(A, B, M) \2000 ((int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \2001 (__v16qi)(__m128i)(B), (int)(M)))2002 2003/// Uses the immediate operand \a M to perform a comparison of string2004/// data with implicitly defined lengths that is contained in source operands2005/// \a A and \a B. Returns 1 if the length of the string in \a B is less than2006/// the maximum, otherwise, returns 0.2007///2008/// \headerfile <x86intrin.h>2009///2010/// \code2011/// int _mm_cmpistrz(__m128i A, __m128i B, const int M);2012/// \endcode2013///2014/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c>2015/// instruction.2016///2017/// \param A2018/// A 128-bit integer vector containing one of the source operands to be2019/// compared.2020/// \param B2021/// A 128-bit integer vector containing one of the source operands to be2022/// compared.2023/// \param M2024/// An 8-bit immediate operand specifying whether the characters are bytes or2025/// words and the type of comparison to perform. \n2026/// Bits [1:0]: Determine source data format. \n2027/// 00: 16 unsigned bytes \n2028/// 01: 8 unsigned words \n2029/// 10: 16 signed bytes \n2030/// 11: 8 signed words \n2031/// Bits [3:2]: Determine comparison type and aggregation method. \n2032/// 00: Subset: Each character in \a B is compared for equality with all2033/// the characters in \a A. \n2034/// 01: Ranges: Each character in \a B is compared to \a A. The comparison2035/// basis is greater than or equal for even-indexed elements in \a A,2036/// and less than or equal for odd-indexed elements in \a A. \n2037/// 10: Match: Compare each pair of corresponding characters in \a A and2038/// \a B for equality. \n2039/// 11: Substring: Search \a B for substring matches of \a A. \n2040/// Bits [5:4]: Determine whether to perform a one's complement on the bit2041/// mask of the comparison results. \n2042/// 00: No effect. \n2043/// 01: Negate the bit mask. \n2044/// 10: No effect. \n2045/// 11: Negate the bit mask only for bits with an index less than or equal2046/// to the size of \a A or \a B.2047/// \returns Returns 1 if the length of the string in \a B is less than the2048/// maximum, otherwise, returns 0.2049#define _mm_cmpistrz(A, B, M) \2050 ((int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \2051 (__v16qi)(__m128i)(B), (int)(M)))2052 2053/// Uses the immediate operand \a M to perform a comparison of string2054/// data with explicitly defined lengths that is contained in source operands2055/// \a A and \a B. Returns 1 if the bit mask is zero and the length of the2056/// string in \a B is the maximum, otherwise, returns 0.2057///2058/// \headerfile <x86intrin.h>2059///2060/// \code2061/// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M);2062/// \endcode2063///2064/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>2065/// instruction.2066///2067/// \param A2068/// A 128-bit integer vector containing one of the source operands to be2069/// compared.2070/// \param LA2071/// An integer that specifies the length of the string in \a A.2072/// \param B2073/// A 128-bit integer vector containing one of the source operands to be2074/// compared.2075/// \param LB2076/// An integer that specifies the length of the string in \a B.2077/// \param M2078/// An 8-bit immediate operand specifying whether the characters are bytes or2079/// words and the type of comparison to perform. \n2080/// Bits [1:0]: Determine source data format. \n2081/// 00: 16 unsigned bytes \n2082/// 01: 8 unsigned words \n2083/// 10: 16 signed bytes \n2084/// 11: 8 signed words \n2085/// Bits [3:2]: Determine comparison type and aggregation method. \n2086/// 00: Subset: Each character in \a B is compared for equality with all2087/// the characters in \a A. \n2088/// 01: Ranges: Each character in \a B is compared to \a A. The comparison2089/// basis is greater than or equal for even-indexed elements in \a A,2090/// and less than or equal for odd-indexed elements in \a A. \n2091/// 10: Match: Compare each pair of corresponding characters in \a A and2092/// \a B for equality. \n2093/// 11: Substring: Search \a B for substring matches of \a A. \n2094/// Bits [5:4]: Determine whether to perform a one's complement on the bit2095/// mask of the comparison results. \n2096/// 00: No effect. \n2097/// 01: Negate the bit mask. \n2098/// 10: No effect. \n2099/// 11: Negate the bit mask only for bits with an index less than or equal2100/// to the size of \a A or \a B.2101/// \returns Returns 1 if the bit mask is zero and the length of the string in2102/// \a B is the maximum, otherwise, returns 0.2103#define _mm_cmpestra(A, LA, B, LB, M) \2104 ((int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \2105 (__v16qi)(__m128i)(B), (int)(LB), \2106 (int)(M)))2107 2108/// Uses the immediate operand \a M to perform a comparison of string2109/// data with explicitly defined lengths that is contained in source operands2110/// \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise,2111/// returns 0.2112///2113/// \headerfile <x86intrin.h>2114///2115/// \code2116/// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M);2117/// \endcode2118///2119/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>2120/// instruction.2121///2122/// \param A2123/// A 128-bit integer vector containing one of the source operands to be2124/// compared.2125/// \param LA2126/// An integer that specifies the length of the string in \a A.2127/// \param B2128/// A 128-bit integer vector containing one of the source operands to be2129/// compared.2130/// \param LB2131/// An integer that specifies the length of the string in \a B.2132/// \param M2133/// An 8-bit immediate operand specifying whether the characters are bytes or2134/// words and the type of comparison to perform. \n2135/// Bits [1:0]: Determine source data format. \n2136/// 00: 16 unsigned bytes \n2137/// 01: 8 unsigned words \n2138/// 10: 16 signed bytes \n2139/// 11: 8 signed words \n2140/// Bits [3:2]: Determine comparison type and aggregation method. \n2141/// 00: Subset: Each character in \a B is compared for equality with all2142/// the characters in \a A. \n2143/// 01: Ranges: Each character in \a B is compared to \a A. The comparison2144/// basis is greater than or equal for even-indexed elements in \a A,2145/// and less than or equal for odd-indexed elements in \a A. \n2146/// 10: Match: Compare each pair of corresponding characters in \a A and2147/// \a B for equality. \n2148/// 11: Substring: Search \a B for substring matches of \a A. \n2149/// Bits [5:4]: Determine whether to perform a one's complement on the bit2150/// mask of the comparison results. \n2151/// 00: No effect. \n2152/// 01: Negate the bit mask. \n2153/// 10: No effect. \n2154/// 11: Negate the bit mask only for bits with an index less than or equal2155/// to the size of \a A or \a B. \n2156/// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0.2157#define _mm_cmpestrc(A, LA, B, LB, M) \2158 ((int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \2159 (__v16qi)(__m128i)(B), (int)(LB), \2160 (int)(M)))2161 2162/// Uses the immediate operand \a M to perform a comparison of string2163/// data with explicitly defined lengths that is contained in source operands2164/// \a A and \a B. Returns bit 0 of the resulting bit mask.2165///2166/// \headerfile <x86intrin.h>2167///2168/// \code2169/// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M);2170/// \endcode2171///2172/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>2173/// instruction.2174///2175/// \param A2176/// A 128-bit integer vector containing one of the source operands to be2177/// compared.2178/// \param LA2179/// An integer that specifies the length of the string in \a A.2180/// \param B2181/// A 128-bit integer vector containing one of the source operands to be2182/// compared.2183/// \param LB2184/// An integer that specifies the length of the string in \a B.2185/// \param M2186/// An 8-bit immediate operand specifying whether the characters are bytes or2187/// words and the type of comparison to perform. \n2188/// Bits [1:0]: Determine source data format. \n2189/// 00: 16 unsigned bytes \n2190/// 01: 8 unsigned words \n2191/// 10: 16 signed bytes \n2192/// 11: 8 signed words \n2193/// Bits [3:2]: Determine comparison type and aggregation method. \n2194/// 00: Subset: Each character in \a B is compared for equality with all2195/// the characters in \a A. \n2196/// 01: Ranges: Each character in \a B is compared to \a A. The comparison2197/// basis is greater than or equal for even-indexed elements in \a A,2198/// and less than or equal for odd-indexed elements in \a A. \n2199/// 10: Match: Compare each pair of corresponding characters in \a A and2200/// \a B for equality. \n2201/// 11: Substring: Search \a B for substring matches of \a A. \n2202/// Bits [5:4]: Determine whether to perform a one's complement on the bit2203/// mask of the comparison results. \n2204/// 00: No effect. \n2205/// 01: Negate the bit mask. \n2206/// 10: No effect. \n2207/// 11: Negate the bit mask only for bits with an index less than or equal2208/// to the size of \a A or \a B.2209/// \returns Returns bit 0 of the resulting bit mask.2210#define _mm_cmpestro(A, LA, B, LB, M) \2211 ((int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \2212 (__v16qi)(__m128i)(B), (int)(LB), \2213 (int)(M)))2214 2215/// Uses the immediate operand \a M to perform a comparison of string2216/// data with explicitly defined lengths that is contained in source operands2217/// \a A and \a B. Returns 1 if the length of the string in \a A is less than2218/// the maximum, otherwise, returns 0.2219///2220/// \headerfile <x86intrin.h>2221///2222/// \code2223/// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M);2224/// \endcode2225///2226/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c>2227/// instruction.2228///2229/// \param A2230/// A 128-bit integer vector containing one of the source operands to be2231/// compared.2232/// \param LA2233/// An integer that specifies the length of the string in \a A.2234/// \param B2235/// A 128-bit integer vector containing one of the source operands to be2236/// compared.2237/// \param LB2238/// An integer that specifies the length of the string in \a B.2239/// \param M2240/// An 8-bit immediate operand specifying whether the characters are bytes or2241/// words and the type of comparison to perform. \n2242/// Bits [1:0]: Determine source data format. \n2243/// 00: 16 unsigned bytes \n2244/// 01: 8 unsigned words \n2245/// 10: 16 signed bytes \n2246/// 11: 8 signed words \n2247/// Bits [3:2]: Determine comparison type and aggregation method. \n2248/// 00: Subset: Each character in \a B is compared for equality with all2249/// the characters in \a A. \n2250/// 01: Ranges: Each character in \a B is compared to \a A. The comparison2251/// basis is greater than or equal for even-indexed elements in \a A,2252/// and less than or equal for odd-indexed elements in \a A. \n2253/// 10: Match: Compare each pair of corresponding characters in \a A and2254/// \a B for equality. \n2255/// 11: Substring: Search \a B for substring matches of \a A. \n2256/// Bits [5:4]: Determine whether to perform a one's complement in the bit2257/// mask of the comparison results. \n2258/// 00: No effect. \n2259/// 01: Negate the bit mask. \n2260/// 10: No effect. \n2261/// 11: Negate the bit mask only for bits with an index less than or equal2262/// to the size of \a A or \a B. \n2263/// \returns Returns 1 if the length of the string in \a A is less than the2264/// maximum, otherwise, returns 0.2265#define _mm_cmpestrs(A, LA, B, LB, M) \2266 ((int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \2267 (__v16qi)(__m128i)(B), (int)(LB), \2268 (int)(M)))2269 2270/// Uses the immediate operand \a M to perform a comparison of string2271/// data with explicitly defined lengths that is contained in source operands2272/// \a A and \a B. Returns 1 if the length of the string in \a B is less than2273/// the maximum, otherwise, returns 0.2274///2275/// \headerfile <x86intrin.h>2276///2277/// \code2278/// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M);2279/// \endcode2280///2281/// This intrinsic corresponds to the <c> VPCMPESTRI </c> instruction.2282///2283/// \param A2284/// A 128-bit integer vector containing one of the source operands to be2285/// compared.2286/// \param LA2287/// An integer that specifies the length of the string in \a A.2288/// \param B2289/// A 128-bit integer vector containing one of the source operands to be2290/// compared.2291/// \param LB2292/// An integer that specifies the length of the string in \a B.2293/// \param M2294/// An 8-bit immediate operand specifying whether the characters are bytes or2295/// words and the type of comparison to perform. \n2296/// Bits [1:0]: Determine source data format. \n2297/// 00: 16 unsigned bytes \n2298/// 01: 8 unsigned words \n2299/// 10: 16 signed bytes \n2300/// 11: 8 signed words \n2301/// Bits [3:2]: Determine comparison type and aggregation method. \n2302/// 00: Subset: Each character in \a B is compared for equality with all2303/// the characters in \a A. \n2304/// 01: Ranges: Each character in \a B is compared to \a A. The comparison2305/// basis is greater than or equal for even-indexed elements in \a A,2306/// and less than or equal for odd-indexed elements in \a A. \n2307/// 10: Match: Compare each pair of corresponding characters in \a A and2308/// \a B for equality. \n2309/// 11: Substring: Search \a B for substring matches of \a A. \n2310/// Bits [5:4]: Determine whether to perform a one's complement on the bit2311/// mask of the comparison results. \n2312/// 00: No effect. \n2313/// 01: Negate the bit mask. \n2314/// 10: No effect. \n2315/// 11: Negate the bit mask only for bits with an index less than or equal2316/// to the size of \a A or \a B.2317/// \returns Returns 1 if the length of the string in \a B is less than the2318/// maximum, otherwise, returns 0.2319#define _mm_cmpestrz(A, LA, B, LB, M) \2320 ((int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \2321 (__v16qi)(__m128i)(B), (int)(LB), \2322 (int)(M)))2323 2324/* SSE4.2 Compare Packed Data -- Greater Than. */2325/// Compares each of the corresponding 64-bit values of the 128-bit2326/// integer vectors to determine if the values in the first operand are2327/// greater than those in the second operand.2328///2329/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.2330///2331/// \headerfile <x86intrin.h>2332///2333/// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction.2334///2335/// \param __V12336/// A 128-bit integer vector.2337/// \param __V22338/// A 128-bit integer vector.2339/// \returns A 128-bit integer vector containing the comparison results.2340static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR2341_mm_cmpgt_epi64(__m128i __V1, __m128i __V2) {2342 return (__m128i)((__v2di)__V1 > (__v2di)__V2);2343}2344 2345#undef __DEFAULT_FN_ATTRS2346#undef __DEFAULT_FN_ATTRS_CONSTEXPR2347 2348#include <popcntintrin.h>2349 2350#include <crc32intrin.h>2351 2352#endif /* __SMMINTRIN_H */2353