-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[X86] make the set/r/4 intrinsics macros into functions #156819
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-clang @llvm/pr-subscribers-backend-x86 Author: Sadiinso (SadiinsoSnowfall) ChangesChange the definitions of Pending questions :
Full diff: https://github.com/llvm/llvm-project/pull/156819.diff 2 Files Affected:
diff --git a/clang/lib/Headers/avx512fp16intrin.h b/clang/lib/Headers/avx512fp16intrin.h
index 25f65aee7ff11..f501974d34c97 100644
--- a/clang/lib/Headers/avx512fp16intrin.h
+++ b/clang/lib/Headers/avx512fp16intrin.h
@@ -100,13 +100,20 @@ _mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4,
__h4, __h3, __h2, __h1};
}
-#define _mm512_setr_ph(h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, \
- h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, \
- h25, h26, h27, h28, h29, h30, h31, h32) \
- _mm512_set_ph((h32), (h31), (h30), (h29), (h28), (h27), (h26), (h25), (h24), \
- (h23), (h22), (h21), (h20), (h19), (h18), (h17), (h16), (h15), \
- (h14), (h13), (h12), (h11), (h10), (h9), (h8), (h7), (h6), \
- (h5), (h4), (h3), (h2), (h1))
+static __inline__ __m512h __DEFAULT_FN_ATTRS512_CONSTEXPR
+_mm512_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4,
+ _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8,
+ _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12,
+ _Float16 __h13, _Float16 __h14, _Float16 __h15, _Float16 __h16,
+ _Float16 __h17, _Float16 __h18, _Float16 __h19, _Float16 __h20,
+ _Float16 __h21, _Float16 __h22, _Float16 __h23, _Float16 __h24,
+ _Float16 __h25, _Float16 __h26, _Float16 __h27, _Float16 __h28,
+ _Float16 __h29, _Float16 __h30, _Float16 __h31, _Float16 __h32) {
+ return _mm512_set_ph(__h32, __h31, __h30, __h29, __h28, __h27, __h26, __h25,
+ __h24, __h23, __h22, __h21, __h20, __h19, __h18, __h17,
+ __h16, __h15, __h14, __h13, __h12, __h11, __h10, __h9,
+ __h8, __h7, __h6, __h5, __h4, __h3, __h2, __h1);
+}
static __inline __m512h __DEFAULT_FN_ATTRS512
_mm512_set1_pch(_Float16 _Complex __h) {
diff --git a/clang/lib/Headers/avx512vlfp16intrin.h b/clang/lib/Headers/avx512vlfp16intrin.h
index 98ad9b54eef39..a74e43170fc33 100644
--- a/clang/lib/Headers/avx512vlfp16intrin.h
+++ b/clang/lib/Headers/avx512vlfp16intrin.h
@@ -81,13 +81,20 @@ _mm256_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4,
__h4, __h3, __h2, __h1};
}
-#define _mm_setr_ph(h1, h2, h3, h4, h5, h6, h7, h8) \
- _mm_set_ph((h8), (h7), (h6), (h5), (h4), (h3), (h2), (h1))
+static __inline__ __m128h __DEFAULT_FN_ATTRS128
+_mm_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4,
+ _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8) {
+ return _mm_set_ph(__h8, __h7, __h6, __h5, __h4, __h3, __h2, __h1);
+}
-#define _mm256_setr_ph(h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, \
- h14, h15, h16) \
- _mm256_set_ph((h16), (h15), (h14), (h13), (h12), (h11), (h10), (h9), (h8), \
- (h7), (h6), (h5), (h4), (h3), (h2), (h1))
+static __inline__ __m256h __DEFAULT_FN_ATTRS256
+_mm256_setr_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4,
+ _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8,
+ _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12,
+ _Float16 __h13, _Float16 __h14, _Float16 __h15, _Float16 __h16) {
+ return _mm256_set_ph(__h16, __h15, __h14, __h13, __h12, __h11, __h10, __h9,
+ __h8, __h7, __h6, __h5, __h4, __h3, __h2, __h1);
+}
static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_add_ph(__m256h __A,
__m256h __B) {
|
#152910 only solves
Yes, you can do it in the same PR. |
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.
None of the avx512vlfp16intrin.h _set_
intrinsics have been converted to constexpr yet so that is fine - I'll raise a separate bug about them - #156866
The other avx512f _setr_
and _setr4_
intrinsics do need converting to (constexpr) functions - if you are willing to do so in this patch that would be great.
97acc94
to
3dfae1b
Compare
3dfae1b
to
1e84828
Compare
I made the suggested additions to my initial commit |
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
@SadiinsoSnowfall 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! |
Change the definitions of
_mm_setr_ph
,_mm256_setr_ph
and_mm512_setr_ph
to be functions instead of macros.Resolves #156709
Pending questions :
_mm_setr_ph
and_mm256_setr_ph
functions be marked as__DEFAULT_FN_A TTRS128_CONSTEXPR
and__DEFAULT_FN_ATTRS256_CONSTEXPR
respectively ? I marked_mm512_setr_ph
as__DEFAULT_FN_ATTRS512_CONSTEXPR
because this attribute list is also applied to_mm512_set_ph
. This is not the case for_mm_set_ph
and_mm256_set_ph
.setr
intrinsics such as_mm512_setr_ps
,_mm512_setr_pd
,_mm512_setr_epi64
, etc... Should they be made into real functions too ? If so, should it be done in this PR ?