Skip to content

Commit 1083683

Browse files
Merge #1336: Use __shiftright128 intrinsic in secp256k1_u128_rshift on MSVC
5b7bf2e Use `__shiftright128` intrinsic in `secp256k1_u128_rshift` on MSVC (Hennadii Stepanov) Pull request description: Closes #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 5b7bf2e real-or-random: ACK 5b7bf2e tested with MSVC x64 Tree-SHA512: bc4c245a9da83c783a0479e751a4bc2ec77a34b99189fcc4431033a5420c93b610f3b960d3f23c15bce2eb010beba665b3e84d468b3fdab3d5846d4f27016898
2 parents 3c1a0fd + 5b7bf2e commit 1083683

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/int128_struct_impl.h

+5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ static SECP256K1_INLINE void secp256k1_u128_rshift(secp256k1_uint128 *r, unsigne
8080
r->lo = r->hi >> (n-64);
8181
r->hi = 0;
8282
} else if (n > 0) {
83+
#if defined(_MSC_VER) && defined(_M_X64)
84+
VERIFY_CHECK(n < 64);
85+
r->lo = __shiftright128(r->lo, r->hi, n);
86+
#else
8387
r->lo = ((1U * r->hi) << (64-n)) | r->lo >> n;
88+
#endif
8489
r->hi >>= n;
8590
}
8691
}

0 commit comments

Comments
 (0)