[clang] 21fe3d1 - [X86] avx512vlfp16intrin.h.h - allow _mm_cvtsh_h/_mm256_cvtsh_h to be used in constexpr (#162275)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 05:55:10 PDT 2025


Author: Simon Pilgrim
Date: 2025-10-07T12:55:05Z
New Revision: 21fe3d1dbb7d2041498f43429e6f5804bb28383b

URL: https://github.com/llvm/llvm-project/commit/21fe3d1dbb7d2041498f43429e6f5804bb28383b
DIFF: https://github.com/llvm/llvm-project/commit/21fe3d1dbb7d2041498f43429e6f5804bb28383b.diff

LOG: [X86] avx512vlfp16intrin.h.h - allow _mm_cvtsh_h/_mm256_cvtsh_h to be used in constexpr (#162275)

This was missed in the earlier f16c/fp16 constexpr patches

Added: 
    

Modified: 
    clang/lib/Headers/avx512vlfp16intrin.h
    clang/test/CodeGen/X86/avx512vlfp16-builtins.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/avx512vlfp16intrin.h b/clang/lib/Headers/avx512vlfp16intrin.h
index c0bcc080dbe93..5b2b3f0d0bbd4 100644
--- a/clang/lib/Headers/avx512vlfp16intrin.h
+++ b/clang/lib/Headers/avx512vlfp16intrin.h
@@ -34,11 +34,13 @@
 #define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128
 #endif
 
-static __inline__ _Float16 __DEFAULT_FN_ATTRS128 _mm_cvtsh_h(__m128h __a) {
+static __inline__ _Float16 __DEFAULT_FN_ATTRS128_CONSTEXPR
+_mm_cvtsh_h(__m128h __a) {
   return __a[0];
 }
 
-static __inline__ _Float16 __DEFAULT_FN_ATTRS256 _mm256_cvtsh_h(__m256h __a) {
+static __inline__ _Float16 __DEFAULT_FN_ATTRS256_CONSTEXPR
+_mm256_cvtsh_h(__m256h __a) {
   return __a[0];
 }
 

diff  --git a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c
index f1865aae4a9e2..68d09849a317b 100644
--- a/clang/test/CodeGen/X86/avx512vlfp16-builtins.c
+++ b/clang/test/CodeGen/X86/avx512vlfp16-builtins.c
@@ -17,12 +17,14 @@ _Float16 test_mm_cvtsh_h(__m128h __A) {
   // CHECK: extractelement <8 x half> %{{.*}}, i32 0
   return _mm_cvtsh_h(__A);
 }
+TEST_CONSTEXPR(_mm_cvtsh_h((__m128h){-8.0, 7.0, -6.0, 5.0, -4.0, 3.0, -2.0, 1.0}) == -8.0);
 
 _Float16 test_mm256_cvtsh_h(__m256h __A) {
   // CHECK-LABEL: test_mm256_cvtsh_h
   // CHECK: extractelement <16 x half> %{{.*}}, i32 0
   return _mm256_cvtsh_h(__A);
 }
+TEST_CONSTEXPR(_mm256_cvtsh_h((__m256h){-32.0, 31.0, -30.0, 29.0, -28.0, 27.0, -26.0, 25.0, -24.0, 23.0, -22.0, 21.0, -20.0, 19.0, -18.0, 17.0}) == -32.0);
 
 __m128h test_mm_set_sh(_Float16 __h) {
   // CHECK-LABEL: test_mm_set_sh


        


More information about the cfe-commits mailing list