Skip to content

Commit 47b8bc4

Browse files
authored
[Headers][X86] Allow AVX1 fixed extraction intrinsics to be used in constexpr (#161218)
Fixes #161204.
1 parent 44f392e commit 47b8bc4

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

clang/lib/Headers/avxintrin.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,10 +2311,9 @@ _mm256_cvttps_epi32(__m256 __a)
23112311
/// \param __a
23122312
/// A 256-bit vector of [4 x double].
23132313
/// \returns A 64 bit double containing the first element of the input vector.
2314-
static __inline double __DEFAULT_FN_ATTRS
2315-
_mm256_cvtsd_f64(__m256d __a)
2316-
{
2317-
return __a[0];
2314+
static __inline double __DEFAULT_FN_ATTRS_CONSTEXPR
2315+
_mm256_cvtsd_f64(__m256d __a) {
2316+
return __a[0];
23182317
}
23192318

23202319
/// Returns the first element of the input vector of [8 x i32].
@@ -2327,11 +2326,10 @@ _mm256_cvtsd_f64(__m256d __a)
23272326
/// \param __a
23282327
/// A 256-bit vector of [8 x i32].
23292328
/// \returns A 32 bit integer containing the first element of the input vector.
2330-
static __inline int __DEFAULT_FN_ATTRS
2331-
_mm256_cvtsi256_si32(__m256i __a)
2332-
{
2333-
__v8si __b = (__v8si)__a;
2334-
return __b[0];
2329+
static __inline int __DEFAULT_FN_ATTRS_CONSTEXPR
2330+
_mm256_cvtsi256_si32(__m256i __a) {
2331+
__v8si __b = (__v8si)__a;
2332+
return __b[0];
23352333
}
23362334

23372335
/// Returns the first element of the input vector of [8 x float].
@@ -2344,10 +2342,9 @@ _mm256_cvtsi256_si32(__m256i __a)
23442342
/// \param __a
23452343
/// A 256-bit vector of [8 x float].
23462344
/// \returns A 32 bit float containing the first element of the input vector.
2347-
static __inline float __DEFAULT_FN_ATTRS
2348-
_mm256_cvtss_f32(__m256 __a)
2349-
{
2350-
return __a[0];
2345+
static __inline float __DEFAULT_FN_ATTRS_CONSTEXPR
2346+
_mm256_cvtss_f32(__m256 __a) {
2347+
return __a[0];
23512348
}
23522349

23532350
/* Vector replicate */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,18 +985,21 @@ double test_mm256_cvtsd_f64(__m256d __a) {
985985
// CHECK: extractelement <4 x double> %{{.*}}, i32 0
986986
return _mm256_cvtsd_f64(__a);
987987
}
988+
TEST_CONSTEXPR(_mm256_cvtsd_f64((__m256d){8.0, 7.0, 6.0, 5.0}) == 8.0);
988989

989990
int test_mm256_cvtsi256_si32(__m256i __a) {
990991
// CHECK-LABEL: test_mm256_cvtsi256_si32
991992
// CHECK: extractelement <8 x i32> %{{.*}}, i32 0
992993
return _mm256_cvtsi256_si32(__a);
993994
}
995+
TEST_CONSTEXPR(_mm256_cvtsi256_si32((__m256i)(__v8si){8, 7, 6, 5, 4, 3, 2, 1}) == 8);
994996

995997
float test_mm256_cvtss_f32(__m256 __a) {
996998
// CHECK-LABEL: test_mm256_cvtss_f32
997999
// CHECK: extractelement <8 x float> %{{.*}}, i32 0
9981000
return _mm256_cvtss_f32(__a);
9991001
}
1002+
TEST_CONSTEXPR(_mm256_cvtss_f32((__m256){8.0f, 7.0f, 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 1.0f}) == 8.0f);
10001003

10011004
__m128i test_mm256_cvttpd_epi32(__m256d A) {
10021005
// CHECK-LABEL: test_mm256_cvttpd_epi32

0 commit comments

Comments
 (0)