From 7209d6a12610d4682c65a99f12b0d0278fbbe81d Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 21 May 2011 22:15:11 +0200 Subject: fix gemv_static_vector_if on architectures that cannot aligned on the stack (e.g., ARM NEON) --- Eigen/src/Core/GeneralProduct.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index 2d63120cf..61bc02a76 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.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 -- cgit v1.2.3