From e3a521be6beeb0db55861a42bb4483a41e553a62 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 21 May 2011 22:19:12 +0200 Subject: [PATCH] backport 7209d6a12610d4682c65a99f12b0d0278fbbe81d (fix gemv_static_vector_if on architectures that cannot aligned on the stack (e.g., ARM NEON)) --- Eigen/src/Core/Product.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index bde25375d..b45946044 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -375,8 +375,23 @@ struct gemv_static_vector_if template struct gemv_static_vector_if { + #if EIGEN_ALIGN_STATICALLY internal::plain_array m_data; EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } + #else + // Some architectures cannot align on the stack, + // => let's manually enforce alignment by allocating more data and return the address of the first aligned element. + enum { + ForceAlignment = internal::packet_traits::Vectorizable, + PacketSize = internal::packet_traits::size + }; + internal::plain_array m_data; + EIGEN_STRONG_INLINE Scalar* data() { + return ForceAlignment + ? reinterpret_cast((reinterpret_cast(m_data.array) & ~(size_t(15))) + 16) + : m_data.array; + } + #endif }; template<> struct gemv_selector