-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Headers][X86] Allow integer arithmetic intrinsics to be used in constexpr #152986
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. |
6f32094 to
2afd5b9
Compare
…texpr Includes SSE2/AVX2/AVX512F/AVX512BW/AVX512DQ
2afd5b9 to
6cce086
Compare
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions h -- clang/lib/Headers/avx2intrin.h clang/lib/Headers/avx512bwintrin.h clang/lib/Headers/avx512dqintrin.h clang/lib/Headers/avx512fintrin.h clang/lib/Headers/avx512vldqintrin.h clang/lib/Headers/emmintrin.h clang/lib/Headers/smmintrin.hView the diff from clang-format here.diff --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h
index 3e289bf7d..892d3a9a7 100644
--- a/clang/lib/Headers/avx2intrin.h
+++ b/clang/lib/Headers/avx2intrin.h
@@ -292,8 +292,7 @@ _mm256_packus_epi32(__m256i __V1, __m256i __V2)
/// A 256-bit integer vector containing one of the source operands.
/// \returns A 256-bit integer vector containing the sums.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_add_epi8(__m256i __a, __m256i __b)
-{
+_mm256_add_epi8(__m256i __a, __m256i __b) {
return (__m256i)((__v32qu)__a + (__v32qu)__b);
}
@@ -311,8 +310,7 @@ _mm256_add_epi8(__m256i __a, __m256i __b)
/// A 256-bit vector of [16 x i16] containing one of the source operands.
/// \returns A 256-bit vector of [16 x i16] containing the sums.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_add_epi16(__m256i __a, __m256i __b)
-{
+_mm256_add_epi16(__m256i __a, __m256i __b) {
return (__m256i)((__v16hu)__a + (__v16hu)__b);
}
@@ -330,8 +328,7 @@ _mm256_add_epi16(__m256i __a, __m256i __b)
/// A 256-bit vector of [8 x i32] containing one of the source operands.
/// \returns A 256-bit vector of [8 x i32] containing the sums.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_add_epi32(__m256i __a, __m256i __b)
-{
+_mm256_add_epi32(__m256i __a, __m256i __b) {
return (__m256i)((__v8su)__a + (__v8su)__b);
}
@@ -349,8 +346,7 @@ _mm256_add_epi32(__m256i __a, __m256i __b)
/// A 256-bit vector of [4 x i64] containing one of the source operands.
/// \returns A 256-bit vector of [4 x i64] containing the sums.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_add_epi64(__m256i __a, __m256i __b)
-{
+_mm256_add_epi64(__m256i __a, __m256i __b) {
return (__m256i)((__v4du)__a + (__v4du)__b);
}
@@ -642,8 +638,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);
}
@@ -668,8 +663,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);
}
@@ -694,8 +688,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);
}
@@ -720,8 +713,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);
}
@@ -746,8 +738,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);
@@ -774,8 +765,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);
}
@@ -800,8 +790,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);
}
@@ -826,8 +815,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);
}
@@ -1774,9 +1762,8 @@ _mm256_mullo_epi16(__m256i __a, __m256i __b)
/// \param __b
/// A 256-bit vector of [8 x i32] containing one of the source operands.
/// \returns A 256-bit vector of [8 x i32] containing the products.
-static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_mullo_epi32 (__m256i __a, __m256i __b)
-{
+static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
+_mm256_mullo_epi32(__m256i __a, __m256i __b) {
return (__m256i)((__v8su)__a * (__v8su)__b);
}
@@ -2503,8 +2490,7 @@ _mm256_srl_epi64(__m256i __a, __m128i __count)
/// A 256-bit integer vector containing the subtrahends.
/// \returns A 256-bit integer vector containing the differences.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_sub_epi8(__m256i __a, __m256i __b)
-{
+_mm256_sub_epi8(__m256i __a, __m256i __b) {
return (__m256i)((__v32qu)__a - (__v32qu)__b);
}
@@ -2530,8 +2516,7 @@ _mm256_sub_epi8(__m256i __a, __m256i __b)
/// A 256-bit vector of [16 x i16] containing the subtrahends.
/// \returns A 256-bit vector of [16 x i16] containing the differences.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_sub_epi16(__m256i __a, __m256i __b)
-{
+_mm256_sub_epi16(__m256i __a, __m256i __b) {
return (__m256i)((__v16hu)__a - (__v16hu)__b);
}
@@ -2556,8 +2541,7 @@ _mm256_sub_epi16(__m256i __a, __m256i __b)
/// A 256-bit vector of [8 x i32] containing the subtrahends.
/// \returns A 256-bit vector of [8 x i32] containing the differences.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_sub_epi32(__m256i __a, __m256i __b)
-{
+_mm256_sub_epi32(__m256i __a, __m256i __b) {
return (__m256i)((__v8su)__a - (__v8su)__b);
}
@@ -2582,8 +2566,7 @@ _mm256_sub_epi32(__m256i __a, __m256i __b)
/// A 256-bit vector of [4 x i64] containing the subtrahends.
/// \returns A 256-bit vector of [4 x i64] containing the differences.
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_sub_epi64(__m256i __a, __m256i __b)
-{
+_mm256_sub_epi64(__m256i __a, __m256i __b) {
return (__m256i)((__v4du)__a - (__v4du)__b);
}
diff --git a/clang/lib/Headers/avx512bwintrin.h b/clang/lib/Headers/avx512bwintrin.h
index 6d0ab9d13..4873ed668 100644
--- a/clang/lib/Headers/avx512bwintrin.h
+++ b/clang/lib/Headers/avx512bwintrin.h
@@ -371,7 +371,7 @@ static __inline__ void __DEFAULT_FN_ATTRS _store_mask64(__mmask64 *__A,
_mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE)
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_add_epi8 (__m512i __A, __m512i __B) {
+_mm512_add_epi8(__m512i __A, __m512i __B) {
return (__m512i) ((__v64qu) __A + (__v64qu) __B);
}
@@ -390,7 +390,7 @@ _mm512_maskz_add_epi8(__mmask64 __U, __m512i __A, __m512i __B) {
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_sub_epi8 (__m512i __A, __m512i __B) {
+_mm512_sub_epi8(__m512i __A, __m512i __B) {
return (__m512i) ((__v64qu) __A - (__v64qu) __B);
}
@@ -409,7 +409,7 @@ _mm512_maskz_sub_epi8(__mmask64 __U, __m512i __A, __m512i __B) {
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_add_epi16 (__m512i __A, __m512i __B) {
+_mm512_add_epi16(__m512i __A, __m512i __B) {
return (__m512i) ((__v32hu) __A + (__v32hu) __B);
}
@@ -428,7 +428,7 @@ _mm512_maskz_add_epi16(__mmask32 __U, __m512i __A, __m512i __B) {
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_sub_epi16 (__m512i __A, __m512i __B) {
+_mm512_sub_epi16(__m512i __A, __m512i __B) {
return (__m512i) ((__v32hu) __A - (__v32hu) __B);
}
diff --git a/clang/lib/Headers/avx512dqintrin.h b/clang/lib/Headers/avx512dqintrin.h
index 385ef1d42..e97ee4f74 100644
--- a/clang/lib/Headers/avx512dqintrin.h
+++ b/clang/lib/Headers/avx512dqintrin.h
@@ -157,7 +157,7 @@ _store_mask8(__mmask8 *__A, __mmask8 __B) {
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_mullo_epi64 (__m512i __A, __m512i __B) {
+_mm512_mullo_epi64(__m512i __A, __m512i __B) {
return (__m512i) ((__v8du) __A * (__v8du) __B);
}
diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h
index 0ec950628..6a869c797 100644
--- a/clang/lib/Headers/avx512fintrin.h
+++ b/clang/lib/Headers/avx512fintrin.h
@@ -882,8 +882,7 @@ _mm512_maskz_add_epi64(__mmask8 __U, __m512i __A, __m512i __B)
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_sub_epi64 (__m512i __A, __m512i __B)
-{
+_mm512_sub_epi64(__m512i __A, __m512i __B) {
return (__m512i) ((__v8du) __A - (__v8du) __B);
}
@@ -904,8 +903,7 @@ _mm512_maskz_sub_epi64(__mmask8 __U, __m512i __A, __m512i __B)
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_add_epi32 (__m512i __A, __m512i __B)
-{
+_mm512_add_epi32(__m512i __A, __m512i __B) {
return (__m512i) ((__v16su) __A + (__v16su) __B);
}
@@ -926,8 +924,7 @@ _mm512_maskz_add_epi32 (__mmask16 __U, __m512i __A, __m512i __B)
}
static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_sub_epi32 (__m512i __A, __m512i __B)
-{
+_mm512_sub_epi32(__m512i __A, __m512i __B) {
return (__m512i) ((__v16su) __A - (__v16su) __B);
}
@@ -1462,8 +1459,7 @@ _mm512_maskz_mul_epu32(__mmask8 __M, __m512i __X, __m512i __Y)
}
static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_mullo_epi32 (__m512i __A, __m512i __B)
-{
+_mm512_mullo_epi32(__m512i __A, __m512i __B) {
return (__m512i) ((__v16su) __A * (__v16su) __B);
}
diff --git a/clang/lib/Headers/avx512vldqintrin.h b/clang/lib/Headers/avx512vldqintrin.h
index a1728b9da..ce1cd2328 100644
--- a/clang/lib/Headers/avx512vldqintrin.h
+++ b/clang/lib/Headers/avx512vldqintrin.h
@@ -25,7 +25,7 @@
__min_vector_width__(256)))
static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR
-_mm256_mullo_epi64 (__m256i __A, __m256i __B) {
+_mm256_mullo_epi64(__m256i __A, __m256i __B) {
return (__m256i) ((__v4du) __A * (__v4du) __B);
}
@@ -44,7 +44,7 @@ _mm256_maskz_mullo_epi64(__mmask8 __U, __m256i __A, __m256i __B) {
}
static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR
-_mm_mullo_epi64 (__m128i __A, __m128i __B) {
+_mm_mullo_epi64(__m128i __A, __m128i __B) {
return (__m128i) ((__v2du) __A * (__v2du) __B);
}
|
| __min_vector_width__(256))) | ||
|
|
||
| static __inline__ __m256i __DEFAULT_FN_ATTRS256 | ||
| static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR |
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.
avx512vldqintrin.h hasn't had any constexpr intrinsics yet - you need to define the __DEFAULT_FN_ATTRS256_CONSTEXPR at the top of the header (and undef it at the end) - see some of the other files to see examples of this.
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.
Thanks, I will try it later.
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.
This was fixed by #153363
For SSE2/AVX2/AVX512F/AVX512BW/AVX512DQ
fix: #152490