From eb4b2eeffa91f92a664bcae77f05af77499ad46d Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Fri, 27 Mar 2026 19:54:10 +0000 Subject: [PATCH] UBSAN: use appropriate SSE intrinsics for loading 4 and 8 bytes libeigen/eigen!2346 --- Eigen/src/Core/arch/SSE/PacketMath.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index e7039d4a5..28e635b27 100644 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -1398,7 +1398,7 @@ template EIGEN_STRONG_INLINE Packet ploadl(const typename unpacket_traits::type* from); template <> EIGEN_STRONG_INLINE Packet4f ploadl(const float* from) { - EIGEN_DEBUG_UNALIGNED_LOAD return _mm_castpd_ps(_mm_load_sd(reinterpret_cast(from))); + EIGEN_DEBUG_UNALIGNED_LOAD return _mm_castsi128_ps(_mm_loadu_si64(reinterpret_cast(from))); } template <> EIGEN_STRONG_INLINE Packet2d ploadl(const double* from) { @@ -1419,7 +1419,7 @@ EIGEN_STRONG_INLINE Packet2d ploads(const double* from) { template <> EIGEN_STRONG_INLINE Packet4f ploaddup(const float* from) { - return vec4f_swizzle1(_mm_castpd_ps(_mm_load_sd(reinterpret_cast(from))), 0, 0, 1, 1); + return vec4f_swizzle1(_mm_castsi128_ps(_mm_loadu_si64(reinterpret_cast(from))), 0, 0, 1, 1); } template <> EIGEN_STRONG_INLINE Packet2d ploaddup(const double* from) { @@ -1446,7 +1446,7 @@ EIGEN_STRONG_INLINE Packet4ui ploaddup(const uint32_t* from) { // {b0, b0, b1, b1, b2, b2, b3, b3, b4, b4, b5, b5, b6, b6, b7, b7} template <> EIGEN_STRONG_INLINE Packet16b ploaddup(const bool* from) { - __m128i tmp = _mm_castpd_si128(pload1(reinterpret_cast(from))); + __m128i tmp = _mm_loadu_si64(reinterpret_cast(from)); return _mm_unpacklo_epi8(tmp, tmp); } @@ -1454,7 +1454,10 @@ EIGEN_STRONG_INLINE Packet16b ploaddup(const bool* from) { // {b0, b0 b0, b0, b1, b1, b1, b1, b2, b2, b2, b2, b3, b3, b3, b3} template <> EIGEN_STRONG_INLINE Packet16b ploadquad(const bool* from) { - __m128i tmp = _mm_castps_si128(pload1(reinterpret_cast(from))); + EIGEN_USING_STD(memcpy); + int val; + memcpy(&val, from, sizeof(int)); + __m128i tmp = _mm_cvtsi32_si128(val); tmp = _mm_unpacklo_epi8(tmp, tmp); return _mm_unpacklo_epi16(tmp, tmp); }