mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
Merge bitcoin/bitcoin#28893: Fix SSE4.1-related issues
d440f13db0
crypto: Guard code with `ENABLE_SSE41` macro (Hennadii Stepanov)6ec1ca7c85
build: Fix test for SSE4.1 intrinsics (Hennadii Stepanov) Pull request description: 1. Fix the test for SSE4.1 intrinsics during build system configuration, which currently can be false positive, for example, when `CXXFLAGS="-mno-sse4.1"` provided. This PR fixes the test by adding the `_mm_blend_epi16` SSE4.1 function used in our codebase. 2. Guard `sha_x86_shani.cpp` code with `ENABLE_SSE41` macro as it uses the `_mm_blend_epi16` function from the SSE4.1 instruction set. It is possible that SHA-NI is enabled even when SSE4.1 is disabled, which causes compile errors in the master branch. Closes https://github.com/bitcoin/bitcoin/issues/28864. ACKs for top commit: sipa: utACKd440f13db0
willcl-ark: tACKd440f13db0
theuni: utACKd440f13db0
Tree-SHA512: a6e1e8c94e1b94874ff51846815ef445e6135cbdb01b08eb695b3548115f2340dd835ebe53673ae46a553fe6be4815e68d8642c34235dd7af5106c4b7c9ea6f3
This commit is contained in:
commit
3679fa167f
4 changed files with 11 additions and 10 deletions
|
@ -482,11 +482,12 @@ TEMP_CXXFLAGS="$CXXFLAGS"
|
||||||
CXXFLAGS="$SSE41_CXXFLAGS $CXXFLAGS"
|
CXXFLAGS="$SSE41_CXXFLAGS $CXXFLAGS"
|
||||||
AC_MSG_CHECKING([for SSE4.1 intrinsics])
|
AC_MSG_CHECKING([for SSE4.1 intrinsics])
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||||
#include <stdint.h>
|
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
]],[[
|
]],[[
|
||||||
__m128i l = _mm_set1_epi32(0);
|
__m128i a = _mm_set1_epi32(0);
|
||||||
return _mm_extract_epi32(l, 3);
|
__m128i b = _mm_set1_epi32(1);
|
||||||
|
__m128i r = _mm_blend_epi16(a, b, 0xFF);
|
||||||
|
return _mm_extract_epi32(r, 3);
|
||||||
]])],
|
]])],
|
||||||
[ AC_MSG_RESULT([yes]); enable_sse41=yes; AC_DEFINE([ENABLE_SSE41], [1], [Define this symbol to build code that uses SSE4.1 intrinsics]) ],
|
[ AC_MSG_RESULT([yes]); enable_sse41=yes; AC_DEFINE([ENABLE_SSE41], [1], [Define this symbol to build code that uses SSE4.1 intrinsics]) ],
|
||||||
[ AC_MSG_RESULT([no])]
|
[ AC_MSG_RESULT([no])]
|
||||||
|
|
|
@ -51,15 +51,15 @@ LIBBITCOIN_CRYPTO = $(LIBBITCOIN_CRYPTO_BASE)
|
||||||
if ENABLE_SSE41
|
if ENABLE_SSE41
|
||||||
LIBBITCOIN_CRYPTO_SSE41 = crypto/libbitcoin_crypto_sse41.la
|
LIBBITCOIN_CRYPTO_SSE41 = crypto/libbitcoin_crypto_sse41.la
|
||||||
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SSE41)
|
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SSE41)
|
||||||
|
if ENABLE_X86_SHANI
|
||||||
|
LIBBITCOIN_CRYPTO_X86_SHANI = crypto/libbitcoin_crypto_x86_shani.la
|
||||||
|
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_X86_SHANI)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
if ENABLE_AVX2
|
if ENABLE_AVX2
|
||||||
LIBBITCOIN_CRYPTO_AVX2 = crypto/libbitcoin_crypto_avx2.la
|
LIBBITCOIN_CRYPTO_AVX2 = crypto/libbitcoin_crypto_avx2.la
|
||||||
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_AVX2)
|
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_AVX2)
|
||||||
endif
|
endif
|
||||||
if ENABLE_X86_SHANI
|
|
||||||
LIBBITCOIN_CRYPTO_X86_SHANI = crypto/libbitcoin_crypto_x86_shani.la
|
|
||||||
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_X86_SHANI)
|
|
||||||
endif
|
|
||||||
if ENABLE_ARM_SHANI
|
if ENABLE_ARM_SHANI
|
||||||
LIBBITCOIN_CRYPTO_ARM_SHANI = crypto/libbitcoin_crypto_arm_shani.la
|
LIBBITCOIN_CRYPTO_ARM_SHANI = crypto/libbitcoin_crypto_arm_shani.la
|
||||||
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_ARM_SHANI)
|
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_ARM_SHANI)
|
||||||
|
@ -622,7 +622,7 @@ crypto_libbitcoin_crypto_x86_shani_la_LDFLAGS = $(AM_LDFLAGS) -static
|
||||||
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -static
|
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -static
|
||||||
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS = $(AM_CPPFLAGS)
|
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS += $(X86_SHANI_CXXFLAGS)
|
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS += $(X86_SHANI_CXXFLAGS)
|
||||||
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS += -DENABLE_X86_SHANI
|
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS += -DENABLE_SSE41 -DENABLE_X86_SHANI
|
||||||
crypto_libbitcoin_crypto_x86_shani_la_SOURCES = crypto/sha256_x86_shani.cpp
|
crypto_libbitcoin_crypto_x86_shani_la_SOURCES = crypto/sha256_x86_shani.cpp
|
||||||
|
|
||||||
# See explanation for -static in crypto_libbitcoin_crypto_base_la's LDFLAGS and
|
# See explanation for -static in crypto_libbitcoin_crypto_base_la's LDFLAGS and
|
||||||
|
|
|
@ -621,7 +621,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_X86_SHANI)
|
#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
|
||||||
if (have_x86_shani) {
|
if (have_x86_shani) {
|
||||||
Transform = sha256_x86_shani::Transform;
|
Transform = sha256_x86_shani::Transform;
|
||||||
TransformD64 = TransformD64Wrapper<sha256_x86_shani::Transform>;
|
TransformD64 = TransformD64Wrapper<sha256_x86_shani::Transform>;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// Written and placed in public domain by Jeffrey Walton.
|
// Written and placed in public domain by Jeffrey Walton.
|
||||||
// Based on code from Intel, and by Sean Gulley for the miTLS project.
|
// Based on code from Intel, and by Sean Gulley for the miTLS project.
|
||||||
|
|
||||||
#ifdef ENABLE_X86_SHANI
|
#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
|
Loading…
Add table
Reference in a new issue