Merge bitcoin-core/secp256k1#1336: Use __shiftright128
intrinsic in secp256k1_u128_rshift
on MSVC
5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb Use `__shiftright128` intrinsic in `secp256k1_u128_rshift` on MSVC (Hennadii Stepanov) Pull request description: Closes https://github.com/bitcoin-core/secp256k1/issues/1324. As the `__shiftright128` [docs](https://learn.microsoft.com/en-us/cpp/intrinsics/shiftright128) state: > The `Shift` value is always modulo 64... it is not applicable for the `n >= 64` branch. ACKs for top commit: sipa: utACK 5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb real-or-random: ACK 5b7bf2e9d4ee02cbec1105ad6e890c34a4da1beb tested with MSVC x64 Tree-SHA512: bc4c245a9da83c783a0479e751a4bc2ec77a34b99189fcc4431033a5420c93b610f3b960d3f23c15bce2eb010beba665b3e84d468b3fdab3d5846d4f27016898
This commit is contained in:
commit
10836832e7
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user