[clang] 7585e2f - [clang][x86] Add constexpr support for _mm_movepi64_pi64 and _mm_move_epi64

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 07:20:13 PST 2024


Author: Simon Pilgrim
Date: 2024-11-06T15:19:00Z
New Revision: 7585e2fd3caee30d5332c93995b7a6f51ab06660

URL: https://github.com/llvm/llvm-project/commit/7585e2fd3caee30d5332c93995b7a6f51ab06660
DIFF: https://github.com/llvm/llvm-project/commit/7585e2fd3caee30d5332c93995b7a6f51ab06660.diff

LOG: [clang][x86] Add constexpr support for _mm_movepi64_pi64 and _mm_move_epi64

Added: 
    

Modified: 
    clang/lib/Headers/emmintrin.h
    clang/test/CodeGen/X86/builtin_test_helpers.h
    clang/test/CodeGen/X86/sse2-builtins.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index 4f00b7f1a8d9d4..69c3a2f229efc9 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -4610,7 +4610,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpacklo_epi64(__m128i __a,
 ///    A 128-bit integer vector operand. The lower 64 bits are moved to the
 ///    destination.
 /// \returns A 64-bit integer containing the lower 64 bits of the parameter.
-static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_movepi64_pi64(__m128i __a) {
+static __inline__ __m64 __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_movepi64_pi64(__m128i __a) {
   return (__m64)__a[0];
 }
 
@@ -4641,7 +4642,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_movpi64_epi64(__m64 __a) {
 ///    destination.
 /// \returns A 128-bit integer vector. The lower 64 bits contain the value from
 ///    the operand. The upper 64 bits are assigned zeros.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_move_epi64(__m128i __a) {
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
+_mm_move_epi64(__m128i __a) {
   return __builtin_shufflevector((__v2di)__a, _mm_setzero_si128(), 0, 2);
 }
 

diff  --git a/clang/test/CodeGen/X86/builtin_test_helpers.h b/clang/test/CodeGen/X86/builtin_test_helpers.h
index 0a57dabde1a652..0edec1441b33bd 100644
--- a/clang/test/CodeGen/X86/builtin_test_helpers.h
+++ b/clang/test/CodeGen/X86/builtin_test_helpers.h
@@ -4,6 +4,11 @@
 
 #if defined(__cplusplus) && (__cplusplus >= 201103L)
 
+constexpr bool match_m64(__m64 _v, unsigned long long a) {
+  __v1du v = (__v1du)_v;
+  return v[0] == a;
+}
+
 constexpr bool match_m128(__m128 v, float a, float b, float c, float d) {
   return v[0] == a && v[1] == b && v[2] == c && v[3] == d;
 }

diff  --git a/clang/test/CodeGen/X86/sse2-builtins.c b/clang/test/CodeGen/X86/sse2-builtins.c
index adcb6876f7f55d..dec8d7599b8ddc 100644
--- a/clang/test/CodeGen/X86/sse2-builtins.c
+++ b/clang/test/CodeGen/X86/sse2-builtins.c
@@ -868,6 +868,7 @@ __m64 test_mm_movepi64_pi64(__m128i A)
   // CHECK: [[EXT:%.*]] = extractelement <2 x i64> %1, i32 0
   return _mm_movepi64_pi64(A);
 }
+TEST_CONSTEXPR(match_m64(_mm_movepi64_pi64((__m128i){8, -8}), 8ULL));
 
 __m128i test_mm_movpi64_epi64(__m64 A)
 {
@@ -883,6 +884,7 @@ __m128i test_mm_move_epi64(__m128i A) {
   // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> <i32 0, i32 2>
   return _mm_move_epi64(A);
 }
+TEST_CONSTEXPR(match_m128i(_mm_move_epi64((__m128i){16LL, 15LL}), 16ULL, 0ULL));
 
 __m128d test_mm_move_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_move_sd


        


More information about the cfe-commits mailing list