From c24bee6120d40987b15df0cbdaaa60e3de877e01 Mon Sep 17 00:00:00 2001 From: Chip Kerchner Date: Fri, 2 Apr 2021 16:27:08 +0000 Subject: [PATCH] Fix address of temporary object errors in clang11. This fixes the problem with taking the address of temporary objects which clang11 treats as errors. --- Eigen/src/Core/arch/AltiVec/Complex.h | 4 +- Eigen/src/Core/arch/AltiVec/MatrixProduct.h | 57 ++++++++----------- .../Core/arch/AltiVec/MatrixProductCommon.h | 2 +- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/Eigen/src/Core/arch/AltiVec/Complex.h b/Eigen/src/Core/arch/AltiVec/Complex.h index 8110f53d0..c6cb59e8f 100644 --- a/Eigen/src/Core/arch/AltiVec/Complex.h +++ b/Eigen/src/Core/arch/AltiVec/Complex.h @@ -139,8 +139,8 @@ EIGEN_STRONG_INLINE Packet2cf pload2(const std::complex* from0, const std __asm__ ("xxpermdi %x0, %x2, %x1, 0" : "=wa" (res0) : "wa" (res0), "wa" (res1)); #endif #else - *((std::complex *)&res0[0]) = *from0; - *((std::complex *)&res1[0]) = *from1; + *reinterpret_cast *>(&res0) = *from0; + *reinterpret_cast *>(&res1) = *from1; res0 = vec_perm(res0, res1, p16uc_TRANSPOSE64_HI); #endif return Packet2cf(res0); diff --git a/Eigen/src/Core/arch/AltiVec/MatrixProduct.h b/Eigen/src/Core/arch/AltiVec/MatrixProduct.h index 30b814241..e3ba06159 100644 --- a/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +++ b/Eigen/src/Core/arch/AltiVec/MatrixProduct.h @@ -486,19 +486,28 @@ struct dhs_cpack { if(((StorageOrder == ColMajor) && UseLhs) || (((StorageOrder == RowMajor) && !UseLhs))) { if (UseLhs) { - cblock.packet[0] = pload(&lhs(j + 0, i)); - cblock.packet[1] = pload(&lhs(j + 2, i)); + cblock.packet[0] = lhs.template loadPacket(j + 0, i); + cblock.packet[1] = lhs.template loadPacket(j + 2, i); } else { - cblock.packet[0] = pload(&lhs(i, j + 0)); - cblock.packet[1] = pload(&lhs(i, j + 2)); + cblock.packet[0] = lhs.template loadPacket(i, j + 0); + cblock.packet[1] = lhs.template loadPacket(i, j + 2); } } else { + const std::complex *lhs0, *lhs1; if (UseLhs) { - cblock.packet[0] = pload2(&lhs(j + 0, i), &lhs(j + 1, i)); - cblock.packet[1] = pload2(&lhs(j + 2, i), &lhs(j + 3, i)); + lhs0 = &lhs(j + 0, i); + lhs1 = &lhs(j + 1, i); + cblock.packet[0] = pload2(lhs0, lhs1); + lhs0 = &lhs(j + 2, i); + lhs1 = &lhs(j + 3, i); + cblock.packet[1] = pload2(lhs0, lhs1); } else { - cblock.packet[0] = pload2(&lhs(i, j + 0), &lhs(i, j + 1)); - cblock.packet[1] = pload2(&lhs(i, j + 2), &lhs(i, j + 3)); + lhs0 = &lhs(i, j + 0); + lhs1 = &lhs(i, j + 1); + cblock.packet[0] = pload2(lhs0, lhs1); + lhs0 = &lhs(i, j + 2); + lhs1 = &lhs(i, j + 3); + cblock.packet[1] = pload2(lhs0, lhs1); } } @@ -859,8 +868,8 @@ struct dhs_cpack blockr, blocki; PacketBlock cblock; - cblock.packet[0] = pload(&lhs(j + 0, i)); - cblock.packet[1] = pload(&lhs(j + 1, i)); + cblock.packet[0] = lhs.template loadPacket(j + 0, i); + cblock.packet[1] = lhs.template loadPacket(j + 1, i); blockr.packet[0] = vec_perm(cblock.packet[0].v, cblock.packet[1].v, p16uc_GETREAL64); blocki.packet[0] = vec_perm(cblock.packet[0].v, cblock.packet[1].v, p16uc_GETIMAG64); @@ -1100,7 +1109,7 @@ EIGEN_STRONG_INLINE void pgerc(PacketBlock* accReal, PacketBlock EIGEN_STRONG_INLINE Packet ploadLhs(const Scalar* lhs) { - return *((Packet *)lhs); + return *reinterpret_cast(const_cast(lhs)); } // Zero the accumulator on PacketBlock. @@ -1799,24 +1808,6 @@ EIGEN_STRONG_INLINE void MICRO_COMPLEX_EXTRA_COL( else EIGEN_UNUSED_VARIABLE(rhs_ptr_imag); } -template -EIGEN_STRONG_INLINE void pstore_add_half(std::complex* to, Packetc &from) -{ -#ifdef __VSX__ - Packetc from2; -#ifndef _BIG_ENDIAN - __asm__ ("xxswapd %x0, %x0" : : "wa" (from.v)); -#endif - __asm__ ("lxsdx %x0,%y1" : "=wa" (from2.v) : "Z" (*to)); - from2 += from; - __asm__ ("stxsdx %x0,%y1" : : "wa" (from2.v), "Z" (*to)); -#else - std::complex mem[accColsC]; - pstoreu >(mem, from); - *to += *mem; -#endif -} - template EIGEN_STRONG_INLINE void gemm_complex_extra_col( const DataMapper& res, @@ -1886,12 +1877,12 @@ EIGEN_STRONG_INLINE void gemm_complex_extra_col( if ((sizeof(Scalar) == sizeof(float)) && (remaining_rows == 1)) { - pstore_add_half(&res(row + 0, col + 0), acc0.packet[0]); + res(row + 0, col + 0) += pfirst(acc0.packet[0]); } else { acc0.packet[0] += res.template loadPacket(row + 0, col + 0); res.template storePacketBlock(row + 0, col + 0, acc0); if(remaining_rows > accColsC) { - pstore_add_half(&res(row + accColsC, col + 0), acc1.packet[0]); + res(row + accColsC, col + 0) += pfirst(acc1.packet[0]); } } } @@ -1997,7 +1988,7 @@ asm("#gemm_complex begin"); if ((sizeof(Scalar) == sizeof(float)) && (remaining_rows == 1)) { for(Index j = 0; j < 4; j++) { - pstore_add_half(&res(row + 0, col + j), acc0.packet[j]); + res(row + 0, col + j) += pfirst(acc0.packet[j]); } } else { for(Index j = 0; j < 4; j++) { @@ -2005,7 +1996,7 @@ asm("#gemm_complex begin"); acc2.packet[0] = res.template loadPacket(row + 0, col + j) + acc0.packet[j]; res.template storePacketBlock(row + 0, col + j, acc2); if(remaining_rows > accColsC) { - pstore_add_half(&res(row + accColsC, col + j), acc1.packet[j]); + res(row + accColsC, col + j) += pfirst(acc1.packet[j]); } } } diff --git a/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h b/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h index 024767868..6e74116b9 100644 --- a/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +++ b/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h @@ -214,7 +214,7 @@ EIGEN_STRONG_INLINE void bcouple_common(PacketBlock EIGEN_STRONG_INLINE Packet ploadRhs(const Scalar* rhs) { - return *((Packet *)rhs); + return *reinterpret_cast(const_cast(rhs)); } } // end namespace internal