13 #ifndef MLIR_SUPPORT_MATHEXTRAS_H_ 14 #define MLIR_SUPPORT_MATHEXTRAS_H_ 17 #include "llvm/ADT/APInt.h" 23 inline int64_t
ceilDiv(int64_t lhs, int64_t rhs) {
26 return lhs % rhs > 0 ? lhs / rhs + 1 : lhs / rhs;
31 inline int64_t
floorDiv(int64_t lhs, int64_t rhs) {
34 return lhs % rhs < 0 ? lhs / rhs - 1 : lhs / rhs;
41 inline int64_t
mod(int64_t lhs, int64_t rhs) {
43 return lhs % rhs < 0 ? lhs % rhs + rhs : lhs % rhs;
47 inline int64_t
lcm(int64_t a, int64_t b) {
48 uint64_t x = std::abs(a);
49 uint64_t y = std::abs(b);
50 int64_t
lcm = (x * y) / llvm::GreatestCommonDivisor64(x, y);
51 assert((lcm >= a && lcm >= b) &&
"LCM overflow");
56 #endif // MLIR_SUPPORT_MATHEXTRAS_H_ Definition: InferTypeOpInterface.cpp:20
int64_t lcm(int64_t a, int64_t b)
Returns the least common multiple of 'a' and 'b'.
Definition: MathExtras.h:47
int64_t floorDiv(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:31
int64_t ceilDiv(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:23
int64_t mod(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:41