From 7b9532b8781c5beaf99eef8ca7535d969a129d78 Mon Sep 17 00:00:00 2001 From: alkis Date: Fri, 2 Jun 2017 10:21:49 -0700 Subject: Improve the SSE2 macro check on Windows. This lands https://github.com/google/snappy/pull/37 --- snappy.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/snappy.cc b/snappy.cc index 90c0787..8bb5d23 100644 --- a/snappy.cc +++ b/snappy.cc @@ -30,7 +30,16 @@ #include "snappy-internal.h" #include "snappy-sinksource.h" -#ifdef __SSE2__ +#ifndef SNAPPY_HAVE_SSE2 +#if defined(__SSE2__) || defined(_M_X64) || \ + (defined(_M_IX86_FP) && _M_IX86_FP >= 2) +#define SNAPPY_HAVE_SSE2 1 +#else +#define SNAPPY_HAVE_SSE2 0 +#endif +#endif + +#if SNAPPY_HAVE_SSE2 #include #endif #include @@ -96,7 +105,7 @@ void UnalignedCopy64(const void* src, void* dst) { void UnalignedCopy128(const void* src, void* dst) { // TODO(alkis): Remove this when we upgrade to a recent compiler that emits // SSE2 moves for memcpy(dst, src, 16). -#ifdef __SSE2__ +#if SNAPPY_HAVE_SSE2 __m128i x = _mm_loadu_si128(static_cast(src)); _mm_storeu_si128(static_cast<__m128i*>(dst), x); #else -- cgit v1.2.3