From 5e8edd21863b8321fc6b9c82322e6cc8cfc47c14 Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Thu, 13 Mar 2025 22:23:45 -0700 Subject: [PATCH] Fix undefined behavior in PPC load. VSX vec_xl is Causing a bunch of test failures and failing `-fsanitize=undefined` with g++. Removing the instruction allows tests to pass and eliminates the warning. --- Eigen/src/Core/arch/AltiVec/PacketMath.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h index 27f61a49b..9022a71e0 100755 --- a/Eigen/src/Core/arch/AltiVec/PacketMath.h +++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h @@ -224,29 +224,25 @@ inline std::ostream & operator <<(std::ostream & s, const Packet4ui & v) return s; } -template -EIGEN_STRONG_INLINE Packet pload_common(const __UNPACK_TYPE__(Packet)* from) +template +EIGEN_STRONG_INLINE Packet pload_common(const Scalar* from) { // some versions of GCC throw "unused-but-set-parameter". // ignoring these warnings for now. EIGEN_UNUSED_VARIABLE(from); EIGEN_DEBUG_ALIGNED_LOAD -#ifdef __VSX__ - return vec_xl(0, const_cast<__UNPACK_TYPE__(Packet)*>(from)); -#else return vec_ld(0, from); -#endif } // Need to define them first or we get specialization after instantiation errors template<> EIGEN_STRONG_INLINE Packet4f pload(const float* from) { - return pload_common(from); + return pload_common(from); } template<> EIGEN_STRONG_INLINE Packet4i pload(const int* from) { - return pload_common(from); + return pload_common(from); } template @@ -455,15 +451,11 @@ template<> EIGEN_STRONG_INLINE Packet4f pfloor(const Packet4f& a) { re template EIGEN_STRONG_INLINE Packet ploadu_common(const __UNPACK_TYPE__(Packet)* from) { EIGEN_DEBUG_UNALIGNED_LOAD -#ifdef __VSX__ - return vec_xl(0, const_cast<__UNPACK_TYPE__(Packet)*>(from)); -#else Packet16uc mask = vec_lvsl(0, from); // create the permute mask Packet16uc MSQ = vec_ld(0, (unsigned char *)from); // most significant quadword Packet16uc LSQ = vec_ld(15, (unsigned char *)from); // least significant quadword //TODO: Add static_cast here return (Packet) vec_perm(MSQ, LSQ, mask); // align the data -#endif } template<> EIGEN_STRONG_INLINE Packet4f ploadu(const float* from)