From 842f1cf2db0959280386bd8a28afdbfde66026d5 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 26 Aug 2018 01:49:26 -0400 Subject: Simplify code for SIMD_4x32::rho --- src/lib/utils/simd/simd_32.h | 53 ++++---------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) (limited to 'src/lib/utils/simd') diff --git a/src/lib/utils/simd/simd_32.h b/src/lib/utils/simd/simd_32.h index 8e6ac3639..20589939c 100644 --- a/src/lib/utils/simd/simd_32.h +++ b/src/lib/utils/simd/simd_32.h @@ -268,55 +268,10 @@ class SIMD_4x32 final template SIMD_4x32 rho() const { - SIMD_4x32 res; - -#if defined(BOTAN_SIMD_USE_SSE2) - - res.m_sse = _mm_or_si128(_mm_slli_epi32(m_sse, static_cast(32-ROT1)), - _mm_srli_epi32(m_sse, static_cast(ROT1))); - res.m_sse = _mm_xor_si128( - res.m_sse, - _mm_or_si128(_mm_slli_epi32(m_sse, static_cast(32-ROT2)), - _mm_srli_epi32(m_sse, static_cast(ROT2)))); - res.m_sse = _mm_xor_si128( - res.m_sse, - _mm_or_si128(_mm_slli_epi32(m_sse, static_cast(32-ROT3)), - _mm_srli_epi32(m_sse, static_cast(ROT3)))); - -#elif defined(BOTAN_SIMD_USE_ALTIVEC) - - const unsigned int r1 = static_cast(32-ROT1); - const unsigned int r2 = static_cast(32-ROT2); - const unsigned int r3 = static_cast(32-ROT3); - res.m_vmx = vec_rl(m_vmx, (__vector unsigned int){r1, r1, r1, r1}); - res.m_vmx = vec_xor(res.m_vmx, vec_rl(m_vmx, (__vector unsigned int){r2, r2, r2, r2})); - res.m_vmx = vec_xor(res.m_vmx, vec_rl(m_vmx, (__vector unsigned int){r3, r3, r3, r3})); - -#elif defined(BOTAN_SIMD_USE_NEON) - res.m_neon = vorrq_u32(vshlq_n_u32(m_neon, static_cast(32-ROT1)), - vshrq_n_u32(m_neon, static_cast(ROT1))); - - res.m_neon = veorq_u32( - res.m_neon, - vorrq_u32(vshlq_n_u32(m_neon, static_cast(32-ROT2)), - vshrq_n_u32(m_neon, static_cast(ROT2)))); - - res.m_neon = veorq_u32( - res.m_neon, - vorrq_u32(vshlq_n_u32(m_neon, static_cast(32-ROT3)), - vshrq_n_u32(m_neon, static_cast(ROT3)))); - -#else - - for(size_t i = 0; i != 4; ++i) - { - res.m_scalar[i] = Botan::rotr(m_scalar[i]) ^ - Botan::rotr(m_scalar[i]) ^ - Botan::rotr(m_scalar[i]); - } -#endif - - return res; + const SIMD_4x32 rot1 = this->rotr(); + const SIMD_4x32 rot2 = this->rotr(); + const SIMD_4x32 rot3 = this->rotr(); + return (rot1 ^ rot2 ^ rot3); } /** -- cgit v1.2.3