[PATCH] D39719: [X86][AVX512] lowering kunpack intrinsic - clang part

jina via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 13 01:00:28 PST 2017


jina.nahias updated this revision to Diff 122617.

https://reviews.llvm.org/D39719

Files:
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512f-builtins.c


Index: test/CodeGen/avx512f-builtins.c
===================================================================
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -6224,10 +6224,17 @@
   return _mm512_kortestz(__A, __B); 
 }
 
-__mmask16 test_mm512_kunpackb(__mmask16 __A, __mmask16 __B) {
+__mmask16 test_mm512_kunpackb(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackb
-  // CHECK: @llvm.x86.avx512.kunpck.bw
-  return _mm512_kunpackb(__A, __B); 
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: bitcast <16 x i1> %{{.*}} to i16
+  // CHECK: and i32 %{{.*}}, 255
+  // CHECK: shl i32 %{{.*}}, 8
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i16 %{{.*}} to <16 x i1>
+  return _mm512_mask_cmpneq_epu32_mask(_mm512_kunpackb(_mm512_cmpneq_epu32_mask(__A, __B),
+                                                       _mm512_cmpneq_epu32_mask(__C, __D)),
+                                                       __E, __F);
 }
 
 __mmask16 test_mm512_kxnor(__mmask16 __A, __mmask16 __B) {
Index: test/CodeGen/avx512bw-builtins.c
===================================================================
--- test/CodeGen/avx512bw-builtins.c
+++ test/CodeGen/avx512bw-builtins.c
@@ -1626,16 +1626,26 @@
   return _mm512_maskz_set1_epi8(__M, __A); 
 }
 
-__mmask64 test_mm512_kunpackd(__mmask64 __A, __mmask64 __B) {
+__mmask64 test_mm512_kunpackd(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackd
-  // CHECK: @llvm.x86.avx512.kunpck.dq
-  return _mm512_kunpackd(__A, __B); 
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: bitcast <64 x i1> %{{.*}} to i64
+  // CHECK: and i64 %{{.*}}, 4294967295
+  // CHECK: shl i64 %{{.*}}, 32
+  // CHECK: or i64 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i64 %{{.*}} to <64 x i1>
+  return _mm512_mask_cmpneq_epu8_mask(_mm512_kunpackd(_mm512_cmpneq_epu8_mask(__B, __A),_mm512_cmpneq_epu8_mask(__C, __D)), __E, __F); 
 }
 
-__mmask32 test_mm512_kunpackw(__mmask32 __A, __mmask32 __B) {
+__mmask32 test_mm512_kunpackw(__m512i __A, __m512i __B, __m512i __C, __m512i __D, __m512i __E, __m512i __F) {
   // CHECK-LABEL: @test_mm512_kunpackw
-  // CHECK: @llvm.x86.avx512.kunpck.wd
-  return _mm512_kunpackw(__A, __B); 
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: bitcast <32 x i1> %{{.*}} to i32
+  // CHECK: and i32 %{{.*}}, 65535
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: or i32 %{{.*}}, %{{.*}}
+  // CHECK: bitcast i32 %{{.*}} to <32 x i1>
+  return _mm512_mask_cmpneq_epu16_mask(_mm512_kunpackw(_mm512_cmpneq_epu16_mask(__B, __A),_mm512_cmpneq_epu16_mask(__C, __D)), __E, __F); 
 }
 
 __m512i test_mm512_mask_loadu_epi16(__m512i __W, __mmask32 __U, void const *__P) {
Index: lib/Headers/avx512fintrin.h
===================================================================
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -8823,7 +8823,7 @@
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
 _mm512_kunpackb (__mmask16 __A, __mmask16 __B)
 {
-  return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) __B);
+  return (__mmask16)  (( __A  & 0xFF) | ( __B << 8));
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
Index: lib/Headers/avx512bwintrin.h
===================================================================
--- lib/Headers/avx512bwintrin.h
+++ lib/Headers/avx512bwintrin.h
@@ -1854,15 +1854,13 @@
 static __inline__ __mmask64 __DEFAULT_FN_ATTRS
 _mm512_kunpackd (__mmask64 __A, __mmask64 __B)
 {
-  return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A,
-                (__mmask64) __B);
+  return (__mmask64)  (( __A  & 0xFFFFFFFF) | ( __B << 32));
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
 _mm512_kunpackw (__mmask32 __A, __mmask32 __B)
 {
-  return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A,
-                (__mmask32) __B);
+return (__mmask32)  (( __A  & 0xFFFF) | ( __B << 16));
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39719.122617.patch
Type: text/x-patch
Size: 4042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171113/e31b8383/attachment-0001.bin>


More information about the cfe-commits mailing list