diff --git a/blake2.cpp b/blake2.cpp index 1fa6ef44..e8f3ca68 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -13,7 +13,8 @@ NAMESPACE_BEGIN(CryptoPP) -// Uncomment for benchmarking C++ against NEON +// Uncomment for benchmarking C++ against SSE2 or NEON +#undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE // #undef CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE // Visual Studio needs both VS2005 (1400) and _M_64 for SSE2 and _mm_set_epi64x() @@ -34,10 +35,20 @@ NAMESPACE_BEGIN(CryptoPP) # undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE #endif -// SunCC needs 12.4 for _mm_set_epi64x, _mm_blend_epi16, _mm_shuffle_epi16, etc +// Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. +// Also see http://stackoverflow.com/a/38547909/608639 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5130) -# undef CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE -# undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE +inline __m128i _mm_set_epi64x(const uint64_t a, const uint64_t b) +{ + union INT_128_64x2 { + __m128i v128; + uint64_t v64[2]; + }; + + INT_128_64x2 val; + val.v64[0] = b; val.v64[1] = a; + return val.v128; +} #endif // C/C++ implementation diff --git a/chacha.cpp b/chacha.cpp index b6ebd9c5..833a6acb 100644 --- a/chacha.cpp +++ b/chacha.cpp @@ -1,6 +1,6 @@ // chacha.cpp - written and placed in the public domain by Jeffrey Walton. // Copyright assigned to the Crypto++ project. -// Based on Wei Dai's Salsa20 and Bernstein's reference ChaCha +// Based on Wei Dai's Salsa20 and Bernstein's reference ChaCha // family implementation at http://cr.yp.to/chacha.html. #include "pch.h" @@ -141,7 +141,7 @@ void ChaCha_Policy::OperateKeystream(KeystreamOperation operation, byte *outp #endif ++m_state[12]; - m_state[13] += !!(m_state[12] == 0); + m_state[13] += static_cast(m_state[12] == 0); } } diff --git a/chacha.h b/chacha.h index 302c477d..28b8c7af 100644 --- a/chacha.h +++ b/chacha.h @@ -1,6 +1,6 @@ // chacha.h - written and placed in the public domain by Jeffrey Walton. // Copyright assigned to the Crypto++ project. -// Based on Wei Dai's Salsa20 and Bernstein's reference ChaCha +// Based on Wei Dai's Salsa20 and Bernstein's reference ChaCha // family implementation at http://cr.yp.to/chacha.html. //! \file chacha.h diff --git a/cryptest.sh b/cryptest.sh index 5689d691..b7837bb9 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -522,6 +522,11 @@ if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then if [[ ("$HAVE_ARM_VFPV4" -gt "0") ]]; then HAVE_ARM_VFPV4=1; fi fi + if [[ (-z "$HAVE_ARM_VFPV5") ]]; then + HAVE_ARM_VFPV5=$(echo "$ARM_FEATURES" | "$GREP" -i -c 'fpv5') + if [[ ("$HAVE_ARM_VFPV5" -gt "0") ]]; then HAVE_ARM_VFPV5=1; fi + fi + if [[ (-z "$HAVE_ARM_VFPD32") ]]; then HAVE_ARM_VFPD32=$(echo "$ARM_FEATURES" | "$GREP" -i -c 'vfpd32') if [[ ("$HAVE_ARM_VFPD32" -gt "0") ]]; then HAVE_ARM_VFPD32=1; fi @@ -859,10 +864,18 @@ if [[ ("$IS_ARM32" -ne "0" || "$IS_ARM64" -ne "0") ]]; then # Also see http://lists.linaro.org/pipermail/linaro-toolchain/2016-July/005821.html if [[ ("$HAVE_ARM_NEON" -ne "0" && "$HAVE_ARM_VFPV4" -ne "0") ]]; then PLATFORM_CXXFLAGS+=("-mfpu=neon-vfpv4 ") - elif [[ ("$HAVE_ARM_VFPV3" -ne "0" || "$HAVE_ARM_VFPV4" -ne "0") && "$HAVE_ARM_VFPD32" -ne "0" ]]; then - PLATFORM_CXXFLAGS+=("-mfpu=neon ") elif [[ ("$HAVE_ARM_NEON" -ne "0") ]]; then PLATFORM_CXXFLAGS+=("-mfpu=neon ") + elif [[ ("$HAVE_ARM_VFPV3" -ne "0" || "$HAVE_ARM_VFPV4" -ne "0") && "$HAVE_ARM_VFPD32" -ne "0" ]]; then + PLATFORM_CXXFLAGS+=("-mfpu=neon ") + elif [[ ("$HAVE_ARM_VFPV5" -ne "0" && "$HAVE_ARM_VFPD32" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-mfpu=fpv5 ") + elif [[ ("$HAVE_ARM_VFPV4" -ne "0" && "$HAVE_ARM_VFPD32" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-mfpu=vfpv4 ") + elif [[ ("$HAVE_ARM_VFPV3" -ne "0" && "$HAVE_ARM_VFPD32" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-mfpu=vfpv3 ") + elif [[ ("$HAVE_ARM_VFPV5" -ne "0") ]]; then + PLATFORM_CXXFLAGS+=("-mfpu=fpv5-d16 ") elif [[ ("$HAVE_ARM_VFPV4" -ne "0") ]]; then PLATFORM_CXXFLAGS+=("-mfpu=vfpv4-d16 ") elif [[ ("$HAVE_ARM_VFPV3" -ne "0") ]]; then diff --git a/panama.h b/panama.h index e7f20c95..18e60338 100644 --- a/panama.h +++ b/panama.h @@ -11,7 +11,7 @@ #include "secblock.h" // Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler error with .intel_syntax -#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30500)) +#if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_INTEL_ASM) # define CRYPTOPP_DISABLE_PANAMA_ASM #endif