-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Win/X86] Make _m_prefetch[w] builtins to avoid winnt.h conflicts #115099
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
Changes from 6 commits
e5f485a
80e6138
2c07705
452f72b
371d448
57f92b7
445ad48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2197,10 +2197,7 @@ _mm_storer_ps(float *__p, __m128 __a) | |
#define _MM_HINT_T2 1 | ||
#define _MM_HINT_NTA 0 | ||
|
||
#ifndef _MSC_VER | ||
/* FIXME: We have to #define this because "sel" must be a constant integer, and | ||
Sema doesn't do any form of constant propagation yet. */ | ||
|
||
#if 0 | ||
/// Loads one cache line of data from the specified address to a location | ||
/// closer to the processor. | ||
/// | ||
|
@@ -2225,6 +2222,10 @@ _mm_storer_ps(float *__p, __m128 __a) | |
/// be generated. \n | ||
/// _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will | ||
/// be generated. | ||
/// | ||
/// _mm_prefetch is implemented as a "library builtin" directly in Clang, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this interact with doxygen (https://clang.llvm.org/doxygen/xmmintrin_8h.html#a938d3f37a8561a80cecbac4f7b55898f)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not well. I can put this inside an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use |
||
/// similar to how it is done in MSVC. Clang will warn if the user doesn't | ||
/// include xmmintrin.h or immintrin.h. | ||
#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \ | ||
((sel) >> 2) & 1, (sel) & 0x3)) | ||
#endif | ||
|
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.
prefetchw should map to feature prfchw?
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.
Yes, it should! I looked at the Intel intrinsic documentation, and it said these intrinsics were part of the deprecated 3dnow ISA extension, and I wasn't sure what to. However, I took the time to check the Intel ISA manual and I updated this feature set and the _mm_prefetch feature check to "sse", since that seems to be the correct feature. PTAL, since I've expanded scope a bit.
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.
The whole thing is sort of confusing...
AMD originally implemented 3dnow including prefetch and prefetchw instructions. Intel then implemented SSE with different prefetch instructions... but didn't include one with a write hint. Later, they implemented prefetchw, and added a corresponding CPUID bit.
Modern LLVM never generates "prefetch"; _m_prefetch is actually lowered to the SSE prefetcht0.
_mm_prefetch(x, _MM_HINT_ET0)
generates different instructions depending on the command-line: if the target only supports SSE, it generates prefetcht0. If it supports prefetchw (-mprfchw
), it generates prefetchw.I guess given that behavior, this feature mapping is probably fine?