-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[Headers][X86] Allow _mm512_set1_epi8/16/pd/ps intrinsics to be used in constexpr #152746
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…in constexpr Pulled out of llvm#152288 as I need this to proceed with several other patches
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang Author: Simon Pilgrim (RKSimon) ChangesPulled out of #152288 as I need this to proceed with several other patches Full diff: https://github.com/llvm/llvm-project/pull/152746.diff 2 Files Affected:
diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h
index e3bc71ed8e918..95b80cc59bb02 100644
--- a/clang/lib/Headers/avx512fintrin.h
+++ b/clang/lib/Headers/avx512fintrin.h
@@ -277,20 +277,20 @@ _mm512_setzero_pd(void) {
return __extension__(__m512d){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
}
-static __inline __m512 __DEFAULT_FN_ATTRS512
+static __inline __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_ps(float __w)
{
return __extension__ (__m512){ __w, __w, __w, __w, __w, __w, __w, __w,
__w, __w, __w, __w, __w, __w, __w, __w };
}
-static __inline __m512d __DEFAULT_FN_ATTRS512
+static __inline __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_pd(double __w)
{
return __extension__ (__m512d){ __w, __w, __w, __w, __w, __w, __w, __w };
}
-static __inline __m512i __DEFAULT_FN_ATTRS512
+static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_epi8(char __w)
{
return __extension__ (__m512i)(__v64qi){
@@ -304,7 +304,7 @@ _mm512_set1_epi8(char __w)
__w, __w, __w, __w, __w, __w, __w, __w };
}
-static __inline __m512i __DEFAULT_FN_ATTRS512
+static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
_mm512_set1_epi16(short __w)
{
return __extension__ (__m512i)(__v32hi){
diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c
index d59799e2c24e5..8c446f5715c00 100644
--- a/clang/test/CodeGen/X86/avx512f-builtins.c
+++ b/clang/test/CodeGen/X86/avx512f-builtins.c
@@ -439,6 +439,22 @@ __m512d test_mm512_set1_pd(double d)
// CHECK: insertelement <8 x double> {{.*}}, i32 7
return _mm512_set1_pd(d);
}
+TEST_CONSTEXPR(match_m512d(_mm512_set1_pd(-100.0), -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0, -100.0));
+
+__m512 test_mm512_set1_ps(float d)
+{
+ // CHECK-LABEL: test_mm512_set1_ps
+ // CHECK: insertelement <16 x float> {{.*}}, i32 0
+ // CHECK: insertelement <16 x float> {{.*}}, i32 1
+ // CHECK: insertelement <16 x float> {{.*}}, i32 2
+ // CHECK: insertelement <16 x float> {{.*}}, i32 3
+ // CHECK: insertelement <16 x float> {{.*}}, i32 4
+ // CHECK: insertelement <16 x float> {{.*}}, i32 5
+ // CHECK: insertelement <16 x float> {{.*}}, i32 6
+ // CHECK: insertelement <16 x float> {{.*}}, i32 15
+ return _mm512_set1_ps(d);
+}
+TEST_CONSTEXPR(match_m512(_mm512_set1_ps(-55.0f), -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f, -55.0f));
__mmask16 test_mm512_knot(__mmask16 a)
{
@@ -9046,6 +9062,7 @@ __m512i test_mm512_set1_epi8(char d)
// CHECK: insertelement <64 x i8> {{.*}}, i32 63
return _mm512_set1_epi8(d);
}
+TEST_CONSTEXPR(match_v64qi(_mm512_set1_epi8(127), 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127));
__m512i test_mm512_set1_epi16(short d)
{
@@ -9061,6 +9078,7 @@ __m512i test_mm512_set1_epi16(short d)
// CHECK: insertelement <32 x i16> {{.*}}, i32 31
return _mm512_set1_epi16(d);
}
+TEST_CONSTEXPR(match_v32hi(_mm512_set1_epi16(-511), -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511, -511));
__m512i test_mm512_set1_epi32(int d)
{
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions c,h -- clang/lib/Headers/avx512fintrin.h clang/test/CodeGen/X86/avx512f-builtins.c View the diff from clang-format here.diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h
index 95b80cc59..b4a0ff206 100644
--- a/clang/lib/Headers/avx512fintrin.h
+++ b/clang/lib/Headers/avx512fintrin.h
@@ -278,21 +278,18 @@ _mm512_setzero_pd(void) {
}
static __inline __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_set1_ps(float __w)
-{
+_mm512_set1_ps(float __w) {
return __extension__ (__m512){ __w, __w, __w, __w, __w, __w, __w, __w,
__w, __w, __w, __w, __w, __w, __w, __w };
}
static __inline __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_set1_pd(double __w)
-{
+_mm512_set1_pd(double __w) {
return __extension__ (__m512d){ __w, __w, __w, __w, __w, __w, __w, __w };
}
static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_set1_epi8(char __w)
-{
+_mm512_set1_epi8(char __w) {
return __extension__ (__m512i)(__v64qi){
__w, __w, __w, __w, __w, __w, __w, __w,
__w, __w, __w, __w, __w, __w, __w, __w,
@@ -305,8 +302,7 @@ _mm512_set1_epi8(char __w)
}
static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR
-_mm512_set1_epi16(short __w)
-{
+_mm512_set1_epi16(short __w) {
return __extension__ (__m512i)(__v32hi){
__w, __w, __w, __w, __w, __w, __w, __w,
__w, __w, __w, __w, __w, __w, __w, __w,
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backend:X86
clang:headers
Headers provided by Clang, e.g. for intrinsics
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pulled out of #152288 as I need this to proceed with several other patches