smmintrin.h revision 327952
1206084Srdivacky/*===---- smmintrin.h - SSE4 intrinsics ------------------------------------=== 2206084Srdivacky * 3206084Srdivacky * Permission is hereby granted, free of charge, to any person obtaining a copy 4206084Srdivacky * of this software and associated documentation files (the "Software"), to deal 5206084Srdivacky * in the Software without restriction, including without limitation the rights 6206084Srdivacky * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7206084Srdivacky * copies of the Software, and to permit persons to whom the Software is 8206084Srdivacky * furnished to do so, subject to the following conditions: 9206084Srdivacky * 10206084Srdivacky * The above copyright notice and this permission notice shall be included in 11206084Srdivacky * all copies or substantial portions of the Software. 12206084Srdivacky * 13206084Srdivacky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14206084Srdivacky * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15206084Srdivacky * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16206084Srdivacky * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17206084Srdivacky * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18206084Srdivacky * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19206084Srdivacky * THE SOFTWARE. 20206084Srdivacky * 21206084Srdivacky *===-----------------------------------------------------------------------=== 22206084Srdivacky */ 23204793Srdivacky 24204793Srdivacky#ifndef _SMMINTRIN_H 25204793Srdivacky#define _SMMINTRIN_H 26204793Srdivacky 27204793Srdivacky#include <tmmintrin.h> 28204793Srdivacky 29288943Sdim/* Define the default attributes for the functions in this file. */ 30296417Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.1"))) 31288943Sdim 32204793Srdivacky/* SSE4 Rounding macros. */ 33204793Srdivacky#define _MM_FROUND_TO_NEAREST_INT 0x00 34204793Srdivacky#define _MM_FROUND_TO_NEG_INF 0x01 35204793Srdivacky#define _MM_FROUND_TO_POS_INF 0x02 36204793Srdivacky#define _MM_FROUND_TO_ZERO 0x03 37204793Srdivacky#define _MM_FROUND_CUR_DIRECTION 0x04 38204793Srdivacky 39204793Srdivacky#define _MM_FROUND_RAISE_EXC 0x00 40204793Srdivacky#define _MM_FROUND_NO_EXC 0x08 41204793Srdivacky 42204793Srdivacky#define _MM_FROUND_NINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEAREST_INT) 43204793Srdivacky#define _MM_FROUND_FLOOR (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEG_INF) 44204793Srdivacky#define _MM_FROUND_CEIL (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_POS_INF) 45204793Srdivacky#define _MM_FROUND_TRUNC (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_ZERO) 46204793Srdivacky#define _MM_FROUND_RINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION) 47204962Srdivacky#define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION) 48204793Srdivacky 49321369Sdim/// \brief Rounds up each element of the 128-bit vector of [4 x float] to an 50321369Sdim/// integer and returns the rounded values in a 128-bit vector of 51321369Sdim/// [4 x float]. 52321369Sdim/// 53321369Sdim/// \headerfile <x86intrin.h> 54321369Sdim/// 55321369Sdim/// \code 56321369Sdim/// __m128 _mm_ceil_ps(__m128 X); 57321369Sdim/// \endcode 58321369Sdim/// 59321369Sdim/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction. 60321369Sdim/// 61321369Sdim/// \param X 62321369Sdim/// A 128-bit vector of [4 x float] values to be rounded up. 63321369Sdim/// \returns A 128-bit vector of [4 x float] containing the rounded values. 64204793Srdivacky#define _mm_ceil_ps(X) _mm_round_ps((X), _MM_FROUND_CEIL) 65321369Sdim 66321369Sdim/// \brief Rounds up each element of the 128-bit vector of [2 x double] to an 67321369Sdim/// integer and returns the rounded values in a 128-bit vector of 68321369Sdim/// [2 x double]. 69321369Sdim/// 70321369Sdim/// \headerfile <x86intrin.h> 71321369Sdim/// 72321369Sdim/// \code 73321369Sdim/// __m128d _mm_ceil_pd(__m128d X); 74321369Sdim/// \endcode 75321369Sdim/// 76321369Sdim/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction. 77321369Sdim/// 78321369Sdim/// \param X 79321369Sdim/// A 128-bit vector of [2 x double] values to be rounded up. 80321369Sdim/// \returns A 128-bit vector of [2 x double] containing the rounded values. 81204793Srdivacky#define _mm_ceil_pd(X) _mm_round_pd((X), _MM_FROUND_CEIL) 82321369Sdim 83321369Sdim/// \brief Copies three upper elements of the first 128-bit vector operand to 84321369Sdim/// the corresponding three upper elements of the 128-bit result vector of 85321369Sdim/// [4 x float]. Rounds up the lowest element of the second 128-bit vector 86321369Sdim/// operand to an integer and copies it to the lowest element of the 128-bit 87321369Sdim/// result vector of [4 x float]. 88321369Sdim/// 89321369Sdim/// \headerfile <x86intrin.h> 90321369Sdim/// 91321369Sdim/// \code 92321369Sdim/// __m128 _mm_ceil_ss(__m128 X, __m128 Y); 93321369Sdim/// \endcode 94321369Sdim/// 95321369Sdim/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction. 96321369Sdim/// 97321369Sdim/// \param X 98321369Sdim/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are 99321369Sdim/// copied to the corresponding bits of the result. 100321369Sdim/// \param Y 101321369Sdim/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is 102321369Sdim/// rounded up to the nearest integer and copied to the corresponding bits 103321369Sdim/// of the result. 104321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and rounded 105321369Sdim/// values. 106204793Srdivacky#define _mm_ceil_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_CEIL) 107321369Sdim 108321369Sdim/// \brief Copies the upper element of the first 128-bit vector operand to the 109321369Sdim/// corresponding upper element of the 128-bit result vector of [2 x double]. 110321369Sdim/// Rounds up the lower element of the second 128-bit vector operand to an 111321369Sdim/// integer and copies it to the lower element of the 128-bit result vector 112321369Sdim/// of [2 x double]. 113321369Sdim/// 114321369Sdim/// \headerfile <x86intrin.h> 115321369Sdim/// 116321369Sdim/// \code 117321369Sdim/// __m128d _mm_ceil_sd(__m128d X, __m128d Y); 118321369Sdim/// \endcode 119321369Sdim/// 120321369Sdim/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction. 121321369Sdim/// 122321369Sdim/// \param X 123321369Sdim/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is 124321369Sdim/// copied to the corresponding bits of the result. 125321369Sdim/// \param Y 126321369Sdim/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is 127321369Sdim/// rounded up to the nearest integer and copied to the corresponding bits 128321369Sdim/// of the result. 129321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied and rounded 130321369Sdim/// values. 131204793Srdivacky#define _mm_ceil_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_CEIL) 132204793Srdivacky 133321369Sdim/// \brief Rounds down each element of the 128-bit vector of [4 x float] to an 134321369Sdim/// an integer and returns the rounded values in a 128-bit vector of 135321369Sdim/// [4 x float]. 136321369Sdim/// 137321369Sdim/// \headerfile <x86intrin.h> 138321369Sdim/// 139321369Sdim/// \code 140321369Sdim/// __m128 _mm_floor_ps(__m128 X); 141321369Sdim/// \endcode 142321369Sdim/// 143321369Sdim/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction. 144321369Sdim/// 145321369Sdim/// \param X 146321369Sdim/// A 128-bit vector of [4 x float] values to be rounded down. 147321369Sdim/// \returns A 128-bit vector of [4 x float] containing the rounded values. 148204793Srdivacky#define _mm_floor_ps(X) _mm_round_ps((X), _MM_FROUND_FLOOR) 149321369Sdim 150321369Sdim/// \brief Rounds down each element of the 128-bit vector of [2 x double] to an 151321369Sdim/// integer and returns the rounded values in a 128-bit vector of 152321369Sdim/// [2 x double]. 153321369Sdim/// 154321369Sdim/// \headerfile <x86intrin.h> 155321369Sdim/// 156321369Sdim/// \code 157321369Sdim/// __m128d _mm_floor_pd(__m128d X); 158321369Sdim/// \endcode 159321369Sdim/// 160321369Sdim/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction. 161321369Sdim/// 162321369Sdim/// \param X 163321369Sdim/// A 128-bit vector of [2 x double]. 164321369Sdim/// \returns A 128-bit vector of [2 x double] containing the rounded values. 165204793Srdivacky#define _mm_floor_pd(X) _mm_round_pd((X), _MM_FROUND_FLOOR) 166321369Sdim 167321369Sdim/// \brief Copies three upper elements of the first 128-bit vector operand to 168321369Sdim/// the corresponding three upper elements of the 128-bit result vector of 169321369Sdim/// [4 x float]. Rounds down the lowest element of the second 128-bit vector 170321369Sdim/// operand to an integer and copies it to the lowest element of the 128-bit 171321369Sdim/// result vector of [4 x float]. 172321369Sdim/// 173321369Sdim/// \headerfile <x86intrin.h> 174321369Sdim/// 175321369Sdim/// \code 176321369Sdim/// __m128 _mm_floor_ss(__m128 X, __m128 Y); 177321369Sdim/// \endcode 178321369Sdim/// 179321369Sdim/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction. 180321369Sdim/// 181321369Sdim/// \param X 182321369Sdim/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are 183321369Sdim/// copied to the corresponding bits of the result. 184321369Sdim/// \param Y 185321369Sdim/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is 186321369Sdim/// rounded down to the nearest integer and copied to the corresponding bits 187321369Sdim/// of the result. 188321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and rounded 189321369Sdim/// values. 190204793Srdivacky#define _mm_floor_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_FLOOR) 191321369Sdim 192321369Sdim/// \brief Copies the upper element of the first 128-bit vector operand to the 193321369Sdim/// corresponding upper element of the 128-bit result vector of [2 x double]. 194321369Sdim/// Rounds down the lower element of the second 128-bit vector operand to an 195321369Sdim/// integer and copies it to the lower element of the 128-bit result vector 196321369Sdim/// of [2 x double]. 197321369Sdim/// 198321369Sdim/// \headerfile <x86intrin.h> 199321369Sdim/// 200321369Sdim/// \code 201321369Sdim/// __m128d _mm_floor_sd(__m128d X, __m128d Y); 202321369Sdim/// \endcode 203321369Sdim/// 204321369Sdim/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction. 205321369Sdim/// 206321369Sdim/// \param X 207321369Sdim/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is 208321369Sdim/// copied to the corresponding bits of the result. 209321369Sdim/// \param Y 210321369Sdim/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is 211321369Sdim/// rounded down to the nearest integer and copied to the corresponding bits 212321369Sdim/// of the result. 213321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied and rounded 214321369Sdim/// values. 215204793Srdivacky#define _mm_floor_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_FLOOR) 216204793Srdivacky 217321369Sdim/// \brief Rounds each element of the 128-bit vector of [4 x float] to an 218321369Sdim/// integer value according to the rounding control specified by the second 219321369Sdim/// argument and returns the rounded values in a 128-bit vector of 220321369Sdim/// [4 x float]. 221321369Sdim/// 222321369Sdim/// \headerfile <x86intrin.h> 223321369Sdim/// 224321369Sdim/// \code 225321369Sdim/// __m128 _mm_round_ps(__m128 X, const int M); 226321369Sdim/// \endcode 227321369Sdim/// 228321369Sdim/// This intrinsic corresponds to the <c> VROUNDPS / ROUNDPS </c> instruction. 229321369Sdim/// 230321369Sdim/// \param X 231321369Sdim/// A 128-bit vector of [4 x float]. 232321369Sdim/// \param M 233321369Sdim/// An integer value that specifies the rounding operation. \n 234321369Sdim/// Bits [7:4] are reserved. \n 235321369Sdim/// Bit [3] is a precision exception value: \n 236321369Sdim/// 0: A normal PE exception is used \n 237321369Sdim/// 1: The PE field is not updated \n 238321369Sdim/// Bit [2] is the rounding control source: \n 239321369Sdim/// 0: Use bits [1:0] of \a M \n 240321369Sdim/// 1: Use the current MXCSR setting \n 241321369Sdim/// Bits [1:0] contain the rounding control definition: \n 242321369Sdim/// 00: Nearest \n 243321369Sdim/// 01: Downward (toward negative infinity) \n 244321369Sdim/// 10: Upward (toward positive infinity) \n 245321369Sdim/// 11: Truncated 246321369Sdim/// \returns A 128-bit vector of [4 x float] containing the rounded values. 247234353Sdim#define _mm_round_ps(X, M) __extension__ ({ \ 248296417Sdim (__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M)); }) 249204793Srdivacky 250321369Sdim/// \brief Copies three upper elements of the first 128-bit vector operand to 251321369Sdim/// the corresponding three upper elements of the 128-bit result vector of 252321369Sdim/// [4 x float]. Rounds the lowest element of the second 128-bit vector 253321369Sdim/// operand to an integer value according to the rounding control specified 254321369Sdim/// by the third argument and copies it to the lowest element of the 128-bit 255321369Sdim/// result vector of [4 x float]. 256321369Sdim/// 257321369Sdim/// \headerfile <x86intrin.h> 258321369Sdim/// 259321369Sdim/// \code 260321369Sdim/// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M); 261321369Sdim/// \endcode 262321369Sdim/// 263321369Sdim/// This intrinsic corresponds to the <c> VROUNDSS / ROUNDSS </c> instruction. 264321369Sdim/// 265321369Sdim/// \param X 266321369Sdim/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are 267321369Sdim/// copied to the corresponding bits of the result. 268321369Sdim/// \param Y 269321369Sdim/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is 270321369Sdim/// rounded to the nearest integer using the specified rounding control and 271321369Sdim/// copied to the corresponding bits of the result. 272321369Sdim/// \param M 273321369Sdim/// An integer value that specifies the rounding operation. \n 274321369Sdim/// Bits [7:4] are reserved. \n 275321369Sdim/// Bit [3] is a precision exception value: \n 276321369Sdim/// 0: A normal PE exception is used \n 277321369Sdim/// 1: The PE field is not updated \n 278321369Sdim/// Bit [2] is the rounding control source: \n 279321369Sdim/// 0: Use bits [1:0] of \a M \n 280321369Sdim/// 1: Use the current MXCSR setting \n 281321369Sdim/// Bits [1:0] contain the rounding control definition: \n 282321369Sdim/// 00: Nearest \n 283321369Sdim/// 01: Downward (toward negative infinity) \n 284321369Sdim/// 10: Upward (toward positive infinity) \n 285321369Sdim/// 11: Truncated 286321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied and rounded 287321369Sdim/// values. 288234353Sdim#define _mm_round_ss(X, Y, M) __extension__ ({ \ 289296417Sdim (__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), \ 290296417Sdim (__v4sf)(__m128)(Y), (M)); }) 291234353Sdim 292321369Sdim/// \brief Rounds each element of the 128-bit vector of [2 x double] to an 293321369Sdim/// integer value according to the rounding control specified by the second 294321369Sdim/// argument and returns the rounded values in a 128-bit vector of 295321369Sdim/// [2 x double]. 296321369Sdim/// 297321369Sdim/// \headerfile <x86intrin.h> 298321369Sdim/// 299321369Sdim/// \code 300321369Sdim/// __m128d _mm_round_pd(__m128d X, const int M); 301321369Sdim/// \endcode 302321369Sdim/// 303321369Sdim/// This intrinsic corresponds to the <c> VROUNDPD / ROUNDPD </c> instruction. 304321369Sdim/// 305321369Sdim/// \param X 306321369Sdim/// A 128-bit vector of [2 x double]. 307321369Sdim/// \param M 308321369Sdim/// An integer value that specifies the rounding operation. \n 309321369Sdim/// Bits [7:4] are reserved. \n 310321369Sdim/// Bit [3] is a precision exception value: \n 311321369Sdim/// 0: A normal PE exception is used \n 312321369Sdim/// 1: The PE field is not updated \n 313321369Sdim/// Bit [2] is the rounding control source: \n 314321369Sdim/// 0: Use bits [1:0] of \a M \n 315321369Sdim/// 1: Use the current MXCSR setting \n 316321369Sdim/// Bits [1:0] contain the rounding control definition: \n 317321369Sdim/// 00: Nearest \n 318321369Sdim/// 01: Downward (toward negative infinity) \n 319321369Sdim/// 10: Upward (toward positive infinity) \n 320321369Sdim/// 11: Truncated 321321369Sdim/// \returns A 128-bit vector of [2 x double] containing the rounded values. 322234353Sdim#define _mm_round_pd(X, M) __extension__ ({ \ 323296417Sdim (__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M)); }) 324234353Sdim 325321369Sdim/// \brief Copies the upper element of the first 128-bit vector operand to the 326321369Sdim/// corresponding upper element of the 128-bit result vector of [2 x double]. 327321369Sdim/// Rounds the lower element of the second 128-bit vector operand to an 328321369Sdim/// integer value according to the rounding control specified by the third 329321369Sdim/// argument and copies it to the lower element of the 128-bit result vector 330321369Sdim/// of [2 x double]. 331321369Sdim/// 332321369Sdim/// \headerfile <x86intrin.h> 333321369Sdim/// 334321369Sdim/// \code 335321369Sdim/// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M); 336321369Sdim/// \endcode 337321369Sdim/// 338321369Sdim/// This intrinsic corresponds to the <c> VROUNDSD / ROUNDSD </c> instruction. 339321369Sdim/// 340321369Sdim/// \param X 341321369Sdim/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is 342321369Sdim/// copied to the corresponding bits of the result. 343321369Sdim/// \param Y 344321369Sdim/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is 345321369Sdim/// rounded to the nearest integer using the specified rounding control and 346321369Sdim/// copied to the corresponding bits of the result. 347321369Sdim/// \param M 348321369Sdim/// An integer value that specifies the rounding operation. \n 349321369Sdim/// Bits [7:4] are reserved. \n 350321369Sdim/// Bit [3] is a precision exception value: \n 351321369Sdim/// 0: A normal PE exception is used \n 352321369Sdim/// 1: The PE field is not updated \n 353321369Sdim/// Bit [2] is the rounding control source: \n 354321369Sdim/// 0: Use bits [1:0] of \a M \n 355321369Sdim/// 1: Use the current MXCSR setting \n 356321369Sdim/// Bits [1:0] contain the rounding control definition: \n 357321369Sdim/// 00: Nearest \n 358321369Sdim/// 01: Downward (toward negative infinity) \n 359321369Sdim/// 10: Upward (toward positive infinity) \n 360321369Sdim/// 11: Truncated 361321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied and rounded 362321369Sdim/// values. 363234353Sdim#define _mm_round_sd(X, Y, M) __extension__ ({ \ 364296417Sdim (__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), \ 365296417Sdim (__v2df)(__m128d)(Y), (M)); }) 366234353Sdim 367204793Srdivacky/* SSE4 Packed Blending Intrinsics. */ 368321369Sdim/// \brief Returns a 128-bit vector of [2 x double] where the values are 369321369Sdim/// selected from either the first or second operand as specified by the 370321369Sdim/// third operand, the control mask. 371321369Sdim/// 372321369Sdim/// \headerfile <x86intrin.h> 373321369Sdim/// 374321369Sdim/// \code 375321369Sdim/// __m128d _mm_blend_pd(__m128d V1, __m128d V2, const int M); 376321369Sdim/// \endcode 377321369Sdim/// 378321369Sdim/// This intrinsic corresponds to the <c> VBLENDPD / BLENDPD </c> instruction. 379321369Sdim/// 380321369Sdim/// \param V1 381321369Sdim/// A 128-bit vector of [2 x double]. 382321369Sdim/// \param V2 383321369Sdim/// A 128-bit vector of [2 x double]. 384321369Sdim/// \param M 385321369Sdim/// An immediate integer operand, with mask bits [1:0] specifying how the 386321369Sdim/// values are to be copied. The position of the mask bit corresponds to the 387321369Sdim/// index of a copied value. When a mask bit is 0, the corresponding 64-bit 388321369Sdim/// element in operand \a V1 is copied to the same position in the result. 389321369Sdim/// When a mask bit is 1, the corresponding 64-bit element in operand \a V2 390321369Sdim/// is copied to the same position in the result. 391321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied values. 392234353Sdim#define _mm_blend_pd(V1, V2, M) __extension__ ({ \ 393296417Sdim (__m128d)__builtin_shufflevector((__v2df)(__m128d)(V1), \ 394296417Sdim (__v2df)(__m128d)(V2), \ 395276479Sdim (((M) & 0x01) ? 2 : 0), \ 396276479Sdim (((M) & 0x02) ? 3 : 1)); }) 397204793Srdivacky 398321369Sdim/// \brief Returns a 128-bit vector of [4 x float] where the values are selected 399321369Sdim/// from either the first or second operand as specified by the third 400321369Sdim/// operand, the control mask. 401321369Sdim/// 402321369Sdim/// \headerfile <x86intrin.h> 403321369Sdim/// 404321369Sdim/// \code 405321369Sdim/// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M); 406321369Sdim/// \endcode 407321369Sdim/// 408321369Sdim/// This intrinsic corresponds to the <c> VBLENDPS / BLENDPS </c> instruction. 409321369Sdim/// 410321369Sdim/// \param V1 411321369Sdim/// A 128-bit vector of [4 x float]. 412321369Sdim/// \param V2 413321369Sdim/// A 128-bit vector of [4 x float]. 414321369Sdim/// \param M 415321369Sdim/// An immediate integer operand, with mask bits [3:0] specifying how the 416321369Sdim/// values are to be copied. The position of the mask bit corresponds to the 417321369Sdim/// index of a copied value. When a mask bit is 0, the corresponding 32-bit 418321369Sdim/// element in operand \a V1 is copied to the same position in the result. 419321369Sdim/// When a mask bit is 1, the corresponding 32-bit element in operand \a V2 420321369Sdim/// is copied to the same position in the result. 421321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied values. 422234353Sdim#define _mm_blend_ps(V1, V2, M) __extension__ ({ \ 423296417Sdim (__m128)__builtin_shufflevector((__v4sf)(__m128)(V1), (__v4sf)(__m128)(V2), \ 424276479Sdim (((M) & 0x01) ? 4 : 0), \ 425276479Sdim (((M) & 0x02) ? 5 : 1), \ 426276479Sdim (((M) & 0x04) ? 6 : 2), \ 427276479Sdim (((M) & 0x08) ? 7 : 3)); }) 428204793Srdivacky 429321369Sdim/// \brief Returns a 128-bit vector of [2 x double] where the values are 430321369Sdim/// selected from either the first or second operand as specified by the 431321369Sdim/// third operand, the control mask. 432321369Sdim/// 433321369Sdim/// \headerfile <x86intrin.h> 434321369Sdim/// 435321369Sdim/// This intrinsic corresponds to the <c> VBLENDVPD / BLENDVPD </c> instruction. 436321369Sdim/// 437321369Sdim/// \param __V1 438321369Sdim/// A 128-bit vector of [2 x double]. 439321369Sdim/// \param __V2 440321369Sdim/// A 128-bit vector of [2 x double]. 441321369Sdim/// \param __M 442321369Sdim/// A 128-bit vector operand, with mask bits 127 and 63 specifying how the 443321369Sdim/// values are to be copied. The position of the mask bit corresponds to the 444321369Sdim/// most significant bit of a copied value. When a mask bit is 0, the 445321369Sdim/// corresponding 64-bit element in operand \a __V1 is copied to the same 446321369Sdim/// position in the result. When a mask bit is 1, the corresponding 64-bit 447321369Sdim/// element in operand \a __V2 is copied to the same position in the result. 448321369Sdim/// \returns A 128-bit vector of [2 x double] containing the copied values. 449288943Sdimstatic __inline__ __m128d __DEFAULT_FN_ATTRS 450204793Srdivacky_mm_blendv_pd (__m128d __V1, __m128d __V2, __m128d __M) 451204793Srdivacky{ 452204793Srdivacky return (__m128d) __builtin_ia32_blendvpd ((__v2df)__V1, (__v2df)__V2, 453204793Srdivacky (__v2df)__M); 454204793Srdivacky} 455204793Srdivacky 456321369Sdim/// \brief Returns a 128-bit vector of [4 x float] where the values are 457321369Sdim/// selected from either the first or second operand as specified by the 458321369Sdim/// third operand, the control mask. 459321369Sdim/// 460321369Sdim/// \headerfile <x86intrin.h> 461321369Sdim/// 462321369Sdim/// This intrinsic corresponds to the <c> VBLENDVPS / BLENDVPS </c> instruction. 463321369Sdim/// 464321369Sdim/// \param __V1 465321369Sdim/// A 128-bit vector of [4 x float]. 466321369Sdim/// \param __V2 467321369Sdim/// A 128-bit vector of [4 x float]. 468321369Sdim/// \param __M 469321369Sdim/// A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying 470321369Sdim/// how the values are to be copied. The position of the mask bit corresponds 471321369Sdim/// to the most significant bit of a copied value. When a mask bit is 0, the 472321369Sdim/// corresponding 32-bit element in operand \a __V1 is copied to the same 473321369Sdim/// position in the result. When a mask bit is 1, the corresponding 32-bit 474321369Sdim/// element in operand \a __V2 is copied to the same position in the result. 475321369Sdim/// \returns A 128-bit vector of [4 x float] containing the copied values. 476288943Sdimstatic __inline__ __m128 __DEFAULT_FN_ATTRS 477204793Srdivacky_mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M) 478204793Srdivacky{ 479204793Srdivacky return (__m128) __builtin_ia32_blendvps ((__v4sf)__V1, (__v4sf)__V2, 480204793Srdivacky (__v4sf)__M); 481204793Srdivacky} 482204793Srdivacky 483321369Sdim/// \brief Returns a 128-bit vector of [16 x i8] where the values are selected 484321369Sdim/// from either of the first or second operand as specified by the third 485321369Sdim/// operand, the control mask. 486321369Sdim/// 487321369Sdim/// \headerfile <x86intrin.h> 488321369Sdim/// 489321369Sdim/// This intrinsic corresponds to the <c> VPBLENDVB / PBLENDVB </c> instruction. 490321369Sdim/// 491321369Sdim/// \param __V1 492321369Sdim/// A 128-bit vector of [16 x i8]. 493321369Sdim/// \param __V2 494321369Sdim/// A 128-bit vector of [16 x i8]. 495321369Sdim/// \param __M 496321369Sdim/// A 128-bit vector operand, with mask bits 127, 119, 111 ... 7 specifying 497321369Sdim/// how the values are to be copied. The position of the mask bit corresponds 498321369Sdim/// to the most significant bit of a copied value. When a mask bit is 0, the 499321369Sdim/// corresponding 8-bit element in operand \a __V1 is copied to the same 500321369Sdim/// position in the result. When a mask bit is 1, the corresponding 8-bit 501321369Sdim/// element in operand \a __V2 is copied to the same position in the result. 502321369Sdim/// \returns A 128-bit vector of [16 x i8] containing the copied values. 503288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 504204793Srdivacky_mm_blendv_epi8 (__m128i __V1, __m128i __V2, __m128i __M) 505204793Srdivacky{ 506204793Srdivacky return (__m128i) __builtin_ia32_pblendvb128 ((__v16qi)__V1, (__v16qi)__V2, 507204793Srdivacky (__v16qi)__M); 508204793Srdivacky} 509204793Srdivacky 510321369Sdim/// \brief Returns a 128-bit vector of [8 x i16] where the values are selected 511321369Sdim/// from either of the first or second operand as specified by the third 512321369Sdim/// operand, the control mask. 513321369Sdim/// 514321369Sdim/// \headerfile <x86intrin.h> 515321369Sdim/// 516321369Sdim/// \code 517321369Sdim/// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M); 518321369Sdim/// \endcode 519321369Sdim/// 520321369Sdim/// This intrinsic corresponds to the <c> VPBLENDW / PBLENDW </c> instruction. 521321369Sdim/// 522321369Sdim/// \param V1 523321369Sdim/// A 128-bit vector of [8 x i16]. 524321369Sdim/// \param V2 525321369Sdim/// A 128-bit vector of [8 x i16]. 526321369Sdim/// \param M 527321369Sdim/// An immediate integer operand, with mask bits [7:0] specifying how the 528321369Sdim/// values are to be copied. The position of the mask bit corresponds to the 529321369Sdim/// index of a copied value. When a mask bit is 0, the corresponding 16-bit 530321369Sdim/// element in operand \a V1 is copied to the same position in the result. 531321369Sdim/// When a mask bit is 1, the corresponding 16-bit element in operand \a V2 532321369Sdim/// is copied to the same position in the result. 533321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the copied values. 534234353Sdim#define _mm_blend_epi16(V1, V2, M) __extension__ ({ \ 535296417Sdim (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(V1), \ 536296417Sdim (__v8hi)(__m128i)(V2), \ 537276479Sdim (((M) & 0x01) ? 8 : 0), \ 538276479Sdim (((M) & 0x02) ? 9 : 1), \ 539276479Sdim (((M) & 0x04) ? 10 : 2), \ 540276479Sdim (((M) & 0x08) ? 11 : 3), \ 541276479Sdim (((M) & 0x10) ? 12 : 4), \ 542276479Sdim (((M) & 0x20) ? 13 : 5), \ 543276479Sdim (((M) & 0x40) ? 14 : 6), \ 544276479Sdim (((M) & 0x80) ? 15 : 7)); }) 545204793Srdivacky 546204962Srdivacky/* SSE4 Dword Multiply Instructions. */ 547321369Sdim/// \brief Multiples corresponding elements of two 128-bit vectors of [4 x i32] 548321369Sdim/// and returns the lower 32 bits of the each product in a 128-bit vector of 549321369Sdim/// [4 x i32]. 550321369Sdim/// 551321369Sdim/// \headerfile <x86intrin.h> 552321369Sdim/// 553321369Sdim/// This intrinsic corresponds to the <c> VPMULLD / PMULLD </c> instruction. 554321369Sdim/// 555321369Sdim/// \param __V1 556321369Sdim/// A 128-bit integer vector. 557321369Sdim/// \param __V2 558321369Sdim/// A 128-bit integer vector. 559321369Sdim/// \returns A 128-bit integer vector containing the products of both operands. 560288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 561204962Srdivacky_mm_mullo_epi32 (__m128i __V1, __m128i __V2) 562204962Srdivacky{ 563309124Sdim return (__m128i) ((__v4su)__V1 * (__v4su)__V2); 564204962Srdivacky} 565204962Srdivacky 566321369Sdim/// \brief Multiplies corresponding even-indexed elements of two 128-bit 567321369Sdim/// vectors of [4 x i32] and returns a 128-bit vector of [2 x i64] 568321369Sdim/// containing the products. 569321369Sdim/// 570321369Sdim/// \headerfile <x86intrin.h> 571321369Sdim/// 572321369Sdim/// This intrinsic corresponds to the <c> VPMULDQ / PMULDQ </c> instruction. 573321369Sdim/// 574321369Sdim/// \param __V1 575321369Sdim/// A 128-bit vector of [4 x i32]. 576321369Sdim/// \param __V2 577321369Sdim/// A 128-bit vector of [4 x i32]. 578321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the products of both 579321369Sdim/// operands. 580288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 581204962Srdivacky_mm_mul_epi32 (__m128i __V1, __m128i __V2) 582204962Srdivacky{ 583204962Srdivacky return (__m128i) __builtin_ia32_pmuldq128 ((__v4si)__V1, (__v4si)__V2); 584204962Srdivacky} 585204962Srdivacky 586204962Srdivacky/* SSE4 Floating Point Dot Product Instructions. */ 587321369Sdim/// \brief Computes the dot product of the two 128-bit vectors of [4 x float] 588321369Sdim/// and returns it in the elements of the 128-bit result vector of 589321369Sdim/// [4 x float]. 590321369Sdim/// 591321369Sdim/// The immediate integer operand controls which input elements 592321369Sdim/// will contribute to the dot product, and where the final results are 593321369Sdim/// returned. 594321369Sdim/// 595321369Sdim/// \headerfile <x86intrin.h> 596321369Sdim/// 597321369Sdim/// \code 598321369Sdim/// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M); 599321369Sdim/// \endcode 600321369Sdim/// 601321369Sdim/// This intrinsic corresponds to the <c> VDPPS / DPPS </c> instruction. 602321369Sdim/// 603321369Sdim/// \param X 604321369Sdim/// A 128-bit vector of [4 x float]. 605321369Sdim/// \param Y 606321369Sdim/// A 128-bit vector of [4 x float]. 607321369Sdim/// \param M 608321369Sdim/// An immediate integer operand. Mask bits [7:4] determine which elements 609321369Sdim/// of the input vectors are used, with bit [4] corresponding to the lowest 610321369Sdim/// element and bit [7] corresponding to the highest element of each [4 x 611321369Sdim/// float] vector. If a bit is set, the corresponding elements from the two 612321369Sdim/// input vectors are used as an input for dot product; otherwise that input 613321369Sdim/// is treated as zero. Bits [3:0] determine which elements of the result 614321369Sdim/// will receive a copy of the final dot product, with bit [0] corresponding 615321369Sdim/// to the lowest element and bit [3] corresponding to the highest element of 616321369Sdim/// each [4 x float] subvector. If a bit is set, the dot product is returned 617321369Sdim/// in the corresponding element; otherwise that element is set to zero. 618321369Sdim/// \returns A 128-bit vector of [4 x float] containing the dot product. 619234353Sdim#define _mm_dp_ps(X, Y, M) __extension__ ({ \ 620296417Sdim (__m128) __builtin_ia32_dpps((__v4sf)(__m128)(X), \ 621296417Sdim (__v4sf)(__m128)(Y), (M)); }) 622204962Srdivacky 623321369Sdim/// \brief Computes the dot product of the two 128-bit vectors of [2 x double] 624321369Sdim/// and returns it in the elements of the 128-bit result vector of 625321369Sdim/// [2 x double]. 626321369Sdim/// 627321369Sdim/// The immediate integer operand controls which input 628321369Sdim/// elements will contribute to the dot product, and where the final results 629321369Sdim/// are returned. 630321369Sdim/// 631321369Sdim/// \headerfile <x86intrin.h> 632321369Sdim/// 633321369Sdim/// \code 634321369Sdim/// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M); 635321369Sdim/// \endcode 636321369Sdim/// 637321369Sdim/// This intrinsic corresponds to the <c> VDPPD / DPPD </c> instruction. 638321369Sdim/// 639321369Sdim/// \param X 640321369Sdim/// A 128-bit vector of [2 x double]. 641321369Sdim/// \param Y 642321369Sdim/// A 128-bit vector of [2 x double]. 643321369Sdim/// \param M 644321369Sdim/// An immediate integer operand. Mask bits [5:4] determine which elements 645321369Sdim/// of the input vectors are used, with bit [4] corresponding to the lowest 646321369Sdim/// element and bit [5] corresponding to the highest element of each of [2 x 647321369Sdim/// double] vector. If a bit is set, the corresponding elements from the two 648321369Sdim/// input vectors are used as an input for dot product; otherwise that input 649321369Sdim/// is treated as zero. Bits [1:0] determine which elements of the result 650321369Sdim/// will receive a copy of the final dot product, with bit [0] corresponding 651327952Sdim/// to the lowest element and bit [1] corresponding to the highest element of 652321369Sdim/// each [2 x double] vector. If a bit is set, the dot product is returned in 653321369Sdim/// the corresponding element; otherwise that element is set to zero. 654234353Sdim#define _mm_dp_pd(X, Y, M) __extension__ ({\ 655296417Sdim (__m128d) __builtin_ia32_dppd((__v2df)(__m128d)(X), \ 656296417Sdim (__v2df)(__m128d)(Y), (M)); }) 657234353Sdim 658204962Srdivacky/* SSE4 Streaming Load Hint Instruction. */ 659321369Sdim/// \brief Loads integer values from a 128-bit aligned memory location to a 660321369Sdim/// 128-bit integer vector. 661321369Sdim/// 662321369Sdim/// \headerfile <x86intrin.h> 663321369Sdim/// 664321369Sdim/// This intrinsic corresponds to the <c> VMOVNTDQA / MOVNTDQA </c> instruction. 665321369Sdim/// 666321369Sdim/// \param __V 667321369Sdim/// A pointer to a 128-bit aligned memory location that contains the integer 668321369Sdim/// values. 669321369Sdim/// \returns A 128-bit integer vector containing the data stored at the 670321369Sdim/// specified memory location. 671288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 672296417Sdim_mm_stream_load_si128 (__m128i const *__V) 673204962Srdivacky{ 674321369Sdim return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V); 675204962Srdivacky} 676204962Srdivacky 677204962Srdivacky/* SSE4 Packed Integer Min/Max Instructions. */ 678321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 679321369Sdim/// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser 680321369Sdim/// of the two values. 681321369Sdim/// 682321369Sdim/// \headerfile <x86intrin.h> 683321369Sdim/// 684321369Sdim/// This intrinsic corresponds to the <c> VPMINSB / PMINSB </c> instruction. 685321369Sdim/// 686321369Sdim/// \param __V1 687321369Sdim/// A 128-bit vector of [16 x i8]. 688321369Sdim/// \param __V2 689321369Sdim/// A 128-bit vector of [16 x i8] 690321369Sdim/// \returns A 128-bit vector of [16 x i8] containing the lesser values. 691288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 692204962Srdivacky_mm_min_epi8 (__m128i __V1, __m128i __V2) 693204962Srdivacky{ 694204962Srdivacky return (__m128i) __builtin_ia32_pminsb128 ((__v16qi) __V1, (__v16qi) __V2); 695204962Srdivacky} 696204962Srdivacky 697321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 698321369Sdim/// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the 699321369Sdim/// greater value of the two. 700321369Sdim/// 701321369Sdim/// \headerfile <x86intrin.h> 702321369Sdim/// 703321369Sdim/// This intrinsic corresponds to the <c> VPMAXSB / PMAXSB </c> instruction. 704321369Sdim/// 705321369Sdim/// \param __V1 706321369Sdim/// A 128-bit vector of [16 x i8]. 707321369Sdim/// \param __V2 708321369Sdim/// A 128-bit vector of [16 x i8]. 709321369Sdim/// \returns A 128-bit vector of [16 x i8] containing the greater values. 710288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 711204962Srdivacky_mm_max_epi8 (__m128i __V1, __m128i __V2) 712204962Srdivacky{ 713204962Srdivacky return (__m128i) __builtin_ia32_pmaxsb128 ((__v16qi) __V1, (__v16qi) __V2); 714204962Srdivacky} 715204962Srdivacky 716321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 717321369Sdim/// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser 718321369Sdim/// value of the two. 719321369Sdim/// 720321369Sdim/// \headerfile <x86intrin.h> 721321369Sdim/// 722321369Sdim/// This intrinsic corresponds to the <c> VPMINUW / PMINUW </c> instruction. 723321369Sdim/// 724321369Sdim/// \param __V1 725321369Sdim/// A 128-bit vector of [8 x u16]. 726321369Sdim/// \param __V2 727321369Sdim/// A 128-bit vector of [8 x u16]. 728321369Sdim/// \returns A 128-bit vector of [8 x u16] containing the lesser values. 729288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 730204962Srdivacky_mm_min_epu16 (__m128i __V1, __m128i __V2) 731204962Srdivacky{ 732204962Srdivacky return (__m128i) __builtin_ia32_pminuw128 ((__v8hi) __V1, (__v8hi) __V2); 733204962Srdivacky} 734204962Srdivacky 735321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 736321369Sdim/// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the 737321369Sdim/// greater value of the two. 738321369Sdim/// 739321369Sdim/// \headerfile <x86intrin.h> 740321369Sdim/// 741321369Sdim/// This intrinsic corresponds to the <c> VPMAXUW / PMAXUW </c> instruction. 742321369Sdim/// 743321369Sdim/// \param __V1 744321369Sdim/// A 128-bit vector of [8 x u16]. 745321369Sdim/// \param __V2 746321369Sdim/// A 128-bit vector of [8 x u16]. 747321369Sdim/// \returns A 128-bit vector of [8 x u16] containing the greater values. 748288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 749204962Srdivacky_mm_max_epu16 (__m128i __V1, __m128i __V2) 750204962Srdivacky{ 751204962Srdivacky return (__m128i) __builtin_ia32_pmaxuw128 ((__v8hi) __V1, (__v8hi) __V2); 752204962Srdivacky} 753204962Srdivacky 754321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 755321369Sdim/// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser 756321369Sdim/// value of the two. 757321369Sdim/// 758321369Sdim/// \headerfile <x86intrin.h> 759321369Sdim/// 760321369Sdim/// This intrinsic corresponds to the <c> VPMINSD / PMINSD </c> instruction. 761321369Sdim/// 762321369Sdim/// \param __V1 763321369Sdim/// A 128-bit vector of [4 x i32]. 764321369Sdim/// \param __V2 765321369Sdim/// A 128-bit vector of [4 x i32]. 766321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the lesser values. 767288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 768204962Srdivacky_mm_min_epi32 (__m128i __V1, __m128i __V2) 769204962Srdivacky{ 770204962Srdivacky return (__m128i) __builtin_ia32_pminsd128 ((__v4si) __V1, (__v4si) __V2); 771204962Srdivacky} 772204962Srdivacky 773321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 774321369Sdim/// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the 775321369Sdim/// greater value of the two. 776321369Sdim/// 777321369Sdim/// \headerfile <x86intrin.h> 778321369Sdim/// 779321369Sdim/// This intrinsic corresponds to the <c> VPMAXSD / PMAXSD </c> instruction. 780321369Sdim/// 781321369Sdim/// \param __V1 782321369Sdim/// A 128-bit vector of [4 x i32]. 783321369Sdim/// \param __V2 784321369Sdim/// A 128-bit vector of [4 x i32]. 785321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the greater values. 786288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 787204962Srdivacky_mm_max_epi32 (__m128i __V1, __m128i __V2) 788204962Srdivacky{ 789204962Srdivacky return (__m128i) __builtin_ia32_pmaxsd128 ((__v4si) __V1, (__v4si) __V2); 790204962Srdivacky} 791204962Srdivacky 792321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 793321369Sdim/// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser 794321369Sdim/// value of the two. 795321369Sdim/// 796321369Sdim/// \headerfile <x86intrin.h> 797321369Sdim/// 798321369Sdim/// This intrinsic corresponds to the <c> VPMINUD / PMINUD </c> instruction. 799321369Sdim/// 800321369Sdim/// \param __V1 801321369Sdim/// A 128-bit vector of [4 x u32]. 802321369Sdim/// \param __V2 803321369Sdim/// A 128-bit vector of [4 x u32]. 804321369Sdim/// \returns A 128-bit vector of [4 x u32] containing the lesser values. 805288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 806204962Srdivacky_mm_min_epu32 (__m128i __V1, __m128i __V2) 807204962Srdivacky{ 808204962Srdivacky return (__m128i) __builtin_ia32_pminud128((__v4si) __V1, (__v4si) __V2); 809204962Srdivacky} 810204962Srdivacky 811321369Sdim/// \brief Compares the corresponding elements of two 128-bit vectors of 812321369Sdim/// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the 813321369Sdim/// greater value of the two. 814321369Sdim/// 815321369Sdim/// \headerfile <x86intrin.h> 816321369Sdim/// 817321369Sdim/// This intrinsic corresponds to the <c> VPMAXUD / PMAXUD </c> instruction. 818321369Sdim/// 819321369Sdim/// \param __V1 820321369Sdim/// A 128-bit vector of [4 x u32]. 821321369Sdim/// \param __V2 822321369Sdim/// A 128-bit vector of [4 x u32]. 823321369Sdim/// \returns A 128-bit vector of [4 x u32] containing the greater values. 824288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 825204962Srdivacky_mm_max_epu32 (__m128i __V1, __m128i __V2) 826204962Srdivacky{ 827204962Srdivacky return (__m128i) __builtin_ia32_pmaxud128((__v4si) __V1, (__v4si) __V2); 828204962Srdivacky} 829204962Srdivacky 830204962Srdivacky/* SSE4 Insertion and Extraction from XMM Register Instructions. */ 831321369Sdim/// \brief Takes the first argument \a X and inserts an element from the second 832321369Sdim/// argument \a Y as selected by the third argument \a N. That result then 833321369Sdim/// has elements zeroed out also as selected by the third argument \a N. The 834321369Sdim/// resulting 128-bit vector of [4 x float] is then returned. 835321369Sdim/// 836321369Sdim/// \headerfile <x86intrin.h> 837321369Sdim/// 838321369Sdim/// \code 839321369Sdim/// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N); 840321369Sdim/// \endcode 841321369Sdim/// 842321369Sdim/// This intrinsic corresponds to the <c> VINSERTPS </c> instruction. 843321369Sdim/// 844321369Sdim/// \param X 845321369Sdim/// A 128-bit vector source operand of [4 x float]. With the exception of 846321369Sdim/// those bits in the result copied from parameter \a Y and zeroed by bits 847321369Sdim/// [3:0] of \a N, all bits from this parameter are copied to the result. 848321369Sdim/// \param Y 849321369Sdim/// A 128-bit vector source operand of [4 x float]. One single-precision 850321369Sdim/// floating-point element from this source, as determined by the immediate 851321369Sdim/// parameter, is copied to the result. 852321369Sdim/// \param N 853321369Sdim/// Specifies which bits from operand \a Y will be copied, which bits in the 854321369Sdim/// result they will be be copied to, and which bits in the result will be 855321369Sdim/// cleared. The following assignments are made: \n 856321369Sdim/// Bits [7:6] specify the bits to copy from operand \a Y: \n 857321369Sdim/// 00: Selects bits [31:0] from operand \a Y. \n 858321369Sdim/// 01: Selects bits [63:32] from operand \a Y. \n 859321369Sdim/// 10: Selects bits [95:64] from operand \a Y. \n 860321369Sdim/// 11: Selects bits [127:96] from operand \a Y. \n 861321369Sdim/// Bits [5:4] specify the bits in the result to which the selected bits 862321369Sdim/// from operand \a Y are copied: \n 863321369Sdim/// 00: Copies the selected bits from \a Y to result bits [31:0]. \n 864321369Sdim/// 01: Copies the selected bits from \a Y to result bits [63:32]. \n 865321369Sdim/// 10: Copies the selected bits from \a Y to result bits [95:64]. \n 866321369Sdim/// 11: Copies the selected bits from \a Y to result bits [127:96]. \n 867321369Sdim/// Bits[3:0]: If any of these bits are set, the corresponding result 868321369Sdim/// element is cleared. 869327952Sdim/// \returns A 128-bit vector of [4 x float] containing the copied 870327952Sdim/// single-precision floating point elements from the operands. 871204962Srdivacky#define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N)) 872321369Sdim 873321369Sdim/// \brief Extracts a 32-bit integer from a 128-bit vector of [4 x float] and 874321369Sdim/// returns it, using the immediate value parameter \a N as a selector. 875321369Sdim/// 876321369Sdim/// \headerfile <x86intrin.h> 877321369Sdim/// 878321369Sdim/// \code 879321369Sdim/// int _mm_extract_ps(__m128 X, const int N); 880321369Sdim/// \endcode 881321369Sdim/// 882321369Sdim/// This intrinsic corresponds to the <c> VEXTRACTPS / EXTRACTPS </c> 883321369Sdim/// instruction. 884321369Sdim/// 885321369Sdim/// \param X 886321369Sdim/// A 128-bit vector of [4 x float]. 887321369Sdim/// \param N 888321369Sdim/// An immediate value. Bits [1:0] determines which bits from the argument 889321369Sdim/// \a X are extracted and returned: \n 890321369Sdim/// 00: Bits [31:0] of parameter \a X are returned. \n 891321369Sdim/// 01: Bits [63:32] of parameter \a X are returned. \n 892321369Sdim/// 10: Bits [95:64] of parameter \a X are returned. \n 893321369Sdim/// 11: Bits [127:96] of parameter \a X are returned. 894321369Sdim/// \returns A 32-bit integer containing the extracted 32 bits of float data. 895204962Srdivacky#define _mm_extract_ps(X, N) (__extension__ \ 896249423Sdim ({ union { int __i; float __f; } __t; \ 897296417Sdim __v4sf __a = (__v4sf)(__m128)(X); \ 898261991Sdim __t.__f = __a[(N) & 3]; \ 899249423Sdim __t.__i;})) 900204962Srdivacky 901204962Srdivacky/* Miscellaneous insert and extract macros. */ 902204962Srdivacky/* Extract a single-precision float from X at index N into D. */ 903210299Sed#define _MM_EXTRACT_FLOAT(D, X, N) (__extension__ ({ __v4sf __a = (__v4sf)(X); \ 904204962Srdivacky (D) = __a[N]; })) 905296417Sdim 906204962Srdivacky/* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create 907204962Srdivacky an index suitable for _mm_insert_ps. */ 908204962Srdivacky#define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z)) 909296417Sdim 910204962Srdivacky/* Extract a float from X at index N into the first index of the return. */ 911204962Srdivacky#define _MM_PICK_OUT_PS(X, N) _mm_insert_ps (_mm_setzero_ps(), (X), \ 912204962Srdivacky _MM_MK_INSERTPS_NDX((N), 0, 0x0e)) 913296417Sdim 914205219Srdivacky/* Insert int into packed integer array at index. */ 915321369Sdim/// \brief Constructs a 128-bit vector of [16 x i8] by first making a copy of 916321369Sdim/// the 128-bit integer vector parameter, and then inserting the lower 8 bits 917321369Sdim/// of an integer parameter \a I into an offset specified by the immediate 918321369Sdim/// value parameter \a N. 919321369Sdim/// 920321369Sdim/// \headerfile <x86intrin.h> 921321369Sdim/// 922321369Sdim/// \code 923321369Sdim/// __m128i _mm_insert_epi8(__m128i X, int I, const int N); 924321369Sdim/// \endcode 925321369Sdim/// 926321369Sdim/// This intrinsic corresponds to the <c> VPINSRB / PINSRB </c> instruction. 927321369Sdim/// 928321369Sdim/// \param X 929321369Sdim/// A 128-bit integer vector of [16 x i8]. This vector is copied to the 930321369Sdim/// result and then one of the sixteen elements in the result vector is 931321369Sdim/// replaced by the lower 8 bits of \a I. 932321369Sdim/// \param I 933321369Sdim/// An integer. The lower 8 bits of this operand are written to the result 934321369Sdim/// beginning at the offset specified by \a N. 935321369Sdim/// \param N 936321369Sdim/// An immediate value. Bits [3:0] specify the bit offset in the result at 937321369Sdim/// which the lower 8 bits of \a I are written. \n 938321369Sdim/// 0000: Bits [7:0] of the result are used for insertion. \n 939321369Sdim/// 0001: Bits [15:8] of the result are used for insertion. \n 940321369Sdim/// 0010: Bits [23:16] of the result are used for insertion. \n 941321369Sdim/// 0011: Bits [31:24] of the result are used for insertion. \n 942321369Sdim/// 0100: Bits [39:32] of the result are used for insertion. \n 943321369Sdim/// 0101: Bits [47:40] of the result are used for insertion. \n 944321369Sdim/// 0110: Bits [55:48] of the result are used for insertion. \n 945321369Sdim/// 0111: Bits [63:56] of the result are used for insertion. \n 946321369Sdim/// 1000: Bits [71:64] of the result are used for insertion. \n 947321369Sdim/// 1001: Bits [79:72] of the result are used for insertion. \n 948321369Sdim/// 1010: Bits [87:80] of the result are used for insertion. \n 949321369Sdim/// 1011: Bits [95:88] of the result are used for insertion. \n 950321369Sdim/// 1100: Bits [103:96] of the result are used for insertion. \n 951321369Sdim/// 1101: Bits [111:104] of the result are used for insertion. \n 952321369Sdim/// 1110: Bits [119:112] of the result are used for insertion. \n 953321369Sdim/// 1111: Bits [127:120] of the result are used for insertion. 954321369Sdim/// \returns A 128-bit integer vector containing the constructed values. 955296417Sdim#define _mm_insert_epi8(X, I, N) (__extension__ \ 956296417Sdim ({ __v16qi __a = (__v16qi)(__m128i)(X); \ 957296417Sdim __a[(N) & 15] = (I); \ 958309124Sdim (__m128i)__a;})) 959321369Sdim 960321369Sdim/// \brief Constructs a 128-bit vector of [4 x i32] by first making a copy of 961321369Sdim/// the 128-bit integer vector parameter, and then inserting the 32-bit 962321369Sdim/// integer parameter \a I at the offset specified by the immediate value 963321369Sdim/// parameter \a N. 964321369Sdim/// 965321369Sdim/// \headerfile <x86intrin.h> 966321369Sdim/// 967321369Sdim/// \code 968321369Sdim/// __m128i _mm_insert_epi32(__m128i X, int I, const int N); 969321369Sdim/// \endcode 970321369Sdim/// 971321369Sdim/// This intrinsic corresponds to the <c> VPINSRD / PINSRD </c> instruction. 972321369Sdim/// 973321369Sdim/// \param X 974321369Sdim/// A 128-bit integer vector of [4 x i32]. This vector is copied to the 975321369Sdim/// result and then one of the four elements in the result vector is 976321369Sdim/// replaced by \a I. 977321369Sdim/// \param I 978321369Sdim/// A 32-bit integer that is written to the result beginning at the offset 979321369Sdim/// specified by \a N. 980321369Sdim/// \param N 981321369Sdim/// An immediate value. Bits [1:0] specify the bit offset in the result at 982321369Sdim/// which the integer \a I is written. \n 983321369Sdim/// 00: Bits [31:0] of the result are used for insertion. \n 984321369Sdim/// 01: Bits [63:32] of the result are used for insertion. \n 985321369Sdim/// 10: Bits [95:64] of the result are used for insertion. \n 986321369Sdim/// 11: Bits [127:96] of the result are used for insertion. 987321369Sdim/// \returns A 128-bit integer vector containing the constructed values. 988296417Sdim#define _mm_insert_epi32(X, I, N) (__extension__ \ 989296417Sdim ({ __v4si __a = (__v4si)(__m128i)(X); \ 990296417Sdim __a[(N) & 3] = (I); \ 991309124Sdim (__m128i)__a;})) 992321369Sdim 993205219Srdivacky#ifdef __x86_64__ 994321369Sdim/// \brief Constructs a 128-bit vector of [2 x i64] by first making a copy of 995321369Sdim/// the 128-bit integer vector parameter, and then inserting the 64-bit 996321369Sdim/// integer parameter \a I, using the immediate value parameter \a N as an 997321369Sdim/// insertion location selector. 998321369Sdim/// 999321369Sdim/// \headerfile <x86intrin.h> 1000321369Sdim/// 1001321369Sdim/// \code 1002321369Sdim/// __m128i _mm_insert_epi64(__m128i X, long long I, const int N); 1003321369Sdim/// \endcode 1004321369Sdim/// 1005321369Sdim/// This intrinsic corresponds to the <c> VPINSRQ / PINSRQ </c> instruction. 1006321369Sdim/// 1007321369Sdim/// \param X 1008321369Sdim/// A 128-bit integer vector of [2 x i64]. This vector is copied to the 1009321369Sdim/// result and then one of the two elements in the result vector is replaced 1010321369Sdim/// by \a I. 1011321369Sdim/// \param I 1012321369Sdim/// A 64-bit integer that is written to the result beginning at the offset 1013321369Sdim/// specified by \a N. 1014321369Sdim/// \param N 1015321369Sdim/// An immediate value. Bit [0] specifies the bit offset in the result at 1016321369Sdim/// which the integer \a I is written. \n 1017321369Sdim/// 0: Bits [63:0] of the result are used for insertion. \n 1018321369Sdim/// 1: Bits [127:64] of the result are used for insertion. \n 1019321369Sdim/// \returns A 128-bit integer vector containing the constructed values. 1020296417Sdim#define _mm_insert_epi64(X, I, N) (__extension__ \ 1021296417Sdim ({ __v2di __a = (__v2di)(__m128i)(X); \ 1022296417Sdim __a[(N) & 1] = (I); \ 1023309124Sdim (__m128i)__a;})) 1024205219Srdivacky#endif /* __x86_64__ */ 1025204962Srdivacky 1026212904Sdim/* Extract int from packed integer array at index. This returns the element 1027212904Sdim * as a zero extended value, so it is unsigned. 1028212904Sdim */ 1029321369Sdim/// \brief Extracts an 8-bit element from the 128-bit integer vector of 1030321369Sdim/// [16 x i8], using the immediate value parameter \a N as a selector. 1031321369Sdim/// 1032321369Sdim/// \headerfile <x86intrin.h> 1033321369Sdim/// 1034321369Sdim/// \code 1035321369Sdim/// int _mm_extract_epi8(__m128i X, const int N); 1036321369Sdim/// \endcode 1037321369Sdim/// 1038321369Sdim/// This intrinsic corresponds to the <c> VPEXTRB / PEXTRB </c> instruction. 1039321369Sdim/// 1040321369Sdim/// \param X 1041321369Sdim/// A 128-bit integer vector. 1042321369Sdim/// \param N 1043321369Sdim/// An immediate value. Bits [3:0] specify which 8-bit vector element from 1044321369Sdim/// the argument \a X to extract and copy to the result. \n 1045321369Sdim/// 0000: Bits [7:0] of parameter \a X are extracted. \n 1046321369Sdim/// 0001: Bits [15:8] of the parameter \a X are extracted. \n 1047321369Sdim/// 0010: Bits [23:16] of the parameter \a X are extracted. \n 1048321369Sdim/// 0011: Bits [31:24] of the parameter \a X are extracted. \n 1049321369Sdim/// 0100: Bits [39:32] of the parameter \a X are extracted. \n 1050321369Sdim/// 0101: Bits [47:40] of the parameter \a X are extracted. \n 1051321369Sdim/// 0110: Bits [55:48] of the parameter \a X are extracted. \n 1052321369Sdim/// 0111: Bits [63:56] of the parameter \a X are extracted. \n 1053321369Sdim/// 1000: Bits [71:64] of the parameter \a X are extracted. \n 1054321369Sdim/// 1001: Bits [79:72] of the parameter \a X are extracted. \n 1055321369Sdim/// 1010: Bits [87:80] of the parameter \a X are extracted. \n 1056321369Sdim/// 1011: Bits [95:88] of the parameter \a X are extracted. \n 1057321369Sdim/// 1100: Bits [103:96] of the parameter \a X are extracted. \n 1058321369Sdim/// 1101: Bits [111:104] of the parameter \a X are extracted. \n 1059321369Sdim/// 1110: Bits [119:112] of the parameter \a X are extracted. \n 1060321369Sdim/// 1111: Bits [127:120] of the parameter \a X are extracted. 1061321369Sdim/// \returns An unsigned integer, whose lower 8 bits are selected from the 1062321369Sdim/// 128-bit integer vector parameter and the remaining bits are assigned 1063321369Sdim/// zeros. 1064296417Sdim#define _mm_extract_epi8(X, N) (__extension__ \ 1065296417Sdim ({ __v16qi __a = (__v16qi)(__m128i)(X); \ 1066296417Sdim (int)(unsigned char) __a[(N) & 15];})) 1067321369Sdim 1068321369Sdim/// \brief Extracts a 32-bit element from the 128-bit integer vector of 1069321369Sdim/// [4 x i32], using the immediate value parameter \a N as a selector. 1070321369Sdim/// 1071321369Sdim/// \headerfile <x86intrin.h> 1072321369Sdim/// 1073321369Sdim/// \code 1074321369Sdim/// int _mm_extract_epi32(__m128i X, const int N); 1075321369Sdim/// \endcode 1076321369Sdim/// 1077321369Sdim/// This intrinsic corresponds to the <c> VPEXTRD / PEXTRD </c> instruction. 1078321369Sdim/// 1079321369Sdim/// \param X 1080321369Sdim/// A 128-bit integer vector. 1081321369Sdim/// \param N 1082321369Sdim/// An immediate value. Bits [1:0] specify which 32-bit vector element from 1083321369Sdim/// the argument \a X to extract and copy to the result. \n 1084321369Sdim/// 00: Bits [31:0] of the parameter \a X are extracted. \n 1085321369Sdim/// 01: Bits [63:32] of the parameter \a X are extracted. \n 1086321369Sdim/// 10: Bits [95:64] of the parameter \a X are extracted. \n 1087321369Sdim/// 11: Bits [127:96] of the parameter \a X are exracted. 1088321369Sdim/// \returns An integer, whose lower 32 bits are selected from the 128-bit 1089321369Sdim/// integer vector parameter and the remaining bits are assigned zeros. 1090296417Sdim#define _mm_extract_epi32(X, N) (__extension__ \ 1091296417Sdim ({ __v4si __a = (__v4si)(__m128i)(X); \ 1092296417Sdim (int)__a[(N) & 3];})) 1093321369Sdim 1094205219Srdivacky#ifdef __x86_64__ 1095321369Sdim/// \brief Extracts a 64-bit element from the 128-bit integer vector of 1096321369Sdim/// [2 x i64], using the immediate value parameter \a N as a selector. 1097321369Sdim/// 1098321369Sdim/// \headerfile <x86intrin.h> 1099321369Sdim/// 1100321369Sdim/// \code 1101321369Sdim/// long long _mm_extract_epi64(__m128i X, const int N); 1102321369Sdim/// \endcode 1103321369Sdim/// 1104321369Sdim/// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction. 1105321369Sdim/// 1106321369Sdim/// \param X 1107321369Sdim/// A 128-bit integer vector. 1108321369Sdim/// \param N 1109321369Sdim/// An immediate value. Bit [0] specifies which 64-bit vector element from 1110321369Sdim/// the argument \a X to return. \n 1111321369Sdim/// 0: Bits [63:0] are returned. \n 1112321369Sdim/// 1: Bits [127:64] are returned. \n 1113321369Sdim/// \returns A 64-bit integer. 1114296417Sdim#define _mm_extract_epi64(X, N) (__extension__ \ 1115296417Sdim ({ __v2di __a = (__v2di)(__m128i)(X); \ 1116296417Sdim (long long)__a[(N) & 1];})) 1117205219Srdivacky#endif /* __x86_64 */ 1118205219Srdivacky 1119205219Srdivacky/* SSE4 128-bit Packed Integer Comparisons. */ 1120321369Sdim/// \brief Tests whether the specified bits in a 128-bit integer vector are all 1121321369Sdim/// zeros. 1122321369Sdim/// 1123321369Sdim/// \headerfile <x86intrin.h> 1124321369Sdim/// 1125321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction. 1126321369Sdim/// 1127321369Sdim/// \param __M 1128321369Sdim/// A 128-bit integer vector containing the bits to be tested. 1129321369Sdim/// \param __V 1130321369Sdim/// A 128-bit integer vector selecting which bits to test in operand \a __M. 1131321369Sdim/// \returns TRUE if the specified bits are all zeros; FALSE otherwise. 1132288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS 1133205219Srdivacky_mm_testz_si128(__m128i __M, __m128i __V) 1134205219Srdivacky{ 1135205219Srdivacky return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V); 1136205219Srdivacky} 1137205219Srdivacky 1138321369Sdim/// \brief Tests whether the specified bits in a 128-bit integer vector are all 1139321369Sdim/// ones. 1140321369Sdim/// 1141321369Sdim/// \headerfile <x86intrin.h> 1142321369Sdim/// 1143321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction. 1144321369Sdim/// 1145321369Sdim/// \param __M 1146321369Sdim/// A 128-bit integer vector containing the bits to be tested. 1147321369Sdim/// \param __V 1148321369Sdim/// A 128-bit integer vector selecting which bits to test in operand \a __M. 1149321369Sdim/// \returns TRUE if the specified bits are all ones; FALSE otherwise. 1150288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS 1151205219Srdivacky_mm_testc_si128(__m128i __M, __m128i __V) 1152205219Srdivacky{ 1153205219Srdivacky return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V); 1154205219Srdivacky} 1155205219Srdivacky 1156321369Sdim/// \brief Tests whether the specified bits in a 128-bit integer vector are 1157321369Sdim/// neither all zeros nor all ones. 1158321369Sdim/// 1159321369Sdim/// \headerfile <x86intrin.h> 1160321369Sdim/// 1161321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction. 1162321369Sdim/// 1163321369Sdim/// \param __M 1164321369Sdim/// A 128-bit integer vector containing the bits to be tested. 1165321369Sdim/// \param __V 1166321369Sdim/// A 128-bit integer vector selecting which bits to test in operand \a __M. 1167321369Sdim/// \returns TRUE if the specified bits are neither all zeros nor all ones; 1168321369Sdim/// FALSE otherwise. 1169288943Sdimstatic __inline__ int __DEFAULT_FN_ATTRS 1170205219Srdivacky_mm_testnzc_si128(__m128i __M, __m128i __V) 1171205219Srdivacky{ 1172205219Srdivacky return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V); 1173205219Srdivacky} 1174205219Srdivacky 1175321369Sdim/// \brief Tests whether the specified bits in a 128-bit integer vector are all 1176321369Sdim/// ones. 1177321369Sdim/// 1178321369Sdim/// \headerfile <x86intrin.h> 1179321369Sdim/// 1180321369Sdim/// \code 1181321369Sdim/// int _mm_test_all_ones(__m128i V); 1182321369Sdim/// \endcode 1183321369Sdim/// 1184321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction. 1185321369Sdim/// 1186321369Sdim/// \param V 1187321369Sdim/// A 128-bit integer vector containing the bits to be tested. 1188321369Sdim/// \returns TRUE if the bits specified in the operand are all set to 1; FALSE 1189321369Sdim/// otherwise. 1190205219Srdivacky#define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V))) 1191321369Sdim 1192321369Sdim/// \brief Tests whether the specified bits in a 128-bit integer vector are 1193321369Sdim/// neither all zeros nor all ones. 1194321369Sdim/// 1195321369Sdim/// \headerfile <x86intrin.h> 1196321369Sdim/// 1197321369Sdim/// \code 1198321369Sdim/// int _mm_test_mix_ones_zeros(__m128i M, __m128i V); 1199321369Sdim/// \endcode 1200321369Sdim/// 1201321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction. 1202321369Sdim/// 1203321369Sdim/// \param M 1204321369Sdim/// A 128-bit integer vector containing the bits to be tested. 1205321369Sdim/// \param V 1206321369Sdim/// A 128-bit integer vector selecting which bits to test in operand \a M. 1207321369Sdim/// \returns TRUE if the specified bits are neither all zeros nor all ones; 1208321369Sdim/// FALSE otherwise. 1209205219Srdivacky#define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V)) 1210321369Sdim 1211321369Sdim/// \brief Tests whether the specified bits in a 128-bit integer vector are all 1212321369Sdim/// zeros. 1213321369Sdim/// 1214321369Sdim/// \headerfile <x86intrin.h> 1215321369Sdim/// 1216321369Sdim/// \code 1217321369Sdim/// int _mm_test_all_zeros(__m128i M, __m128i V); 1218321369Sdim/// \endcode 1219321369Sdim/// 1220321369Sdim/// This intrinsic corresponds to the <c> VPTEST / PTEST </c> instruction. 1221321369Sdim/// 1222321369Sdim/// \param M 1223321369Sdim/// A 128-bit integer vector containing the bits to be tested. 1224321369Sdim/// \param V 1225321369Sdim/// A 128-bit integer vector selecting which bits to test in operand \a M. 1226321369Sdim/// \returns TRUE if the specified bits are all zeros; FALSE otherwise. 1227234353Sdim#define _mm_test_all_zeros(M, V) _mm_testz_si128 ((M), (V)) 1228205219Srdivacky 1229205219Srdivacky/* SSE4 64-bit Packed Integer Comparisons. */ 1230321369Sdim/// \brief Compares each of the corresponding 64-bit values of the 128-bit 1231321369Sdim/// integer vectors for equality. 1232321369Sdim/// 1233321369Sdim/// \headerfile <x86intrin.h> 1234321369Sdim/// 1235321369Sdim/// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction. 1236321369Sdim/// 1237321369Sdim/// \param __V1 1238321369Sdim/// A 128-bit integer vector. 1239321369Sdim/// \param __V2 1240321369Sdim/// A 128-bit integer vector. 1241321369Sdim/// \returns A 128-bit integer vector containing the comparison results. 1242288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1243205219Srdivacky_mm_cmpeq_epi64(__m128i __V1, __m128i __V2) 1244205219Srdivacky{ 1245234353Sdim return (__m128i)((__v2di)__V1 == (__v2di)__V2); 1246205219Srdivacky} 1247205219Srdivacky 1248205219Srdivacky/* SSE4 Packed Integer Sign-Extension. */ 1249321369Sdim/// \brief Sign-extends each of the lower eight 8-bit integer elements of a 1250321369Sdim/// 128-bit vector of [16 x i8] to 16-bit values and returns them in a 1251321369Sdim/// 128-bit vector of [8 x i16]. The upper eight elements of the input vector 1252321369Sdim/// are unused. 1253321369Sdim/// 1254321369Sdim/// \headerfile <x86intrin.h> 1255321369Sdim/// 1256321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXBW / PMOVSXBW </c> instruction. 1257321369Sdim/// 1258321369Sdim/// \param __V 1259321369Sdim/// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are sign- 1260321369Sdim/// extended to 16-bit values. 1261321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the sign-extended values. 1262288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1263205219Srdivacky_mm_cvtepi8_epi16(__m128i __V) 1264205219Srdivacky{ 1265296417Sdim /* This function always performs a signed extension, but __v16qi is a char 1266296417Sdim which may be signed or unsigned, so use __v16qs. */ 1267296417Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi); 1268205219Srdivacky} 1269205219Srdivacky 1270321369Sdim/// \brief Sign-extends each of the lower four 8-bit integer elements of a 1271321369Sdim/// 128-bit vector of [16 x i8] to 32-bit values and returns them in a 1272321369Sdim/// 128-bit vector of [4 x i32]. The upper twelve elements of the input 1273321369Sdim/// vector are unused. 1274321369Sdim/// 1275321369Sdim/// \headerfile <x86intrin.h> 1276321369Sdim/// 1277321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXBD / PMOVSXBD </c> instruction. 1278321369Sdim/// 1279321369Sdim/// \param __V 1280321369Sdim/// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are sign- 1281321369Sdim/// extended to 32-bit values. 1282321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values. 1283288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1284205219Srdivacky_mm_cvtepi8_epi32(__m128i __V) 1285205219Srdivacky{ 1286296417Sdim /* This function always performs a signed extension, but __v16qi is a char 1287296417Sdim which may be signed or unsigned, so use __v16qs. */ 1288296417Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si); 1289205219Srdivacky} 1290205219Srdivacky 1291321369Sdim/// \brief Sign-extends each of the lower two 8-bit integer elements of a 1292321369Sdim/// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in 1293321369Sdim/// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input 1294321369Sdim/// vector are unused. 1295321369Sdim/// 1296321369Sdim/// \headerfile <x86intrin.h> 1297321369Sdim/// 1298321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXBQ / PMOVSXBQ </c> instruction. 1299321369Sdim/// 1300321369Sdim/// \param __V 1301321369Sdim/// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are sign- 1302321369Sdim/// extended to 64-bit values. 1303321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values. 1304288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1305205219Srdivacky_mm_cvtepi8_epi64(__m128i __V) 1306205219Srdivacky{ 1307296417Sdim /* This function always performs a signed extension, but __v16qi is a char 1308296417Sdim which may be signed or unsigned, so use __v16qs. */ 1309296417Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di); 1310205219Srdivacky} 1311205219Srdivacky 1312321369Sdim/// \brief Sign-extends each of the lower four 16-bit integer elements of a 1313321369Sdim/// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in 1314321369Sdim/// a 128-bit vector of [4 x i32]. The upper four elements of the input 1315321369Sdim/// vector are unused. 1316321369Sdim/// 1317321369Sdim/// \headerfile <x86intrin.h> 1318321369Sdim/// 1319321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXWD / PMOVSXWD </c> instruction. 1320321369Sdim/// 1321321369Sdim/// \param __V 1322321369Sdim/// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are sign- 1323321369Sdim/// extended to 32-bit values. 1324321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values. 1325288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1326205219Srdivacky_mm_cvtepi16_epi32(__m128i __V) 1327205219Srdivacky{ 1328296417Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si); 1329205219Srdivacky} 1330205219Srdivacky 1331321369Sdim/// \brief Sign-extends each of the lower two 16-bit integer elements of a 1332321369Sdim/// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in 1333321369Sdim/// a 128-bit vector of [2 x i64]. The upper six elements of the input 1334321369Sdim/// vector are unused. 1335321369Sdim/// 1336321369Sdim/// \headerfile <x86intrin.h> 1337321369Sdim/// 1338321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXWQ / PMOVSXWQ </c> instruction. 1339321369Sdim/// 1340321369Sdim/// \param __V 1341321369Sdim/// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are sign- 1342321369Sdim/// extended to 64-bit values. 1343321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values. 1344288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1345205219Srdivacky_mm_cvtepi16_epi64(__m128i __V) 1346205219Srdivacky{ 1347296417Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di); 1348205219Srdivacky} 1349205219Srdivacky 1350321369Sdim/// \brief Sign-extends each of the lower two 32-bit integer elements of a 1351321369Sdim/// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in 1352321369Sdim/// a 128-bit vector of [2 x i64]. The upper two elements of the input vector 1353321369Sdim/// are unused. 1354321369Sdim/// 1355321369Sdim/// \headerfile <x86intrin.h> 1356321369Sdim/// 1357321369Sdim/// This intrinsic corresponds to the <c> VPMOVSXDQ / PMOVSXDQ </c> instruction. 1358321369Sdim/// 1359321369Sdim/// \param __V 1360321369Sdim/// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are sign- 1361321369Sdim/// extended to 64-bit values. 1362321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values. 1363288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1364205219Srdivacky_mm_cvtepi32_epi64(__m128i __V) 1365205219Srdivacky{ 1366296417Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di); 1367205219Srdivacky} 1368205219Srdivacky 1369205219Srdivacky/* SSE4 Packed Integer Zero-Extension. */ 1370321369Sdim/// \brief Zero-extends each of the lower eight 8-bit integer elements of a 1371321369Sdim/// 128-bit vector of [16 x i8] to 16-bit values and returns them in a 1372321369Sdim/// 128-bit vector of [8 x i16]. The upper eight elements of the input vector 1373321369Sdim/// are unused. 1374321369Sdim/// 1375321369Sdim/// \headerfile <x86intrin.h> 1376321369Sdim/// 1377321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXBW / PMOVZXBW </c> instruction. 1378321369Sdim/// 1379321369Sdim/// \param __V 1380321369Sdim/// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are zero- 1381321369Sdim/// extended to 16-bit values. 1382321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the zero-extended values. 1383288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1384205219Srdivacky_mm_cvtepu8_epi16(__m128i __V) 1385205219Srdivacky{ 1386309124Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8hi); 1387205219Srdivacky} 1388205219Srdivacky 1389321369Sdim/// \brief Zero-extends each of the lower four 8-bit integer elements of a 1390321369Sdim/// 128-bit vector of [16 x i8] to 32-bit values and returns them in a 1391321369Sdim/// 128-bit vector of [4 x i32]. The upper twelve elements of the input 1392321369Sdim/// vector are unused. 1393321369Sdim/// 1394321369Sdim/// \headerfile <x86intrin.h> 1395321369Sdim/// 1396321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXBD / PMOVZXBD </c> instruction. 1397321369Sdim/// 1398321369Sdim/// \param __V 1399321369Sdim/// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are zero- 1400321369Sdim/// extended to 32-bit values. 1401321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values. 1402288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1403205219Srdivacky_mm_cvtepu8_epi32(__m128i __V) 1404205219Srdivacky{ 1405309124Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si); 1406205219Srdivacky} 1407205219Srdivacky 1408321369Sdim/// \brief Zero-extends each of the lower two 8-bit integer elements of a 1409321369Sdim/// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in 1410321369Sdim/// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input 1411321369Sdim/// vector are unused. 1412321369Sdim/// 1413321369Sdim/// \headerfile <x86intrin.h> 1414321369Sdim/// 1415321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXBQ / PMOVZXBQ </c> instruction. 1416321369Sdim/// 1417321369Sdim/// \param __V 1418321369Sdim/// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are zero- 1419321369Sdim/// extended to 64-bit values. 1420321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values. 1421288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1422205219Srdivacky_mm_cvtepu8_epi64(__m128i __V) 1423205219Srdivacky{ 1424309124Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di); 1425205219Srdivacky} 1426205219Srdivacky 1427321369Sdim/// \brief Zero-extends each of the lower four 16-bit integer elements of a 1428321369Sdim/// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in 1429321369Sdim/// a 128-bit vector of [4 x i32]. The upper four elements of the input 1430321369Sdim/// vector are unused. 1431321369Sdim/// 1432321369Sdim/// \headerfile <x86intrin.h> 1433321369Sdim/// 1434321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXWD / PMOVZXWD </c> instruction. 1435321369Sdim/// 1436321369Sdim/// \param __V 1437321369Sdim/// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are zero- 1438321369Sdim/// extended to 32-bit values. 1439321369Sdim/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values. 1440288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1441205219Srdivacky_mm_cvtepu16_epi32(__m128i __V) 1442205219Srdivacky{ 1443309124Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si); 1444205219Srdivacky} 1445205219Srdivacky 1446321369Sdim/// \brief Zero-extends each of the lower two 16-bit integer elements of a 1447321369Sdim/// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in 1448321369Sdim/// a 128-bit vector of [2 x i64]. The upper six elements of the input vector 1449321369Sdim/// are unused. 1450321369Sdim/// 1451321369Sdim/// \headerfile <x86intrin.h> 1452321369Sdim/// 1453321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXWQ / PMOVZXWQ </c> instruction. 1454321369Sdim/// 1455321369Sdim/// \param __V 1456321369Sdim/// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are zero- 1457321369Sdim/// extended to 64-bit values. 1458321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values. 1459288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1460205219Srdivacky_mm_cvtepu16_epi64(__m128i __V) 1461205219Srdivacky{ 1462309124Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di); 1463205219Srdivacky} 1464205219Srdivacky 1465321369Sdim/// \brief Zero-extends each of the lower two 32-bit integer elements of a 1466321369Sdim/// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in 1467321369Sdim/// a 128-bit vector of [2 x i64]. The upper two elements of the input vector 1468321369Sdim/// are unused. 1469321369Sdim/// 1470321369Sdim/// \headerfile <x86intrin.h> 1471321369Sdim/// 1472321369Sdim/// This intrinsic corresponds to the <c> VPMOVZXDQ / PMOVZXDQ </c> instruction. 1473321369Sdim/// 1474321369Sdim/// \param __V 1475321369Sdim/// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are zero- 1476321369Sdim/// extended to 64-bit values. 1477321369Sdim/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values. 1478288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1479205219Srdivacky_mm_cvtepu32_epi64(__m128i __V) 1480205219Srdivacky{ 1481309124Sdim return (__m128i)__builtin_convertvector(__builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di); 1482205219Srdivacky} 1483205219Srdivacky 1484205219Srdivacky/* SSE4 Pack with Unsigned Saturation. */ 1485321369Sdim/// \brief Converts 32-bit signed integers from both 128-bit integer vector 1486321369Sdim/// operands into 16-bit unsigned integers, and returns the packed result. 1487321369Sdim/// Values greater than 0xFFFF are saturated to 0xFFFF. Values less than 1488321369Sdim/// 0x0000 are saturated to 0x0000. 1489321369Sdim/// 1490321369Sdim/// \headerfile <x86intrin.h> 1491321369Sdim/// 1492321369Sdim/// This intrinsic corresponds to the <c> VPACKUSDW / PACKUSDW </c> instruction. 1493321369Sdim/// 1494321369Sdim/// \param __V1 1495321369Sdim/// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a 1496321369Sdim/// signed integer and is converted to a 16-bit unsigned integer with 1497321369Sdim/// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values 1498321369Sdim/// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values 1499321369Sdim/// are written to the lower 64 bits of the result. 1500321369Sdim/// \param __V2 1501321369Sdim/// A 128-bit vector of [4 x i32]. Each 32-bit element is treated as a 1502321369Sdim/// signed integer and is converted to a 16-bit unsigned integer with 1503321369Sdim/// saturation. Values greater than 0xFFFF are saturated to 0xFFFF. Values 1504321369Sdim/// less than 0x0000 are saturated to 0x0000. The converted [4 x i16] values 1505321369Sdim/// are written to the higher 64 bits of the result. 1506321369Sdim/// \returns A 128-bit vector of [8 x i16] containing the converted values. 1507288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1508205219Srdivacky_mm_packus_epi32(__m128i __V1, __m128i __V2) 1509205219Srdivacky{ 1510205219Srdivacky return (__m128i) __builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2); 1511205219Srdivacky} 1512205219Srdivacky 1513205219Srdivacky/* SSE4 Multiple Packed Sums of Absolute Difference. */ 1514321369Sdim/// \brief Subtracts 8-bit unsigned integer values and computes the absolute 1515321369Sdim/// values of the differences to the corresponding bits in the destination. 1516321369Sdim/// Then sums of the absolute differences are returned according to the bit 1517321369Sdim/// fields in the immediate operand. 1518321369Sdim/// 1519321369Sdim/// \headerfile <x86intrin.h> 1520321369Sdim/// 1521321369Sdim/// \code 1522321369Sdim/// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M); 1523321369Sdim/// \endcode 1524321369Sdim/// 1525321369Sdim/// This intrinsic corresponds to the <c> VMPSADBW / MPSADBW </c> instruction. 1526321369Sdim/// 1527321369Sdim/// \param X 1528321369Sdim/// A 128-bit vector of [16 x i8]. 1529321369Sdim/// \param Y 1530321369Sdim/// A 128-bit vector of [16 x i8]. 1531321369Sdim/// \param M 1532321369Sdim/// An 8-bit immediate operand specifying how the absolute differences are to 1533321369Sdim/// be calculated, according to the following algorithm: 1534321369Sdim/// \code 1535321369Sdim/// // M2 represents bit 2 of the immediate operand 1536321369Sdim/// // M10 represents bits [1:0] of the immediate operand 1537321369Sdim/// i = M2 * 4 1538321369Sdim/// j = M10 * 4 1539321369Sdim/// for (k = 0; k < 8; k = k + 1) { 1540321369Sdim/// d0 = abs(X[i + k + 0] - Y[j + 0]) 1541321369Sdim/// d1 = abs(X[i + k + 1] - Y[j + 1]) 1542321369Sdim/// d2 = abs(X[i + k + 2] - Y[j + 2]) 1543321369Sdim/// d3 = abs(X[i + k + 3] - Y[j + 3]) 1544321369Sdim/// r[k] = d0 + d1 + d2 + d3 1545321369Sdim/// } 1546321369Sdim/// \endcode 1547321369Sdim/// \returns A 128-bit integer vector containing the sums of the sets of 1548321369Sdim/// absolute differences between both operands. 1549234353Sdim#define _mm_mpsadbw_epu8(X, Y, M) __extension__ ({ \ 1550296417Sdim (__m128i) __builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \ 1551296417Sdim (__v16qi)(__m128i)(Y), (M)); }) 1552205219Srdivacky 1553321369Sdim/// \brief Finds the minimum unsigned 16-bit element in the input 128-bit 1554321369Sdim/// vector of [8 x u16] and returns it and along with its index. 1555321369Sdim/// 1556321369Sdim/// \headerfile <x86intrin.h> 1557321369Sdim/// 1558321369Sdim/// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c> 1559321369Sdim/// instruction. 1560321369Sdim/// 1561321369Sdim/// \param __V 1562321369Sdim/// A 128-bit vector of [8 x u16]. 1563321369Sdim/// \returns A 128-bit value where bits [15:0] contain the minimum value found 1564321369Sdim/// in parameter \a __V, bits [18:16] contain the index of the minimum value 1565321369Sdim/// and the remaining bits are set to 0. 1566288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 1567234353Sdim_mm_minpos_epu16(__m128i __V) 1568234353Sdim{ 1569234353Sdim return (__m128i) __builtin_ia32_phminposuw128((__v8hi)__V); 1570234353Sdim} 1571234353Sdim 1572296417Sdim/* Handle the sse4.2 definitions here. */ 1573296417Sdim 1574205408Srdivacky/* These definitions are normally in nmmintrin.h, but gcc puts them in here 1575205408Srdivacky so we'll do the same. */ 1576205408Srdivacky 1577296417Sdim#undef __DEFAULT_FN_ATTRS 1578296417Sdim#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4.2"))) 1579296417Sdim 1580205408Srdivacky/* These specify the type of data that we're comparing. */ 1581205408Srdivacky#define _SIDD_UBYTE_OPS 0x00 1582205408Srdivacky#define _SIDD_UWORD_OPS 0x01 1583205408Srdivacky#define _SIDD_SBYTE_OPS 0x02 1584205408Srdivacky#define _SIDD_SWORD_OPS 0x03 1585205408Srdivacky 1586205408Srdivacky/* These specify the type of comparison operation. */ 1587205408Srdivacky#define _SIDD_CMP_EQUAL_ANY 0x00 1588205408Srdivacky#define _SIDD_CMP_RANGES 0x04 1589205408Srdivacky#define _SIDD_CMP_EQUAL_EACH 0x08 1590205408Srdivacky#define _SIDD_CMP_EQUAL_ORDERED 0x0c 1591205408Srdivacky 1592205408Srdivacky/* These macros specify the polarity of the operation. */ 1593205408Srdivacky#define _SIDD_POSITIVE_POLARITY 0x00 1594205408Srdivacky#define _SIDD_NEGATIVE_POLARITY 0x10 1595205408Srdivacky#define _SIDD_MASKED_POSITIVE_POLARITY 0x20 1596205408Srdivacky#define _SIDD_MASKED_NEGATIVE_POLARITY 0x30 1597205408Srdivacky 1598205408Srdivacky/* These macros are used in _mm_cmpXstri() to specify the return. */ 1599205408Srdivacky#define _SIDD_LEAST_SIGNIFICANT 0x00 1600205408Srdivacky#define _SIDD_MOST_SIGNIFICANT 0x40 1601205408Srdivacky 1602205408Srdivacky/* These macros are used in _mm_cmpXstri() to specify the return. */ 1603205408Srdivacky#define _SIDD_BIT_MASK 0x00 1604205408Srdivacky#define _SIDD_UNIT_MASK 0x40 1605205408Srdivacky 1606205408Srdivacky/* SSE4.2 Packed Comparison Intrinsics. */ 1607321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1608321369Sdim/// data with implicitly defined lengths that is contained in source operands 1609321369Sdim/// \a A and \a B. Returns a 128-bit integer vector representing the result 1610321369Sdim/// mask of the comparison. 1611321369Sdim/// 1612321369Sdim/// \headerfile <x86intrin.h> 1613321369Sdim/// 1614321369Sdim/// \code 1615321369Sdim/// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M); 1616321369Sdim/// \endcode 1617321369Sdim/// 1618321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRM / PCMPISTRM </c> 1619321369Sdim/// instruction. 1620321369Sdim/// 1621321369Sdim/// \param A 1622321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1623321369Sdim/// compared. 1624321369Sdim/// \param B 1625321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1626321369Sdim/// compared. 1627321369Sdim/// \param M 1628321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1629321369Sdim/// words, the type of comparison to perform, and the format of the return 1630321369Sdim/// value. \n 1631321369Sdim/// Bits [1:0]: Determine source data format. \n 1632321369Sdim/// 00: 16 unsigned bytes \n 1633321369Sdim/// 01: 8 unsigned words \n 1634321369Sdim/// 10: 16 signed bytes \n 1635321369Sdim/// 11: 8 signed words \n 1636321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1637321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1638321369Sdim/// the characters in \a A. \n 1639321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1640321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1641321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1642321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1643321369Sdim/// \a B for equality. \n 1644321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 1645321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1646321369Sdim/// mask of the comparison results. \n 1647321369Sdim/// 00: No effect. \n 1648321369Sdim/// 01: Negate the bit mask. \n 1649321369Sdim/// 10: No effect. \n 1650321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1651321369Sdim/// to the size of \a A or \a B. \n 1652321369Sdim/// Bit [6]: Determines whether the result is zero-extended or expanded to 16 1653321369Sdim/// bytes. \n 1654321369Sdim/// 0: The result is zero-extended to 16 bytes. \n 1655321369Sdim/// 1: The result is expanded to 16 bytes (this expansion is performed by 1656321369Sdim/// repeating each bit 8 or 16 times). 1657321369Sdim/// \returns Returns a 128-bit integer vector representing the result mask of 1658321369Sdim/// the comparison. 1659296417Sdim#define _mm_cmpistrm(A, B, M) \ 1660296417Sdim (__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \ 1661296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 1662321369Sdim 1663321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1664321369Sdim/// data with implicitly defined lengths that is contained in source operands 1665321369Sdim/// \a A and \a B. Returns an integer representing the result index of the 1666321369Sdim/// comparison. 1667321369Sdim/// 1668321369Sdim/// \headerfile <x86intrin.h> 1669321369Sdim/// 1670321369Sdim/// \code 1671321369Sdim/// int _mm_cmpistri(__m128i A, __m128i B, const int M); 1672321369Sdim/// \endcode 1673321369Sdim/// 1674321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c> 1675321369Sdim/// instruction. 1676321369Sdim/// 1677321369Sdim/// \param A 1678321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1679321369Sdim/// compared. 1680321369Sdim/// \param B 1681321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1682321369Sdim/// compared. 1683321369Sdim/// \param M 1684321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1685321369Sdim/// words, the type of comparison to perform, and the format of the return 1686321369Sdim/// value. \n 1687321369Sdim/// Bits [1:0]: Determine source data format. \n 1688321369Sdim/// 00: 16 unsigned bytes \n 1689321369Sdim/// 01: 8 unsigned words \n 1690321369Sdim/// 10: 16 signed bytes \n 1691321369Sdim/// 11: 8 signed words \n 1692321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1693321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1694321369Sdim/// the characters in \a A. \n 1695321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1696321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1697321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1698321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1699321369Sdim/// \a B for equality. \n 1700321369Sdim/// 11: Substring: Search B for substring matches of \a A. \n 1701321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1702321369Sdim/// mask of the comparison results. \n 1703321369Sdim/// 00: No effect. \n 1704321369Sdim/// 01: Negate the bit mask. \n 1705321369Sdim/// 10: No effect. \n 1706321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1707321369Sdim/// to the size of \a A or \a B. \n 1708321369Sdim/// Bit [6]: Determines whether the index of the lowest set bit or the 1709321369Sdim/// highest set bit is returned. \n 1710321369Sdim/// 0: The index of the least significant set bit. \n 1711321369Sdim/// 1: The index of the most significant set bit. \n 1712321369Sdim/// \returns Returns an integer representing the result index of the comparison. 1713296417Sdim#define _mm_cmpistri(A, B, M) \ 1714296417Sdim (int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \ 1715296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 1716205408Srdivacky 1717321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1718321369Sdim/// data with explicitly defined lengths that is contained in source operands 1719321369Sdim/// \a A and \a B. Returns a 128-bit integer vector representing the result 1720321369Sdim/// mask of the comparison. 1721321369Sdim/// 1722321369Sdim/// \headerfile <x86intrin.h> 1723321369Sdim/// 1724321369Sdim/// \code 1725321369Sdim/// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M); 1726321369Sdim/// \endcode 1727321369Sdim/// 1728321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRM / PCMPESTRM </c> 1729321369Sdim/// instruction. 1730321369Sdim/// 1731321369Sdim/// \param A 1732321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1733321369Sdim/// compared. 1734321369Sdim/// \param LA 1735321369Sdim/// An integer that specifies the length of the string in \a A. 1736321369Sdim/// \param B 1737321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1738321369Sdim/// compared. 1739321369Sdim/// \param LB 1740321369Sdim/// An integer that specifies the length of the string in \a B. 1741321369Sdim/// \param M 1742321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1743321369Sdim/// words, the type of comparison to perform, and the format of the return 1744321369Sdim/// value. \n 1745321369Sdim/// Bits [1:0]: Determine source data format. \n 1746321369Sdim/// 00: 16 unsigned bytes \n 1747321369Sdim/// 01: 8 unsigned words \n 1748321369Sdim/// 10: 16 signed bytes \n 1749321369Sdim/// 11: 8 signed words \n 1750321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1751321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1752321369Sdim/// the characters in \a A. \n 1753321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1754321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1755321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1756321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1757321369Sdim/// \a B for equality. \n 1758321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 1759321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1760321369Sdim/// mask of the comparison results. \n 1761321369Sdim/// 00: No effect. \n 1762321369Sdim/// 01: Negate the bit mask. \n 1763321369Sdim/// 10: No effect. \n 1764321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1765321369Sdim/// to the size of \a A or \a B. \n 1766321369Sdim/// Bit [6]: Determines whether the result is zero-extended or expanded to 16 1767321369Sdim/// bytes. \n 1768321369Sdim/// 0: The result is zero-extended to 16 bytes. \n 1769321369Sdim/// 1: The result is expanded to 16 bytes (this expansion is performed by 1770321369Sdim/// repeating each bit 8 or 16 times). \n 1771321369Sdim/// \returns Returns a 128-bit integer vector representing the result mask of 1772321369Sdim/// the comparison. 1773205408Srdivacky#define _mm_cmpestrm(A, LA, B, LB, M) \ 1774296417Sdim (__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \ 1775296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 1776296417Sdim (int)(M)) 1777321369Sdim 1778321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1779321369Sdim/// data with explicitly defined lengths that is contained in source operands 1780321369Sdim/// \a A and \a B. Returns an integer representing the result index of the 1781321369Sdim/// comparison. 1782321369Sdim/// 1783321369Sdim/// \headerfile <x86intrin.h> 1784321369Sdim/// 1785321369Sdim/// \code 1786321369Sdim/// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M); 1787321369Sdim/// \endcode 1788321369Sdim/// 1789321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c> 1790321369Sdim/// instruction. 1791321369Sdim/// 1792321369Sdim/// \param A 1793321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1794321369Sdim/// compared. 1795321369Sdim/// \param LA 1796321369Sdim/// An integer that specifies the length of the string in \a A. 1797321369Sdim/// \param B 1798321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1799321369Sdim/// compared. 1800321369Sdim/// \param LB 1801321369Sdim/// An integer that specifies the length of the string in \a B. 1802321369Sdim/// \param M 1803321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1804321369Sdim/// words, the type of comparison to perform, and the format of the return 1805321369Sdim/// value. \n 1806321369Sdim/// Bits [1:0]: Determine source data format. \n 1807321369Sdim/// 00: 16 unsigned bytes \n 1808321369Sdim/// 01: 8 unsigned words \n 1809321369Sdim/// 10: 16 signed bytes \n 1810321369Sdim/// 11: 8 signed words \n 1811321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1812321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1813321369Sdim/// the characters in \a A. \n 1814321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1815321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1816321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1817321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1818321369Sdim/// \a B for equality. \n 1819321369Sdim/// 11: Substring: Search B for substring matches of \a A. \n 1820321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1821321369Sdim/// mask of the comparison results. \n 1822321369Sdim/// 00: No effect. \n 1823321369Sdim/// 01: Negate the bit mask. \n 1824321369Sdim/// 10: No effect. \n 1825321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1826321369Sdim/// to the size of \a A or \a B. \n 1827321369Sdim/// Bit [6]: Determines whether the index of the lowest set bit or the 1828321369Sdim/// highest set bit is returned. \n 1829321369Sdim/// 0: The index of the least significant set bit. \n 1830321369Sdim/// 1: The index of the most significant set bit. \n 1831321369Sdim/// \returns Returns an integer representing the result index of the comparison. 1832234353Sdim#define _mm_cmpestri(A, LA, B, LB, M) \ 1833296417Sdim (int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \ 1834296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 1835296417Sdim (int)(M)) 1836296417Sdim 1837205408Srdivacky/* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */ 1838321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1839321369Sdim/// data with implicitly defined lengths that is contained in source operands 1840321369Sdim/// \a A and \a B. Returns 1 if the bit mask is zero and the length of the 1841321369Sdim/// string in \a B is the maximum, otherwise, returns 0. 1842321369Sdim/// 1843321369Sdim/// \headerfile <x86intrin.h> 1844321369Sdim/// 1845321369Sdim/// \code 1846321369Sdim/// int _mm_cmpistra(__m128i A, __m128i B, const int M); 1847321369Sdim/// \endcode 1848321369Sdim/// 1849321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c> 1850321369Sdim/// instruction. 1851321369Sdim/// 1852321369Sdim/// \param A 1853321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1854321369Sdim/// compared. 1855321369Sdim/// \param B 1856321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1857321369Sdim/// compared. 1858321369Sdim/// \param M 1859321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1860321369Sdim/// words and the type of comparison to perform. \n 1861321369Sdim/// Bits [1:0]: Determine source data format. \n 1862321369Sdim/// 00: 16 unsigned bytes \n 1863321369Sdim/// 01: 8 unsigned words \n 1864321369Sdim/// 10: 16 signed bytes \n 1865321369Sdim/// 11: 8 signed words \n 1866321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1867321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1868321369Sdim/// the characters in \a A. \n 1869321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1870321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1871321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1872321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1873321369Sdim/// \a B for equality. \n 1874321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 1875321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1876321369Sdim/// mask of the comparison results. \n 1877321369Sdim/// 00: No effect. \n 1878321369Sdim/// 01: Negate the bit mask. \n 1879321369Sdim/// 10: No effect. \n 1880321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1881321369Sdim/// to the size of \a A or \a B. \n 1882321369Sdim/// \returns Returns 1 if the bit mask is zero and the length of the string in 1883321369Sdim/// \a B is the maximum; otherwise, returns 0. 1884234353Sdim#define _mm_cmpistra(A, B, M) \ 1885296417Sdim (int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \ 1886296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 1887321369Sdim 1888321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1889321369Sdim/// data with implicitly defined lengths that is contained in source operands 1890321369Sdim/// \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns 1891321369Sdim/// 0. 1892321369Sdim/// 1893321369Sdim/// \headerfile <x86intrin.h> 1894321369Sdim/// 1895321369Sdim/// \code 1896321369Sdim/// int _mm_cmpistrc(__m128i A, __m128i B, const int M); 1897321369Sdim/// \endcode 1898321369Sdim/// 1899321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c> 1900321369Sdim/// instruction. 1901321369Sdim/// 1902321369Sdim/// \param A 1903321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1904321369Sdim/// compared. 1905321369Sdim/// \param B 1906321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1907321369Sdim/// compared. 1908321369Sdim/// \param M 1909321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1910321369Sdim/// words and the type of comparison to perform. \n 1911321369Sdim/// Bits [1:0]: Determine source data format. \n 1912321369Sdim/// 00: 16 unsigned bytes \n 1913321369Sdim/// 01: 8 unsigned words \n 1914321369Sdim/// 10: 16 signed bytes \n 1915321369Sdim/// 11: 8 signed words \n 1916321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1917321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1918321369Sdim/// the characters in \a A. \n 1919321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1920321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1921321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1922321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1923321369Sdim/// \a B for equality. \n 1924321369Sdim/// 11: Substring: Search B for substring matches of \a A. \n 1925321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1926321369Sdim/// mask of the comparison results. \n 1927321369Sdim/// 00: No effect. \n 1928321369Sdim/// 01: Negate the bit mask. \n 1929321369Sdim/// 10: No effect. \n 1930321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1931321369Sdim/// to the size of \a A or \a B. 1932321369Sdim/// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0. 1933234353Sdim#define _mm_cmpistrc(A, B, M) \ 1934296417Sdim (int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \ 1935296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 1936321369Sdim 1937321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1938321369Sdim/// data with implicitly defined lengths that is contained in source operands 1939321369Sdim/// \a A and \a B. Returns bit 0 of the resulting bit mask. 1940321369Sdim/// 1941321369Sdim/// \headerfile <x86intrin.h> 1942321369Sdim/// 1943321369Sdim/// \code 1944321369Sdim/// int _mm_cmpistro(__m128i A, __m128i B, const int M); 1945321369Sdim/// \endcode 1946321369Sdim/// 1947321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c> 1948321369Sdim/// instruction. 1949321369Sdim/// 1950321369Sdim/// \param A 1951321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1952321369Sdim/// compared. 1953321369Sdim/// \param B 1954321369Sdim/// A 128-bit integer vector containing one of the source operands to be 1955321369Sdim/// compared. 1956321369Sdim/// \param M 1957321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 1958321369Sdim/// words and the type of comparison to perform. \n 1959321369Sdim/// Bits [1:0]: Determine source data format. \n 1960321369Sdim/// 00: 16 unsigned bytes \n 1961321369Sdim/// 01: 8 unsigned words \n 1962321369Sdim/// 10: 16 signed bytes \n 1963321369Sdim/// 11: 8 signed words \n 1964321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 1965321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 1966321369Sdim/// the characters in \a A. \n 1967321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 1968321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 1969321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 1970321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 1971321369Sdim/// \a B for equality. \n 1972321369Sdim/// 11: Substring: Search B for substring matches of \a A. \n 1973321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 1974321369Sdim/// mask of the comparison results. \n 1975321369Sdim/// 00: No effect. \n 1976321369Sdim/// 01: Negate the bit mask. \n 1977321369Sdim/// 10: No effect. \n 1978321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 1979321369Sdim/// to the size of \a A or \a B. \n 1980321369Sdim/// \returns Returns bit 0 of the resulting bit mask. 1981234353Sdim#define _mm_cmpistro(A, B, M) \ 1982296417Sdim (int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \ 1983296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 1984321369Sdim 1985321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 1986321369Sdim/// data with implicitly defined lengths that is contained in source operands 1987321369Sdim/// \a A and \a B. Returns 1 if the length of the string in \a A is less than 1988321369Sdim/// the maximum, otherwise, returns 0. 1989321369Sdim/// 1990321369Sdim/// \headerfile <x86intrin.h> 1991321369Sdim/// 1992321369Sdim/// \code 1993321369Sdim/// int _mm_cmpistrs(__m128i A, __m128i B, const int M); 1994321369Sdim/// \endcode 1995321369Sdim/// 1996321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c> 1997321369Sdim/// instruction. 1998321369Sdim/// 1999321369Sdim/// \param A 2000321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2001321369Sdim/// compared. 2002321369Sdim/// \param B 2003321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2004321369Sdim/// compared. 2005321369Sdim/// \param M 2006321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2007321369Sdim/// words and the type of comparison to perform. \n 2008321369Sdim/// Bits [1:0]: Determine source data format. \n 2009321369Sdim/// 00: 16 unsigned bytes \n 2010321369Sdim/// 01: 8 unsigned words \n 2011321369Sdim/// 10: 16 signed bytes \n 2012321369Sdim/// 11: 8 signed words \n 2013321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2014321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2015321369Sdim/// the characters in \a A. \n 2016321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2017321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2018321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2019321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2020321369Sdim/// \a B for equality. \n 2021321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2022321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 2023321369Sdim/// mask of the comparison results. \n 2024321369Sdim/// 00: No effect. \n 2025321369Sdim/// 01: Negate the bit mask. \n 2026321369Sdim/// 10: No effect. \n 2027321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2028321369Sdim/// to the size of \a A or \a B. \n 2029321369Sdim/// \returns Returns 1 if the length of the string in \a A is less than the 2030321369Sdim/// maximum, otherwise, returns 0. 2031234353Sdim#define _mm_cmpistrs(A, B, M) \ 2032296417Sdim (int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \ 2033296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 2034321369Sdim 2035321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 2036321369Sdim/// data with implicitly defined lengths that is contained in source operands 2037321369Sdim/// \a A and \a B. Returns 1 if the length of the string in \a B is less than 2038321369Sdim/// the maximum, otherwise, returns 0. 2039321369Sdim/// 2040321369Sdim/// \headerfile <x86intrin.h> 2041321369Sdim/// 2042321369Sdim/// \code 2043321369Sdim/// int _mm_cmpistrz(__m128i A, __m128i B, const int M); 2044321369Sdim/// \endcode 2045321369Sdim/// 2046321369Sdim/// This intrinsic corresponds to the <c> VPCMPISTRI / PCMPISTRI </c> 2047321369Sdim/// instruction. 2048321369Sdim/// 2049321369Sdim/// \param A 2050321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2051321369Sdim/// compared. 2052321369Sdim/// \param B 2053321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2054321369Sdim/// compared. 2055321369Sdim/// \param M 2056321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2057321369Sdim/// words and the type of comparison to perform. \n 2058321369Sdim/// Bits [1:0]: Determine source data format. \n 2059321369Sdim/// 00: 16 unsigned bytes \n 2060321369Sdim/// 01: 8 unsigned words \n 2061321369Sdim/// 10: 16 signed bytes \n 2062321369Sdim/// 11: 8 signed words \n 2063321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2064321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2065321369Sdim/// the characters in \a A. \n 2066321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2067321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2068321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2069321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2070321369Sdim/// \a B for equality. \n 2071321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2072321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 2073321369Sdim/// mask of the comparison results. \n 2074321369Sdim/// 00: No effect. \n 2075321369Sdim/// 01: Negate the bit mask. \n 2076321369Sdim/// 10: No effect. \n 2077321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2078321369Sdim/// to the size of \a A or \a B. 2079321369Sdim/// \returns Returns 1 if the length of the string in \a B is less than the 2080321369Sdim/// maximum, otherwise, returns 0. 2081234353Sdim#define _mm_cmpistrz(A, B, M) \ 2082296417Sdim (int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \ 2083296417Sdim (__v16qi)(__m128i)(B), (int)(M)) 2084205408Srdivacky 2085321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 2086321369Sdim/// data with explicitly defined lengths that is contained in source operands 2087321369Sdim/// \a A and \a B. Returns 1 if the bit mask is zero and the length of the 2088321369Sdim/// string in \a B is the maximum, otherwise, returns 0. 2089321369Sdim/// 2090321369Sdim/// \headerfile <x86intrin.h> 2091321369Sdim/// 2092321369Sdim/// \code 2093321369Sdim/// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M); 2094321369Sdim/// \endcode 2095321369Sdim/// 2096321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c> 2097321369Sdim/// instruction. 2098321369Sdim/// 2099321369Sdim/// \param A 2100321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2101321369Sdim/// compared. 2102321369Sdim/// \param LA 2103321369Sdim/// An integer that specifies the length of the string in \a A. 2104321369Sdim/// \param B 2105321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2106321369Sdim/// compared. 2107321369Sdim/// \param LB 2108321369Sdim/// An integer that specifies the length of the string in \a B. 2109321369Sdim/// \param M 2110321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2111321369Sdim/// words and the type of comparison to perform. \n 2112321369Sdim/// Bits [1:0]: Determine source data format. \n 2113321369Sdim/// 00: 16 unsigned bytes \n 2114321369Sdim/// 01: 8 unsigned words \n 2115321369Sdim/// 10: 16 signed bytes \n 2116321369Sdim/// 11: 8 signed words \n 2117321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2118321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2119321369Sdim/// the characters in \a A. \n 2120321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2121321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2122321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2123321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2124321369Sdim/// \a B for equality. \n 2125321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2126321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 2127321369Sdim/// mask of the comparison results. \n 2128321369Sdim/// 00: No effect. \n 2129321369Sdim/// 01: Negate the bit mask. \n 2130321369Sdim/// 10: No effect. \n 2131321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2132321369Sdim/// to the size of \a A or \a B. 2133321369Sdim/// \returns Returns 1 if the bit mask is zero and the length of the string in 2134321369Sdim/// \a B is the maximum, otherwise, returns 0. 2135205408Srdivacky#define _mm_cmpestra(A, LA, B, LB, M) \ 2136296417Sdim (int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \ 2137296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 2138296417Sdim (int)(M)) 2139321369Sdim 2140321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 2141321369Sdim/// data with explicitly defined lengths that is contained in source operands 2142321369Sdim/// \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise, 2143321369Sdim/// returns 0. 2144321369Sdim/// 2145321369Sdim/// \headerfile <x86intrin.h> 2146321369Sdim/// 2147321369Sdim/// \code 2148321369Sdim/// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M); 2149321369Sdim/// \endcode 2150321369Sdim/// 2151321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c> 2152321369Sdim/// instruction. 2153321369Sdim/// 2154321369Sdim/// \param A 2155321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2156321369Sdim/// compared. 2157321369Sdim/// \param LA 2158321369Sdim/// An integer that specifies the length of the string in \a A. 2159321369Sdim/// \param B 2160321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2161321369Sdim/// compared. 2162321369Sdim/// \param LB 2163321369Sdim/// An integer that specifies the length of the string in \a B. 2164321369Sdim/// \param M 2165321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2166321369Sdim/// words and the type of comparison to perform. \n 2167321369Sdim/// Bits [1:0]: Determine source data format. \n 2168321369Sdim/// 00: 16 unsigned bytes \n 2169321369Sdim/// 01: 8 unsigned words \n 2170321369Sdim/// 10: 16 signed bytes \n 2171321369Sdim/// 11: 8 signed words \n 2172321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2173321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2174321369Sdim/// the characters in \a A. \n 2175321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2176321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2177321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2178321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2179321369Sdim/// \a B for equality. \n 2180321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2181321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 2182321369Sdim/// mask of the comparison results. \n 2183321369Sdim/// 00: No effect. \n 2184321369Sdim/// 01: Negate the bit mask. \n 2185321369Sdim/// 10: No effect. \n 2186321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2187321369Sdim/// to the size of \a A or \a B. \n 2188321369Sdim/// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0. 2189205408Srdivacky#define _mm_cmpestrc(A, LA, B, LB, M) \ 2190296417Sdim (int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \ 2191296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 2192296417Sdim (int)(M)) 2193321369Sdim 2194321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 2195321369Sdim/// data with explicitly defined lengths that is contained in source operands 2196321369Sdim/// \a A and \a B. Returns bit 0 of the resulting bit mask. 2197321369Sdim/// 2198321369Sdim/// \headerfile <x86intrin.h> 2199321369Sdim/// 2200321369Sdim/// \code 2201321369Sdim/// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M); 2202321369Sdim/// \endcode 2203321369Sdim/// 2204321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c> 2205321369Sdim/// instruction. 2206321369Sdim/// 2207321369Sdim/// \param A 2208321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2209321369Sdim/// compared. 2210321369Sdim/// \param LA 2211321369Sdim/// An integer that specifies the length of the string in \a A. 2212321369Sdim/// \param B 2213321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2214321369Sdim/// compared. 2215321369Sdim/// \param LB 2216321369Sdim/// An integer that specifies the length of the string in \a B. 2217321369Sdim/// \param M 2218321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2219321369Sdim/// words and the type of comparison to perform. \n 2220321369Sdim/// Bits [1:0]: Determine source data format. \n 2221321369Sdim/// 00: 16 unsigned bytes \n 2222321369Sdim/// 01: 8 unsigned words \n 2223321369Sdim/// 10: 16 signed bytes \n 2224321369Sdim/// 11: 8 signed words \n 2225321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2226321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2227321369Sdim/// the characters in \a A. \n 2228321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2229321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2230321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2231321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2232321369Sdim/// \a B for equality. \n 2233321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2234321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 2235321369Sdim/// mask of the comparison results. \n 2236321369Sdim/// 00: No effect. \n 2237321369Sdim/// 01: Negate the bit mask. \n 2238321369Sdim/// 10: No effect. \n 2239321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2240321369Sdim/// to the size of \a A or \a B. 2241321369Sdim/// \returns Returns bit 0 of the resulting bit mask. 2242205408Srdivacky#define _mm_cmpestro(A, LA, B, LB, M) \ 2243296417Sdim (int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \ 2244296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 2245296417Sdim (int)(M)) 2246321369Sdim 2247321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 2248321369Sdim/// data with explicitly defined lengths that is contained in source operands 2249321369Sdim/// \a A and \a B. Returns 1 if the length of the string in \a A is less than 2250321369Sdim/// the maximum, otherwise, returns 0. 2251321369Sdim/// 2252321369Sdim/// \headerfile <x86intrin.h> 2253321369Sdim/// 2254321369Sdim/// \code 2255321369Sdim/// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M); 2256321369Sdim/// \endcode 2257321369Sdim/// 2258321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI / PCMPESTRI </c> 2259321369Sdim/// instruction. 2260321369Sdim/// 2261321369Sdim/// \param A 2262321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2263321369Sdim/// compared. 2264321369Sdim/// \param LA 2265321369Sdim/// An integer that specifies the length of the string in \a A. 2266321369Sdim/// \param B 2267321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2268321369Sdim/// compared. 2269321369Sdim/// \param LB 2270321369Sdim/// An integer that specifies the length of the string in \a B. 2271321369Sdim/// \param M 2272321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2273321369Sdim/// words and the type of comparison to perform. \n 2274321369Sdim/// Bits [1:0]: Determine source data format. \n 2275321369Sdim/// 00: 16 unsigned bytes \n 2276321369Sdim/// 01: 8 unsigned words \n 2277321369Sdim/// 10: 16 signed bytes \n 2278321369Sdim/// 11: 8 signed words \n 2279321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2280321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2281321369Sdim/// the characters in \a A. \n 2282321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2283321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2284321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2285321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2286321369Sdim/// \a B for equality. \n 2287321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2288321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement in the bit 2289321369Sdim/// mask of the comparison results. \n 2290321369Sdim/// 00: No effect. \n 2291321369Sdim/// 01: Negate the bit mask. \n 2292321369Sdim/// 10: No effect. \n 2293321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2294321369Sdim/// to the size of \a A or \a B. \n 2295321369Sdim/// \returns Returns 1 if the length of the string in \a A is less than the 2296321369Sdim/// maximum, otherwise, returns 0. 2297205408Srdivacky#define _mm_cmpestrs(A, LA, B, LB, M) \ 2298296417Sdim (int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \ 2299296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 2300296417Sdim (int)(M)) 2301321369Sdim 2302321369Sdim/// \brief Uses the immediate operand \a M to perform a comparison of string 2303321369Sdim/// data with explicitly defined lengths that is contained in source operands 2304321369Sdim/// \a A and \a B. Returns 1 if the length of the string in \a B is less than 2305321369Sdim/// the maximum, otherwise, returns 0. 2306321369Sdim/// 2307321369Sdim/// \headerfile <x86intrin.h> 2308321369Sdim/// 2309321369Sdim/// \code 2310321369Sdim/// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M); 2311321369Sdim/// \endcode 2312321369Sdim/// 2313321369Sdim/// This intrinsic corresponds to the <c> VPCMPESTRI </c> instruction. 2314321369Sdim/// 2315321369Sdim/// \param A 2316321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2317321369Sdim/// compared. 2318321369Sdim/// \param LA 2319321369Sdim/// An integer that specifies the length of the string in \a A. 2320321369Sdim/// \param B 2321321369Sdim/// A 128-bit integer vector containing one of the source operands to be 2322321369Sdim/// compared. 2323321369Sdim/// \param LB 2324321369Sdim/// An integer that specifies the length of the string in \a B. 2325321369Sdim/// \param M 2326321369Sdim/// An 8-bit immediate operand specifying whether the characters are bytes or 2327321369Sdim/// words and the type of comparison to perform. \n 2328321369Sdim/// Bits [1:0]: Determine source data format. \n 2329321369Sdim/// 00: 16 unsigned bytes \n 2330321369Sdim/// 01: 8 unsigned words \n 2331321369Sdim/// 10: 16 signed bytes \n 2332321369Sdim/// 11: 8 signed words \n 2333321369Sdim/// Bits [3:2]: Determine comparison type and aggregation method. \n 2334321369Sdim/// 00: Subset: Each character in \a B is compared for equality with all 2335321369Sdim/// the characters in \a A. \n 2336321369Sdim/// 01: Ranges: Each character in \a B is compared to \a A. The comparison 2337321369Sdim/// basis is greater than or equal for even-indexed elements in \a A, 2338321369Sdim/// and less than or equal for odd-indexed elements in \a A. \n 2339321369Sdim/// 10: Match: Compare each pair of corresponding characters in \a A and 2340321369Sdim/// \a B for equality. \n 2341321369Sdim/// 11: Substring: Search \a B for substring matches of \a A. \n 2342321369Sdim/// Bits [5:4]: Determine whether to perform a one's complement on the bit 2343321369Sdim/// mask of the comparison results. \n 2344321369Sdim/// 00: No effect. \n 2345321369Sdim/// 01: Negate the bit mask. \n 2346321369Sdim/// 10: No effect. \n 2347321369Sdim/// 11: Negate the bit mask only for bits with an index less than or equal 2348321369Sdim/// to the size of \a A or \a B. 2349321369Sdim/// \returns Returns 1 if the length of the string in \a B is less than the 2350321369Sdim/// maximum, otherwise, returns 0. 2351205408Srdivacky#define _mm_cmpestrz(A, LA, B, LB, M) \ 2352296417Sdim (int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \ 2353296417Sdim (__v16qi)(__m128i)(B), (int)(LB), \ 2354296417Sdim (int)(M)) 2355205408Srdivacky 2356205408Srdivacky/* SSE4.2 Compare Packed Data -- Greater Than. */ 2357321369Sdim/// \brief Compares each of the corresponding 64-bit values of the 128-bit 2358321369Sdim/// integer vectors to determine if the values in the first operand are 2359321369Sdim/// greater than those in the second operand. 2360321369Sdim/// 2361321369Sdim/// \headerfile <x86intrin.h> 2362321369Sdim/// 2363321369Sdim/// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction. 2364321369Sdim/// 2365321369Sdim/// \param __V1 2366321369Sdim/// A 128-bit integer vector. 2367321369Sdim/// \param __V2 2368321369Sdim/// A 128-bit integer vector. 2369321369Sdim/// \returns A 128-bit integer vector containing the comparison results. 2370288943Sdimstatic __inline__ __m128i __DEFAULT_FN_ATTRS 2371205408Srdivacky_mm_cmpgt_epi64(__m128i __V1, __m128i __V2) 2372205408Srdivacky{ 2373234353Sdim return (__m128i)((__v2di)__V1 > (__v2di)__V2); 2374205408Srdivacky} 2375205408Srdivacky 2376205408Srdivacky/* SSE4.2 Accumulate CRC32. */ 2377321369Sdim/// \brief Adds the unsigned integer operand to the CRC-32C checksum of the 2378321369Sdim/// unsigned char operand. 2379321369Sdim/// 2380321369Sdim/// \headerfile <x86intrin.h> 2381321369Sdim/// 2382321369Sdim/// This intrinsic corresponds to the <c> CRC32B </c> instruction. 2383321369Sdim/// 2384321369Sdim/// \param __C 2385321369Sdim/// An unsigned integer operand to add to the CRC-32C checksum of operand 2386321369Sdim/// \a __D. 2387321369Sdim/// \param __D 2388321369Sdim/// An unsigned 8-bit integer operand used to compute the CRC-32C checksum. 2389321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of 2390321369Sdim/// operand \a __D. 2391288943Sdimstatic __inline__ unsigned int __DEFAULT_FN_ATTRS 2392205408Srdivacky_mm_crc32_u8(unsigned int __C, unsigned char __D) 2393205408Srdivacky{ 2394205408Srdivacky return __builtin_ia32_crc32qi(__C, __D); 2395205408Srdivacky} 2396205408Srdivacky 2397321369Sdim/// \brief Adds the unsigned integer operand to the CRC-32C checksum of the 2398321369Sdim/// unsigned short operand. 2399321369Sdim/// 2400321369Sdim/// \headerfile <x86intrin.h> 2401321369Sdim/// 2402321369Sdim/// This intrinsic corresponds to the <c> CRC32W </c> instruction. 2403321369Sdim/// 2404321369Sdim/// \param __C 2405321369Sdim/// An unsigned integer operand to add to the CRC-32C checksum of operand 2406321369Sdim/// \a __D. 2407321369Sdim/// \param __D 2408321369Sdim/// An unsigned 16-bit integer operand used to compute the CRC-32C checksum. 2409321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of 2410321369Sdim/// operand \a __D. 2411288943Sdimstatic __inline__ unsigned int __DEFAULT_FN_ATTRS 2412205408Srdivacky_mm_crc32_u16(unsigned int __C, unsigned short __D) 2413205408Srdivacky{ 2414205408Srdivacky return __builtin_ia32_crc32hi(__C, __D); 2415205408Srdivacky} 2416205408Srdivacky 2417321369Sdim/// \brief Adds the first unsigned integer operand to the CRC-32C checksum of 2418321369Sdim/// the second unsigned integer operand. 2419321369Sdim/// 2420321369Sdim/// \headerfile <x86intrin.h> 2421321369Sdim/// 2422321369Sdim/// This intrinsic corresponds to the <c> CRC32L </c> instruction. 2423321369Sdim/// 2424321369Sdim/// \param __C 2425321369Sdim/// An unsigned integer operand to add to the CRC-32C checksum of operand 2426321369Sdim/// \a __D. 2427321369Sdim/// \param __D 2428321369Sdim/// An unsigned 32-bit integer operand used to compute the CRC-32C checksum. 2429321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of 2430321369Sdim/// operand \a __D. 2431288943Sdimstatic __inline__ unsigned int __DEFAULT_FN_ATTRS 2432205408Srdivacky_mm_crc32_u32(unsigned int __C, unsigned int __D) 2433205408Srdivacky{ 2434205408Srdivacky return __builtin_ia32_crc32si(__C, __D); 2435205408Srdivacky} 2436205408Srdivacky 2437205408Srdivacky#ifdef __x86_64__ 2438321369Sdim/// \brief Adds the unsigned integer operand to the CRC-32C checksum of the 2439321369Sdim/// unsigned 64-bit integer operand. 2440321369Sdim/// 2441321369Sdim/// \headerfile <x86intrin.h> 2442321369Sdim/// 2443321369Sdim/// This intrinsic corresponds to the <c> CRC32Q </c> instruction. 2444321369Sdim/// 2445321369Sdim/// \param __C 2446321369Sdim/// An unsigned integer operand to add to the CRC-32C checksum of operand 2447321369Sdim/// \a __D. 2448321369Sdim/// \param __D 2449321369Sdim/// An unsigned 64-bit integer operand used to compute the CRC-32C checksum. 2450321369Sdim/// \returns The result of adding operand \a __C to the CRC-32C checksum of 2451321369Sdim/// operand \a __D. 2452288943Sdimstatic __inline__ unsigned long long __DEFAULT_FN_ATTRS 2453205408Srdivacky_mm_crc32_u64(unsigned long long __C, unsigned long long __D) 2454205408Srdivacky{ 2455205408Srdivacky return __builtin_ia32_crc32di(__C, __D); 2456205408Srdivacky} 2457205408Srdivacky#endif /* __x86_64__ */ 2458205408Srdivacky 2459288943Sdim#undef __DEFAULT_FN_ATTRS 2460288943Sdim 2461234353Sdim#ifdef __POPCNT__ 2462234353Sdim#include <popcntintrin.h> 2463234353Sdim#endif 2464205408Srdivacky 2465204793Srdivacky#endif /* _SMMINTRIN_H */ 2466