diff --git a/include/gc_inline.h b/include/gc_inline.h index dca8fa3a1..b67725107 100644 --- a/include/gc_inline.h +++ b/include/gc_inline.h @@ -31,6 +31,10 @@ #include "gc.h" #include "gc_tiny_fl.h" +# ifdef _MSC_VER +# include /* for prefetch intrinsics */ +# endif + #if GC_GNUC_PREREQ(3, 0) # define GC_EXPECT(expr, outcome) __builtin_expect(expr,outcome) /* Equivalent to (expr), but predict that usually (expr)==outcome. */ @@ -54,6 +58,8 @@ #ifndef GC_PREFETCH_FOR_WRITE # if GC_GNUC_PREREQ(3, 0) && !defined(GC_NO_PREFETCH_FOR_WRITE) # define GC_PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1) +# elif defined(_MSC_VER) && !defined(GC_NO_PREFETCH_FOR_WRITE) && !defined(_M_ARM) && !defined(_M_ARM64) +# define GC_PREFETCH_FOR_WRITE(x) _mm_prefetch((x), _MM_HINT_T0) # else # define GC_PREFETCH_FOR_WRITE(x) (void)0 # endif diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index ab87692bc..c33eda90f 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -34,6 +34,10 @@ # include /* For size_t etc. */ # endif +# ifdef _MSC_VER +# include /* for prefetch intrinsics */ +# endif + /* Note: Only wrap our own declarations, and not the included headers. */ /* In this case, wrap our entire file, but temporarily unwrap/rewrap */ /* around #includes. Types and macros do not need such wrapping, only */ @@ -3195,6 +3199,8 @@ EXTERN_C_BEGIN #ifndef PREFETCH # if GC_GNUC_PREREQ(3, 0) && !defined(NO_PREFETCH) # define PREFETCH(x) __builtin_prefetch((x), 0, 0) +# elif defined(_MSC_VER) && !defined(NO_PREFETCH) && !defined(_M_ARM) && !defined(_M_ARM64) +# define PREFETCH(x) _mm_prefetch((x), _MM_HINT_T0) # else # define PREFETCH(x) (void)0 # endif @@ -3203,6 +3209,8 @@ EXTERN_C_BEGIN #ifndef GC_PREFETCH_FOR_WRITE # if GC_GNUC_PREREQ(3, 0) && !defined(GC_NO_PREFETCH_FOR_WRITE) # define GC_PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1) +# elif defined(_MSC_VER) && !defined(GC_NO_PREFETCH_FOR_WRITE) && !defined(_M_ARM) && !defined(_M_ARM64) +# define GC_PREFETCH_FOR_WRITE(x) _mm_prefetch((x), _MM_HINT_T0) # else # define GC_PREFETCH_FOR_WRITE(x) (void)0 # endif