#endif
+/* Constant helper to represent the ternary logic operations among
+ vector A, B and C. */
+typedef enum
+{
+ _MM_TERNLOG_A = 0xF0,
+ _MM_TERNLOG_B = 0xCC,
+ _MM_TERNLOG_C = 0xAA
+} _MM_TERNLOG_ENUM;
+
#ifdef __OPTIMIZE__
extern __inline __m512i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm512_ternarylogic_epi64 (__m512i __A, __m512i __B, __m512i __C,
const int __imm)
{
- return (__m512i) __builtin_ia32_pternlogq512_mask ((__v8di) __A,
- (__v8di) __B,
- (__v8di) __C, __imm,
- (__mmask8) -1);
+ return (__m512i)
+ __builtin_ia32_pternlogq512_mask ((__v8di) __A,
+ (__v8di) __B,
+ (__v8di) __C,
+ (unsigned char) __imm,
+ (__mmask8) -1);
}
extern __inline __m512i
_mm512_mask_ternarylogic_epi64 (__m512i __A, __mmask8 __U, __m512i __B,
__m512i __C, const int __imm)
{
- return (__m512i) __builtin_ia32_pternlogq512_mask ((__v8di) __A,
- (__v8di) __B,
- (__v8di) __C, __imm,
- (__mmask8) __U);
+ return (__m512i)
+ __builtin_ia32_pternlogq512_mask ((__v8di) __A,
+ (__v8di) __B,
+ (__v8di) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m512i
_mm512_maskz_ternarylogic_epi64 (__mmask8 __U, __m512i __A, __m512i __B,
__m512i __C, const int __imm)
{
- return (__m512i) __builtin_ia32_pternlogq512_maskz ((__v8di) __A,
- (__v8di) __B,
- (__v8di) __C,
- __imm, (__mmask8) __U);
+ return (__m512i)
+ __builtin_ia32_pternlogq512_maskz ((__v8di) __A,
+ (__v8di) __B,
+ (__v8di) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m512i
_mm512_ternarylogic_epi32 (__m512i __A, __m512i __B, __m512i __C,
const int __imm)
{
- return (__m512i) __builtin_ia32_pternlogd512_mask ((__v16si) __A,
- (__v16si) __B,
- (__v16si) __C,
- __imm, (__mmask16) -1);
+ return (__m512i)
+ __builtin_ia32_pternlogd512_mask ((__v16si) __A,
+ (__v16si) __B,
+ (__v16si) __C,
+ (unsigned char) __imm,
+ (__mmask16) -1);
}
extern __inline __m512i
_mm512_mask_ternarylogic_epi32 (__m512i __A, __mmask16 __U, __m512i __B,
__m512i __C, const int __imm)
{
- return (__m512i) __builtin_ia32_pternlogd512_mask ((__v16si) __A,
- (__v16si) __B,
- (__v16si) __C,
- __imm, (__mmask16) __U);
+ return (__m512i)
+ __builtin_ia32_pternlogd512_mask ((__v16si) __A,
+ (__v16si) __B,
+ (__v16si) __C,
+ (unsigned char) __imm,
+ (__mmask16) __U);
}
extern __inline __m512i
_mm512_maskz_ternarylogic_epi32 (__mmask16 __U, __m512i __A, __m512i __B,
__m512i __C, const int __imm)
{
- return (__m512i) __builtin_ia32_pternlogd512_maskz ((__v16si) __A,
- (__v16si) __B,
- (__v16si) __C,
- __imm, (__mmask16) __U);
+ return (__m512i)
+ __builtin_ia32_pternlogd512_maskz ((__v16si) __A,
+ (__v16si) __B,
+ (__v16si) __C,
+ (unsigned char) __imm,
+ (__mmask16) __U);
}
#else
-#define _mm512_ternarylogic_epi64(A, B, C, I) \
- ((__m512i) __builtin_ia32_pternlogq512_mask ((__v8di)(__m512i)(A), \
- (__v8di)(__m512i)(B), (__v8di)(__m512i)(C), (int)(I), (__mmask8)-1))
-#define _mm512_mask_ternarylogic_epi64(A, U, B, C, I) \
- ((__m512i) __builtin_ia32_pternlogq512_mask ((__v8di)(__m512i)(A), \
- (__v8di)(__m512i)(B), (__v8di)(__m512i)(C), (int)(I), (__mmask8)(U)))
-#define _mm512_maskz_ternarylogic_epi64(U, A, B, C, I) \
- ((__m512i) __builtin_ia32_pternlogq512_maskz ((__v8di)(__m512i)(A), \
- (__v8di)(__m512i)(B), (__v8di)(__m512i)(C), (int)(I), (__mmask8)(U)))
-#define _mm512_ternarylogic_epi32(A, B, C, I) \
- ((__m512i) __builtin_ia32_pternlogd512_mask ((__v16si)(__m512i)(A), \
- (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), (int)(I), \
- (__mmask16)-1))
-#define _mm512_mask_ternarylogic_epi32(A, U, B, C, I) \
- ((__m512i) __builtin_ia32_pternlogd512_mask ((__v16si)(__m512i)(A), \
- (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), (int)(I), \
- (__mmask16)(U)))
-#define _mm512_maskz_ternarylogic_epi32(U, A, B, C, I) \
- ((__m512i) __builtin_ia32_pternlogd512_maskz ((__v16si)(__m512i)(A), \
- (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), (int)(I), \
- (__mmask16)(U)))
+#define _mm512_ternarylogic_epi64(A, B, C, I) \
+ ((__m512i) \
+ __builtin_ia32_pternlogq512_mask ((__v8di) (__m512i) (A), \
+ (__v8di) (__m512i) (B), \
+ (__v8di) (__m512i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) -1))
+#define _mm512_mask_ternarylogic_epi64(A, U, B, C, I) \
+ ((__m512i) \
+ __builtin_ia32_pternlogq512_mask ((__v8di) (__m512i) (A), \
+ (__v8di) (__m512i) (B), \
+ (__v8di) (__m512i) (C), \
+ (unsigned char)(I), \
+ (__mmask8) (U)))
+#define _mm512_maskz_ternarylogic_epi64(U, A, B, C, I) \
+ ((__m512i) \
+ __builtin_ia32_pternlogq512_maskz ((__v8di) (__m512i) (A), \
+ (__v8di) (__m512i) (B), \
+ (__v8di) (__m512i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+#define _mm512_ternarylogic_epi32(A, B, C, I) \
+ ((__m512i) \
+ __builtin_ia32_pternlogd512_mask ((__v16si) (__m512i) (A), \
+ (__v16si) (__m512i) (B), \
+ (__v16si) (__m512i) (C), \
+ (unsigned char) (I), \
+ (__mmask16) -1))
+#define _mm512_mask_ternarylogic_epi32(A, U, B, C, I) \
+ ((__m512i) \
+ __builtin_ia32_pternlogd512_mask ((__v16si) (__m512i) (A), \
+ (__v16si) (__m512i) (B), \
+ (__v16si) (__m512i) (C), \
+ (unsigned char) (I), \
+ (__mmask16) (U)))
+#define _mm512_maskz_ternarylogic_epi32(U, A, B, C, I) \
+ ((__m512i) \
+ __builtin_ia32_pternlogd512_maskz ((__v16si) (__m512i) (A), \
+ (__v16si) (__m512i) (B), \
+ (__v16si) (__m512i) (C), \
+ (unsigned char) (I), \
+ (__mmask16) (U)))
#endif
extern __inline __m512d
_mm256_ternarylogic_epi64 (__m256i __A, __m256i __B, __m256i __C,
const int __imm)
{
- return (__m256i) __builtin_ia32_pternlogq256_mask ((__v4di) __A,
- (__v4di) __B,
- (__v4di) __C, __imm,
- (__mmask8) -1);
+ return (__m256i)
+ __builtin_ia32_pternlogq256_mask ((__v4di) __A,
+ (__v4di) __B,
+ (__v4di) __C,
+ (unsigned char) __imm,
+ (__mmask8) -1);
}
extern __inline __m256i
__m256i __B, __m256i __C,
const int __imm)
{
- return (__m256i) __builtin_ia32_pternlogq256_mask ((__v4di) __A,
- (__v4di) __B,
- (__v4di) __C, __imm,
- (__mmask8) __U);
+ return (__m256i)
+ __builtin_ia32_pternlogq256_mask ((__v4di) __A,
+ (__v4di) __B,
+ (__v4di) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m256i
__m256i __B, __m256i __C,
const int __imm)
{
- return (__m256i) __builtin_ia32_pternlogq256_maskz ((__v4di) __A,
- (__v4di) __B,
- (__v4di) __C,
- __imm,
- (__mmask8) __U);
+ return (__m256i)
+ __builtin_ia32_pternlogq256_maskz ((__v4di) __A,
+ (__v4di) __B,
+ (__v4di) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m256i
_mm256_ternarylogic_epi32 (__m256i __A, __m256i __B, __m256i __C,
const int __imm)
{
- return (__m256i) __builtin_ia32_pternlogd256_mask ((__v8si) __A,
- (__v8si) __B,
- (__v8si) __C, __imm,
- (__mmask8) -1);
+ return (__m256i)
+ __builtin_ia32_pternlogd256_mask ((__v8si) __A,
+ (__v8si) __B,
+ (__v8si) __C,
+ (unsigned char) __imm,
+ (__mmask8) -1);
}
extern __inline __m256i
__m256i __B, __m256i __C,
const int __imm)
{
- return (__m256i) __builtin_ia32_pternlogd256_mask ((__v8si) __A,
- (__v8si) __B,
- (__v8si) __C, __imm,
- (__mmask8) __U);
+ return (__m256i)
+ __builtin_ia32_pternlogd256_mask ((__v8si) __A,
+ (__v8si) __B,
+ (__v8si) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m256i
__m256i __B, __m256i __C,
const int __imm)
{
- return (__m256i) __builtin_ia32_pternlogd256_maskz ((__v8si) __A,
- (__v8si) __B,
- (__v8si) __C,
- __imm,
- (__mmask8) __U);
+ return (__m256i)
+ __builtin_ia32_pternlogd256_maskz ((__v8si) __A,
+ (__v8si) __B,
+ (__v8si) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m128i
_mm_ternarylogic_epi64 (__m128i __A, __m128i __B, __m128i __C,
const int __imm)
{
- return (__m128i) __builtin_ia32_pternlogq128_mask ((__v2di) __A,
- (__v2di) __B,
- (__v2di) __C, __imm,
- (__mmask8) -1);
+ return (__m128i)
+ __builtin_ia32_pternlogq128_mask ((__v2di) __A,
+ (__v2di) __B,
+ (__v2di) __C,
+ (unsigned char) __imm,
+ (__mmask8) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_ternarylogic_epi64 (__m128i __A, __mmask8 __U,
- __m128i __B, __m128i __C, const int __imm)
+ __m128i __B, __m128i __C,
+ const int __imm)
{
- return (__m128i) __builtin_ia32_pternlogq128_mask ((__v2di) __A,
- (__v2di) __B,
- (__v2di) __C, __imm,
- (__mmask8) __U);
+ return (__m128i)
+ __builtin_ia32_pternlogq128_mask ((__v2di) __A,
+ (__v2di) __B,
+ (__v2di) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_ternarylogic_epi64 (__mmask8 __U, __m128i __A,
- __m128i __B, __m128i __C, const int __imm)
+ __m128i __B, __m128i __C,
+ const int __imm)
{
- return (__m128i) __builtin_ia32_pternlogq128_maskz ((__v2di) __A,
- (__v2di) __B,
- (__v2di) __C,
- __imm,
- (__mmask8) __U);
+ return (__m128i)
+ __builtin_ia32_pternlogq128_maskz ((__v2di) __A,
+ (__v2di) __B,
+ (__v2di) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m128i
_mm_ternarylogic_epi32 (__m128i __A, __m128i __B, __m128i __C,
const int __imm)
{
- return (__m128i) __builtin_ia32_pternlogd128_mask ((__v4si) __A,
- (__v4si) __B,
- (__v4si) __C, __imm,
- (__mmask8) -1);
+ return (__m128i)
+ __builtin_ia32_pternlogd128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si) __C,
+ (unsigned char) __imm,
+ (__mmask8) -1);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_mask_ternarylogic_epi32 (__m128i __A, __mmask8 __U,
- __m128i __B, __m128i __C, const int __imm)
+ __m128i __B, __m128i __C,
+ const int __imm)
{
- return (__m128i) __builtin_ia32_pternlogd128_mask ((__v4si) __A,
- (__v4si) __B,
- (__v4si) __C, __imm,
- (__mmask8) __U);
+ return (__m128i)
+ __builtin_ia32_pternlogd128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
_mm_maskz_ternarylogic_epi32 (__mmask8 __U, __m128i __A,
- __m128i __B, __m128i __C, const int __imm)
+ __m128i __B, __m128i __C,
+ const int __imm)
{
- return (__m128i) __builtin_ia32_pternlogd128_maskz ((__v4si) __A,
- (__v4si) __B,
- (__v4si) __C,
- __imm,
- (__mmask8) __U);
+ return (__m128i)
+ __builtin_ia32_pternlogd128_maskz ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si) __C,
+ (unsigned char) __imm,
+ (__mmask8) __U);
}
extern __inline __m256
(__v2di)(__m128i)_mm_setzero_si128 (),\
(__mmask8)(U)))
-#define _mm256_ternarylogic_epi64(A, B, C, I) \
- ((__m256i) __builtin_ia32_pternlogq256_mask ((__v4di)(__m256i)(A), \
- (__v4di)(__m256i)(B), (__v4di)(__m256i)(C), (int)(I), (__mmask8)-1))
-
-#define _mm256_mask_ternarylogic_epi64(A, U, B, C, I) \
- ((__m256i) __builtin_ia32_pternlogq256_mask ((__v4di)(__m256i)(A), \
- (__v4di)(__m256i)(B), (__v4di)(__m256i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm256_maskz_ternarylogic_epi64(U, A, B, C, I) \
- ((__m256i) __builtin_ia32_pternlogq256_maskz ((__v4di)(__m256i)(A), \
- (__v4di)(__m256i)(B), (__v4di)(__m256i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm256_ternarylogic_epi32(A, B, C, I) \
- ((__m256i) __builtin_ia32_pternlogd256_mask ((__v8si)(__m256i)(A), \
- (__v8si)(__m256i)(B), (__v8si)(__m256i)(C), (int)(I), (__mmask8)-1))
-
-#define _mm256_mask_ternarylogic_epi32(A, U, B, C, I) \
- ((__m256i) __builtin_ia32_pternlogd256_mask ((__v8si)(__m256i)(A), \
- (__v8si)(__m256i)(B), (__v8si)(__m256i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm256_maskz_ternarylogic_epi32(U, A, B, C, I) \
- ((__m256i) __builtin_ia32_pternlogd256_maskz ((__v8si)(__m256i)(A), \
- (__v8si)(__m256i)(B), (__v8si)(__m256i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm_ternarylogic_epi64(A, B, C, I) \
- ((__m128i) __builtin_ia32_pternlogq128_mask ((__v2di)(__m128i)(A), \
- (__v2di)(__m128i)(B), (__v2di)(__m128i)(C), (int)(I), (__mmask8)-1))
-
-#define _mm_mask_ternarylogic_epi64(A, U, B, C, I) \
- ((__m128i) __builtin_ia32_pternlogq128_mask ((__v2di)(__m128i)(A), \
- (__v2di)(__m128i)(B), (__v2di)(__m128i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm_maskz_ternarylogic_epi64(U, A, B, C, I) \
- ((__m128i) __builtin_ia32_pternlogq128_maskz ((__v2di)(__m128i)(A), \
- (__v2di)(__m128i)(B), (__v2di)(__m128i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm_ternarylogic_epi32(A, B, C, I) \
- ((__m128i) __builtin_ia32_pternlogd128_mask ((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), (__v4si)(__m128i)(C), (int)(I), (__mmask8)-1))
-
-#define _mm_mask_ternarylogic_epi32(A, U, B, C, I) \
- ((__m128i) __builtin_ia32_pternlogd128_mask ((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), (__v4si)(__m128i)(C), (int)(I), (__mmask8)(U)))
-
-#define _mm_maskz_ternarylogic_epi32(U, A, B, C, I) \
- ((__m128i) __builtin_ia32_pternlogd128_maskz ((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), (__v4si)(__m128i)(C), (int)(I), (__mmask8)(U)))
+#define _mm256_ternarylogic_epi64(A, B, C, I) \
+ ((__m256i) \
+ __builtin_ia32_pternlogq256_mask ((__v4di) (__m256i) (A), \
+ (__v4di) (__m256i) (B), \
+ (__v4di) (__m256i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) -1))
+
+#define _mm256_mask_ternarylogic_epi64(A, U, B, C, I) \
+ ((__m256i) \
+ __builtin_ia32_pternlogq256_mask ((__v4di) (__m256i) (A), \
+ (__v4di) (__m256i) (B), \
+ (__v4di) (__m256i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm256_maskz_ternarylogic_epi64(U, A, B, C, I) \
+ ((__m256i) \
+ __builtin_ia32_pternlogq256_maskz ((__v4di) (__m256i) (A), \
+ (__v4di) (__m256i) (B), \
+ (__v4di) (__m256i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm256_ternarylogic_epi32(A, B, C, I) \
+ ((__m256i) \
+ __builtin_ia32_pternlogd256_mask ((__v8si) (__m256i) (A), \
+ (__v8si) (__m256i) (B), \
+ (__v8si) (__m256i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) -1))
+
+#define _mm256_mask_ternarylogic_epi32(A, U, B, C, I) \
+ ((__m256i) \
+ __builtin_ia32_pternlogd256_mask ((__v8si) (__m256i) (A), \
+ (__v8si) (__m256i) (B), \
+ (__v8si) (__m256i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm256_maskz_ternarylogic_epi32(U, A, B, C, I) \
+ ((__m256i) \
+ __builtin_ia32_pternlogd256_maskz ((__v8si) (__m256i) (A), \
+ (__v8si) (__m256i) (B), \
+ (__v8si) (__m256i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm_ternarylogic_epi64(A, B, C, I) \
+ ((__m128i) \
+ __builtin_ia32_pternlogq128_mask ((__v2di) (__m128i) (A), \
+ (__v2di) (__m128i) (B), \
+ (__v2di) (__m128i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) -1))
+
+#define _mm_mask_ternarylogic_epi64(A, U, B, C, I) \
+ ((__m128i) \
+ __builtin_ia32_pternlogq128_mask ((__v2di) (__m128i) (A), \
+ (__v2di) (__m128i) (B), \
+ (__v2di) (__m128i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm_maskz_ternarylogic_epi64(U, A, B, C, I) \
+ ((__m128i) \
+ __builtin_ia32_pternlogq128_maskz ((__v2di) (__m128i) (A), \
+ (__v2di) (__m128i) (B), \
+ (__v2di) (__m128i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm_ternarylogic_epi32(A, B, C, I) \
+ ((__m128i) \
+ __builtin_ia32_pternlogd128_mask ((__v4si) (__m128i) (A), \
+ (__v4si) (__m128i) (B), \
+ (__v4si) (__m128i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) -1))
+
+#define _mm_mask_ternarylogic_epi32(A, U, B, C, I) \
+ ((__m128i) \
+ __builtin_ia32_pternlogd128_mask ((__v4si) (__m128i) (A), \
+ (__v4si) (__m128i) (B), \
+ (__v4si) (__m128i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
+
+#define _mm_maskz_ternarylogic_epi32(U, A, B, C, I) \
+ ((__m128i) \
+ __builtin_ia32_pternlogd128_maskz ((__v4si) (__m128i) (A), \
+ (__v4si) (__m128i) (B), \
+ (__v4si) (__m128i) (C), \
+ (unsigned char) (I), \
+ (__mmask8) (U)))
#define _mm256_roundscale_ps(A, B) \
((__m256) __builtin_ia32_rndscaleps_256_mask ((__v8sf)(__m256)(A), \