Skip to content

Commit

Permalink
[X86] Add missing _m_prefetch intrinsic
Browse files Browse the repository at this point in the history
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

llvm-svn: 243305
  • Loading branch information
RKSimon committed Jul 27, 2015
1 parent 93d6746 commit f81966d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions clang/lib/Headers/prfchwintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 8 additions & 2 deletions clang/test/CodeGen/prefetchw-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@

#include <x86intrin.h>

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)
}

0 comments on commit f81966d

Please sign in to comment.