From 821702e77154ead54ebf2a30f8e76481c12f7d44 Mon Sep 17 00:00:00 2001 From: Guoqiang QI <425418567@qq.com> Date: Mon, 21 Sep 2020 15:49:00 +0000 Subject: [PATCH] Fix the #issue1997 and #issue1991 bug triggered by unsupport a[index](type a: __i28d) ops with MSVC compiler --- Eigen/src/Core/arch/SSE/TypeCasting.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Eigen/src/Core/arch/SSE/TypeCasting.h b/Eigen/src/Core/arch/SSE/TypeCasting.h index e75df2bfa..1f01d3c28 100644 --- a/Eigen/src/Core/arch/SSE/TypeCasting.h +++ b/Eigen/src/Core/arch/SSE/TypeCasting.h @@ -70,7 +70,16 @@ template<> EIGEN_STRONG_INLINE Packet2d pcast(const Packet4f } template<> EIGEN_STRONG_INLINE Packet2l pcast(const Packet2d& a) { + // using a[1]/a[0] to get high/low 64 bit from __m128d is faster than _mm_cvtsd_f64() ,but + // it will trigger the bug report at https://gitlab.com/libeigen/eigen/-/issues/1997 since the + // a[index] ops was not supported by MSVC compiler(supported by gcc). +#if EIGEN_COMP_MSVC + return _mm_set_epi64x(int64_t(_mm_cvtsd_f64(_mm_unpackhi_pd(a,a))), int64_t(_mm_cvtsd_f64(a))); +#elif ((defined EIGEN_VECTORIZE_AVX) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_MINGW) && (__GXX_ABI_VERSION < 1004)) || EIGEN_OS_QNX + return _mm_set_epi64x(int64_t(a.m_val[1]), int64_t(a.m_val[0])); +#else return _mm_set_epi64x(int64_t(a[1]), int64_t(a[0])); +#endif } template <>