From: Adam Nemet Date: Wed, 30 Jul 2014 16:51:24 +0000 (+0000) Subject: [AVX512] Add some of the FP cast intrinsics X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3576987dc54b355506ecddd77615855b2c0dc1ff;p=clang [AVX512] Add some of the FP cast intrinsics Part of git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214315 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/avx512fintrin.h b/lib/Headers/avx512fintrin.h index a336f6d746..2d3a8bba45 100644 --- a/lib/Headers/avx512fintrin.h +++ b/lib/Headers/avx512fintrin.h @@ -117,6 +117,33 @@ _mm512_set1_epi64(long long __d) return (__m512i)(__v8di){ __d, __d, __d, __d, __d, __d, __d, __d }; } +/* Cast between vector types */ + +static __inline __m512d __attribute__((__always_inline__, __nodebug__)) +_mm512_castpd256_pd512(__m256d __a) +{ + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, -1, -1, -1, -1); +} + +static __inline __m512 __attribute__((__always_inline__, __nodebug__)) +_mm512_castps256_ps512(__m256 __a) +{ + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, + -1, -1, -1, -1, -1, -1, -1, -1); +} + +static __inline __m128d __attribute__((__always_inline__, __nodebug__)) +_mm512_castpd512_pd128(__m512d __a) +{ + return __builtin_shufflevector(__a, __a, 0, 1); +} + +static __inline __m128 __attribute__((__always_inline__, __nodebug__)) +_mm512_castps512_ps128(__m512 __a) +{ + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3); +} + /* Arithmetic */ static __inline __m512d __attribute__((__always_inline__, __nodebug__)) diff --git a/test/CodeGen/avx512f-builtins.c b/test/CodeGen/avx512f-builtins.c index ddeb3b6365..8a2dd07230 100644 --- a/test/CodeGen/avx512f-builtins.c +++ b/test/CodeGen/avx512f-builtins.c @@ -102,3 +102,10 @@ __m512d test_mm512_set1_pd(double d) // CHECK: insertelement <8 x double> {{.*}}, i32 7 return _mm512_set1_pd(d); } + +__m512d test_mm512_castpd256_pd512(__m256d a) +{ + // CHECK-LABEL: @test_mm512_castpd256_pd512 + // CHECK: shufflevector <4 x double> {{.*}} + return _mm512_castpd256_pd512(a); +}