diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:33:54 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:36:09 +0900 |
commit | d9ec475d945d3035377a0d89ed42e382d8988891 (patch) | |
tree | 34aff2cee4b209906243ab5499d61f3edee2982f /boost/uuid | |
parent | 71d216b90256936a9638f325af9bc69d720e75de (diff) | |
download | boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.gz boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.bz2 boost-d9ec475d945d3035377a0d89ed42e382d8988891.zip |
Imported Upstream version 1.60.0
Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/uuid')
-rw-r--r-- | boost/uuid/detail/config.hpp | 22 | ||||
-rw-r--r-- | boost/uuid/detail/uuid_x86.hpp | 30 | ||||
-rw-r--r-- | boost/uuid/seed_rng.hpp | 5 |
3 files changed, 49 insertions, 8 deletions
diff --git a/boost/uuid/detail/config.hpp b/boost/uuid/detail/config.hpp index 997f882131..602d4ab6af 100644 --- a/boost/uuid/detail/config.hpp +++ b/boost/uuid/detail/config.hpp @@ -36,15 +36,23 @@ #define BOOST_UUID_USE_SSE41 #endif -#elif defined(_MSC_VER) && (defined(_M_X64) || (defined(_M_IX86) && defined(_M_IX86_FP) && _M_IX86_FP >= 2)) +#elif defined(_MSC_VER) -#ifndef BOOST_UUID_USE_SSE2 +#if (defined(_M_X64) || (defined(_M_IX86) && defined(_M_IX86_FP) && _M_IX86_FP >= 2)) && !defined(BOOST_UUID_USE_SSE2) #define BOOST_UUID_USE_SSE2 #endif -#elif !defined(BOOST_UUID_USE_SSE41) && !defined(BOOST_UUID_USE_SSE3) && !defined(BOOST_UUID_USE_SSE2) - -#define BOOST_UUID_NO_SIMD +#if defined(__AVX__) +#if !defined(BOOST_UUID_USE_SSE41) +#define BOOST_UUID_USE_SSE41 +#endif +#if !defined(BOOST_UUID_USE_SSE3) +#define BOOST_UUID_USE_SSE3 +#endif +#if !defined(BOOST_UUID_USE_SSE2) +#define BOOST_UUID_USE_SSE2 +#endif +#endif #endif @@ -57,6 +65,10 @@ #define BOOST_UUID_USE_SSE2 #endif +#if !defined(BOOST_UUID_NO_SIMD) && !defined(BOOST_UUID_USE_SSE41) && !defined(BOOST_UUID_USE_SSE3) && !defined(BOOST_UUID_USE_SSE2) +#define BOOST_UUID_NO_SIMD +#endif + #endif // !defined(BOOST_UUID_NO_SIMD) #endif // BOOST_UUID_DETAIL_CONFIG_HPP_INCLUDED_ diff --git a/boost/uuid/detail/uuid_x86.hpp b/boost/uuid/detail/uuid_x86.hpp index 5b573aac15..5c736708e6 100644 --- a/boost/uuid/detail/uuid_x86.hpp +++ b/boost/uuid/detail/uuid_x86.hpp @@ -22,6 +22,23 @@ #include <emmintrin.h> #endif +#if defined(BOOST_MSVC) && defined(_M_X64) && !defined(BOOST_UUID_USE_SSE3) && (BOOST_MSVC < 1900 /* Fixed in Visual Studio 2015 */ ) +// At least MSVC 9 (VS2008) and 12 (VS2013) have an optimizer bug that sometimes results in incorrect SIMD code +// generated in Release x64 mode. In particular, it affects operator==, where the compiler sometimes generates +// pcmpeqd with a memory opereand instead of movdqu followed by pcmpeqd. The problem is that uuid can be +// not aligned to 16 bytes and pcmpeqd causes alignment violation in this case. We cannot be sure that other +// MSVC versions are not affected so we apply the workaround for all versions, except VS2015 on up where +// the bug has been fixed. +// +// https://svn.boost.org/trac/boost/ticket/8509#comment:3 +// https://connect.microsoft.com/VisualStudio/feedbackdetail/view/981648#tabs +#define BOOST_UUID_DETAIL_MSVC_BUG981648 +#if BOOST_MSVC >= 1600 +extern "C" void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#endif +#endif + namespace boost { namespace uuids { namespace detail { @@ -30,8 +47,16 @@ BOOST_FORCEINLINE __m128i load_unaligned_si128(const uint8_t* p) BOOST_NOEXCEPT { #if defined(BOOST_UUID_USE_SSE3) return _mm_lddqu_si128(reinterpret_cast< const __m128i* >(p)); -#else +#elif !defined(BOOST_UUID_DETAIL_MSVC_BUG981648) return _mm_loadu_si128(reinterpret_cast< const __m128i* >(p)); +#elif BOOST_MSVC >= 1600 + __m128i mm = _mm_loadu_si128(reinterpret_cast< const __m128i* >(p)); + // Make sure this load doesn't get merged with the subsequent instructions + _ReadWriteBarrier(); + return mm; +#else + // VS2008 x64 doesn't respect _ReadWriteBarrier above, so we have to generate this crippled code to load unaligned data + return _mm_unpacklo_epi64(_mm_loadl_epi64(reinterpret_cast< const __m128i* >(p)), _mm_loadl_epi64(reinterpret_cast< const __m128i* >(p + 8))); #endif } @@ -62,8 +87,9 @@ inline bool operator== (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT __m128i mm_right = uuids::detail::load_unaligned_si128(rhs.data); __m128i mm_cmp = _mm_cmpeq_epi32(mm_left, mm_right); + #if defined(BOOST_UUID_USE_SSE41) - return _mm_test_all_ones(mm_cmp); + return _mm_test_all_ones(mm_cmp) != 0; #else return _mm_movemask_epi8(mm_cmp) == 0xFFFF; #endif diff --git a/boost/uuid/seed_rng.hpp b/boost/uuid/seed_rng.hpp index 877e4ebb20..5299b04821 100644 --- a/boost/uuid/seed_rng.hpp +++ b/boost/uuid/seed_rng.hpp @@ -40,11 +40,14 @@ #if defined(_MSC_VER) # pragma warning(push) // Save warning settings. # pragma warning(disable : 4996) // Disable deprecated std::fopen +# pragma comment(lib, "advapi32.lib") +#endif + +#if defined(BOOST_WINDOWS) # include <boost/detail/winapi/crypt.hpp> // for CryptAcquireContextA, CryptGenRandom, CryptReleaseContext # include <boost/detail/winapi/timers.hpp> # include <boost/detail/winapi/process.hpp> # include <boost/detail/winapi/thread.hpp> -# pragma comment(lib, "advapi32.lib") #else # include <sys/time.h> // for gettimeofday # include <sys/types.h> // for pid_t |