Skip to content

Commit 2b3376b

Browse files
m-alvarezaa755dhil
authored andcommitted
Apply suggestions from code review
Co-authored-by: Abhishek Anand <[email protected]> Co-authored-by: Daniel Hillerström <[email protected]>
1 parent 874e4f7 commit 2b3376b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

category/vm/runtime/uint256.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
#error "Target architecture must support AVX2"
3232
#endif
3333

34+
#ifndef __BMI2__
35+
# error "Target architecture must support BMI2 (for MULX)"
36+
#endif
37+
3438
// GCC's overeager SLP vectorizer sometimes pessimizes code. For functions that
3539
// are particularly sensitive about this (such as multiplication), the
3640
// vectorizer can be turned off with the MONAD_VM_NO_VECTORIZE pragma.
@@ -731,9 +735,9 @@ namespace monad::vm::runtime
731735
inline constexpr std::pair<uint64_t, uint64_t>
732736
mulx_constexpr(uint64_t const x, uint64_t const y) noexcept
733737
{
734-
auto const prod = static_cast<uint128_t>(x) * y;
735-
auto const hi = static_cast<uint64_t>(prod >> 64);
736-
auto const lo = static_cast<uint64_t>(prod);
738+
uint128_t const prod = static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
739+
uint64_t const hi = static_cast<uint64_t>(prod >> uint128_t{64});
740+
uint64_t const lo = static_cast<uint64_t>(prod);
737741
return {hi, lo};
738742
}
739743

@@ -970,10 +974,10 @@ namespace monad::vm::runtime
970974
requires(0 < R && 0 < M && 0 < N && R <= M + N)
971975
{
972976
if consteval {
973-
return truncating_mul_constexpr<R>(x, y);
977+
return truncating_mul_constexpr<R, M, N>(x, y);
974978
}
975979
else {
976-
return truncating_mul_runtime<R>(x, y);
980+
return truncating_mul_runtime<R, M, N>(x, y);
977981
}
978982
}
979983

0 commit comments

Comments
 (0)