From 0612768c1c12b46a9a529c9c1b52e2c7493ac641 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sun, 27 Feb 2011 21:59:07 -0500 Subject: [PATCH] fix bug #201: Clang too has intrinsics bugs preventing us to use custom unaligned loads --- Eigen/src/Core/arch/SSE/PacketMath.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index 6e57bfe98..d9c0c9812 100644 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -245,10 +245,21 @@ template<> EIGEN_STRONG_INLINE Packet4i pload(const int* from) { E // a correct instruction dependency. // TODO: do the same for MSVC (ICC is compatible) // NOTE: with the code below, MSVC's compiler crashes! + +#if defined(__GNUC__) && defined(__i386__) + // bug 195: gcc/i386 emits weird x87 fldl/fstpl instructions for _mm_load_sd + #define EIGEN_AVOID_CUSTOM_UNALIGNED_LOADS 1 +#elif defined(__clang__) + // bug 201: Segfaults in __mm_loadh_pd with clang 2.8 + #define EIGEN_AVOID_CUSTOM_UNALIGNED_LOADS 1 +#else + #define EIGEN_AVOID_CUSTOM_UNALIGNED_LOADS 0 +#endif + template<> EIGEN_STRONG_INLINE Packet4f ploadu(const float* from) { EIGEN_DEBUG_UNALIGNED_LOAD -#if defined(__GNUC__) && defined(__i386__) +#if EIGEN_AVOID_CUSTOM_UNALIGNED_LOADS // bug 195: gcc/i386 emits weird x87 fldl/fstpl instructions for _mm_load_sd return _mm_loadu_ps(from); #else @@ -261,7 +272,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ploadu(const float* from) template<> EIGEN_STRONG_INLINE Packet2d ploadu(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD -#if defined(__GNUC__) && defined(__i386__) +#if EIGEN_AVOID_CUSTOM_UNALIGNED_LOADS // bug 195: gcc/i386 emits weird x87 fldl/fstpl instructions for _mm_load_sd return _mm_loadu_pd(from); #else @@ -274,7 +285,7 @@ template<> EIGEN_STRONG_INLINE Packet2d ploadu(const double* from) template<> EIGEN_STRONG_INLINE Packet4i ploadu(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD -#if defined(__GNUC__) && defined(__i386__) +#if EIGEN_AVOID_CUSTOM_UNALIGNED_LOADS // bug 195: gcc/i386 emits weird x87 fldl/fstpl instructions for _mm_load_sd return _mm_loadu_si128(reinterpret_cast(from)); #else