diff options
Diffstat (limited to 'include/llvm/Support/MathExtras.h')
-rw-r--r-- | include/llvm/Support/MathExtras.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index fd29865c8475e..a37a16784e2ac 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -424,7 +424,7 @@ constexpr inline bool isPowerOf2_32(uint32_t Value) { /// Return true if the argument is a power of two > 0 (64 bit edition.) constexpr inline bool isPowerOf2_64(uint64_t Value) { - return Value && !(Value & (Value - int64_t(1L))); + return Value && !(Value & (Value - 1)); } /// Return a byte-swapped representation of the 16-bit argument. @@ -687,6 +687,11 @@ template <uint64_t Align> constexpr inline uint64_t alignTo(uint64_t Value) { return (Value + Align - 1) / Align * Align; } +/// Returns the integer ceil(Numerator / Denominator). +inline uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator) { + return alignTo(Numerator, Denominator) / Denominator; +} + /// \c alignTo for contexts where a constant expression is required. /// \sa alignTo /// |