[clang] 53e6f62 - [clang][x86] _mm_movpi64_epi64 - convert to shufflevector pattern instead of bitcasting to i64

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 06:42:10 PST 2024


Author: Simon Pilgrim
Date: 2024-11-08T14:38:33Z
New Revision: 53e6f627d7e81633b2e159675884bfcce11bdc00

URL: https://github.com/llvm/llvm-project/commit/53e6f627d7e81633b2e159675884bfcce11bdc00
DIFF: https://github.com/llvm/llvm-project/commit/53e6f627d7e81633b2e159675884bfcce11bdc00.diff

LOG: [clang][x86] _mm_movpi64_epi64 - convert to shufflevector pattern instead of bitcasting to i64

Don't bitcast a v1i64 to i64 as constant expressions will struggle to handle this - convert to a shufflevector concat pattern like _mm_move_epi64 instead

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 947ad891d2c85c..de453cc1a38b99 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -4627,7 +4627,7 @@ _mm_movepi64_pi64(__m128i __a) {
 /// \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_movpi64_epi64(__m64 __a) {
-  return __extension__(__m128i)(__v2di){(long long)__a, 0};
+  return __builtin_shufflevector((__v1di)__a, _mm_setzero_si64(), 0, 1);
 }
 
 /// Moves the lower 64 bits of a 128-bit integer vector to a 128-bit

diff  --git a/clang/test/CodeGen/X86/sse2-builtins.c b/clang/test/CodeGen/X86/sse2-builtins.c
index 1db40587be466d..6defd94c5d5073 100644
--- a/clang/test/CodeGen/X86/sse2-builtins.c
+++ b/clang/test/CodeGen/X86/sse2-builtins.c
@@ -878,9 +878,7 @@ TEST_CONSTEXPR(match_m64(_mm_movepi64_pi64((__m128i){8, -8}), 8ULL));
 __m128i test_mm_movpi64_epi64(__m64 A)
 {
   // CHECK-LABEL: test_mm_movpi64_epi64
-  // CHECK: [[CAST:%.*]] = bitcast <1 x i64> %{{.*}} to i64
-  // CHECK: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[CAST]], i32 0
-  // CHECK: insertelement <2 x i64> [[INS]], i64 0, i32 1
+  // CHECK: shufflevector <1 x i64> %{{.*}}, <1 x i64> %{{.*}}, <2 x i32> <i32 0, i32 1>
   return _mm_movpi64_epi64(A);
 }
 


        


More information about the cfe-commits mailing list