[clang] 8306114 - [clang][x86] Add constexpr support for _mm_cvtsi32_ss/_mm_cvt_si2ss/_mm_cvtsi64_ss SSE1 intrinsics
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 04:52:57 PDT 2024
Author: Simon Pilgrim
Date: 2024-10-10T12:49:56+01:00
New Revision: 8306114ed2313a7febdb0d0d0c31df357ed53fdd
URL: https://github.com/llvm/llvm-project/commit/8306114ed2313a7febdb0d0d0c31df357ed53fdd
DIFF: https://github.com/llvm/llvm-project/commit/8306114ed2313a7febdb0d0d0c31df357ed53fdd.diff
LOG: [clang][x86] Add constexpr support for _mm_cvtsi32_ss/_mm_cvt_si2ss/_mm_cvtsi64_ss SSE1 intrinsics
Followup to #111001
Added:
Modified:
clang/lib/Headers/xmmintrin.h
clang/test/CodeGen/X86/sse-builtins.c
Removed:
################################################################################
diff --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 2aa688adefc25a..20e66d190113a3 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -1618,9 +1618,8 @@ _mm_cvtt_ps2pi(__m128 __a)
/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
/// converted value of the second operand. The upper 96 bits are copied from
/// the upper 96 bits of the first operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_cvtsi32_ss(__m128 __a, int __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvtsi32_ss(__m128 __a,
+ int __b) {
__a[0] = __b;
return __a;
}
@@ -1641,9 +1640,8 @@ _mm_cvtsi32_ss(__m128 __a, int __b)
/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
/// converted value of the second operand. The upper 96 bits are copied from
/// the upper 96 bits of the first operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_cvt_si2ss(__m128 __a, int __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvt_si2ss(__m128 __a,
+ int __b) {
return _mm_cvtsi32_ss(__a, __b);
}
@@ -1665,9 +1663,8 @@ _mm_cvt_si2ss(__m128 __a, int __b)
/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the
/// converted value of the second operand. The upper 96 bits are copied from
/// the upper 96 bits of the first operand.
-static __inline__ __m128 __DEFAULT_FN_ATTRS
-_mm_cvtsi64_ss(__m128 __a, long long __b)
-{
+static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_cvtsi64_ss(__m128 __a, long long __b) {
__a[0] = __b;
return __a;
}
diff --git a/clang/test/CodeGen/X86/sse-builtins.c b/clang/test/CodeGen/X86/sse-builtins.c
index 932d6f36b09b66..391e049a6ae3ef 100644
--- a/clang/test/CodeGen/X86/sse-builtins.c
+++ b/clang/test/CodeGen/X86/sse-builtins.c
@@ -948,6 +948,15 @@ void test_constexpr() {
constexpr __m128 v_mm_movelh_ps = _mm_movelh_ps(k1, k2);
static_assert(v_mm_movelh_ps[0] == +1.0f && v_mm_movelh_ps[1] == +0.0f && v_mm_movelh_ps[2] == +8.0f && v_mm_movelh_ps[3] == +4.0f);
+ constexpr __m128 v_mm_cvtsi32_ss = _mm_cvtsi32_ss(k1, 42);
+ static_assert(v_mm_cvtsi32_ss[0] == 42.0f && v_mm_cvtsi32_ss[1] == +0.0f && v_mm_cvtsi32_ss[2] == +2.0f && v_mm_cvtsi32_ss[3] == +4.0f);
+
+ constexpr __m128 v_mm_cvt_si2ss = _mm_cvt_si2ss(k2, -99);
+ static_assert(v_mm_cvt_si2ss[0] == -99.0f && v_mm_cvt_si2ss[1] == +4.0f && v_mm_cvt_si2ss[2] == +2.0f && v_mm_cvt_si2ss[3] == +1.0f);
+
+ constexpr __m128 v_mm_cvtsi64_ss = _mm_cvtsi64_ss(k3, 555);
+ static_assert(v_mm_cvtsi64_ss[0] == 555.0f && v_mm_cvtsi64_ss[1] == -5.0f && v_mm_cvtsi64_ss[2] == +6.0f && v_mm_cvtsi64_ss[3] == +7.0f);
+
static_assert(_mm_cvtss_f32(k2) == +8.0f);
}
More information about the cfe-commits
mailing list