diff --git a/Eigen/src/Core/arch/AVX/Complex.h b/Eigen/src/Core/arch/AVX/Complex.h index 407300289..f891e0bc3 100644 --- a/Eigen/src/Core/arch/AVX/Complex.h +++ b/Eigen/src/Core/arch/AVX/Complex.h @@ -454,7 +454,15 @@ EIGEN_STRONG_INLINE Packet4cf plog(const Packet4cf& a) { template <> EIGEN_STRONG_INLINE Packet2cd pexp(const Packet2cd& a) { +#ifdef EIGEN_VECTORIZE_AVX2 return pexp_complex(a); +#else + // Without AVX2, pexp_complex requires psincos_double which needs + // 256-bit integer operations (Packet4l) not available on AVX-only targets. + // Process as two independent Packet1cd using the SSE implementation instead. + return Packet2cd(_mm256_insertf128_pd(_mm256_castpd128_pd256(pexp(Packet1cd(_mm256_castpd256_pd128(a.v))).v), + pexp(Packet1cd(_mm256_extractf128_pd(a.v, 1))).v, 1)); +#endif } template <> diff --git a/Eigen/src/Core/arch/AVX/MathFunctions.h b/Eigen/src/Core/arch/AVX/MathFunctions.h index f4f6794a1..965883c44 100644 --- a/Eigen/src/Core/arch/AVX/MathFunctions.h +++ b/Eigen/src/Core/arch/AVX/MathFunctions.h @@ -33,6 +33,24 @@ EIGEN_DOUBLE_PACKET_FUNCTION(cbrt, Packet4d) EIGEN_DOUBLE_PACKET_FUNCTION(sin, Packet4d) EIGEN_DOUBLE_PACKET_FUNCTION(cos, Packet4d) EIGEN_DOUBLE_PACKET_FUNCTION(tan, Packet4d) +#else +// Without AVX2, psincos_double requires 256-bit integer operations (Packet4l) +// that are not available. Process as two Packet2d halves using the SSE implementation. +template <> +EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4d psin(const Packet4d& x) { + return _mm256_insertf128_pd(_mm256_castpd128_pd256(psin(_mm256_castpd256_pd128(x))), + psin(_mm256_extractf128_pd(x, 1)), 1); +} +template <> +EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4d pcos(const Packet4d& x) { + return _mm256_insertf128_pd(_mm256_castpd128_pd256(pcos(_mm256_castpd256_pd128(x))), + pcos(_mm256_extractf128_pd(x, 1)), 1); +} +template <> +EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4d ptan(const Packet4d& x) { + return _mm256_insertf128_pd(_mm256_castpd128_pd256(ptan(_mm256_castpd256_pd128(x))), + ptan(_mm256_extractf128_pd(x, 1)), 1); +} #endif EIGEN_GENERIC_PACKET_FUNCTION(atan, Packet4d) EIGEN_GENERIC_PACKET_FUNCTION(exp2, Packet4d)