From 758e31d5a01967469116310e5a59b4ce58429380 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 24 Nov 2018 03:27:12 -0500 Subject: [PATCH] Add 64-bit element rotates for POWER7 --- ppc_simd.h | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/ppc_simd.h b/ppc_simd.h index f52540c8..631e19e7 100644 --- a/ppc_simd.h +++ b/ppc_simd.h @@ -25,7 +25,7 @@ // DO NOT USE this pattern in VecLoad and VecStore. We have to use the // spaghetti code tangled in preprocessor macros because XLC 12 generates // bad code in some places. To verify the bad code generation test on -// GCC111 with XLC 12.01 installed. XLC 13 on GCC112 and GCC119 is OK. +// GCC111 with XLC 12.01 installed. XLC 13 on GCC112 and GCC119 are OK. // // inline uint32x4_p VecLoad(const byte src[16]) // { @@ -338,7 +338,6 @@ inline uint64x2_p VecLoad(int off, const word64 src[2]) #endif // _ARCH_PWR7 - /// \brief Loads a vector from an aligned byte array /// \param src the byte array /// \details VecLoadAligned loads a vector in from an aligned byte array. @@ -1144,6 +1143,26 @@ inline uint32x4_p VecRotateLeft(const uint32x4_p vec) return vec_rl(vec, m); } +#if defined(_ARCH_PWR7) || defined(CRYPTOPP_DOXYGEN_PROCESSING) + +/// \brief Rotate a vector left +/// \tparam C shift bit count +/// \param vec the vector +/// \returns vector +/// \details VecRotateLeft rotates each element in a packed vector by bit count. +/// \details VecRotateLeft with 64-bit elements is available on POWER7 and above. +/// \par Wraps +/// vec_rl +/// \since Crypto++ 8.0 +template +inline uint64x2_p VecRotateLeft(const uint64x2_p vec) +{ + const uint64x2_p m = {C, C}; + return vec_rl(vec, m); +} + +#endif + /// \brief Rotate a vector right /// \tparam C shift bit count /// \param vec the vector @@ -1159,6 +1178,26 @@ inline uint32x4_p VecRotateRight(const uint32x4_p vec) return vec_rl(vec, m); } +#if defined(_ARCH_PWR7) || defined(CRYPTOPP_DOXYGEN_PROCESSING) + +/// \brief Rotate a vector right +/// \tparam C shift bit count +/// \param vec the vector +/// \returns vector +/// \details VecRotateRight rotates each element in a packed vector by bit count. +/// \details VecRotateRight with 64-bit elements is available on POWER7 and above. +/// \par Wraps +/// vec_rl +/// \since Crypto++ 8.0 +template +inline uint64x2_p VecRotateRight(const uint64x2_p vec) +{ + const uint64x2_p m = {64-C, 64-C}; + return vec_rl(vec, m); +} + +#endif + /// \brief Exchange high and low double words /// \tparam T vector type /// \param vec the vector