From 5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 4 Jun 2023 15:51:44 +0100 Subject: [PATCH] Use `__shiftright128` intrinsic in `secp256k1_u128_rshift` on MSVC --- src/int128_struct_impl.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/int128_struct_impl.h b/src/int128_struct_impl.h index 990982da8..962a71d13 100644 --- a/src/int128_struct_impl.h +++ b/src/int128_struct_impl.h @@ -80,7 +80,12 @@ static SECP256K1_INLINE void secp256k1_u128_rshift(secp256k1_uint128 *r, unsigne r->lo = r->hi >> (n-64); r->hi = 0; } else if (n > 0) { +#if defined(_MSC_VER) && defined(_M_X64) + VERIFY_CHECK(n < 64); + r->lo = __shiftright128(r->lo, r->hi, n); +#else r->lo = ((1U * r->hi) << (64-n)) | r->lo >> n; +#endif r->hi >>= n; } }