Skip to content

Commit

Permalink
Avoid checking unsigned values for negativity (#2997)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Schellenberger Costa <[email protected]>
  • Loading branch information
bernhardmgruber and miscco authored Dec 2, 2024
1 parent 4e307bf commit 08c7aa4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cub/cub/detail/fast_modulo_division.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@ multiply_extract_higher_bits(T value, R multiplier)
static_assert(supported_integral<R>::value, "unsupported type");
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_ICC(186) // pointless comparison of unsigned integer with zero
_CCCL_ASSERT(value >= 0, "value must be non-negative");
_CCCL_ASSERT(multiplier >= 0, "multiplier must be non-negative");
_CCCL_IF_CONSTEXPR (_CCCL_TRAIT(::cuda::std::is_signed, T))
{
_CCCL_ASSERT(value >= 0, "value must be non-negative");
}
_CCCL_IF_CONSTEXPR (_CCCL_TRAIT(::cuda::std::is_signed, R))
{
_CCCL_ASSERT(multiplier >= 0, "multiplier must be non-negative");
}
_CCCL_DIAG_POP
static constexpr int NumBits = sizeof(DivisorType) * CHAR_BIT;
using unsigned_t = unsigned_implicit_prom_t<DivisorType>;
Expand Down

0 comments on commit 08c7aa4

Please sign in to comment.