From 2aaa6466fe00a1720a1c62c6d35b3d3efaf13160 Mon Sep 17 00:00:00 2001 From: "Wang, Pengfei" Date: Sat, 11 Sep 2021 17:45:30 +0800 Subject: [PATCH] [X86] Support *_set1_pch(Float16 _Complex h) Reviewed By: LuoYuanke Differential Revision: https://reviews.llvm.org/D109487 --- clang/lib/Headers/avx512fp16intrin.h | 5 +++++ clang/lib/Headers/avx512vlfp16intrin.h | 10 ++++++++++ clang/test/CodeGen/X86/avx512fp16-builtins.c | 23 +++++++++++++++++++++++ clang/test/CodeGen/X86/avx512vlfp16-builtins.c | 26 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/clang/lib/Headers/avx512fp16intrin.h b/clang/lib/Headers/avx512fp16intrin.h index 8911b4e..80f22ab 100644 --- a/clang/lib/Headers/avx512fp16intrin.h +++ b/clang/lib/Headers/avx512fp16intrin.h @@ -97,6 +97,11 @@ _mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, (h14), (h13), (h12), (h11), (h10), (h9), (h8), (h7), (h6), \ (h5), (h4), (h3), (h2), (h1)) +static __inline __m512h __DEFAULT_FN_ATTRS512 +_mm512_set1_pch(_Float16 _Complex h) { + return (__m512h)_mm512_set1_ps(__builtin_bit_cast(float, h)); +} + static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_castph_ps(__m128h __a) { return (__m128)__a; } diff --git a/clang/lib/Headers/avx512vlfp16intrin.h b/clang/lib/Headers/avx512vlfp16intrin.h index b8cd554..69f81af 100644 --- a/clang/lib/Headers/avx512vlfp16intrin.h +++ b/clang/lib/Headers/avx512vlfp16intrin.h @@ -52,6 +52,16 @@ _mm_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, } static __inline __m256h __DEFAULT_FN_ATTRS256 +_mm256_set1_pch(_Float16 _Complex h) { + return (__m256h)_mm256_set1_ps(__builtin_bit_cast(float, h)); +} + +static __inline __m128h __DEFAULT_FN_ATTRS128 +_mm_set1_pch(_Float16 _Complex h) { + return (__m128h)_mm_set1_ps(__builtin_bit_cast(float, h)); +} + +static __inline __m256h __DEFAULT_FN_ATTRS256 _mm256_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12, diff --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c b/clang/test/CodeGen/X86/avx512fp16-builtins.c index ee4bed5..7fccb21 100644 --- a/clang/test/CodeGen/X86/avx512fp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c @@ -81,6 +81,29 @@ __m512h test_mm512_set1_ph(_Float16 h) { return _mm512_set1_ph(h); } +__m512h test_mm512_set1_pch(_Float16 _Complex h) { + // CHECK-LABEL: @test_mm512_set1_pch + // CHECK: bitcast { half, half }{{.*}} to float + // CHECK: insertelement <16 x float> {{.*}}, i32 0 + // CHECK: insertelement <16 x float> {{.*}}, i32 1 + // CHECK: insertelement <16 x float> {{.*}}, i32 2 + // CHECK: insertelement <16 x float> {{.*}}, i32 3 + // CHECK: insertelement <16 x float> {{.*}}, i32 4 + // CHECK: insertelement <16 x float> {{.*}}, i32 5 + // CHECK: insertelement <16 x float> {{.*}}, i32 6 + // CHECK: insertelement <16 x float> {{.*}}, i32 7 + // CHECK: insertelement <16 x float> {{.*}}, i32 8 + // CHECK: insertelement <16 x float> {{.*}}, i32 9 + // CHECK: insertelement <16 x float> {{.*}}, i32 10 + // CHECK: insertelement <16 x float> {{.*}}, i32 11 + // CHECK: insertelement <16 x float> {{.*}}, i32 12 + // CHECK: insertelement <16 x float> {{.*}}, i32 13 + // CHECK: insertelement <16 x float> {{.*}}, i32 14 + // CHECK: insertelement <16 x float> {{.*}}, i32 15 + // CHECK: bitcast <16 x float>{{.*}} to <32 x half> + return _mm512_set1_pch(h); +} + __m512h test_mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12, diff --git a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c index 948e6ad..2864157 100644 --- a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c @@ -61,6 +61,32 @@ __m256h test_mm256_set1_ph(_Float16 h) { return _mm256_set1_ph(h); } +__m128h test_mm_set1_pch(_Float16 _Complex h) { + // CHECK-LABEL: @test_mm_set1_pch + // CHECK: bitcast { half, half }{{.*}} to float + // CHECK: insertelement <4 x float> {{.*}}, i32 0 + // CHECK: insertelement <4 x float> {{.*}}, i32 1 + // CHECK: insertelement <4 x float> {{.*}}, i32 2 + // CHECK: insertelement <4 x float> {{.*}}, i32 3 + // CHECK: bitcast <4 x float>{{.*}} to <8 x half> + return _mm_set1_pch(h); +} + +__m256h test_mm256_set1_pch(_Float16 _Complex h) { + // CHECK-LABEL: @test_mm256_set1_pch + // CHECK: bitcast { half, half }{{.*}} to float + // CHECK: insertelement <8 x float> {{.*}}, i32 0 + // CHECK: insertelement <8 x float> {{.*}}, i32 1 + // CHECK: insertelement <8 x float> {{.*}}, i32 2 + // CHECK: insertelement <8 x float> {{.*}}, i32 3 + // CHECK: insertelement <8 x float> {{.*}}, i32 4 + // CHECK: insertelement <8 x float> {{.*}}, i32 5 + // CHECK: insertelement <8 x float> {{.*}}, i32 6 + // CHECK: insertelement <8 x float> {{.*}}, i32 7 + // CHECK: bitcast <8 x float>{{.*}} to <16 x half> + return _mm256_set1_pch(h); +} + __m128h test_mm_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8) { // CHECK-LABEL: @test_mm_set_ph -- 2.7.4