diff options
author | Jack Lloyd <[email protected]> | 2017-12-10 11:25:22 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-10 11:51:38 -0500 |
commit | 5e69b9a4e4b703247189e46652a41b901de06dae (patch) | |
tree | 688ffe88f81613facbb0d4d44f4b21909290eba8 /src/lib/utils | |
parent | 6284d7507130288fa8cc7ece096ecac56a81f8cd (diff) |
Enable using NEON on Clang
Clang doesn't like the way SIMD shifts were implemented, I guess
it fails to inline the constant. Make it a template parameter instead.
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/simd/simd_32.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib/utils/simd/simd_32.h b/src/lib/utils/simd/simd_32.h index aca7a8e9a..d9a41c800 100644 --- a/src/lib/utils/simd/simd_32.h +++ b/src/lib/utils/simd/simd_32.h @@ -508,37 +508,38 @@ class SIMD_4x32 final #endif } - SIMD_4x32 operator<<(size_t shift) const + + template<int SHIFT> SIMD_4x32 shl() const { #if defined(BOTAN_SIMD_USE_SSE2) - return SIMD_4x32(_mm_slli_epi32(m_sse, static_cast<int>(shift))); + return SIMD_4x32(_mm_slli_epi32(m_sse, SHIFT)); #elif defined(BOTAN_SIMD_USE_ALTIVEC) - const unsigned int s = static_cast<unsigned int>(shift); + const unsigned int s = static_cast<unsigned int>(SHIFT); return SIMD_4x32(vec_sl(m_vmx, (__vector unsigned int){s, s, s, s})); #elif defined(BOTAN_SIMD_USE_NEON) - return SIMD_4x32(vshlq_n_u32(m_neon, static_cast<int>(shift))); + return SIMD_4x32(vshlq_n_u32(m_neon, SHIFT)); #else - return SIMD_4x32(m_scalar[0] << shift, - m_scalar[1] << shift, - m_scalar[2] << shift, - m_scalar[3] << shift); + return SIMD_4x32(m_scalar[0] << SHIFT, + m_scalar[1] << SHIFT, + m_scalar[2] << SHIFT, + m_scalar[3] << SHIFT); #endif } - SIMD_4x32 operator>>(size_t shift) const + template<int SHIFT> SIMD_4x32 shr() const { #if defined(BOTAN_SIMD_USE_SSE2) - return SIMD_4x32(_mm_srli_epi32(m_sse, static_cast<int>(shift))); + return SIMD_4x32(_mm_srli_epi32(m_sse, SHIFT)); #elif defined(BOTAN_SIMD_USE_ALTIVEC) - const unsigned int s = static_cast<unsigned int>(shift); + const unsigned int s = static_cast<unsigned int>(SHIFT); return SIMD_4x32(vec_sr(m_vmx, (__vector unsigned int){s, s, s, s})); #elif defined(BOTAN_SIMD_USE_NEON) - return SIMD_4x32(vshrq_n_u32(m_neon, static_cast<int>(shift))); + return SIMD_4x32(vshrq_n_u32(m_neon, SHIFT)); #else - return SIMD_4x32(m_scalar[0] >> shift, m_scalar[1] >> shift, - m_scalar[2] >> shift, m_scalar[3] >> shift); + return SIMD_4x32(m_scalar[0] >> SHIFT, m_scalar[1] >> SHIFT, + m_scalar[2] >> SHIFT, m_scalar[3] >> SHIFT); #endif } |