| 1 | From f046e326d9e30772725d8fb26dc33328e418d9d3 Mon Sep 17 00:00:00 2001
|
| 2 | From: Antonio Sanchez <[email protected]>
|
| 3 | Date: Fri, 17 Sep 2021 12:49:01 -0700
|
| 4 | Subject: [PATCH] Fix strict aliasing bug causing product_small failure.
|
| 5 |
|
| 6 | Packet loading is skipped due to aliasing violation, leading to nullopt matrix
|
| 7 | multiplication.
|
| 8 |
|
| 9 | Fixes #2327.
|
| 10 |
|
| 11 |
|
| 12 | (cherry picked from commit 3c724c44cff3f9e2e9e35351abff0b5c022b320d)
|
| 13 | ---
|
| 14 | Eigen/src/Core/arch/AVX/Complex.h | 4 +++-
|
| 15 | Eigen/src/Core/arch/AVX512/Complex.h | 4 +++-
|
| 16 | Eigen/src/Core/arch/SSE/Complex.h | 11 +++--------
|
| 17 | 3 files changed, 9 insertions(+), 10 deletions(-)
|
| 18 |
|
| 19 | diff --git a/Eigen/src/Core/arch/AVX/Complex.h b/Eigen/src/Core/arch/AVX/Complex.h
|
| 20 | index ab7bd6c65..e9096c0a1 100644
|
| 21 | |
| 22 | |
| 23 | @@ -99,7 +99,9 @@ template<> EIGEN_STRONG_INLINE Packet4cf ploadu<Packet4cf>(const std::complex<fl
|
| 24 |
|
| 25 | template<> EIGEN_STRONG_INLINE Packet4cf pset1<Packet4cf>(const std::complex<float>& from)
|
| 26 | {
|
| 27 | - return Packet4cf(_mm256_castpd_ps(_mm256_broadcast_sd((const double*)(const void*)&from)));
|
| 28 | + const float re = std::real(from);
|
| 29 | + const float im = std::imag(from);
|
| 30 | + return Packet4cf(_mm256_set_ps(im, re, im, re, im, re, im, re));
|
| 31 | }
|
| 32 |
|
| 33 | template<> EIGEN_STRONG_INLINE Packet4cf ploaddup<Packet4cf>(const std::complex<float>* from)
|
| 34 | diff --git a/Eigen/src/Core/arch/AVX512/Complex.h b/Eigen/src/Core/arch/AVX512/Complex.h
|
| 35 | index 49c72b3f1..074253859 100644
|
| 36 | |
| 37 | |
| 38 | @@ -97,7 +97,9 @@ template<> EIGEN_STRONG_INLINE Packet8cf ploadu<Packet8cf>(const std::complex<fl
|
| 39 |
|
| 40 | template<> EIGEN_STRONG_INLINE Packet8cf pset1<Packet8cf>(const std::complex<float>& from)
|
| 41 | {
|
| 42 | - return Packet8cf(_mm512_castpd_ps(pload1<Packet8d>((const double*)(const void*)&from)));
|
| 43 | + const float re = std::real(from);
|
| 44 | + const float im = std::imag(from);
|
| 45 | + return Packet8cf(_mm512_set_ps(im, re, im, re, im, re, im, re, im, re, im, re, im, re, im, re));
|
| 46 | }
|
| 47 |
|
| 48 | template<> EIGEN_STRONG_INLINE Packet8cf ploaddup<Packet8cf>(const std::complex<float>* from)
|
| 49 | diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h
|
| 50 | index 8fe22da46..215bfd7bb 100644
|
| 51 | |
| 52 | |
| 53 | @@ -106,14 +106,9 @@ template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(const std::complex<fl
|
| 54 |
|
| 55 | template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<float>& from)
|
| 56 | {
|
| 57 | - Packet2cf res;
|
| 58 | -#ifdef EIGEN_VECTORIZE_SSE3
|
| 59 | - res.v = _mm_castpd_ps(_mm_loaddup_pd(reinterpret_cast<double const*>(&from)));
|
| 60 | -#else
|
| 61 | - res.v = _mm_castpd_ps(_mm_load_sd(reinterpret_cast<double const*>(&from)));
|
| 62 | - res.v = _mm_movelh_ps(res.v, res.v);
|
| 63 | -#endif
|
| 64 | - return res;
|
| 65 | + const float re = std::real(from);
|
| 66 | + const float im = std::imag(from);
|
| 67 | + return Packet2cf(_mm_set_ps(im, re, im, re));
|
| 68 | }
|
| 69 |
|
| 70 | template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<float>* from) { return pset1<Packet2cf>(*from); }
|
| 71 | --
|
| 72 | 2.37.0
|
| 73 |
|