From: Simon Pilgrim Date: Mon, 27 Jul 2015 19:01:52 +0000 (+0000) Subject: [X86] Add missing _m_prefetch intrinsic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81cd15fc6ba0defc832c49526b3d82f8ba38f648;p=clang [X86] Add missing _m_prefetch intrinsic The 3DNOW/PRFCHW cpu targets define both the PREFETCHW (set cache line modified) and PREFETCH (set cache line exclusive) instructions but only the _m_prefetchw (PREFETCHW) intrinsic is included in the header. This patch adds the missing _m_prefetch intrinsic. I'm basing this off AMD documentation - the intel docs on the support for PREFETCHW isn't clear whether Silvermont/Broadwell properly support PREFETCH but given that the intrinsic implementation is a default __builtin_prefetch call, it is safe whatever. Fix for PR23648 Differential Revision: http://reviews.llvm.org/D11338 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243305 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/prfchwintrin.h b/lib/Headers/prfchwintrin.h index 9825bd8c97..ba02857518 100644 --- a/lib/Headers/prfchwintrin.h +++ b/lib/Headers/prfchwintrin.h @@ -29,6 +29,12 @@ #define __PRFCHWINTRIN_H #if defined(__PRFCHW__) || defined(__3dNOW__) +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_m_prefetch(void *__P) +{ + __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); +} + static __inline__ void __attribute__((__always_inline__, __nodebug__)) _m_prefetchw(void *__P) { diff --git a/test/CodeGen/prefetchw-builtins.c b/test/CodeGen/prefetchw-builtins.c index 9c5fdc7233..a422062157 100644 --- a/test/CodeGen/prefetchw-builtins.c +++ b/test/CodeGen/prefetchw-builtins.c @@ -5,8 +5,14 @@ #include -void prefetch_w(void *p) { +void test_m_prefetch(void *p) { + return _m_prefetch(p); + // CHECK-LABEL: define void @test_m_prefetch + // CHECK: call void @llvm.prefetch({{.*}}, i32 0, i32 3, i32 1) +} + +void test_m_prefetch_w(void *p) { return _m_prefetchw(p); -// CHECK: @prefetch_w +// CHECK-LABEL: define void : @test_m_prefetch_w // CHECK: call void @llvm.prefetch({{.*}}, i32 1, i32 3, i32 1) }