aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/simd
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-26 01:49:26 -0400
committerJack Lloyd <[email protected]>2018-08-26 01:49:26 -0400
commit842f1cf2db0959280386bd8a28afdbfde66026d5 (patch)
tree77b7fa4faeb2cfcff194dfea344a6e927c0f8b02 /src/lib/utils/simd
parent8acd3f0f494a052b056809dbc42b76906d2b080e (diff)
Simplify code for SIMD_4x32::rho
Diffstat (limited to 'src/lib/utils/simd')
-rw-r--r--src/lib/utils/simd/simd_32.h53
1 files changed, 4 insertions, 49 deletions
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<size_t ROT1, size_t ROT2, size_t ROT3>
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<int>(32-ROT1)),
- _mm_srli_epi32(m_sse, static_cast<int>(ROT1)));
- res.m_sse = _mm_xor_si128(
- res.m_sse,
- _mm_or_si128(_mm_slli_epi32(m_sse, static_cast<int>(32-ROT2)),
- _mm_srli_epi32(m_sse, static_cast<int>(ROT2))));
- res.m_sse = _mm_xor_si128(
- res.m_sse,
- _mm_or_si128(_mm_slli_epi32(m_sse, static_cast<int>(32-ROT3)),
- _mm_srli_epi32(m_sse, static_cast<int>(ROT3))));
-
-#elif defined(BOTAN_SIMD_USE_ALTIVEC)
-
- const unsigned int r1 = static_cast<unsigned int>(32-ROT1);
- const unsigned int r2 = static_cast<unsigned int>(32-ROT2);
- const unsigned int r3 = static_cast<unsigned int>(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<int>(32-ROT1)),
- vshrq_n_u32(m_neon, static_cast<int>(ROT1)));
-
- res.m_neon = veorq_u32(
- res.m_neon,
- vorrq_u32(vshlq_n_u32(m_neon, static_cast<int>(32-ROT2)),
- vshrq_n_u32(m_neon, static_cast<int>(ROT2))));
-
- res.m_neon = veorq_u32(
- res.m_neon,
- vorrq_u32(vshlq_n_u32(m_neon, static_cast<int>(32-ROT3)),
- vshrq_n_u32(m_neon, static_cast<int>(ROT3))));
-
-#else
-
- for(size_t i = 0; i != 4; ++i)
- {
- res.m_scalar[i] = Botan::rotr<ROT1>(m_scalar[i]) ^
- Botan::rotr<ROT2>(m_scalar[i]) ^
- Botan::rotr<ROT3>(m_scalar[i]);
- }
-#endif
-
- return res;
+ const SIMD_4x32 rot1 = this->rotr<ROT1>();
+ const SIMD_4x32 rot2 = this->rotr<ROT2>();
+ const SIMD_4x32 rot3 = this->rotr<ROT3>();
+ return (rot1 ^ rot2 ^ rot3);
}
/**