-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Update SSE/AVX integer comparison intrinsics to be used in constexpr #155656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-backend-x86 Author: Smokey (smoke-y) ChangesCloses #155413 Full diff: https://github.com/llvm/llvm-project/pull/155656.diff 7 Files Affected:
diff --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h
index ce5b2b7544d8c..05bd15385d149 100644
--- a/clang/lib/Headers/avx2intrin.h
+++ b/clang/lib/Headers/avx2intrin.h
@@ -637,7 +637,7 @@ _mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
/// \param __b
/// A 256-bit integer vector containing one of the inputs.
/// \returns A 256-bit integer vector containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi8(__m256i __a, __m256i __b)
{
return (__m256i)((__v32qi)__a == (__v32qi)__b);
@@ -663,7 +663,7 @@ _mm256_cmpeq_epi8(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [16 x i16] containing one of the inputs.
/// \returns A 256-bit vector of [16 x i16] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi16(__m256i __a, __m256i __b)
{
return (__m256i)((__v16hi)__a == (__v16hi)__b);
@@ -689,7 +689,7 @@ _mm256_cmpeq_epi16(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [8 x i32] containing one of the inputs.
/// \returns A 256-bit vector of [8 x i32] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi32(__m256i __a, __m256i __b)
{
return (__m256i)((__v8si)__a == (__v8si)__b);
@@ -715,7 +715,7 @@ _mm256_cmpeq_epi32(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [4 x i64] containing one of the inputs.
/// \returns A 256-bit vector of [4 x i64] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi64(__m256i __a, __m256i __b)
{
return (__m256i)((__v4di)__a == (__v4di)__b);
@@ -741,7 +741,7 @@ _mm256_cmpeq_epi64(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit integer vector containing one of the inputs.
/// \returns A 256-bit integer vector containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi8(__m256i __a, __m256i __b)
{
/* This function always performs a signed comparison, but __v32qi is a char
@@ -769,7 +769,7 @@ _mm256_cmpgt_epi8(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [16 x i16] containing one of the inputs.
/// \returns A 256-bit vector of [16 x i16] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi16(__m256i __a, __m256i __b)
{
return (__m256i)((__v16hi)__a > (__v16hi)__b);
@@ -795,7 +795,7 @@ _mm256_cmpgt_epi16(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [8 x i32] containing one of the inputs.
/// \returns A 256-bit vector of [8 x i32] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi32(__m256i __a, __m256i __b)
{
return (__m256i)((__v8si)__a > (__v8si)__b);
@@ -821,7 +821,7 @@ _mm256_cmpgt_epi32(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [4 x i64] containing one of the inputs.
/// \returns A 256-bit vector of [4 x i64] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi64(__m256i __a, __m256i __b)
{
return (__m256i)((__v4di)__a > (__v4di)__b);
diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index 8b6b62458dac1..7f69019e01b06 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -3090,7 +3090,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi64(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi8(__m128i __a,
__m128i __b) {
return (__m128i)((__v16qi)__a == (__v16qi)__b);
}
@@ -3109,7 +3109,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi16(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi16(__m128i __a,
__m128i __b) {
return (__m128i)((__v8hi)__a == (__v8hi)__b);
}
@@ -3128,7 +3128,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi16(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi32(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi32(__m128i __a,
__m128i __b) {
return (__m128i)((__v4si)__a == (__v4si)__b);
}
@@ -3148,7 +3148,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi32(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi8(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi8(__m128i __a,
__m128i __b) {
/* This function always performs a signed comparison, but __v16qi is a char
which may be signed or unsigned, so use __v16qs. */
@@ -3170,7 +3170,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi8(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi16(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi16(__m128i __a,
__m128i __b) {
return (__m128i)((__v8hi)__a > (__v8hi)__b);
}
@@ -3190,7 +3190,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi16(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi32(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi32(__m128i __a,
__m128i __b) {
return (__m128i)((__v4si)__a > (__v4si)__b);
}
@@ -3210,7 +3210,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi32(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi8(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmplt_epi8(__m128i __a,
__m128i __b) {
return _mm_cmpgt_epi8(__b, __a);
}
@@ -3230,7 +3230,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi8(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi16(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmplt_epi16(__m128i __a,
__m128i __b) {
return _mm_cmpgt_epi16(__b, __a);
}
@@ -3250,7 +3250,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi16(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi32(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmplt_epi32(__m128i __a,
__m128i __b) {
return _mm_cmpgt_epi32(__b, __a);
}
diff --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h
index 57d0d329312af..3f44c786fb75f 100644
--- a/clang/lib/Headers/smmintrin.h
+++ b/clang/lib/Headers/smmintrin.h
@@ -1211,7 +1211,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_testnzc_si128(__m128i __M,
/// \param __V2
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi64(__m128i __V1,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi64(__m128i __V1,
__m128i __V2) {
return (__m128i)((__v2di)__V1 == (__v2di)__V2);
}
@@ -2338,7 +2338,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_minpos_epu16(__m128i __V) {
/// \param __V2
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi64(__m128i __V1,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi64(__m128i __V1,
__m128i __V2) {
return (__m128i)((__v2di)__V1 > (__v2di)__V2);
}
diff --git a/clang/test/CodeGen/X86/avx2-builtins.c b/clang/test/CodeGen/X86/avx2-builtins.c
index 49e35230ba225..84a4db9695b88 100644
--- a/clang/test/CodeGen/X86/avx2-builtins.c
+++ b/clang/test/CodeGen/X86/avx2-builtins.c
@@ -287,48 +287,56 @@ __m256i test_mm256_cmpeq_epi8(__m256i a, __m256i b) {
// CHECK: icmp eq <32 x i8>
return _mm256_cmpeq_epi8(a, b);
}
+TEST_CONSTEXPR(match_v32qi(_mm256_cmpeq_epi8((__m256i)(__v32qi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}, (__m256i)(__v32qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16,17,36,38,20,42,22,46,24,50,26,54,28,58,30,62,32}), 0,-1,0,-1,-1,0,0,-1,-1,0,0,-1,0,-1,0,-1,-1,0,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1));
__m256i test_mm256_cmpeq_epi16(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpeq_epi16
// CHECK: icmp eq <16 x i16>
return _mm256_cmpeq_epi16(a, b);
}
+TEST_CONSTEXPR(match_v16hi(_mm256_cmpeq_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-10, -2, +6, -4, +5, -12, +14, -8, +9, -20, +22, -12, +26, -14, +30, -16}), 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 0, -1, 0, -1, 0, -1));
__m256i test_mm256_cmpeq_epi32(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpeq_epi32
// CHECK: icmp eq <8 x i32>
return _mm256_cmpeq_epi32(a, b);
}
+TEST_CONSTEXPR(match_v8si(_mm256_cmpeq_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-10, -2, +6, -4, +5, -12, +14, -8}), 0, -1, 0, -1, -1, 0, 0, -1));
__m256i test_mm256_cmpeq_epi64(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpeq_epi64
// CHECK: icmp eq <4 x i64>
return _mm256_cmpeq_epi64(a, b);
}
+TEST_CONSTEXPR(match_v4di(_mm256_cmpeq_epi64((__m256i)(__v4di){+1, -2, +3, -4}, (__m256i)(__v4di){-10, -2, +6, -4}), 0, -1, 0, -1));
__m256i test_mm256_cmpgt_epi8(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi8
// CHECK: icmp sgt <32 x i8>
return _mm256_cmpgt_epi8(a, b);
}
+TEST_CONSTEXPR(match_v32qi(_mm256_cmpgt_epi8((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v32qi){10, 2, 6, 5, 30, 7, 8, 1, 20, 3, 12, 8, 25, 10, 9, 2, 10, 2, 6, 5, 30, 7, 8, 1, 20, 3, 12, 8, 25, 10, 9, 2}), 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1));
__m256i test_mm256_cmpgt_epi16(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi16
// CHECK: icmp sgt <16 x i16>
return _mm256_cmpgt_epi16(a, b);
}
+TEST_CONSTEXPR(match_v16hi(_mm256_cmpgt_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v16hi){-10, -2, +6, -5, +30, -7, +8, -1, -10, -2, +6, -5, +30, -7, +8, -1}), -1, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, -1, 0, -1, 0, 0));
__m256i test_mm256_cmpgt_epi32(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi32
// CHECK: icmp sgt <8 x i32>
return _mm256_cmpgt_epi32(a, b);
}
+TEST_CONSTEXPR(match_v8si(_mm256_cmpgt_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-10, -2, +6, -5, +30, -7, +8, -1}), -1, 0, 0, -1, 0, -1, 0, 0));
__m256i test_mm256_cmpgt_epi64(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi64
// CHECK: icmp sgt <4 x i64>
return _mm256_cmpgt_epi64(a, b);
}
+TEST_CONSTEXPR(match_v4di(_mm256_cmpgt_epi64((__m256i)(__v4di){+1, -2, +3, -4}, (__m256i)(__v4di){-10, -2, +6, -5}), -1, 0, 0, -1));
__m256i test_mm256_cvtepi8_epi16(__m128i a) {
// CHECK-LABEL: test_mm256_cvtepi8_epi16
diff --git a/clang/test/CodeGen/X86/sse2-builtins.c b/clang/test/CodeGen/X86/sse2-builtins.c
index 38d5e877a5036..a578f04c97c71 100644
--- a/clang/test/CodeGen/X86/sse2-builtins.c
+++ b/clang/test/CodeGen/X86/sse2-builtins.c
@@ -243,18 +243,21 @@ __m128i test_mm_cmpeq_epi8(__m128i A, __m128i B) {
// CHECK: icmp eq <16 x i8>
return _mm_cmpeq_epi8(A, B);
}
+TEST_CONSTEXPR(match_v16qi(_mm_cmpeq_epi8((__m128i)(__v16qi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), 0,-1,0,-1,-1,0,0,-1,-1,0,0,-1,0,-1,0,-1));
__m128i test_mm_cmpeq_epi16(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpeq_epi16
// CHECK: icmp eq <8 x i16>
return _mm_cmpeq_epi16(A, B);
}
+TEST_CONSTEXPR(match_v8hi(_mm_cmpeq_epi16((__m128i)(__v8hi){+1, -2, +3, -4, +5, -6, +7, -8}, (__m128i)(__v8hi){-10, -2, +6, -4, +5, -12, +14, -8}), 0, -1, 0, -1, -1, 0, 0, -1));
__m128i test_mm_cmpeq_epi32(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpeq_epi32
// CHECK: icmp eq <4 x i32>
return _mm_cmpeq_epi32(A, B);
}
+TEST_CONSTEXPR(match_v4si(_mm_cmpeq_epi32((__m128i)(__v4si){+1, -2, +3, -4}, (__m128i)(__v4si){-10, -2, +6, -4}), 0, -1, 0, -1));
__m128d test_mm_cmpeq_pd(__m128d A, __m128d B) {
// CHECK-LABEL: test_mm_cmpeq_pd
@@ -293,18 +296,21 @@ __m128i test_mm_cmpgt_epi8(__m128i A, __m128i B) {
// CHECK: icmp sgt <16 x i8>
return _mm_cmpgt_epi8(A, B);
}
+TEST_CONSTEXPR(match_v16qi(_mm_cmpgt_epi8((__m128i)(__v16qi){15,2,8,4,12,6,20,8,25,10,30,12,35,14,40,16}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), -1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0));
__m128i test_mm_cmpgt_epi16(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpgt_epi16
// CHECK: icmp sgt <8 x i16>
return _mm_cmpgt_epi16(A, B);
}
+TEST_CONSTEXPR(match_v8hi(_mm_cmpgt_epi16((__m128i)(__v8hi){15,2,8,4,12,6,20,8}, (__m128i)(__v8hi){10,2,6,4,5,12,14,8}), -1,0,-1,0,-1,0,-1,0));
__m128i test_mm_cmpgt_epi32(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpgt_epi32
// CHECK: icmp sgt <4 x i32>
return _mm_cmpgt_epi32(A, B);
}
+TEST_CONSTEXPR(match_v4si(_mm_cmpgt_epi32((__m128i)(__v4si){15,2,8,4}, (__m128i)(__v4si){10,2,6,4}), -1,0,-1,0));
__m128d test_mm_cmpgt_pd(__m128d A, __m128d B) {
// CHECK-LABEL: test_mm_cmpgt_pd
@@ -343,18 +349,21 @@ __m128i test_mm_cmplt_epi8(__m128i A, __m128i B) {
// CHECK: icmp sgt <16 x i8>
return _mm_cmplt_epi8(A, B);
}
+TEST_CONSTEXPR(match_v16qi(_mm_cmplt_epi8((__m128i)(__v16qi){5,2,3,4,1,6,7,8,9,5,11,12,13,10,15,8}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), -1, 0, -1, 0, -1, -1, -1, 0, 0, -1, -1, 0, -1, -1, -1, -1));
__m128i test_mm_cmplt_epi16(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmplt_epi16
// CHECK: icmp sgt <8 x i16>
return _mm_cmplt_epi16(A, B);
}
+TEST_CONSTEXPR(match_v8hi(_mm_cmplt_epi16((__m128i)(__v8hi){5,2,3,4,1,6,7,8}, (__m128i)(__v8hi){10,2,6,4,5,12,14,8}), -1, 0, -1, 0, -1, -1, -1, 0));
__m128i test_mm_cmplt_epi32(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmplt_epi32
// CHECK: icmp sgt <4 x i32>
return _mm_cmplt_epi32(A, B);
}
+TEST_CONSTEXPR(match_v4si(_mm_cmplt_epi32((__m128i)(__v4si){5,2,3,4}, (__m128i)(__v4si){10,2,6,4}), -1,0,-1,0));
__m128d test_mm_cmplt_pd(__m128d A, __m128d B) {
// CHECK-LABEL: test_mm_cmplt_pd
diff --git a/clang/test/CodeGen/X86/sse41-builtins.c b/clang/test/CodeGen/X86/sse41-builtins.c
index 500b780d49057..4f9f1530ce427 100644
--- a/clang/test/CodeGen/X86/sse41-builtins.c
+++ b/clang/test/CodeGen/X86/sse41-builtins.c
@@ -79,6 +79,7 @@ __m128i test_mm_cmpeq_epi64(__m128i A, __m128i B) {
// CHECK: sext <2 x i1> %{{.*}} to <2 x i64>
return _mm_cmpeq_epi64(A, B);
}
+TEST_CONSTEXPR(match_v2di(_mm_cmpeq_epi64((__m128i)(__v2di){+1, -8}, (__m128i)(__v2di){-10, -8}), 0, -1));
__m128i test_mm_cvtepi8_epi16(__m128i a) {
// CHECK-LABEL: test_mm_cvtepi8_epi16
diff --git a/clang/test/CodeGen/X86/sse42-builtins.c b/clang/test/CodeGen/X86/sse42-builtins.c
index d0c0cce33e1d0..aa598b8f78069 100644
--- a/clang/test/CodeGen/X86/sse42-builtins.c
+++ b/clang/test/CodeGen/X86/sse42-builtins.c
@@ -9,6 +9,7 @@
#include <immintrin.h>
+#include "builtin_test_helpers.h"
// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse42-intrinsics-fast-isel.ll
@@ -59,6 +60,7 @@ __m128i test_mm_cmpgt_epi64(__m128i A, __m128i B) {
// CHECK: icmp sgt <2 x i64>
return _mm_cmpgt_epi64(A, B);
}
+TEST_CONSTEXPR(match_v2di(_mm_cmpgt_epi64((__m128i)(__v2di){+1, -8}, (__m128i)(__v2di){-10, -8}), -1, 0));
int test_mm_cmpistra(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpistra
|
@llvm/pr-subscribers-clang Author: Smokey (smoke-y) ChangesCloses #155413 Full diff: https://github.com/llvm/llvm-project/pull/155656.diff 7 Files Affected:
diff --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h
index ce5b2b7544d8c..05bd15385d149 100644
--- a/clang/lib/Headers/avx2intrin.h
+++ b/clang/lib/Headers/avx2intrin.h
@@ -637,7 +637,7 @@ _mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
/// \param __b
/// A 256-bit integer vector containing one of the inputs.
/// \returns A 256-bit integer vector containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi8(__m256i __a, __m256i __b)
{
return (__m256i)((__v32qi)__a == (__v32qi)__b);
@@ -663,7 +663,7 @@ _mm256_cmpeq_epi8(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [16 x i16] containing one of the inputs.
/// \returns A 256-bit vector of [16 x i16] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi16(__m256i __a, __m256i __b)
{
return (__m256i)((__v16hi)__a == (__v16hi)__b);
@@ -689,7 +689,7 @@ _mm256_cmpeq_epi16(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [8 x i32] containing one of the inputs.
/// \returns A 256-bit vector of [8 x i32] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi32(__m256i __a, __m256i __b)
{
return (__m256i)((__v8si)__a == (__v8si)__b);
@@ -715,7 +715,7 @@ _mm256_cmpeq_epi32(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [4 x i64] containing one of the inputs.
/// \returns A 256-bit vector of [4 x i64] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpeq_epi64(__m256i __a, __m256i __b)
{
return (__m256i)((__v4di)__a == (__v4di)__b);
@@ -741,7 +741,7 @@ _mm256_cmpeq_epi64(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit integer vector containing one of the inputs.
/// \returns A 256-bit integer vector containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi8(__m256i __a, __m256i __b)
{
/* This function always performs a signed comparison, but __v32qi is a char
@@ -769,7 +769,7 @@ _mm256_cmpgt_epi8(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [16 x i16] containing one of the inputs.
/// \returns A 256-bit vector of [16 x i16] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi16(__m256i __a, __m256i __b)
{
return (__m256i)((__v16hi)__a > (__v16hi)__b);
@@ -795,7 +795,7 @@ _mm256_cmpgt_epi16(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [8 x i32] containing one of the inputs.
/// \returns A 256-bit vector of [8 x i32] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi32(__m256i __a, __m256i __b)
{
return (__m256i)((__v8si)__a > (__v8si)__b);
@@ -821,7 +821,7 @@ _mm256_cmpgt_epi32(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [4 x i64] containing one of the inputs.
/// \returns A 256-bit vector of [4 x i64] containing the result.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
_mm256_cmpgt_epi64(__m256i __a, __m256i __b)
{
return (__m256i)((__v4di)__a > (__v4di)__b);
diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index 8b6b62458dac1..7f69019e01b06 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -3090,7 +3090,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi64(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi8(__m128i __a,
__m128i __b) {
return (__m128i)((__v16qi)__a == (__v16qi)__b);
}
@@ -3109,7 +3109,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi16(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi16(__m128i __a,
__m128i __b) {
return (__m128i)((__v8hi)__a == (__v8hi)__b);
}
@@ -3128,7 +3128,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi16(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi32(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi32(__m128i __a,
__m128i __b) {
return (__m128i)((__v4si)__a == (__v4si)__b);
}
@@ -3148,7 +3148,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi32(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi8(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi8(__m128i __a,
__m128i __b) {
/* This function always performs a signed comparison, but __v16qi is a char
which may be signed or unsigned, so use __v16qs. */
@@ -3170,7 +3170,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi8(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi16(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi16(__m128i __a,
__m128i __b) {
return (__m128i)((__v8hi)__a > (__v8hi)__b);
}
@@ -3190,7 +3190,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi16(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi32(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi32(__m128i __a,
__m128i __b) {
return (__m128i)((__v4si)__a > (__v4si)__b);
}
@@ -3210,7 +3210,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi32(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi8(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmplt_epi8(__m128i __a,
__m128i __b) {
return _mm_cmpgt_epi8(__b, __a);
}
@@ -3230,7 +3230,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi8(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi16(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmplt_epi16(__m128i __a,
__m128i __b) {
return _mm_cmpgt_epi16(__b, __a);
}
@@ -3250,7 +3250,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi16(__m128i __a,
/// \param __b
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi32(__m128i __a,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmplt_epi32(__m128i __a,
__m128i __b) {
return _mm_cmpgt_epi32(__b, __a);
}
diff --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h
index 57d0d329312af..3f44c786fb75f 100644
--- a/clang/lib/Headers/smmintrin.h
+++ b/clang/lib/Headers/smmintrin.h
@@ -1211,7 +1211,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_testnzc_si128(__m128i __M,
/// \param __V2
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi64(__m128i __V1,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi64(__m128i __V1,
__m128i __V2) {
return (__m128i)((__v2di)__V1 == (__v2di)__V2);
}
@@ -2338,7 +2338,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_minpos_epu16(__m128i __V) {
/// \param __V2
/// A 128-bit integer vector.
/// \returns A 128-bit integer vector containing the comparison results.
-static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi64(__m128i __V1,
+static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpgt_epi64(__m128i __V1,
__m128i __V2) {
return (__m128i)((__v2di)__V1 > (__v2di)__V2);
}
diff --git a/clang/test/CodeGen/X86/avx2-builtins.c b/clang/test/CodeGen/X86/avx2-builtins.c
index 49e35230ba225..84a4db9695b88 100644
--- a/clang/test/CodeGen/X86/avx2-builtins.c
+++ b/clang/test/CodeGen/X86/avx2-builtins.c
@@ -287,48 +287,56 @@ __m256i test_mm256_cmpeq_epi8(__m256i a, __m256i b) {
// CHECK: icmp eq <32 x i8>
return _mm256_cmpeq_epi8(a, b);
}
+TEST_CONSTEXPR(match_v32qi(_mm256_cmpeq_epi8((__m256i)(__v32qi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}, (__m256i)(__v32qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16,17,36,38,20,42,22,46,24,50,26,54,28,58,30,62,32}), 0,-1,0,-1,-1,0,0,-1,-1,0,0,-1,0,-1,0,-1,-1,0,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1));
__m256i test_mm256_cmpeq_epi16(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpeq_epi16
// CHECK: icmp eq <16 x i16>
return _mm256_cmpeq_epi16(a, b);
}
+TEST_CONSTEXPR(match_v16hi(_mm256_cmpeq_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16}, (__m256i)(__v16hi){-10, -2, +6, -4, +5, -12, +14, -8, +9, -20, +22, -12, +26, -14, +30, -16}), 0, -1, 0, -1, -1, 0, 0, -1, -1, 0, 0, -1, 0, -1, 0, -1));
__m256i test_mm256_cmpeq_epi32(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpeq_epi32
// CHECK: icmp eq <8 x i32>
return _mm256_cmpeq_epi32(a, b);
}
+TEST_CONSTEXPR(match_v8si(_mm256_cmpeq_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-10, -2, +6, -4, +5, -12, +14, -8}), 0, -1, 0, -1, -1, 0, 0, -1));
__m256i test_mm256_cmpeq_epi64(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpeq_epi64
// CHECK: icmp eq <4 x i64>
return _mm256_cmpeq_epi64(a, b);
}
+TEST_CONSTEXPR(match_v4di(_mm256_cmpeq_epi64((__m256i)(__v4di){+1, -2, +3, -4}, (__m256i)(__v4di){-10, -2, +6, -4}), 0, -1, 0, -1));
__m256i test_mm256_cmpgt_epi8(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi8
// CHECK: icmp sgt <32 x i8>
return _mm256_cmpgt_epi8(a, b);
}
+TEST_CONSTEXPR(match_v32qi(_mm256_cmpgt_epi8((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v32qi){10, 2, 6, 5, 30, 7, 8, 1, 20, 3, 12, 8, 25, 10, 9, 2, 10, 2, 6, 5, 30, 7, 8, 1, 20, 3, 12, 8, 25, 10, 9, 2}), 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1));
__m256i test_mm256_cmpgt_epi16(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi16
// CHECK: icmp sgt <16 x i16>
return _mm256_cmpgt_epi16(a, b);
}
+TEST_CONSTEXPR(match_v16hi(_mm256_cmpgt_epi16((__m256i)(__v16hi){+1, -2, +3, -4, +5, -6, +7, -8, +1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v16hi){-10, -2, +6, -5, +30, -7, +8, -1, -10, -2, +6, -5, +30, -7, +8, -1}), -1, 0, 0, -1, 0, -1, 0, 0, -1, 0, 0, -1, 0, -1, 0, 0));
__m256i test_mm256_cmpgt_epi32(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi32
// CHECK: icmp sgt <8 x i32>
return _mm256_cmpgt_epi32(a, b);
}
+TEST_CONSTEXPR(match_v8si(_mm256_cmpgt_epi32((__m256i)(__v8si){+1, -2, +3, -4, +5, -6, +7, -8}, (__m256i)(__v8si){-10, -2, +6, -5, +30, -7, +8, -1}), -1, 0, 0, -1, 0, -1, 0, 0));
__m256i test_mm256_cmpgt_epi64(__m256i a, __m256i b) {
// CHECK-LABEL: test_mm256_cmpgt_epi64
// CHECK: icmp sgt <4 x i64>
return _mm256_cmpgt_epi64(a, b);
}
+TEST_CONSTEXPR(match_v4di(_mm256_cmpgt_epi64((__m256i)(__v4di){+1, -2, +3, -4}, (__m256i)(__v4di){-10, -2, +6, -5}), -1, 0, 0, -1));
__m256i test_mm256_cvtepi8_epi16(__m128i a) {
// CHECK-LABEL: test_mm256_cvtepi8_epi16
diff --git a/clang/test/CodeGen/X86/sse2-builtins.c b/clang/test/CodeGen/X86/sse2-builtins.c
index 38d5e877a5036..a578f04c97c71 100644
--- a/clang/test/CodeGen/X86/sse2-builtins.c
+++ b/clang/test/CodeGen/X86/sse2-builtins.c
@@ -243,18 +243,21 @@ __m128i test_mm_cmpeq_epi8(__m128i A, __m128i B) {
// CHECK: icmp eq <16 x i8>
return _mm_cmpeq_epi8(A, B);
}
+TEST_CONSTEXPR(match_v16qi(_mm_cmpeq_epi8((__m128i)(__v16qi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), 0,-1,0,-1,-1,0,0,-1,-1,0,0,-1,0,-1,0,-1));
__m128i test_mm_cmpeq_epi16(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpeq_epi16
// CHECK: icmp eq <8 x i16>
return _mm_cmpeq_epi16(A, B);
}
+TEST_CONSTEXPR(match_v8hi(_mm_cmpeq_epi16((__m128i)(__v8hi){+1, -2, +3, -4, +5, -6, +7, -8}, (__m128i)(__v8hi){-10, -2, +6, -4, +5, -12, +14, -8}), 0, -1, 0, -1, -1, 0, 0, -1));
__m128i test_mm_cmpeq_epi32(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpeq_epi32
// CHECK: icmp eq <4 x i32>
return _mm_cmpeq_epi32(A, B);
}
+TEST_CONSTEXPR(match_v4si(_mm_cmpeq_epi32((__m128i)(__v4si){+1, -2, +3, -4}, (__m128i)(__v4si){-10, -2, +6, -4}), 0, -1, 0, -1));
__m128d test_mm_cmpeq_pd(__m128d A, __m128d B) {
// CHECK-LABEL: test_mm_cmpeq_pd
@@ -293,18 +296,21 @@ __m128i test_mm_cmpgt_epi8(__m128i A, __m128i B) {
// CHECK: icmp sgt <16 x i8>
return _mm_cmpgt_epi8(A, B);
}
+TEST_CONSTEXPR(match_v16qi(_mm_cmpgt_epi8((__m128i)(__v16qi){15,2,8,4,12,6,20,8,25,10,30,12,35,14,40,16}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), -1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0));
__m128i test_mm_cmpgt_epi16(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpgt_epi16
// CHECK: icmp sgt <8 x i16>
return _mm_cmpgt_epi16(A, B);
}
+TEST_CONSTEXPR(match_v8hi(_mm_cmpgt_epi16((__m128i)(__v8hi){15,2,8,4,12,6,20,8}, (__m128i)(__v8hi){10,2,6,4,5,12,14,8}), -1,0,-1,0,-1,0,-1,0));
__m128i test_mm_cmpgt_epi32(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpgt_epi32
// CHECK: icmp sgt <4 x i32>
return _mm_cmpgt_epi32(A, B);
}
+TEST_CONSTEXPR(match_v4si(_mm_cmpgt_epi32((__m128i)(__v4si){15,2,8,4}, (__m128i)(__v4si){10,2,6,4}), -1,0,-1,0));
__m128d test_mm_cmpgt_pd(__m128d A, __m128d B) {
// CHECK-LABEL: test_mm_cmpgt_pd
@@ -343,18 +349,21 @@ __m128i test_mm_cmplt_epi8(__m128i A, __m128i B) {
// CHECK: icmp sgt <16 x i8>
return _mm_cmplt_epi8(A, B);
}
+TEST_CONSTEXPR(match_v16qi(_mm_cmplt_epi8((__m128i)(__v16qi){5,2,3,4,1,6,7,8,9,5,11,12,13,10,15,8}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), -1, 0, -1, 0, -1, -1, -1, 0, 0, -1, -1, 0, -1, -1, -1, -1));
__m128i test_mm_cmplt_epi16(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmplt_epi16
// CHECK: icmp sgt <8 x i16>
return _mm_cmplt_epi16(A, B);
}
+TEST_CONSTEXPR(match_v8hi(_mm_cmplt_epi16((__m128i)(__v8hi){5,2,3,4,1,6,7,8}, (__m128i)(__v8hi){10,2,6,4,5,12,14,8}), -1, 0, -1, 0, -1, -1, -1, 0));
__m128i test_mm_cmplt_epi32(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmplt_epi32
// CHECK: icmp sgt <4 x i32>
return _mm_cmplt_epi32(A, B);
}
+TEST_CONSTEXPR(match_v4si(_mm_cmplt_epi32((__m128i)(__v4si){5,2,3,4}, (__m128i)(__v4si){10,2,6,4}), -1,0,-1,0));
__m128d test_mm_cmplt_pd(__m128d A, __m128d B) {
// CHECK-LABEL: test_mm_cmplt_pd
diff --git a/clang/test/CodeGen/X86/sse41-builtins.c b/clang/test/CodeGen/X86/sse41-builtins.c
index 500b780d49057..4f9f1530ce427 100644
--- a/clang/test/CodeGen/X86/sse41-builtins.c
+++ b/clang/test/CodeGen/X86/sse41-builtins.c
@@ -79,6 +79,7 @@ __m128i test_mm_cmpeq_epi64(__m128i A, __m128i B) {
// CHECK: sext <2 x i1> %{{.*}} to <2 x i64>
return _mm_cmpeq_epi64(A, B);
}
+TEST_CONSTEXPR(match_v2di(_mm_cmpeq_epi64((__m128i)(__v2di){+1, -8}, (__m128i)(__v2di){-10, -8}), 0, -1));
__m128i test_mm_cvtepi8_epi16(__m128i a) {
// CHECK-LABEL: test_mm_cvtepi8_epi16
diff --git a/clang/test/CodeGen/X86/sse42-builtins.c b/clang/test/CodeGen/X86/sse42-builtins.c
index d0c0cce33e1d0..aa598b8f78069 100644
--- a/clang/test/CodeGen/X86/sse42-builtins.c
+++ b/clang/test/CodeGen/X86/sse42-builtins.c
@@ -9,6 +9,7 @@
#include <immintrin.h>
+#include "builtin_test_helpers.h"
// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse42-intrinsics-fast-isel.ll
@@ -59,6 +60,7 @@ __m128i test_mm_cmpgt_epi64(__m128i A, __m128i B) {
// CHECK: icmp sgt <2 x i64>
return _mm_cmpgt_epi64(A, B);
}
+TEST_CONSTEXPR(match_v2di(_mm_cmpgt_epi64((__m128i)(__v2di){+1, -8}, (__m128i)(__v2di){-10, -8}), -1, 0));
int test_mm_cmpistra(__m128i A, __m128i B) {
// CHECK-LABEL: test_mm_cmpistra
|
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions c,h -- clang/lib/Headers/avx2intrin.h clang/lib/Headers/emmintrin.h clang/lib/Headers/smmintrin.h clang/test/CodeGen/X86/avx2-builtins.c clang/test/CodeGen/X86/sse2-builtins.c clang/test/CodeGen/X86/sse41-builtins.c clang/test/CodeGen/X86/sse42-builtins.c
View the diff from clang-format here.diff --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h
index bcf6278fa..85a096bd1 100644
--- a/clang/lib/Headers/avx2intrin.h
+++ b/clang/lib/Headers/avx2intrin.h
@@ -635,8 +635,7 @@ _mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M)
/// A 256-bit integer vector containing one of the inputs.
/// \returns A 256-bit integer vector containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpeq_epi8(__m256i __a, __m256i __b)
-{
+_mm256_cmpeq_epi8(__m256i __a, __m256i __b) {
return (__m256i)((__v32qi)__a == (__v32qi)__b);
}
@@ -661,8 +660,7 @@ _mm256_cmpeq_epi8(__m256i __a, __m256i __b)
/// A 256-bit vector of [16 x i16] containing one of the inputs.
/// \returns A 256-bit vector of [16 x i16] containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpeq_epi16(__m256i __a, __m256i __b)
-{
+_mm256_cmpeq_epi16(__m256i __a, __m256i __b) {
return (__m256i)((__v16hi)__a == (__v16hi)__b);
}
@@ -687,8 +685,7 @@ _mm256_cmpeq_epi16(__m256i __a, __m256i __b)
/// A 256-bit vector of [8 x i32] containing one of the inputs.
/// \returns A 256-bit vector of [8 x i32] containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpeq_epi32(__m256i __a, __m256i __b)
-{
+_mm256_cmpeq_epi32(__m256i __a, __m256i __b) {
return (__m256i)((__v8si)__a == (__v8si)__b);
}
@@ -713,8 +710,7 @@ _mm256_cmpeq_epi32(__m256i __a, __m256i __b)
/// A 256-bit vector of [4 x i64] containing one of the inputs.
/// \returns A 256-bit vector of [4 x i64] containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpeq_epi64(__m256i __a, __m256i __b)
-{
+_mm256_cmpeq_epi64(__m256i __a, __m256i __b) {
return (__m256i)((__v4di)__a == (__v4di)__b);
}
@@ -739,8 +735,7 @@ _mm256_cmpeq_epi64(__m256i __a, __m256i __b)
/// A 256-bit integer vector containing one of the inputs.
/// \returns A 256-bit integer vector containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpgt_epi8(__m256i __a, __m256i __b)
-{
+_mm256_cmpgt_epi8(__m256i __a, __m256i __b) {
/* This function always performs a signed comparison, but __v32qi is a char
which may be signed or unsigned, so use __v32qs. */
return (__m256i)((__v32qs)__a > (__v32qs)__b);
@@ -767,8 +762,7 @@ _mm256_cmpgt_epi8(__m256i __a, __m256i __b)
/// A 256-bit vector of [16 x i16] containing one of the inputs.
/// \returns A 256-bit vector of [16 x i16] containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpgt_epi16(__m256i __a, __m256i __b)
-{
+_mm256_cmpgt_epi16(__m256i __a, __m256i __b) {
return (__m256i)((__v16hi)__a > (__v16hi)__b);
}
@@ -793,8 +787,7 @@ _mm256_cmpgt_epi16(__m256i __a, __m256i __b)
/// A 256-bit vector of [8 x i32] containing one of the inputs.
/// \returns A 256-bit vector of [8 x i32] containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpgt_epi32(__m256i __a, __m256i __b)
-{
+_mm256_cmpgt_epi32(__m256i __a, __m256i __b) {
return (__m256i)((__v8si)__a > (__v8si)__b);
}
@@ -819,8 +812,7 @@ _mm256_cmpgt_epi32(__m256i __a, __m256i __b)
/// A 256-bit vector of [4 x i64] containing one of the inputs.
/// \returns A 256-bit vector of [4 x i64] containing the result.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_cmpgt_epi64(__m256i __a, __m256i __b)
-{
+_mm256_cmpgt_epi64(__m256i __a, __m256i __b) {
return (__m256i)((__v4di)__a > (__v4di)__b);
}
|
clang/lib/Headers/emmintrin.h
Outdated
@@ -3090,7 +3090,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi64(__m128i __a, | |||
/// \param __b | |||
/// A 128-bit integer vector. | |||
/// \returns A 128-bit integer vector containing the comparison results. | |||
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a, | |||
static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cmpeq_epi8(__m128i __a, | |||
__m128i __b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these lines needs clang-formating:
static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR
_mm_cmpeq_epi8(__m128i __a, __m128i __b) {
@@ -290,48 +290,56 @@ __m256i test_mm256_cmpeq_epi8(__m256i a, __m256i b) { | |||
// CHECK: icmp eq <32 x i8> | |||
return _mm256_cmpeq_epi8(a, b); | |||
} | |||
TEST_CONSTEXPR(match_v32qi(_mm256_cmpeq_epi8((__m256i)(__v32qi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}, (__m256i)(__v32qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16,17,36,38,20,42,22,46,24,50,26,54,28,58,30,62,32}), 0,-1,0,-1,-1,0,0,-1,-1,0,0,-1,0,-1,0,-1,-1,0,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use __v32qs instead of __v32qi to allow you to test -ve values
@@ -243,18 +243,21 @@ __m128i test_mm_cmpeq_epi8(__m128i A, __m128i B) { | |||
// CHECK: icmp eq <16 x i8> | |||
return _mm_cmpeq_epi8(A, B); | |||
} | |||
TEST_CONSTEXPR(match_v16qi(_mm_cmpeq_epi8((__m128i)(__v16qi){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), 0,-1,0,-1,-1,0,0,-1,-1,0,0,-1,0,-1,0,-1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__v16qi -> __v16qs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a few signed char tests need converting
@@ -293,18 +296,21 @@ __m128i test_mm_cmpgt_epi8(__m128i A, __m128i B) { | |||
// CHECK: icmp sgt <16 x i8> | |||
return _mm_cmpgt_epi8(A, B); | |||
} | |||
TEST_CONSTEXPR(match_v16qi(_mm_cmpgt_epi8((__m128i)(__v16qi){15,2,8,4,12,6,20,8,25,10,30,12,35,14,40,16}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), -1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__v16qs
@@ -343,18 +349,21 @@ __m128i test_mm_cmplt_epi8(__m128i A, __m128i B) { | |||
// CHECK: icmp sgt <16 x i8> | |||
return _mm_cmplt_epi8(A, B); | |||
} | |||
TEST_CONSTEXPR(match_v16qi(_mm_cmplt_epi8((__m128i)(__v16qi){5,2,3,4,1,6,7,8,9,5,11,12,13,10,15,8}, (__m128i)(__v16qi){10,2,6,4,5,12,14,8,9,20,22,12,26,14,30,16}), -1, 0, -1, 0, -1, -1, -1, 0, 0, -1, -1, 0, -1, -1, -1, -1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__v16qs
|
||
__m256i test_mm256_cmpgt_epi8(__m256i a, __m256i b) { | ||
// CHECK-LABEL: test_mm256_cmpgt_epi8 | ||
// CHECK: icmp sgt <32 x i8> | ||
return _mm256_cmpgt_epi8(a, b); | ||
} | ||
TEST_CONSTEXPR(match_v32qi(_mm256_cmpgt_epi8((__m256i)(__v32qi){1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, (__m256i)(__v32qi){10, 2, 6, 5, 30, 7, 8, 1, 20, 3, 12, 8, 25, 10, 9, 2, 10, 2, 6, 5, 30, 7, 8, 1, 20, 3, 12, 8, 25, 10, 9, 2}), 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, -1, -1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__v32qs
This PR doesn't require so many commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there! Just don't clang-format lines of a file unless you're editing them - it makes the patch too noisy
clang/lib/Headers/avx2intrin.h
Outdated
#define _mm256_mpsadbw_epu8(X, Y, M) \ | ||
((__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \ | ||
#define _mm256_mpsadbw_epu8(X, Y, M) \ | ||
((__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(style) don't clang-format lines you aren't changing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avx2intrin.h is very broken - you would probably be better off undoing all changes in that file and redoing it
Hey I fixed the file(I screwed up some git command which caused it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers
@smoke-y Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Closes #155413