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 int64_t x = (rhs > 0) ? -1 : 1;
27 return ((lhs != 0) && (lhs > 0) == (rhs > 0)) ? ((lhs + x) / rhs) + 1
33 inline int64_t
floorDiv(int64_t lhs, int64_t rhs) {
36 int64_t x = (rhs < 0) ? 1 : -1;
37 return ((lhs != 0) && ((lhs < 0) != (rhs < 0))) ? -((-lhs + x) / rhs) - 1
45 inline int64_t
mod(int64_t lhs, int64_t rhs) {
47 return lhs % rhs < 0 ? lhs % rhs + rhs : lhs % rhs;
This header declares functions that assist transformations in the MemRef dialect.
int64_t floorDiv(int64_t lhs, int64_t rhs)
Returns the result of MLIR's floordiv operation on constants.
int64_t ceilDiv(int64_t lhs, int64_t rhs)
Returns the result of MLIR's ceildiv operation on constants.
int64_t mod(int64_t lhs, int64_t rhs)
Returns MLIR's mod operation on constants.