Skip to content

Commit 70f36d8

Browse files
committed
Enable AVX2 implementation of SHA256 for MSVC builds
1 parent 38ecdca commit 70f36d8

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

build_msvc/bitcoin_config.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
/* Copyright year */
3030
#define COPYRIGHT_YEAR $
3131

32+
/* Define this symbol to build in assembly routines */
33+
#define USE_ASM 1
34+
35+
/* Define this symbol to build code that uses AVX2 intrinsics */
36+
#define ENABLE_AVX2 1
37+
3238
/* Define to 1 to enable wallet functions */
3339
#define ENABLE_WALLET 1
3440

build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ConfigurationType>StaticLibrary</ConfigurationType>
99
</PropertyGroup>
1010
<ItemGroup>
11+
<ClCompile Include="..\..\src\crypto\sha256_avx2.cpp" />
1112
@SOURCE_FILES@
1213
</ItemGroup>
1314
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ClCompile Include="..\..\src\crypto\ripemd160.cpp" />
1919
<ClCompile Include="..\..\src\crypto\sha1.cpp" />
2020
<ClCompile Include="..\..\src\crypto\sha256.cpp" />
21+
<ClCompile Include="..\..\src\crypto\sha256_avx2.cpp" />
2122
<ClCompile Include="..\..\src\crypto\sha256_sse4.cpp" />
2223
<ClCompile Include="..\..\src\crypto\sha512.cpp" />
2324
<ClCompile Include="..\..\src\hash.cpp" />

src/crypto/sha256_avx2.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ __m256i inline sigma0(__m256i x) { return Xor(Or(ShR(x, 7), ShL(x, 25)), Or(ShR(
4040
__m256i inline sigma1(__m256i x) { return Xor(Or(ShR(x, 17), ShL(x, 15)), Or(ShR(x, 19), ShL(x, 13)), ShR(x, 10)); }
4141

4242
/** One round of SHA-256. */
43-
void inline __attribute__((always_inline)) Round(__m256i a, __m256i b, __m256i c, __m256i& d, __m256i e, __m256i f, __m256i g, __m256i& h, __m256i k)
43+
void inline
44+
#ifdef __GNUC__
45+
__attribute__((always_inline))
46+
#endif
47+
Round(__m256i a, __m256i b, __m256i c, __m256i& d, __m256i e, __m256i f, __m256i g, __m256i& h, __m256i k)
4448
{
4549
__m256i t1 = Add(h, Sigma1(e), Ch(e, f, g), k);
4650
__m256i t2 = Add(Sigma0(a), Maj(a, b, c));

0 commit comments

Comments
 (0)