Allow prefetching on non-x86 platforms with gcc
authorJean-Francois Romang <jeanfrancois.romang@gmail.com>
Fri, 5 Oct 2012 20:30:22 +0000 (04:30 +0800)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 5 Oct 2012 22:43:16 +0000 (00:43 +0200)
In particular on ARM processors. Original patch by
Jean-Francois, sligtly modified by me to preserve
the meaning of NO_PREFETCH flag.

Verified with gcc, clang and icc that prefetch instruction
is correctly created.

No functional change.

src/misc.cpp

index fefa8d4f33cbd2dd7a74ff57f6a481e14468025b..167eedb3250517ed7c0106cd3a1c3c56b7143a86 100644 (file)
@@ -237,8 +237,13 @@ void prefetch(char* addr) {
    __asm__ ("");
 #  endif
 
+#  if defined(__INTEL_COMPILER) || defined(__ICL) || defined(_MSC_VER)
   _mm_prefetch(addr, _MM_HINT_T2);
   _mm_prefetch(addr+64, _MM_HINT_T2); // 64 bytes ahead
+#  else
+  __builtin_prefetch(addr);
+  __builtin_prefetch(addr+64);
+#  endif
 }
 
 #endif