Skip to content

Commit afa536e

Browse files
committed
[x86] Support 3 builtin functions for 32-bits mode
_mm_cvtsi128_si64, _mm_cvtsi64_si128, _mm_extract_epi64 Reviewed By:RKSimon, Topper Craig Differential Revision: https://reviews.llvm.org/D124067
1 parent 7493d9f commit afa536e

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed

clang/include/clang/Basic/BuiltinsX86.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ TARGET_BUILTIN(__builtin_ia32_packsswb128, "V16cV8sV8s", "ncV:128:", "sse2")
261261
TARGET_BUILTIN(__builtin_ia32_packssdw128, "V8sV4iV4i", "ncV:128:", "sse2")
262262
TARGET_BUILTIN(__builtin_ia32_packuswb128, "V16cV8sV8s", "ncV:128:", "sse2")
263263
TARGET_BUILTIN(__builtin_ia32_pmulhuw128, "V8sV8sV8s", "ncV:128:", "sse2")
264+
TARGET_BUILTIN(__builtin_ia32_vec_ext_v2di, "OiV2OiIi", "ncV:128:", "sse2")
264265
TARGET_BUILTIN(__builtin_ia32_vec_ext_v4si, "iV4iIi", "ncV:128:", "sse2")
265266
TARGET_BUILTIN(__builtin_ia32_vec_ext_v4sf, "fV4fIi", "ncV:128:", "sse2")
266267
TARGET_BUILTIN(__builtin_ia32_vec_ext_v8hi, "sV8sIi", "ncV:128:", "sse2")

clang/include/clang/Basic/BuiltinsX86_64.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ TARGET_BUILTIN(__builtin_ia32_cvttss2si64, "OiV4f", "ncV:128:", "sse")
4242
TARGET_BUILTIN(__builtin_ia32_cvtsd2si64, "OiV2d", "ncV:128:", "sse2")
4343
TARGET_BUILTIN(__builtin_ia32_cvttsd2si64, "OiV2d", "ncV:128:", "sse2")
4444
TARGET_BUILTIN(__builtin_ia32_movnti64, "vOi*Oi", "n", "sse2")
45-
TARGET_BUILTIN(__builtin_ia32_vec_ext_v2di, "OiV2OiIi", "ncV:128:", "sse2")
4645
TARGET_BUILTIN(__builtin_ia32_vec_set_v2di, "V2OiV2OiOiIi", "ncV:128:", "sse4.1")
4746
TARGET_BUILTIN(__builtin_ia32_crc32di, "UOiUOiUOi", "nc", "crc32")
4847
TARGET_BUILTIN(__builtin_ia32_vec_ext_v4di, "OiV4OiIi", "ncV:256:", "avx")

clang/lib/Headers/emmintrin.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,21 +3284,20 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtsi32_si128(int __a) {
32843284
return __extension__(__m128i)(__v4si){__a, 0, 0, 0};
32853285
}
32863286

3287-
#ifdef __x86_64__
32883287
/// Returns a vector of [2 x i64] where the lower element is the input
32893288
/// operand and the upper element is zero.
32903289
///
32913290
/// \headerfile <x86intrin.h>
32923291
///
3293-
/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction.
3292+
/// This intrinsic corresponds to the <c> VMOVQ / MOVQ </c> instruction
3293+
/// in 64-bit mode.
32943294
///
32953295
/// \param __a
32963296
/// A 64-bit signed integer operand containing the value to be converted.
32973297
/// \returns A 128-bit vector of [2 x i64] containing the converted value.
32983298
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtsi64_si128(long long __a) {
32993299
return __extension__(__m128i)(__v2di){__a, 0};
33003300
}
3301-
#endif
33023301

33033302
/// Moves the least significant 32 bits of a vector of [4 x i32] to a
33043303
/// 32-bit signed integer value.
@@ -3316,7 +3315,6 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_cvtsi128_si32(__m128i __a) {
33163315
return __b[0];
33173316
}
33183317

3319-
#ifdef __x86_64__
33203318
/// Moves the least significant 64 bits of a vector of [2 x i64] to a
33213319
/// 64-bit signed integer value.
33223320
///
@@ -3331,7 +3329,6 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_cvtsi128_si32(__m128i __a) {
33313329
static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvtsi128_si64(__m128i __a) {
33323330
return __a[0];
33333331
}
3334-
#endif
33353332

33363333
/// Moves packed integer values from an aligned 128-bit memory location
33373334
/// to elements in a 128-bit integer vector.

clang/lib/Headers/smmintrin.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epu32(__m128i __V1,
10541054
#define _mm_extract_epi32(X, N) \
10551055
((int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N)))
10561056

1057-
#ifdef __x86_64__
10581057
/// Extracts a 64-bit element from the 128-bit integer vector of
10591058
/// [2 x i64], using the immediate value parameter \a N as a selector.
10601059
///
@@ -1064,7 +1063,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epu32(__m128i __V1,
10641063
/// long long _mm_extract_epi64(__m128i X, const int N);
10651064
/// \endcode
10661065
///
1067-
/// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction.
1066+
/// This intrinsic corresponds to the <c> VPEXTRQ / PEXTRQ </c> instruction
1067+
/// in 64-bit mode.
10681068
///
10691069
/// \param X
10701070
/// A 128-bit integer vector.
@@ -1076,7 +1076,6 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epu32(__m128i __V1,
10761076
/// \returns A 64-bit integer.
10771077
#define _mm_extract_epi64(X, N) \
10781078
((long long)__builtin_ia32_vec_ext_v2di((__v2di)(__m128i)(X), (int)(N)))
1079-
#endif /* __x86_64 */
10801079

10811080
/* SSE4 128-bit Packed Integer Comparisons. */
10821081
/// Tests whether the specified bits in a 128-bit integer vector are all

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,11 @@ int test_mm_cvtsi128_si32(__m128i A) {
510510
return _mm_cvtsi128_si32(A);
511511
}
512512

513-
#ifdef __x86_64__
514513
long long test_mm_cvtsi128_si64(__m128i A) {
515-
// X64-LABEL: test_mm_cvtsi128_si64
516-
// X64: extractelement <2 x i64> %{{.*}}, i32 0
514+
// CHECK-LABEL: test_mm_cvtsi128_si64
515+
// CHECK: extractelement <2 x i64> %{{.*}}, i32 0
517516
return _mm_cvtsi128_si64(A);
518517
}
519-
#endif
520518

521519
__m128d test_mm_cvtsi32_sd(__m128d A, int B) {
522520
// CHECK-LABEL: test_mm_cvtsi32_sd
@@ -541,14 +539,14 @@ __m128d test_mm_cvtsi64_sd(__m128d A, long long B) {
541539
// X64: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
542540
return _mm_cvtsi64_sd(A, B);
543541
}
542+
#endif
544543

545544
__m128i test_mm_cvtsi64_si128(long long A) {
546-
// X64-LABEL: test_mm_cvtsi64_si128
547-
// X64: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
548-
// X64: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
545+
// CHECK-LABEL: test_mm_cvtsi64_si128
546+
// CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
547+
// CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
549548
return _mm_cvtsi64_si128(A);
550549
}
551-
#endif
552550

553551
__m128d test_mm_cvtss_sd(__m128d A, __m128 B) {
554552
// CHECK-LABEL: test_mm_cvtss_sd

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,11 @@ int test_mm_extract_epi32(__m128i x) {
184184
return _mm_extract_epi32(x, 1);
185185
}
186186

187-
#ifdef __x86_64__
188187
long long test_mm_extract_epi64(__m128i x) {
189-
// X64-LABEL: test_mm_extract_epi64
190-
// X64: extractelement <2 x i64> %{{.*}}, {{i32|i64}} 1
188+
// CHECK-LABEL: test_mm_extract_epi64
189+
// CHECK: extractelement <2 x i64> %{{.*}}, {{i32|i64}} 1
191190
return _mm_extract_epi64(x, 1);
192191
}
193-
#endif
194192

195193
int test_mm_extract_ps(__m128 x) {
196194
// CHECK-LABEL: test_mm_extract_ps

0 commit comments

Comments
 (0)