Skip to content

Commit

Permalink
DASSERT if CeilDiv by zero
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695344538
  • Loading branch information
jan-wassenberg authored and copybara-github committed Nov 11, 2024
1 parent cb1ba56 commit 56b0cfb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hwy/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2570,10 +2570,11 @@ HWY_API constexpr TTo ConvertScalarTo(TTo in) {

template <typename T1, typename T2>
constexpr inline T1 DivCeil(T1 a, T2 b) {
HWY_DASSERT(b != 0);
return (a + b - 1) / b;
}

// Works for any `align`; if a power of two, compiler emits ADD+AND.
// Works for any non-zero `align`; if a power of two, compiler emits ADD+AND.
constexpr inline size_t RoundUpTo(size_t what, size_t align) {
return DivCeil(what, align) * align;
}
Expand Down

0 comments on commit 56b0cfb

Please sign in to comment.