r226496 - [AVX512] Add sub-vector FP extracts

Adam Nemet anemet at apple.com
Mon Jan 19 12:12:05 PST 2015


Author: anemet
Date: Mon Jan 19 14:12:05 2015
New Revision: 226496

URL: http://llvm.org/viewvc/llvm-project?rev=226496&view=rev
Log:
[AVX512] Add sub-vector FP extracts

Analogous to AVX2, these need to be implemented as macros to properly
propagate the immediate index operand.

Part of <rdar://problem/17688758>

Modified:
    cfe/trunk/include/clang/Basic/BuiltinsX86.def
    cfe/trunk/lib/Headers/avx512fintrin.h
    cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=226496&r1=226495&r2=226496&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Jan 19 14:12:05 2015
@@ -912,6 +912,8 @@ BUILTIN(__builtin_ia32_vpermt2varps512_m
 BUILTIN(__builtin_ia32_vpermt2varpd512_mask, "V8dV8LLiV8dV8dUc", "")
 BUILTIN(__builtin_ia32_alignq512_mask, "V8LLiV8LLiV8LLiUcV8LLiUc", "")
 BUILTIN(__builtin_ia32_alignd512_mask, "V16iV16iV16iUcV16iUc", "")
+BUILTIN(__builtin_ia32_extractf64x4_mask, "V4dV8dIcV4dUc", "")
+BUILTIN(__builtin_ia32_extractf32x4_mask, "V4fV16fIcV4fUc", "")
 BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8dvC*V8iUciC", "")
 BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*UsiC", "")
 BUILTIN(__builtin_ia32_gatherdiv8df, "V8dV8dvC*V8LLiUciC", "")

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=226496&r1=226495&r2=226496&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Jan 19 14:12:05 2015
@@ -633,6 +633,24 @@ _mm512_valign_epi32(__m512i __A, __m512i
                                                 (__mmask16) -1);
 }
 
+/* Vector Extract */
+
+#define _mm512_extractf64x4_pd(A, I) __extension__ ({                    \
+      __m512d __A = (A);                                                 \
+      (__m256d)                                                          \
+        __builtin_ia32_extractf64x4_mask((__v8df)__A,                    \
+                                         (I),                            \
+                                         (__v4df)_mm256_setzero_si256(), \
+                                         (__mmask8) -1); })
+
+#define _mm512_extractf32x4_ps(A, I) __extension__ ({                    \
+      __m512 __A = (A);                                                  \
+      (__m128)                                                           \
+        __builtin_ia32_extractf32x4_mask((__v16sf)__A,                   \
+                                         (I),                            \
+                                         (__v4sf)_mm_setzero_ps(),       \
+                                         (__mmask8) -1); })
+
 /* Vector Blend */
 
 static __inline __m512d __attribute__ ((__always_inline__, __nodebug__))

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=226496&r1=226495&r2=226496&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Jan 19 14:12:05 2015
@@ -264,3 +264,17 @@ __mmask8 test_mm512_cmp_pd_mask(__m512 _
   // CHECK: @llvm.x86.avx512.mask.cmp.pd.512
   return _mm512_cmp_pd_mask(__a, __b, 0);
 }
+
+__m256d test_mm512_extractf64x4_pd(__m512d a)
+{
+  // CHECK-LABEL: @test_mm512_extractf64x4_pd
+  // CHECK: @llvm.x86.avx512.mask.vextractf64x4.512
+  return _mm512_extractf64x4_pd(a, 1);
+}
+
+__m128 test_mm512_extractf32x4_ps(__m512 a)
+{
+  // CHECK-LABEL: @test_mm512_extractf32x4_ps
+  // CHECK: @llvm.x86.avx512.mask.vextractf32x4.512
+  return _mm512_extractf32x4_ps(a, 1);
+}





More information about the cfe-commits mailing list