[llvm] [mlir] mlir/MathExtras: consolidate with llvm/MathExtras (PR #95087)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 11 02:16:46 PDT 2024
================
@@ -424,11 +424,47 @@ 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) {
+/// Returns the integer ceil(Numerator / Denominator). Unsigned integer version.
+LLVM_ATTRIBUTE_ALWAYS_INLINE uint64_t divideCeil(uint64_t Numerator,
+ uint64_t Denominator) {
return alignTo(Numerator, Denominator) / Denominator;
}
+/// Returns the integer ceil(Numerator / Denominator). Signed integer version.
+LLVM_ATTRIBUTE_ALWAYS_INLINE int64_t ceilDiv(int64_t Numerator,
+ int64_t Denominator) {
----------------
nikic wrote:
I think either these should have the same name with two overloads, or this should be called divideCeilSigned if there is some kind of overload resolution issue. Having divideCeil mean an unsigned division and ceilDiv a signed division is not at all obvious.
https://github.com/llvm/llvm-project/pull/95087
More information about the llvm-commits
mailing list