Skip to content

Commit 21fe3d1

Browse files
authored
[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
1 parent 13b3629 commit 21fe3d1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

clang/lib/Headers/avx512vlfp16intrin.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128
3535
#endif
3636

37-
static __inline__ _Float16 __DEFAULT_FN_ATTRS128 _mm_cvtsh_h(__m128h __a) {
37+
static __inline__ _Float16 __DEFAULT_FN_ATTRS128_CONSTEXPR
38+
_mm_cvtsh_h(__m128h __a) {
3839
return __a[0];
3940
}
4041

41-
static __inline__ _Float16 __DEFAULT_FN_ATTRS256 _mm256_cvtsh_h(__m256h __a) {
42+
static __inline__ _Float16 __DEFAULT_FN_ATTRS256_CONSTEXPR
43+
_mm256_cvtsh_h(__m256h __a) {
4244
return __a[0];
4345
}
4446

clang/test/CodeGen/X86/avx512vlfp16-builtins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ _Float16 test_mm_cvtsh_h(__m128h __A) {
1717
// CHECK: extractelement <8 x half> %{{.*}}, i32 0
1818
return _mm_cvtsh_h(__A);
1919
}
20+
TEST_CONSTEXPR(_mm_cvtsh_h((__m128h){-8.0, 7.0, -6.0, 5.0, -4.0, 3.0, -2.0, 1.0}) == -8.0);
2021

2122
_Float16 test_mm256_cvtsh_h(__m256h __A) {
2223
// CHECK-LABEL: test_mm256_cvtsh_h
2324
// CHECK: extractelement <16 x half> %{{.*}}, i32 0
2425
return _mm256_cvtsh_h(__A);
2526
}
27+
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);
2628

2729
__m128h test_mm_set_sh(_Float16 __h) {
2830
// CHECK-LABEL: test_mm_set_sh

0 commit comments

Comments
 (0)