From dc70893e6b993343b2400e5dff2cf89017a73654 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 28 Mar 2021 16:12:09 +0200 Subject: [PATCH] Optimize cn-heavy in GCC builds +0.7% in GCC builds, but GCC is still slower than MSVC on cn-heavy. --- src/crypto/cn/CryptoNight_x86.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/crypto/cn/CryptoNight_x86.h b/src/crypto/cn/CryptoNight_x86.h index 4dc886d2..e6392ade 100644 --- a/src/crypto/cn/CryptoNight_x86.h +++ b/src/crypto/cn/CryptoNight_x86.h @@ -740,7 +740,17 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si if (props.isHeavy()) { int64_t n = ((int64_t*)&l0[interleaved_index(idx0 & MASK)])[0]; int64_t d = ((int32_t*)&l0[interleaved_index(idx0 & MASK)])[2]; - int64_t q = n / (d | 0x5); + + int64_t d5; + +# if defined _MSC_VER + d5 = d | 5; +# else + // Workaround for stupid GCC which converts to 32 bit before doing "| 5" and then converts back to 64 bit + asm("mov %1, %0\n\tor $5, %0" : "=r"(d5) : "r"(d)); +# endif + + int64_t q = n / d5; ((int64_t*)&l0[interleaved_index(idx0 & MASK)])[0] = n ^ q;