From ea93df1db4bc05e6220a8899b713897459d575ec Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 1 Oct 2023 16:21:43 -0400 Subject: [PATCH] Use 64bit shift in intrinsic functions Avoids implicit narrowing from u64 to uint32_t even thouugh the value always fits. --- sus/num/__private/intrinsics.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sus/num/__private/intrinsics.h b/sus/num/__private/intrinsics.h index 563d39b2d..27393fc61 100644 --- a/sus/num/__private/intrinsics.h +++ b/sus/num/__private/intrinsics.h @@ -124,14 +124,14 @@ sus_pure_const sus_always_inline constexpr T unchecked_xor(T x, T y) noexcept { template requires(std::is_integral_v && !std::is_signed_v) sus_pure_const sus_always_inline constexpr T unchecked_shl( - T x, uint32_t y) noexcept { + T x, uint64_t y) noexcept { return static_cast(MathType{x} << y); } template requires(std::is_integral_v && !std::is_signed_v) sus_pure_const sus_always_inline constexpr T unchecked_shr( - T x, uint32_t y) noexcept { + T x, uint64_t y) noexcept { return static_cast(MathType{x} >> y); } @@ -1049,7 +1049,7 @@ template (::sus::mem::size_of() == 1 || ::sus::mem::size_of() == 2 || ::sus::mem::size_of() == 4 || ::sus::mem::size_of() == 8)) sus_pure_const inline constexpr OverflowOut shl_with_overflow( - T x, uint32_t shift) noexcept { + T x, uint64_t shift) noexcept { // Using `num_bits() - 1` as a mask only works if num_bits() is a power // of two, so we verify that ::sus::mem::size_of() is a power of 2, which // implies the number of bits is as well (since each byte is 2^3 bits). @@ -1065,7 +1065,7 @@ template (::sus::mem::size_of() == 1 || ::sus::mem::size_of() == 2 || ::sus::mem::size_of() == 4 || ::sus::mem::size_of() == 8)) sus_pure_const inline constexpr OverflowOut shl_with_overflow( - T x, uint32_t shift) noexcept { + T x, uint64_t shift) noexcept { // Using `num_bits() - 1` as a mask only works if num_bits() is a power // of two, so we verify that ::sus::mem::size_of() is a power of 2, which // implies the number of bits is as well (since each byte is 2^3 bits). @@ -1082,7 +1082,7 @@ template (::sus::mem::size_of() == 1 || ::sus::mem::size_of() == 2 || ::sus::mem::size_of() == 4 || ::sus::mem::size_of() == 8)) sus_pure_const inline constexpr OverflowOut shr_with_overflow( - T x, uint32_t shift) noexcept { + T x, uint64_t shift) noexcept { // Using `num_bits() - 1` as a mask only works if num_bits() is a power // of two, so we verify that ::sus::mem::size_of() is a power of 2, which // implies the number of bits is as well (since each byte is 2^3 bits). @@ -1098,7 +1098,7 @@ template (::sus::mem::size_of() == 1 || ::sus::mem::size_of() == 2 || ::sus::mem::size_of() == 4 || ::sus::mem::size_of() == 8)) sus_pure_const inline constexpr OverflowOut shr_with_overflow( - T x, uint32_t shift) noexcept { + T x, uint64_t shift) noexcept { // Using `num_bits() - 1` as a mask only works if num_bits() is a power // of two, so we verify that ::sus::mem::size_of() is a power of 2, which // implies the number of bits is as well (since each byte is 2^3 bits).