Skip to content

Commit 3aa2f63

Browse files
committed
[clang][x86] Add constexpr support for _mm_castps_pd/_mm_castps_si128/_mm_castsi128_pd/_mm_castsi128_ps intrinsics
1 parent f548d39 commit 3aa2f63

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

clang/lib/Headers/emmintrin.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4778,7 +4778,8 @@ _mm_castpd_si128(__m128d __a) {
47784778
/// A 128-bit floating-point vector of [4 x float].
47794779
/// \returns A 128-bit floating-point vector of [2 x double] containing the same
47804780
/// bitwise pattern as the parameter.
4781-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castps_pd(__m128 __a) {
4781+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
4782+
_mm_castps_pd(__m128 __a) {
47824783
return (__m128d)__a;
47834784
}
47844785

@@ -4793,7 +4794,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castps_pd(__m128 __a) {
47934794
/// A 128-bit floating-point vector of [4 x float].
47944795
/// \returns A 128-bit integer vector containing the same bitwise pattern as the
47954796
/// parameter.
4796-
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_castps_si128(__m128 __a) {
4797+
static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
4798+
_mm_castps_si128(__m128 __a) {
47974799
return (__m128i)__a;
47984800
}
47994801

@@ -4808,7 +4810,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_castps_si128(__m128 __a) {
48084810
/// A 128-bit integer vector.
48094811
/// \returns A 128-bit floating-point vector of [4 x float] containing the same
48104812
/// bitwise pattern as the parameter.
4811-
static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_castsi128_ps(__m128i __a) {
4813+
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
4814+
_mm_castsi128_ps(__m128i __a) {
48124815
return (__m128)__a;
48134816
}
48144817

@@ -4823,7 +4826,8 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_castsi128_ps(__m128i __a) {
48234826
/// A 128-bit integer vector.
48244827
/// \returns A 128-bit floating-point vector of [2 x double] containing the same
48254828
/// bitwise pattern as the parameter.
4826-
static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castsi128_pd(__m128i __a) {
4829+
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
4830+
_mm_castsi128_pd(__m128i __a) {
48274831
return (__m128d)__a;
48284832
}
48294833

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,25 @@ __m128d test_mm_castps_pd(__m128 A) {
152152
// CHECK-LABEL: test_mm_castps_pd
153153
return _mm_castps_pd(A);
154154
}
155+
TEST_CONSTEXPR(match_m128d(_mm_castps_pd((__m128){0.0f, -1.0f, 0.0f, 4.0f}), -0.0078125, 512.0));
155156

156157
__m128i test_mm_castps_si128(__m128 A) {
157158
// CHECK-LABEL: test_mm_castps_si128
158159
return _mm_castps_si128(A);
159160
}
161+
TEST_CONSTEXPR(match_m128i(_mm_castps_si128((__m128){1.0f, -2.0f, -4.0f, 8.0f}), 0xC00000003F800000ULL, 0x41000000c0800000ULL));
160162

161163
__m128d test_mm_castsi128_pd(__m128i A) {
162164
// CHECK-LABEL: test_mm_castsi128_pd
163165
return _mm_castsi128_pd(A);
164166
}
167+
TEST_CONSTEXPR(match_m128d(_mm_castsi128_pd((__m128i)(__v2du){0x4070000000000000ULL, 0xC000000000000000ULL}), 256.0, -2.0));
165168

166169
__m128 test_mm_castsi128_ps(__m128i A) {
167170
// CHECK-LABEL: test_mm_castsi128_ps
168171
return _mm_castsi128_ps(A);
169172
}
173+
TEST_CONSTEXPR(match_m128(_mm_castsi128_ps((__m128i)(__v2du){0x42000000c1800000ULL, 0x43000000c2800000ULL}), -16.0f, 32.0f, -64.0f, 128.0f));
170174

171175
void test_mm_clflush(void* A) {
172176
// CHECK-LABEL: test_mm_clflush

0 commit comments

Comments
 (0)