From a1a5fbbd212fb962d2bcc1533ae09037ee4177a1 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 27 Nov 2018 22:57:30 +0100 Subject: [PATCH] Update pshiftleft to pass the shift as a true compile-time integer. --- Eigen/src/Core/GenericPacketMath.h | 8 +++++--- Eigen/src/Core/arch/AVX/PacketMath.h | 8 ++++---- Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 2 +- Eigen/src/Core/arch/SSE/PacketMath.h | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h index 49a1c67cf..c24268443 100644 --- a/Eigen/src/Core/GenericPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -219,9 +219,11 @@ pxor(const Packet& a, const Packet& b) { return a ^ b; } template EIGEN_DEVICE_FUNC inline Packet pandnot(const Packet& a, const Packet& b) { return a & (!b); } -/** \internal \returns \a a shifted by n bits */ -template EIGEN_DEVICE_FUNC inline Packet -pshiftleft(const Packet& a, int n); /* { return a << n; } */ +/** \internal \returns \a a shifted by N bits */ +template EIGEN_DEVICE_FUNC inline int +pshiftleft(const int& a) { return a << N; } +template EIGEN_DEVICE_FUNC inline long int +pshiftleft(const long int& a) { return a << N; } /** \internal \returns the significant and exponent of the underlying floating point numbers * See https://en.cppreference.com/w/cpp/numeric/math/frexp diff --git a/Eigen/src/Core/arch/AVX/PacketMath.h b/Eigen/src/Core/arch/AVX/PacketMath.h index 0e1044aba..969f68d79 100644 --- a/Eigen/src/Core/arch/AVX/PacketMath.h +++ b/Eigen/src/Core/arch/AVX/PacketMath.h @@ -256,12 +256,12 @@ template<> EIGEN_STRONG_INLINE Packet8f pselect(const Packet8f& mask, template<> EIGEN_STRONG_INLINE Packet4d pselect(const Packet4d& mask, const Packet4d& a, const Packet4d& b) { return _mm256_blendv_pd(b,a,mask); } -template<> EIGEN_STRONG_INLINE Packet8i pshiftleft(const Packet8i& a, int n) { +template EIGEN_STRONG_INLINE Packet8i pshiftleft(const Packet8i& a) { #ifdef EIGEN_VECTORIZE_AVX2 - return _mm256_slli_epi32(a, n); + return _mm256_slli_epi32(a, N); #else - __m128i lo = _mm_slli_epi32(_mm256_extractf128_si256(a, 0), n); - __m128i hi = _mm_slli_epi32(_mm256_extractf128_si256(a, 1), n); + __m128i lo = _mm_slli_epi32(_mm256_extractf128_si256(a, 0), N); + __m128i hi = _mm_slli_epi32(_mm256_extractf128_si256(a, 1), N); return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1); #endif } diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 5719d7f91..067d1dbe0 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -270,7 +270,7 @@ Packet psin_float(const Packet& _x) // Compute the sign to apply to the polynomial. // sign = third_bit(y_int1) xor signbit(_x) - Packet sign_bit = pxor(_x, preinterpret(pshiftleft(y_int1, 29))); + Packet sign_bit = pxor(_x, preinterpret(pshiftleft<29>(y_int1))); sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit // Get the polynomial selection mask from the second bit of y_int1 diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index a508ce73e..fbc69ef1f 100755 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -370,7 +370,7 @@ template<> EIGEN_STRONG_INLINE Packet4f pandnot(const Packet4f& a, con template<> EIGEN_STRONG_INLINE Packet2d pandnot(const Packet2d& a, const Packet2d& b) { return _mm_andnot_pd(b,a); } template<> EIGEN_STRONG_INLINE Packet4i pandnot(const Packet4i& a, const Packet4i& b) { return _mm_andnot_si128(b,a); } -template<> EIGEN_STRONG_INLINE Packet4i pshiftleft(const Packet4i& a, int n) { return _mm_slli_epi32(a,n); } +template EIGEN_STRONG_INLINE Packet4i pshiftleft(const Packet4i& a) { return _mm_slli_epi32(a,N); } #ifdef EIGEN_VECTORIZE_SSE4_1 template<> EIGEN_STRONG_INLINE Packet4f pround(const Packet4f& a) { return _mm_round_ps(a, 0); }