[CLANG] [AVX512] [BUILTIN] Adding PSHUF{L|H}W{128|256|512} builtin to clang .
authorMichael Zuckerman <Michael.zuckerman@intel.com>
Wed, 24 Feb 2016 17:39:35 +0000 (17:39 +0000)
committerMichael Zuckerman <Michael.zuckerman@intel.com>
Wed, 24 Feb 2016 17:39:35 +0000 (17:39 +0000)
Differential Revision: http://reviews.llvm.org/D17539

llvm-svn: 261755

clang/include/clang/Basic/BuiltinsX86.def
clang/lib/Headers/avx512bwintrin.h
clang/lib/Headers/avx512vlbwintrin.h
clang/test/CodeGen/avx512bw-builtins.c

index 10ae054..3168858 100644 (file)
@@ -1632,6 +1632,12 @@ TARGET_BUILTIN(__builtin_ia32_prorvd128_mask, "V4iV4iV4iV4iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvd256_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvq128_mask, "V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvq256_mask, "V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshufhw512_mask, "V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pshuflw512_mask, "V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pshufhw128_mask, "V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshufhw256_mask, "V16sV16sIiV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshuflw128_mask, "V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshuflw256_mask, "V16sV16sIiV16sUs","","avx512bw,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN
index b7fa2fe..af4cdec 100644 (file)
@@ -1589,6 +1589,54 @@ _mm512_maskz_cvtepu8_epi16 (__mmask32 __U, __m256i __A)
                                           (__v32hi)(__m512i)(b), \
                                           (p), (__mmask32)(m)); })
 
+#define _mm512_shufflehi_epi16( __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi)( __A),\
+              ( __imm),\
+               (__v32hi)\
+               _mm512_setzero_hi (),\
+               (__mmask32) -1);\
+})
+
+#define _mm512_mask_shufflehi_epi16( __W, __U, __A ,__imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi) (__A),\
+               (__imm),\
+               (__v32hi)( __W),\
+               (__mmask32)( __U));\
+})
+
+
+#define _mm512_maskz_shufflehi_epi16( __U, __A ,__imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi) (__A),\
+               (__imm),\
+               (__v32hi)\
+               _mm512_setzero_hi (),\
+               (__mmask32)( __U));\
+})
+
+#define _mm512_shufflelo_epi16( __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi)( __A),\
+              ( __imm),\
+               (__v32hi)\
+               _mm512_setzero_hi (),\
+               (__mmask32) -1);\
+})
+
+
+#define _mm512_mask_shufflelo_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi) (__A),\
+               (__imm),\
+               (__v32hi)( __W),\
+               (__mmask32)( __U));\
+})
+
+
+#define _mm512_maskz_shufflelo_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi) (__A),\
+               (__imm),\
+               (__v32hi)\
+               _mm512_setzero_hi (),\
+               (__mmask32)( __U));\
+})
 
 #undef __DEFAULT_FN_ATTRS
 
index f2ee269..fe4b1d6 100644 (file)
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512vl,avx512bw")))
 
+static  __inline __m128i __DEFAULT_FN_ATTRS
+_mm_setzero_hi(void){
+    return (__m128i){ 0LL, 0LL };
+}
+
 /* Integer compare */
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
@@ -2401,6 +2406,67 @@ _mm256_maskz_cvtepu8_epi16 (__mmask16 __U, __m128i __A)
                                           (__v16hi)(__m256i)(b), \
                                           (p), (__mmask16)(m)); })
 
+#define _mm_mask_shufflehi_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw128_mask ((__v8hi) __A, (__imm),\
+               (__v8hi)( __W),\
+               (__mmask8)( __U));\
+})
+
+#define _mm_maskz_shufflehi_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw128_mask ((__v8hi)( __A),( __imm),\
+               (__v8hi)\
+               _mm_setzero_hi (),\
+               (__mmask8)( __U));\
+})
+
+
+#define _mm256_mask_shufflehi_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw256_mask ((__v16hi) (__A),\
+               (__imm),\
+               (__v16hi)( __W),\
+               (__mmask16)( __U));\
+})
+
+
+#define _mm256_maskz_shufflehi_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw256_mask ((__v16hi) (__A),\
+               (__imm),\
+               (__v16hi)\
+               _mm256_setzero_si256 (),\
+               (__mmask16)( __U));\
+})
+
+
+#define _mm_mask_shufflelo_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw128_mask ((__v8hi) __A, (__imm),\
+               (__v8hi)( __W),\
+               (__mmask8)( __U));\
+})
+
+#define _mm_maskz_shufflelo_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw128_mask ((__v8hi)( __A),( __imm),\
+               (__v8hi)\
+               _mm_setzero_hi (),\
+               (__mmask8)( __U));\
+})
+
+
+#define _mm256_mask_shufflelo_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw256_mask ((__v16hi) (__A),\
+               (__imm),\
+               (__v16hi)( __W),\
+               (__mmask16)( __U));\
+})
+
+
+#define _mm256_maskz_shufflelo_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw256_mask ((__v16hi) (__A),\
+               (__imm),\
+               (__v16hi)\
+               _mm256_setzero_si256 (),\
+               (__mmask16)( __U));\
+})
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif /* __AVX512VLBWINTRIN_H */
index 5ef2059..21984c2 100644 (file)
@@ -1076,3 +1076,41 @@ __m512i test_mm512_maskz_cvtepu8_epi16(__mmask32 __U, __m256i __A) {
   // CHECK: @llvm.x86.avx512.mask.pmovzxb.w.512
   return _mm512_maskz_cvtepu8_epi16(__U, __A); 
 }
+
+__m512i test_mm512_shufflehi_epi16(__m512i __A) {
+  // CHECK-LABEL: @test_mm512_shufflehi_epi16
+  // CHECK: @llvm.x86.avx512.mask.pshufh.w.512
+  return _mm512_shufflehi_epi16(__A, 5); 
+}
+
+__m512i test_mm512_mask_shufflehi_epi16(__m512i __W, __mmask32 __U, __m512i __A) {
+  // CHECK-LABEL: @test_mm512_mask_shufflehi_epi16
+  // CHECK: @llvm.x86.avx512.mask.pshufh.w.512
+  return _mm512_mask_shufflehi_epi16(__W, __U, __A, 5); 
+}
+
+__m512i test_mm512_maskz_shufflehi_epi16(__mmask32 __U, __m512i __A) {
+  // CHECK-LABEL: @test_mm512_maskz_shufflehi_epi16
+  // CHECK: @llvm.x86.avx512.mask.pshufh.w.512
+  return _mm512_maskz_shufflehi_epi16(__U, __A, 5); 
+}
+
+__m512i test_mm512_shufflelo_epi16(__m512i __A) {
+  // CHECK-LABEL: @test_mm512_shufflelo_epi16
+  // CHECK: @llvm.x86.avx512.mask.pshufl.w.512
+  return _mm512_shufflelo_epi16(__A, 5); 
+}
+
+__m512i test_mm512_mask_shufflelo_epi16(__m512i __W, __mmask32 __U, __m512i __A) {
+  // CHECK-LABEL: @test_mm512_mask_shufflelo_epi16
+  // CHECK: @llvm.x86.avx512.mask.pshufl.w.512
+  return _mm512_mask_shufflelo_epi16(__W, __U, __A, 5); 
+}
+
+__m512i test_mm512_maskz_shufflelo_epi16(__mmask32 __U, __m512i __A) {
+  // CHECK-LABEL: @test_mm512_maskz_shufflelo_epi16
+  // CHECK: @llvm.x86.avx512.mask.pshufl.w.512
+  return _mm512_maskz_shufflelo_epi16(__U, __A, 5); 
+}
+
+