https://github.com/bojle updated https://github.com/llvm/llvm-project/pull/159929
>From 6eb518498bbc03232385b99f422324c09965b183 Mon Sep 17 00:00:00 2001 From: Shreeyash Pandey <shreeyash...@gmail.com> Date: Fri, 12 Sep 2025 19:59:34 +0530 Subject: [PATCH 1/5] [AVX-512] make AVX512fp16 constexpr and add tests Signed-off-by: Shreeyash Pandey <shreeyash...@gmail.com> --- 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 <shreeyash...@gmail.com> Date: Fri, 12 Sep 2025 20:13:25 +0530 Subject: [PATCH 2/5] [AVX-512] add set_ph Signed-off-by: Shreeyash Pandey <shreeyash...@gmail.com> --- 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 >From ec0f58e9f47413f8e5a17f4467740d2f365af002 Mon Sep 17 00:00:00 2001 From: Shreeyash Pandey <shreeyash...@gmail.com> Date: Thu, 25 Sep 2025 19:51:48 +0530 Subject: [PATCH 3/5] [AVX-512] add more functions Signed-off-by: Shreeyash Pandey <shreeyash...@gmail.com> --- clang/lib/Headers/avx512vlfp16intrin.h | 10 +++++----- clang/test/CodeGen/X86/avx512vlfp16-builtins.c | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/clang/lib/Headers/avx512vlfp16intrin.h b/clang/lib/Headers/avx512vlfp16intrin.h index 0b68637bdd507..ecf97406877a0 100644 --- a/clang/lib/Headers/avx512vlfp16intrin.h +++ b/clang/lib/Headers/avx512vlfp16intrin.h @@ -63,17 +63,17 @@ _mm_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, return (__m128h)(__v8hf){__h8, __h7, __h6, __h5, __h4, __h3, __h2, __h1}; } -static __inline __m256h __DEFAULT_FN_ATTRS256 +static __inline __m256h __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_set1_pch(_Float16 _Complex h) { return (__m256h)_mm256_set1_ps(__builtin_bit_cast(float, h)); } -static __inline __m128h __DEFAULT_FN_ATTRS128 +static __inline __m128h __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_set1_pch(_Float16 _Complex h) { return (__m128h)_mm_set1_ps(__builtin_bit_cast(float, h)); } -static __inline __m256h __DEFAULT_FN_ATTRS256 +static __inline __m256h __DEFAULT_FN_ATTRS256_CONSTEXPR _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, @@ -83,13 +83,13 @@ _mm256_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, __h4, __h3, __h2, __h1}; } -static __inline__ __m128h __DEFAULT_FN_ATTRS128 +static __inline__ __m128h __DEFAULT_FN_ATTRS128_CONSTEXPR _mm_setr_ph(_Float16 e0, _Float16 e1, _Float16 e2, _Float16 e3, _Float16 e4, _Float16 e5, _Float16 e6, _Float16 e7) { return _mm_set_ph(e7, e6, e5, e4, e3, e2, e1, e0); } -static __inline__ __m256h __DEFAULT_FN_ATTRS256 +static __inline__ __m256h __DEFAULT_FN_ATTRS256_CONSTEXPR _mm256_setr_ph(_Float16 e0, _Float16 e1, _Float16 e2, _Float16 e3, _Float16 e4, _Float16 e5, _Float16 e6, _Float16 e7, _Float16 e8, _Float16 e9, _Float16 e10, _Float16 e11, _Float16 e12, _Float16 e13, diff --git a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c index 0ed176984bcdc..fe3f425bbf89c 100644 --- a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c @@ -139,6 +139,8 @@ __m256h test_mm256_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h9, __h10, __h11, __h12, __h13, __h14, __h15, __h16); } +TEST_CONSTEXPR(match_m256h(_mm256_set_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 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, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0)); + __m128h test_mm_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8) { // CHECK-LABEL: test_mm_setr_ph @@ -153,6 +155,8 @@ __m128h test_mm_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __ return _mm_setr_ph(__h1, __h2, __h3, __h4, __h5, __h6, __h7, __h8); } +TEST_CONSTEXPR(match_m128h(_mm_setr_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0), 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)); + __m256h test_mm256_setr_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, @@ -178,6 +182,8 @@ __m256h test_mm256_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h9, __h10, __h11, __h12, __h13, __h14, __h15, __h16); } +TEST_CONSTEXPR(match_m256h(_mm256_setr_ph(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0), 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)); + __m256h test_mm256_add_ph(__m256h __A, __m256h __B) { // CHECK-LABEL: test_mm256_add_ph // CHECK: %{{.*}} = fadd <16 x half> %{{.*}}, %{{.*}} >From d8d21f755ffb46878cca07487a2db0f1ba1cb388 Mon Sep 17 00:00:00 2001 From: Shreeyash Pandey <shreeyash...@gmail.com> Date: Thu, 25 Sep 2025 19:54:46 +0530 Subject: [PATCH 4/5] [AVX-512] fix formatting Signed-off-by: Shreeyash Pandey <shreeyash...@gmail.com> --- clang/lib/Headers/avx512vlfp16intrin.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Headers/avx512vlfp16intrin.h b/clang/lib/Headers/avx512vlfp16intrin.h index ecf97406877a0..1036a87c50109 100644 --- a/clang/lib/Headers/avx512vlfp16intrin.h +++ b/clang/lib/Headers/avx512vlfp16intrin.h @@ -42,7 +42,8 @@ static __inline__ _Float16 __DEFAULT_FN_ATTRS256 _mm256_cvtsh_h(__m256h __a) { return __a[0]; } -static __inline__ __m128h __DEFAULT_FN_ATTRS128_CONSTEXPR _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}; } >From ee021a62dee14175592d6d202292b5997c895908 Mon Sep 17 00:00:00 2001 From: Shreeyash Pandey <shreeyash...@gmail.com> Date: Thu, 25 Sep 2025 19:56:47 +0530 Subject: [PATCH 5/5] [AVX-512] fix formatting Signed-off-by: Shreeyash Pandey <shreeyash...@gmail.com> --- clang/test/CodeGen/X86/builtin_test_helpers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/test/CodeGen/X86/builtin_test_helpers.h b/clang/test/CodeGen/X86/builtin_test_helpers.h index 44c2dc7ba808b..fcaf360626a2d 100644 --- a/clang/test/CodeGen/X86/builtin_test_helpers.h +++ b/clang/test/CodeGen/X86/builtin_test_helpers.h @@ -4,7 +4,6 @@ #if defined(__cplusplus) && (__cplusplus >= 201103L) - constexpr bool match_m64(__m64 _v, unsigned long long a) { __v1du v = (__v1du)_v; return v[0] == a; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits