Skip to content

Commit 7585e2f

Browse files
committed
[clang][x86] Add constexpr support for _mm_movepi64_pi64 and _mm_move_epi64
1 parent f61a8bc commit 7585e2f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

clang/lib/Headers/emmintrin.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,7 +4610,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpacklo_epi64(__m128i __a,
46104610
/// A 128-bit integer vector operand. The lower 64 bits are moved to the
46114611
/// destination.
46124612
/// \returns A 64-bit integer containing the lower 64 bits of the parameter.
4613-
static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_movepi64_pi64(__m128i __a) {
4613+
static __inline__ __m64 __DEFAULT_FN_ATTRS_CONSTEXPR
4614+
_mm_movepi64_pi64(__m128i __a) {
46144615
return (__m64)__a[0];
46154616
}
46164617

@@ -4641,7 +4642,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_movpi64_epi64(__m64 __a) {
46414642
/// destination.
46424643
/// \returns A 128-bit integer vector. The lower 64 bits contain the value from
46434644
/// the operand. The upper 64 bits are assigned zeros.
4644-
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_move_epi64(__m128i __a) {
4645+
static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
4646+
_mm_move_epi64(__m128i __a) {
46454647
return __builtin_shufflevector((__v2di)__a, _mm_setzero_si128(), 0, 2);
46464648
}
46474649

clang/test/CodeGen/X86/builtin_test_helpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
#if defined(__cplusplus) && (__cplusplus >= 201103L)
66

7+
constexpr bool match_m64(__m64 _v, unsigned long long a) {
8+
__v1du v = (__v1du)_v;
9+
return v[0] == a;
10+
}
11+
712
constexpr bool match_m128(__m128 v, float a, float b, float c, float d) {
813
return v[0] == a && v[1] == b && v[2] == c && v[3] == d;
914
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ __m64 test_mm_movepi64_pi64(__m128i A)
868868
// CHECK: [[EXT:%.*]] = extractelement <2 x i64> %1, i32 0
869869
return _mm_movepi64_pi64(A);
870870
}
871+
TEST_CONSTEXPR(match_m64(_mm_movepi64_pi64((__m128i){8, -8}), 8ULL));
871872

872873
__m128i test_mm_movpi64_epi64(__m64 A)
873874
{
@@ -883,6 +884,7 @@ __m128i test_mm_move_epi64(__m128i A) {
883884
// CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <2 x i32> <i32 0, i32 2>
884885
return _mm_move_epi64(A);
885886
}
887+
TEST_CONSTEXPR(match_m128i(_mm_move_epi64((__m128i){16LL, 15LL}), 16ULL, 0ULL));
886888

887889
__m128d test_mm_move_sd(__m128d A, __m128d B) {
888890
// CHECK-LABEL: test_mm_move_sd

0 commit comments

Comments
 (0)