Skip to content

Commit 76cef17

Browse files
committed
merge bitcoin#28893: Fix SSE4.1-related issues
1 parent 16209a8 commit 76cef17

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

configure.ac

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,12 @@ TEMP_CXXFLAGS="$CXXFLAGS"
600600
CXXFLAGS="$SSE41_CXXFLAGS $CXXFLAGS"
601601
AC_MSG_CHECKING([for SSE4.1 intrinsics])
602602
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
603-
#include <stdint.h>
604603
#include <immintrin.h>
605604
]],[[
606-
__m128i l = _mm_set1_epi32(0);
607-
return _mm_extract_epi32(l, 3);
605+
__m128i a = _mm_set1_epi32(0);
606+
__m128i b = _mm_set1_epi32(1);
607+
__m128i r = _mm_blend_epi16(a, b, 0xFF);
608+
return _mm_extract_epi32(r, 3);
608609
]])],
609610
[ AC_MSG_RESULT([yes]); enable_sse41=yes; AC_DEFINE([ENABLE_SSE41], [1], [Define this symbol to build code that uses SSE4.1 intrinsics]) ],
610611
[ AC_MSG_RESULT([no])]

src/Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ LIBBITCOIN_CRYPTO = $(LIBBITCOIN_CRYPTO_BASE)
7676
if ENABLE_SSE41
7777
LIBBITCOIN_CRYPTO_SSE41 = crypto/libbitcoin_crypto_sse41.la
7878
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SSE41)
79+
if ENABLE_X86_SHANI
80+
LIBBITCOIN_CRYPTO_X86_SHANI = crypto/libbitcoin_crypto_x86_shani.la
81+
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_X86_SHANI)
82+
endif
7983
endif
8084
if ENABLE_AVX2
8185
LIBBITCOIN_CRYPTO_AVX2 = crypto/libbitcoin_crypto_avx2.la
8286
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_AVX2)
8387
endif
84-
if ENABLE_X86_SHANI
85-
LIBBITCOIN_CRYPTO_X86_SHANI = crypto/libbitcoin_crypto_x86_shani.la
86-
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_X86_SHANI)
87-
endif
8888
if ENABLE_ARM_SHANI
8989
LIBBITCOIN_CRYPTO_ARM_SHANI = crypto/libbitcoin_crypto_arm_shani.la
9090
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_ARM_SHANI)
@@ -740,7 +740,7 @@ crypto_libbitcoin_crypto_x86_shani_la_LDFLAGS = $(AM_LDFLAGS) -static
740740
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -static
741741
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS = $(AM_CPPFLAGS)
742742
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS += $(X86_SHANI_CXXFLAGS)
743-
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS += -DENABLE_X86_SHANI
743+
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS += -DENABLE_SSE41 -DENABLE_X86_SHANI
744744
crypto_libbitcoin_crypto_x86_shani_la_SOURCES = crypto/sha256_x86_shani.cpp
745745

746746
# See explanation for -static in crypto_libbitcoin_crypto_base_la's LDFLAGS and

src/crypto/sha256.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
619619
}
620620
}
621621

622-
#if defined(ENABLE_X86_SHANI)
622+
#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
623623
if (have_x86_shani) {
624624
Transform = sha256_x86_shani::Transform;
625625
TransformD64 = TransformD64Wrapper<sha256_x86_shani::Transform>;

src/crypto/sha256_x86_shani.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Written and placed in public domain by Jeffrey Walton.
77
// Based on code from Intel, and by Sean Gulley for the miTLS project.
88

9-
#ifdef ENABLE_X86_SHANI
9+
#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
1010

1111
#include <stdint.h>
1212
#include <immintrin.h>

0 commit comments

Comments
 (0)