https://github.com/bojle created https://github.com/llvm/llvm-project/pull/159929
Fixes https://github.com/llvm/llvm-project/issues/156866 >From 6eb518498bbc03232385b99f422324c09965b183 Mon Sep 17 00:00:00 2001 From: Shreeyash Pandey <[email protected]> Date: Fri, 12 Sep 2025 19:59:34 +0530 Subject: [PATCH 1/2] [AVX-512] make AVX512fp16 constexpr and add tests Signed-off-by: Shreeyash Pandey <[email protected]> --- clang/lib/Headers/avx512vlfp16intrin.h | 4 ++-- clang/test/CodeGen/X86/avx512vlfp16-builtins.c | 1 + clang/test/CodeGen/X86/builtin_test_helpers.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Headers/avx512vlfp16intrin.h b/clang/lib/Headers/avx512vlfp16intrin.h index 8eb31eae6173b..0b68637bdd507 100644 --- a/clang/lib/Headers/avx512vlfp16intrin.h +++ b/clang/lib/Headers/avx512vlfp16intrin.h @@ -42,7 +42,7 @@ static __inline__ _Float16 __DEFAULT_FN_ATTRS256 _mm256_cvtsh_h(__m256h __a) { return __a[0]; } -static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_set_sh(_Float16 __h) { +static __inline__ __m128h __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_set_sh(_Float16 __h) { return __extension__(__m128h){__h, 0, 0, 0, 0, 0, 0, 0}; } @@ -57,7 +57,7 @@ _mm256_set1_ph(_Float16 __h) { __h, __h, __h, __h, __h, __h, __h, __h}; } -static __inline __m128h __DEFAULT_FN_ATTRS128 +static __inline __m128h __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8) { return (__m128h)(__v8hf){__h8, __h7, __h6, __h5, __h4, __h3, __h2, __h1}; diff --git a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c index fd6ea8fe6056d..14125886ff814 100644 --- a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c @@ -110,6 +110,7 @@ __m128h test_mm_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h // CHECK: insertelement <8 x half> {{.*}}, i32 7 return _mm_set_ph(__h1, __h2, __h3, __h4, __h5, __h6, __h7, __h8); } +TEST_CONSTEXPR(match_m128h(_mm_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0), 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0)); __m256h test_mm256_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, diff --git a/clang/test/CodeGen/X86/builtin_test_helpers.h b/clang/test/CodeGen/X86/builtin_test_helpers.h index fcaf360626a2d..44c2dc7ba808b 100644 --- a/clang/test/CodeGen/X86/builtin_test_helpers.h +++ b/clang/test/CodeGen/X86/builtin_test_helpers.h @@ -4,6 +4,7 @@ #if defined(__cplusplus) && (__cplusplus >= 201103L) + constexpr bool match_m64(__m64 _v, unsigned long long a) { __v1du v = (__v1du)_v; return v[0] == a; >From b52baea59848c054e400cb40860642581019ee62 Mon Sep 17 00:00:00 2001 From: Shreeyash Pandey <[email protected]> Date: Fri, 12 Sep 2025 20:13:25 +0530 Subject: [PATCH 2/2] [AVX-512] add set_ph Signed-off-by: Shreeyash Pandey <[email protected]> --- clang/test/CodeGen/X86/avx512vlfp16-builtins.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c index 14125886ff814..0ed176984bcdc 100644 --- a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c @@ -37,6 +37,8 @@ __m128h test_mm_set_sh(_Float16 __h) { return _mm_set_sh(__h); } +TEST_CONSTEXPR(match_m128h(_mm_set_sh(2.0), 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); + __m128h test_mm_set1_ph(_Float16 h) { // CHECK-LABEL: test_mm_set1_ph // CHECK: insertelement <8 x half> {{.*}}, i32 0 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
