[clang] 3aa2f63 - [clang][x86] Add constexpr support for _mm_castps_pd/_mm_castps_si128/_mm_castsi128_pd/_mm_castsi128_ps intrinsics
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 6 08:17:54 PST 2024
Author: Simon Pilgrim
Date: 2024-11-06T16:17:29Z
New Revision: 3aa2f63822c0d829c875aa41ca2fd0103939dfaf
URL: https://github.com/llvm/llvm-project/commit/3aa2f63822c0d829c875aa41ca2fd0103939dfaf
DIFF: https://github.com/llvm/llvm-project/commit/3aa2f63822c0d829c875aa41ca2fd0103939dfaf.diff
LOG: [clang][x86] Add constexpr support for _mm_castps_pd/_mm_castps_si128/_mm_castsi128_pd/_mm_castsi128_ps intrinsics
Added:
Modified:
clang/lib/Headers/emmintrin.h
clang/test/CodeGen/X86/sse2-builtins.c
Removed:
################################################################################
diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index 69c3a2f229efc9..ac965a13531222 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -4778,7 +4778,8 @@ _mm_castpd_si128(__m128d __a) {
/// A 128-bit floating-point vector of [4 x float].
/// \returns A 128-bit floating-point vector of [2 x double] containing the same
/// bitwise pattern as the parameter.
-static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castps_pd(__m128 __a) {
+static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_castps_pd(__m128 __a) {
return (__m128d)__a;
}
@@ -4793,7 +4794,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castps_pd(__m128 __a) {
/// A 128-bit floating-point vector of [4 x float].
/// \returns A 128-bit integer vector containing the same bitwise pattern as the
/// parameter.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_castps_si128(__m128 __a) {
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_castps_si128(__m128 __a) {
return (__m128i)__a;
}
@@ -4808,7 +4810,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_castps_si128(__m128 __a) {
/// A 128-bit integer vector.
/// \returns A 128-bit floating-point vector of [4 x float] containing the same
/// bitwise pattern as the parameter.
-static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_castsi128_ps(__m128i __a) {
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_castsi128_ps(__m128i __a) {
return (__m128)__a;
}
@@ -4823,7 +4826,8 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_castsi128_ps(__m128i __a) {
/// A 128-bit integer vector.
/// \returns A 128-bit floating-point vector of [2 x double] containing the same
/// bitwise pattern as the parameter.
-static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castsi128_pd(__m128i __a) {
+static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_castsi128_pd(__m128i __a) {
return (__m128d)__a;
}
diff --git a/clang/test/CodeGen/X86/sse2-builtins.c b/clang/test/CodeGen/X86/sse2-builtins.c
index dec8d7599b8ddc..bb87bfd17dabec 100644
--- a/clang/test/CodeGen/X86/sse2-builtins.c
+++ b/clang/test/CodeGen/X86/sse2-builtins.c
@@ -152,21 +152,25 @@ __m128d test_mm_castps_pd(__m128 A) {
// CHECK-LABEL: test_mm_castps_pd
return _mm_castps_pd(A);
}
+TEST_CONSTEXPR(match_m128d(_mm_castps_pd((__m128){0.0f, -1.0f, 0.0f, 4.0f}), -0.0078125, 512.0));
__m128i test_mm_castps_si128(__m128 A) {
// CHECK-LABEL: test_mm_castps_si128
return _mm_castps_si128(A);
}
+TEST_CONSTEXPR(match_m128i(_mm_castps_si128((__m128){1.0f, -2.0f, -4.0f, 8.0f}), 0xC00000003F800000ULL, 0x41000000c0800000ULL));
__m128d test_mm_castsi128_pd(__m128i A) {
// CHECK-LABEL: test_mm_castsi128_pd
return _mm_castsi128_pd(A);
}
+TEST_CONSTEXPR(match_m128d(_mm_castsi128_pd((__m128i)(__v2du){0x4070000000000000ULL, 0xC000000000000000ULL}), 256.0, -2.0));
__m128 test_mm_castsi128_ps(__m128i A) {
// CHECK-LABEL: test_mm_castsi128_ps
return _mm_castsi128_ps(A);
}
+TEST_CONSTEXPR(match_m128(_mm_castsi128_ps((__m128i)(__v2du){0x42000000c1800000ULL, 0x43000000c2800000ULL}), -16.0f, 32.0f, -64.0f, 128.0f));
void test_mm_clflush(void* A) {
// CHECK-LABEL: test_mm_clflush
More information about the cfe-commits
mailing list