Skip to content

Commit 3ae34ad

Browse files
committed
Make _m_prefetch use the mmx feature, and keep the _mm_prefetch macro
1 parent 7360386 commit 3ae34ad

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,15 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
138138
}
139139
}
140140

141+
let Features = "mmx", Header = "mmintrin.h", Attributes = [NoThrow, Const] in {
142+
def _m_prefetch : X86LibBuiltin<"void(void *)">;
143+
}
144+
141145
// PRFCHW
142146
let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
143-
def _m_prefetch : X86LibBuiltin<"void(void *)">;
144147
def _m_prefetchw : X86LibBuiltin<"void(void volatile const *)">;
145148
}
146149

147-
148150
// Mechanically ported builtins from the original `.def` file.
149151
//
150152
// TODO: Build structured ways of synthesizing relevant groups and improve the

clang/lib/Headers/xmmintrin.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,11 @@ _mm_storer_ps(float *__p, __m128 __a)
21972197
#define _MM_HINT_T2 1
21982198
#define _MM_HINT_NTA 0
21992199

2200-
#if 0
2200+
#ifndef _MSC_VER
2201+
// If _MSC_VER is defined, we use the builtin variant of _mm_prefetch.
2202+
// Otherwise, we provide this macro, which includes a cast, allowing the user
2203+
// to pass a pointer of any time. The _mm_prefetch accepts char to match MSVC.
2204+
22012205
/// Loads one cache line of data from the specified address to a location
22022206
/// closer to the processor.
22032207
///
@@ -2222,10 +2226,6 @@ _mm_storer_ps(float *__p, __m128 __a)
22222226
/// be generated. \n
22232227
/// _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
22242228
/// be generated.
2225-
///
2226-
/// _mm_prefetch is implemented as a "library builtin" directly in Clang,
2227-
/// similar to how it is done in MSVC. Clang will warn if the user doesn't
2228-
/// include xmmintrin.h or immintrin.h.
22292229
#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
22302230
((sel) >> 2) & 1, (sel) & 0x3))
22312231
#endif

0 commit comments

Comments
 (0)