diff --git a/mlir/include/mlir/Analysis/Presburger/MPInt.h b/mlir/include/mlir/Analysis/Presburger/MPInt.h --- a/mlir/include/mlir/Analysis/Presburger/MPInt.h +++ b/mlir/include/mlir/Analysis/Presburger/MPInt.h @@ -23,6 +23,17 @@ namespace mlir { namespace presburger { +/// Redefine these functions, which operate on 64-bit ints, to also be part of +/// the mlir::presburger namespace. This is useful because this file defines +/// identically-named functions that operate on MPInts, which would otherwie +/// become the only candidates of overload resolution when calling e.g. ceilDiv +/// from the mlir::presburger namespace. So to access the 64-bit overloads, an +/// explict call to mlir::ceilDiv would be required. These using declarations +/// allow overload resolution to transparently call the right function. +using ::mlir::ceilDiv; +using ::mlir::floorDiv; +using ::mlir::mod; + namespace detail { /// If builtin intrinsics for overflow-checked arithmetic are available, /// use them. Otherwise, call through to LLVM's overflow-checked arithmetic @@ -362,7 +373,7 @@ if (LLVM_LIKELY(lhs.isSmall() && rhs.isSmall())) { if (LLVM_UNLIKELY(detail::divWouldOverflow(lhs.getSmall(), rhs.getSmall()))) return -lhs; - return MPInt(mlir::ceilDiv(lhs.getSmall(), rhs.getSmall())); + return MPInt(ceilDiv(lhs.getSmall(), rhs.getSmall())); } return MPInt(ceilDiv(detail::SlowMPInt(lhs), detail::SlowMPInt(rhs))); } @@ -371,7 +382,7 @@ if (LLVM_LIKELY(lhs.isSmall() && rhs.isSmall())) { if (LLVM_UNLIKELY(detail::divWouldOverflow(lhs.getSmall(), rhs.getSmall()))) return -lhs; - return MPInt(mlir::floorDiv(lhs.getSmall(), rhs.getSmall())); + return MPInt(floorDiv(lhs.getSmall(), rhs.getSmall())); } return MPInt(floorDiv(detail::SlowMPInt(lhs), detail::SlowMPInt(rhs))); } @@ -379,7 +390,7 @@ /// is always non-negative. LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt mod(const MPInt &lhs, const MPInt &rhs) { if (LLVM_LIKELY(lhs.isSmall() && rhs.isSmall())) - return MPInt(mlir::mod(lhs.getSmall(), rhs.getSmall())); + return MPInt(mod(lhs.getSmall(), rhs.getSmall())); return MPInt(mod(detail::SlowMPInt(lhs), detail::SlowMPInt(rhs))); }