Skip to content

Commit 57ba401

Browse files
committed
Enable double-SHA256-for-64-byte code on 32-bit x86
1 parent 0de7cc8 commit 57ba401

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/crypto/sha256.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ TransformD64Type TransformD64 = sha256::TransformD64;
478478
TransformD64Type TransformD64_4way = nullptr;
479479
TransformD64Type TransformD64_8way = nullptr;
480480

481-
#if defined(USE_ASM) && (defined(__x86_64__) || defined(__amd64__))
481+
#if defined(USE_ASM) && (defined(__x86_64__) || defined(__amd64__) || defined(__i386__))
482482
// We can't use cpuid.h's __get_cpuid as it does not support subleafs.
483483
void inline cpuid(uint32_t leaf, uint32_t subleaf, uint32_t& a, uint32_t& b, uint32_t& c, uint32_t& d)
484484
{
@@ -491,12 +491,14 @@ void inline cpuid(uint32_t leaf, uint32_t subleaf, uint32_t& a, uint32_t& b, uin
491491
std::string SHA256AutoDetect()
492492
{
493493
std::string ret = "standard";
494-
#if defined(USE_ASM) && (defined(__x86_64__) || defined(__amd64__))
494+
#if defined(USE_ASM) && (defined(__x86_64__) || defined(__amd64__) || defined(__i386__))
495495
uint32_t eax, ebx, ecx, edx;
496496
cpuid(1, 0, eax, ebx, ecx, edx);
497497
if ((ecx >> 19) & 1) {
498+
#if defined(__x86_64__) || defined(__amd64__)
498499
Transform = sha256_sse4::Transform;
499500
TransformD64 = TransformD64Wrapper<sha256_sse4::Transform>;
501+
#endif
500502
#if defined(ENABLE_SSE41) && !defined(BUILD_BITCOIN_INTERNAL)
501503
TransformD64_4way = sha256d64_sse41::Transform_4way;
502504
ret = "sse4(1way+4way)";

0 commit comments

Comments
 (0)