AVX512F: Add helper enumeration for ternary logic intrinsics.
authorHongyu Wang <hongyu.wang@intel.com>
Fri, 25 Feb 2022 07:09:03 +0000 (15:09 +0800)
committerHongyu Wang <hongyu.wang@intel.com>
Mon, 28 Feb 2022 01:37:25 +0000 (09:37 +0800)
Sync with llvm change in https://reviews.llvm.org/D120307 to
add enumeration and truncate imm to unsigned char, so users could
use ~ on immediates.

gcc/ChangeLog:

* config/i386/avx512fintrin.h (_MM_TERNLOG_ENUM): New enum.
(_mm512_ternarylogic_epi64): Truncate imm to unsigned
char to avoid error when using ~enum as parameter.
(_mm512_mask_ternarylogic_epi64): Likewise.
(_mm512_maskz_ternarylogic_epi64): Likewise.
(_mm512_ternarylogic_epi32): Likewise.
(_mm512_mask_ternarylogic_epi32): Likewise.
(_mm512_maskz_ternarylogic_epi32): Likewise.
* config/i386/avx512vlintrin.h (_mm256_ternarylogic_epi64):
Adjust imm param type to unsigned char.
(_mm256_mask_ternarylogic_epi64): Likewise.
(_mm256_maskz_ternarylogic_epi64): Likewise.
(_mm256_ternarylogic_epi32): Likewise.
(_mm256_mask_ternarylogic_epi32): Likewise.
(_mm256_maskz_ternarylogic_epi32): Likewise.
(_mm_ternarylogic_epi64): Likewise.
(_mm_mask_ternarylogic_epi64): Likewise.
(_mm_maskz_ternarylogic_epi64): Likewise.
(_mm_ternarylogic_epi32): Likewise.
(_mm_mask_ternarylogic_epi32): Likewise.
(_mm_maskz_ternarylogic_epi32): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512f-vpternlogd-1.c: Use new enum.
* gcc.target/i386/avx512f-vpternlogq-1.c: Likewise.
* gcc.target/i386/avx512vl-vpternlogd-1.c: Likewise.
* gcc.target/i386/avx512vl-vpternlogq-1.c: Likewise.
* gcc.target/i386/testimm-10.c: Remove imm check for vpternlog
insns since the imm has been truncated in intrinsic.

gcc/config/i386/avx512fintrin.h
gcc/config/i386/avx512vlintrin.h
gcc/testsuite/gcc.target/i386/avx512f-vpternlogd-1.c
gcc/testsuite/gcc.target/i386/avx512f-vpternlogq-1.c
gcc/testsuite/gcc.target/i386/avx512vl-vpternlogd-1.c
gcc/testsuite/gcc.target/i386/avx512vl-vpternlogq-1.c
gcc/testsuite/gcc.target/i386/testimm-10.c

index bc10c82..29511fd 100644 (file)
@@ -1639,16 +1639,27 @@ _mm_maskz_sub_round_ss (__mmask8 __U, __m128 __A, __m128 __B,
 
 #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
@@ -1656,10 +1667,12 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -1667,10 +1680,12 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -1678,10 +1693,12 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -1689,10 +1706,12 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -1700,33 +1719,56 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
index bbced24..26b286e 100644 (file)
@@ -10575,10 +10575,12 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -10587,10 +10589,12 @@ _mm256_mask_ternarylogic_epi64 (__m256i __A, __mmask8 __U,
                                __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
@@ -10599,11 +10603,12 @@ _mm256_maskz_ternarylogic_epi64 (__mmask8 __U, __m256i __A,
                                 __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
@@ -10611,10 +10616,12 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -10623,10 +10630,12 @@ _mm256_mask_ternarylogic_epi32 (__m256i __A, __mmask8 __U,
                                __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
@@ -10635,11 +10644,12 @@ _mm256_maskz_ternarylogic_epi32 (__mmask8 __U, __m256i __A,
                                 __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
@@ -10647,33 +10657,40 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -10681,33 +10698,40 @@ __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _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
@@ -12910,53 +12934,101 @@ _mm256_permutex_pd (__m256d __X, const int __M)
     (__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),    \
index b14af23..a88153a 100644 (file)
@@ -12,7 +12,8 @@ volatile __mmask16 m;
 void extern
 avx512f_test (void)
 {
-  x = _mm512_ternarylogic_epi32 (x, y, z, 0xF0);
-  x = _mm512_mask_ternarylogic_epi32 (x, m, y, z, 0xF0);
-  x = _mm512_maskz_ternarylogic_epi32 (m, x, y, z, 0xF0);
+  x = _mm512_ternarylogic_epi32 (x, y, z, _MM_TERNLOG_A);
+  x = _mm512_mask_ternarylogic_epi32 (x, m, y, z, _MM_TERNLOG_B);
+  x = _mm512_maskz_ternarylogic_epi32 (m, x, y, z,
+                                      _MM_TERNLOG_A | _MM_TERNLOG_C);
 }
index e7aa7a7..ef30246 100644 (file)
@@ -12,7 +12,8 @@ volatile __mmask8 m;
 void extern
 avx512f_test (void)
 {
-  x = _mm512_ternarylogic_epi64 (x, y, z, 0xF0);
-  x = _mm512_mask_ternarylogic_epi64 (x, m, y, z, 0xF0);
-  x = _mm512_maskz_ternarylogic_epi64 (m, x, y, z, 0xF0);
+  x = _mm512_ternarylogic_epi64 (x, y, z, _MM_TERNLOG_A);
+  x = _mm512_mask_ternarylogic_epi64 (x, m, y, z, _MM_TERNLOG_B);
+  x = _mm512_maskz_ternarylogic_epi64 (m, x, y, z,
+                                      _MM_TERNLOG_A | _MM_TERNLOG_C);
 }
index 590e1ef..045a266 100644 (file)
@@ -16,11 +16,12 @@ volatile __mmask8 m;
 void extern
 avx512vl_test (void)
 {
-  y = _mm256_ternarylogic_epi32 (y, y2, y3, 0xF0);
-  y = _mm256_mask_ternarylogic_epi32 (y, m, y2, y3, 0xF0);
-  y = _mm256_maskz_ternarylogic_epi32 (m, y, y2, y3, 0xF0);
+  y = _mm256_ternarylogic_epi32 (y, y2, y3, _MM_TERNLOG_A);
+  y = _mm256_mask_ternarylogic_epi32 (y, m, y2, y3, _MM_TERNLOG_B);
+  y = _mm256_maskz_ternarylogic_epi32 (m, y, y2, y3, _MM_TERNLOG_C);
 
-  x = _mm_ternarylogic_epi32 (x, x2, x3, 0xF0);
-  x = _mm_mask_ternarylogic_epi32 (x, m, x2, x3, 0xF0);
-  x = _mm_maskz_ternarylogic_epi32 (m, x, x2, x3, 0xF0);
+  x = _mm_ternarylogic_epi32 (x, x2, x3, _MM_TERNLOG_A);
+  x = _mm_mask_ternarylogic_epi32 (x, m, x2, x3, ~_MM_TERNLOG_B);
+  x = _mm_maskz_ternarylogic_epi32 (m, x, x2, x3,
+                                   _MM_TERNLOG_A | _MM_TERNLOG_C);
 }
index 3e08a71..3a6707c 100644 (file)
@@ -16,11 +16,13 @@ volatile __mmask8 m;
 void extern
 avx512vl_test (void)
 {
-  y = _mm256_ternarylogic_epi64 (y, y2, y3, 0xF0);
-  y = _mm256_mask_ternarylogic_epi64 (y, m, y2, y3, 0xF0);
-  y = _mm256_maskz_ternarylogic_epi64 (m, y, y2, y3, 0xF0);
+  y = _mm256_ternarylogic_epi64 (y, y2, y3, _MM_TERNLOG_A);
+  y = _mm256_mask_ternarylogic_epi64 (y, m, y2, y3, ~_MM_TERNLOG_B);
+  y = _mm256_maskz_ternarylogic_epi64 (m, y, y2, y3,
+                                      _MM_TERNLOG_A | _MM_TERNLOG_C);
 
-  x = _mm_ternarylogic_epi64 (x, x2, x3, 0xF0);
-  x = _mm_mask_ternarylogic_epi64 (x, m, x2, x3, 0xF0);
-  x = _mm_maskz_ternarylogic_epi64 (m, x, x2, x3, 0xF0);
+  x = _mm_ternarylogic_epi64 (x, x2, x3, _MM_TERNLOG_A);
+  x = _mm_mask_ternarylogic_epi64 (x, m, x2, x3, ~_MM_TERNLOG_B);
+  x = _mm_maskz_ternarylogic_epi64 (m, x, x2, x3,
+                                   _MM_TERNLOG_A | _MM_TERNLOG_C);
 }
index d0e9b42..426295a 100644 (file)
@@ -22,13 +22,6 @@ test8bit (void)
   m512i = _mm512_mask_permutex_epi64 (m512i, mmask8, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
   m512i = _mm512_maskz_permutex_epi64 (mmask8, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
 
-  m512i = _mm512_ternarylogic_epi64 (m512i, m512i, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
-  m512i = _mm512_mask_ternarylogic_epi64 (m512i, mmask8, m512i, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
-  m512i = _mm512_maskz_ternarylogic_epi64 (mmask8, m512i, m512i, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
-  m512i = _mm512_ternarylogic_epi32 (m512i, m512i, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
-  m512i = _mm512_mask_ternarylogic_epi32 (m512i, mmask16, m512i, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
-  m512i = _mm512_maskz_ternarylogic_epi32 (mmask16, m512i, m512i, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
-
   m512i = _mm512_shuffle_epi32 (m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
   m512i = _mm512_mask_shuffle_epi32 (m512i, mmask16, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
   m512i = _mm512_maskz_shuffle_epi32 (mmask16, m512i, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */