[Mlir-commits] [llvm] [mlir] Revert #95218 and #94953 (PR #95244)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jun 12 06:09:01 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Maksim Levental (makslevental)

<details>
<summary>Changes</summary>

Reverts #<!-- -->95218 and #<!-- -->94953. Next time please revert instead of fixing forward.

---

Patch is 244.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95244.diff


40 Files Affected:

- (removed) llvm/include/llvm/ADT/DynamicAPInt.h (-640) 
- (removed) llvm/include/llvm/ADT/SlowDynamicAPInt.h (-140) 
- (modified) llvm/lib/Support/CMakeLists.txt (-2) 
- (removed) llvm/lib/Support/DynamicAPInt.cpp (-29) 
- (removed) llvm/lib/Support/SlowDynamicAPInt.cpp (-288) 
- (modified) llvm/unittests/ADT/CMakeLists.txt (-1) 
- (removed) llvm/unittests/ADT/DynamicAPIntTest.cpp (-200) 
- (modified) mlir/include/mlir/Analysis/Presburger/Barvinok.h (+1-1) 
- (modified) mlir/include/mlir/Analysis/Presburger/Fraction.h (+23-29) 
- (modified) mlir/include/mlir/Analysis/Presburger/IntegerRelation.h (+43-59) 
- (modified) mlir/include/mlir/Analysis/Presburger/LinearTransform.h (+2-4) 
- (added) mlir/include/mlir/Analysis/Presburger/MPInt.h (+611) 
- (modified) mlir/include/mlir/Analysis/Presburger/Matrix.h (+13-13) 
- (modified) mlir/include/mlir/Analysis/Presburger/PWMAFunction.h (+7-11) 
- (modified) mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h (+4-4) 
- (modified) mlir/include/mlir/Analysis/Presburger/Simplex.h (+20-21) 
- (added) mlir/include/mlir/Analysis/Presburger/SlowMPInt.h (+135) 
- (modified) mlir/include/mlir/Analysis/Presburger/Utils.h (+28-34) 
- (modified) mlir/include/mlir/Support/LLVM.h (-2) 
- (modified) mlir/lib/Analysis/FlatLinearValueConstraints.cpp (+1-2) 
- (modified) mlir/lib/Analysis/Presburger/Barvinok.cpp (+3-3) 
- (modified) mlir/lib/Analysis/Presburger/CMakeLists.txt (+2) 
- (modified) mlir/lib/Analysis/Presburger/IntegerRelation.cpp (+92-100) 
- (modified) mlir/lib/Analysis/Presburger/LinearTransform.cpp (+7-6) 
- (added) mlir/lib/Analysis/Presburger/MPInt.cpp (+38) 
- (modified) mlir/lib/Analysis/Presburger/Matrix.cpp (+12-11) 
- (modified) mlir/lib/Analysis/Presburger/PWMAFunction.cpp (+19-20) 
- (modified) mlir/lib/Analysis/Presburger/PresburgerRelation.cpp (+28-30) 
- (modified) mlir/lib/Analysis/Presburger/Simplex.cpp (+84-88) 
- (added) mlir/lib/Analysis/Presburger/SlowMPInt.cpp (+290) 
- (modified) mlir/lib/Analysis/Presburger/Utils.cpp (+64-73) 
- (modified) mlir/unittests/Analysis/Presburger/CMakeLists.txt (+1) 
- (modified) mlir/unittests/Analysis/Presburger/FractionTest.cpp (+1-1) 
- (modified) mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp (+10-12) 
- (modified) mlir/unittests/Analysis/Presburger/LinearTransformTest.cpp (+1-2) 
- (added) mlir/unittests/Analysis/Presburger/MPIntTest.cpp (+200) 
- (modified) mlir/unittests/Analysis/Presburger/MatrixTest.cpp (+1-1) 
- (modified) mlir/unittests/Analysis/Presburger/SimplexTest.cpp (+14-15) 
- (modified) mlir/unittests/Analysis/Presburger/Utils.h (+9-11) 
- (modified) mlir/unittests/Analysis/Presburger/UtilsTest.cpp (+19-28) 


``````````diff
diff --git a/llvm/include/llvm/ADT/DynamicAPInt.h b/llvm/include/llvm/ADT/DynamicAPInt.h
deleted file mode 100644
index 78a0372e09c49..0000000000000
--- a/llvm/include/llvm/ADT/DynamicAPInt.h
+++ /dev/null
@@ -1,640 +0,0 @@
-//===- DynamicAPInt.h - DynamicAPInt Class ----------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This is a simple class to represent arbitrary precision signed integers.
-// Unlike APInt, one does not have to specify a fixed maximum size, and the
-// integer can take on any arbitrary values. This is optimized for small-values
-// by providing fast-paths for the cases when the value stored fits in 64-bits.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ADT_DYNAMICAPINT_H
-#define LLVM_ADT_DYNAMICAPINT_H
-
-#include "llvm/ADT/SlowDynamicAPInt.h"
-#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
-#include <numeric>
-
-namespace llvm {
-/// This class provides support for dynamic arbitrary-precision arithmetic.
-///
-/// Unlike APInt, this extends the precision as necessary to prevent overflows
-/// and supports operations between objects with differing internal precisions.
-///
-/// This is optimized for small-values by providing fast-paths for the cases
-/// when the value stored fits in 64-bits. We annotate all fastpaths by using
-/// the LLVM_LIKELY/LLVM_UNLIKELY annotations. Removing these would result in
-/// a 1.2x performance slowdown.
-///
-/// We always_inline all operations; removing these results in a 1.5x
-/// performance slowdown.
-///
-/// When HoldsLarge is true, a SlowMPInt is held in the union. If it is false,
-/// the int64_t is held. Using std::variant instead would lead to significantly
-/// worse performance.
-class DynamicAPInt {
-  union {
-    int64_t ValSmall;
-    detail::SlowDynamicAPInt ValLarge;
-  };
-  unsigned HoldsLarge;
-
-  LLVM_ATTRIBUTE_ALWAYS_INLINE void initSmall(int64_t O) {
-    if (LLVM_UNLIKELY(isLarge()))
-      ValLarge.detail::SlowDynamicAPInt::~SlowDynamicAPInt();
-    ValSmall = O;
-    HoldsLarge = false;
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE void
-  initLarge(const detail::SlowDynamicAPInt &O) {
-    if (LLVM_LIKELY(isSmall())) {
-      // The data in memory could be in an arbitrary state, not necessarily
-      // corresponding to any valid state of ValLarge; we cannot call any member
-      // functions, e.g. the assignment operator on it, as they may access the
-      // invalid internal state. We instead construct a new object using
-      // placement new.
-      new (&ValLarge) detail::SlowDynamicAPInt(O);
-    } else {
-      // In this case, we need to use the assignment operator, because if we use
-      // placement-new as above we would lose track of allocated memory
-      // and leak it.
-      ValLarge = O;
-    }
-    HoldsLarge = true;
-  }
-
-  LLVM_ATTRIBUTE_ALWAYS_INLINE explicit DynamicAPInt(
-      const detail::SlowDynamicAPInt &Val)
-      : ValLarge(Val), HoldsLarge(true) {}
-  LLVM_ATTRIBUTE_ALWAYS_INLINE bool isSmall() const { return !HoldsLarge; }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE bool isLarge() const { return HoldsLarge; }
-  /// Get the stored value. For getSmall/Large,
-  /// the stored value should be small/large.
-  LLVM_ATTRIBUTE_ALWAYS_INLINE int64_t getSmall() const {
-    assert(isSmall() &&
-           "getSmall should only be called when the value stored is small!");
-    return ValSmall;
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE int64_t &getSmall() {
-    assert(isSmall() &&
-           "getSmall should only be called when the value stored is small!");
-    return ValSmall;
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE const detail::SlowDynamicAPInt &
-  getLarge() const {
-    assert(isLarge() &&
-           "getLarge should only be called when the value stored is large!");
-    return ValLarge;
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE detail::SlowDynamicAPInt &getLarge() {
-    assert(isLarge() &&
-           "getLarge should only be called when the value stored is large!");
-    return ValLarge;
-  }
-  explicit operator detail::SlowDynamicAPInt() const {
-    if (isSmall())
-      return detail::SlowDynamicAPInt(getSmall());
-    return getLarge();
-  }
-
-public:
-  LLVM_ATTRIBUTE_ALWAYS_INLINE explicit DynamicAPInt(int64_t Val)
-      : ValSmall(Val), HoldsLarge(false) {}
-  LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt() : DynamicAPInt(0) {}
-  LLVM_ATTRIBUTE_ALWAYS_INLINE ~DynamicAPInt() {
-    if (LLVM_UNLIKELY(isLarge()))
-      ValLarge.detail::SlowDynamicAPInt::~SlowDynamicAPInt();
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt(const DynamicAPInt &O)
-      : ValSmall(O.ValSmall), HoldsLarge(false) {
-    if (LLVM_UNLIKELY(O.isLarge()))
-      initLarge(O.ValLarge);
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt &operator=(const DynamicAPInt &O) {
-    if (LLVM_LIKELY(O.isSmall())) {
-      initSmall(O.ValSmall);
-      return *this;
-    }
-    initLarge(O.ValLarge);
-    return *this;
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt &operator=(int X) {
-    initSmall(X);
-    return *this;
-  }
-  LLVM_ATTRIBUTE_ALWAYS_INLINE explicit operator int64_t() const {
-    if (isSmall())
-      return getSmall();
-    return static_cast<int64_t>(getLarge());
-  }
-
-  bool operator==(const DynamicAPInt &O) const;
-  bool operator!=(const DynamicAPInt &O) const;
-  bool operator>(const DynamicAPInt &O) const;
-  bool operator<(const DynamicAPInt &O) const;
-  bool operator<=(const DynamicAPInt &O) const;
-  bool operator>=(const DynamicAPInt &O) const;
-  DynamicAPInt operator+(const DynamicAPInt &O) const;
-  DynamicAPInt operator-(const DynamicAPInt &O) const;
-  DynamicAPInt operator*(const DynamicAPInt &O) const;
-  DynamicAPInt operator/(const DynamicAPInt &O) const;
-  DynamicAPInt operator%(const DynamicAPInt &O) const;
-  DynamicAPInt &operator+=(const DynamicAPInt &O);
-  DynamicAPInt &operator-=(const DynamicAPInt &O);
-  DynamicAPInt &operator*=(const DynamicAPInt &O);
-  DynamicAPInt &operator/=(const DynamicAPInt &O);
-  DynamicAPInt &operator%=(const DynamicAPInt &O);
-  DynamicAPInt operator-() const;
-  DynamicAPInt &operator++();
-  DynamicAPInt &operator--();
-
-  // Divide by a number that is known to be positive.
-  // This is slightly more efficient because it saves an overflow check.
-  DynamicAPInt divByPositive(const DynamicAPInt &O) const;
-  DynamicAPInt &divByPositiveInPlace(const DynamicAPInt &O);
-
-  friend DynamicAPInt abs(const DynamicAPInt &X);
-  friend DynamicAPInt ceilDiv(const DynamicAPInt &LHS, const DynamicAPInt &RHS);
-  friend DynamicAPInt floorDiv(const DynamicAPInt &LHS,
-                               const DynamicAPInt &RHS);
-  // The operands must be non-negative for gcd.
-  friend DynamicAPInt gcd(const DynamicAPInt &A, const DynamicAPInt &B);
-  friend DynamicAPInt lcm(const DynamicAPInt &A, const DynamicAPInt &B);
-  friend DynamicAPInt mod(const DynamicAPInt &LHS, const DynamicAPInt &RHS);
-
-  /// ---------------------------------------------------------------------------
-  /// Convenience operator overloads for int64_t.
-  /// ---------------------------------------------------------------------------
-  friend DynamicAPInt &operator+=(DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt &operator-=(DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt &operator*=(DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt &operator/=(DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt &operator%=(DynamicAPInt &A, int64_t B);
-
-  friend bool operator==(const DynamicAPInt &A, int64_t B);
-  friend bool operator!=(const DynamicAPInt &A, int64_t B);
-  friend bool operator>(const DynamicAPInt &A, int64_t B);
-  friend bool operator<(const DynamicAPInt &A, int64_t B);
-  friend bool operator<=(const DynamicAPInt &A, int64_t B);
-  friend bool operator>=(const DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt operator+(const DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt operator-(const DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt operator*(const DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt operator/(const DynamicAPInt &A, int64_t B);
-  friend DynamicAPInt operator%(const DynamicAPInt &A, int64_t B);
-
-  friend bool operator==(int64_t A, const DynamicAPInt &B);
-  friend bool operator!=(int64_t A, const DynamicAPInt &B);
-  friend bool operator>(int64_t A, const DynamicAPInt &B);
-  friend bool operator<(int64_t A, const DynamicAPInt &B);
-  friend bool operator<=(int64_t A, const DynamicAPInt &B);
-  friend bool operator>=(int64_t A, const DynamicAPInt &B);
-  friend DynamicAPInt operator+(int64_t A, const DynamicAPInt &B);
-  friend DynamicAPInt operator-(int64_t A, const DynamicAPInt &B);
-  friend DynamicAPInt operator*(int64_t A, const DynamicAPInt &B);
-  friend DynamicAPInt operator/(int64_t A, const DynamicAPInt &B);
-  friend DynamicAPInt operator%(int64_t A, const DynamicAPInt &B);
-
-  friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-  raw_ostream &print(raw_ostream &OS) const;
-  LLVM_DUMP_METHOD void dump() const;
-#endif
-};
-
-#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-inline raw_ostream &operator<<(raw_ostream &OS, const DynamicAPInt &X) {
-  X.print(OS);
-  return OS;
-}
-#endif
-
-/// Redeclarations of friend declaration above to
-/// make it discoverable by lookups.
-hash_code hash_value(const DynamicAPInt &X); // NOLINT
-
-/// This just calls through to the operator int64_t, but it's useful when a
-/// function pointer is required. (Although this is marked inline, it is still
-/// possible to obtain and use a function pointer to this.)
-static inline int64_t int64fromDynamicAPInt(const DynamicAPInt &X) {
-  return int64_t(X);
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt dynamicAPIntFromInt64(int64_t X) {
-  return DynamicAPInt(X);
-}
-
-// The RHS is always expected to be positive, and the result
-/// is always non-negative.
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt mod(const DynamicAPInt &LHS,
-                                              const DynamicAPInt &RHS);
-
-namespace detail {
-// Division overflows only when trying to negate the minimal signed value.
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool divWouldOverflow(int64_t X, int64_t Y) {
-  return X == std::numeric_limits<int64_t>::min() && Y == -1;
-}
-} // namespace detail
-
-/// We define the operations here in the header to facilitate inlining.
-
-/// ---------------------------------------------------------------------------
-/// Comparison operators.
-/// ---------------------------------------------------------------------------
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool
-DynamicAPInt::operator==(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return getSmall() == O.getSmall();
-  return detail::SlowDynamicAPInt(*this) == detail::SlowDynamicAPInt(O);
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool
-DynamicAPInt::operator!=(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return getSmall() != O.getSmall();
-  return detail::SlowDynamicAPInt(*this) != detail::SlowDynamicAPInt(O);
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool
-DynamicAPInt::operator>(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return getSmall() > O.getSmall();
-  return detail::SlowDynamicAPInt(*this) > detail::SlowDynamicAPInt(O);
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool
-DynamicAPInt::operator<(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return getSmall() < O.getSmall();
-  return detail::SlowDynamicAPInt(*this) < detail::SlowDynamicAPInt(O);
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool
-DynamicAPInt::operator<=(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return getSmall() <= O.getSmall();
-  return detail::SlowDynamicAPInt(*this) <= detail::SlowDynamicAPInt(O);
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE bool
-DynamicAPInt::operator>=(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return getSmall() >= O.getSmall();
-  return detail::SlowDynamicAPInt(*this) >= detail::SlowDynamicAPInt(O);
-}
-
-/// ---------------------------------------------------------------------------
-/// Arithmetic operators.
-/// ---------------------------------------------------------------------------
-
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt
-DynamicAPInt::operator+(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    DynamicAPInt Result;
-    bool Overflow = AddOverflow(getSmall(), O.getSmall(), Result.getSmall());
-    if (LLVM_LIKELY(!Overflow))
-      return Result;
-    return DynamicAPInt(detail::SlowDynamicAPInt(*this) +
-                        detail::SlowDynamicAPInt(O));
-  }
-  return DynamicAPInt(detail::SlowDynamicAPInt(*this) +
-                      detail::SlowDynamicAPInt(O));
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt
-DynamicAPInt::operator-(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    DynamicAPInt Result;
-    bool Overflow = SubOverflow(getSmall(), O.getSmall(), Result.getSmall());
-    if (LLVM_LIKELY(!Overflow))
-      return Result;
-    return DynamicAPInt(detail::SlowDynamicAPInt(*this) -
-                        detail::SlowDynamicAPInt(O));
-  }
-  return DynamicAPInt(detail::SlowDynamicAPInt(*this) -
-                      detail::SlowDynamicAPInt(O));
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt
-DynamicAPInt::operator*(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    DynamicAPInt Result;
-    bool Overflow = MulOverflow(getSmall(), O.getSmall(), Result.getSmall());
-    if (LLVM_LIKELY(!Overflow))
-      return Result;
-    return DynamicAPInt(detail::SlowDynamicAPInt(*this) *
-                        detail::SlowDynamicAPInt(O));
-  }
-  return DynamicAPInt(detail::SlowDynamicAPInt(*this) *
-                      detail::SlowDynamicAPInt(O));
-}
-
-// Division overflows only occur when negating the minimal possible value.
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt
-DynamicAPInt::divByPositive(const DynamicAPInt &O) const {
-  assert(O > 0);
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return DynamicAPInt(getSmall() / O.getSmall());
-  return DynamicAPInt(detail::SlowDynamicAPInt(*this) /
-                      detail::SlowDynamicAPInt(O));
-}
-
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt
-DynamicAPInt::operator/(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    // Division overflows only occur when negating the minimal possible value.
-    if (LLVM_UNLIKELY(detail::divWouldOverflow(getSmall(), O.getSmall())))
-      return -*this;
-    return DynamicAPInt(getSmall() / O.getSmall());
-  }
-  return DynamicAPInt(detail::SlowDynamicAPInt(*this) /
-                      detail::SlowDynamicAPInt(O));
-}
-
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt abs(const DynamicAPInt &X) {
-  return DynamicAPInt(X >= 0 ? X : -X);
-}
-// Division overflows only occur when negating the minimal possible value.
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt ceilDiv(const DynamicAPInt &LHS,
-                                                  const DynamicAPInt &RHS) {
-  if (LLVM_LIKELY(LHS.isSmall() && RHS.isSmall())) {
-    if (LLVM_UNLIKELY(detail::divWouldOverflow(LHS.getSmall(), RHS.getSmall())))
-      return -LHS;
-    return DynamicAPInt(divideCeilSigned(LHS.getSmall(), RHS.getSmall()));
-  }
-  return DynamicAPInt(
-      ceilDiv(detail::SlowDynamicAPInt(LHS), detail::SlowDynamicAPInt(RHS)));
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt floorDiv(const DynamicAPInt &LHS,
-                                                   const DynamicAPInt &RHS) {
-  if (LLVM_LIKELY(LHS.isSmall() && RHS.isSmall())) {
-    if (LLVM_UNLIKELY(detail::divWouldOverflow(LHS.getSmall(), RHS.getSmall())))
-      return -LHS;
-    return DynamicAPInt(divideFloorSigned(LHS.getSmall(), RHS.getSmall()));
-  }
-  return DynamicAPInt(
-      floorDiv(detail::SlowDynamicAPInt(LHS), detail::SlowDynamicAPInt(RHS)));
-}
-// The RHS is always expected to be positive, and the result
-/// is always non-negative.
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt mod(const DynamicAPInt &LHS,
-                                              const DynamicAPInt &RHS) {
-  if (LLVM_LIKELY(LHS.isSmall() && RHS.isSmall()))
-    return DynamicAPInt(mod(LHS.getSmall(), RHS.getSmall()));
-  return DynamicAPInt(
-      mod(detail::SlowDynamicAPInt(LHS), detail::SlowDynamicAPInt(RHS)));
-}
-
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt gcd(const DynamicAPInt &A,
-                                              const DynamicAPInt &B) {
-  assert(A >= 0 && B >= 0 && "operands must be non-negative!");
-  if (LLVM_LIKELY(A.isSmall() && B.isSmall()))
-    return DynamicAPInt(std::gcd(A.getSmall(), B.getSmall()));
-  return DynamicAPInt(
-      gcd(detail::SlowDynamicAPInt(A), detail::SlowDynamicAPInt(B)));
-}
-
-/// Returns the least common multiple of A and B.
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt lcm(const DynamicAPInt &A,
-                                              const DynamicAPInt &B) {
-  DynamicAPInt X = abs(A);
-  DynamicAPInt Y = abs(B);
-  return (X * Y) / gcd(X, Y);
-}
-
-/// This operation cannot overflow.
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt
-DynamicAPInt::operator%(const DynamicAPInt &O) const {
-  if (LLVM_LIKELY(isSmall() && O.isSmall()))
-    return DynamicAPInt(getSmall() % O.getSmall());
-  return DynamicAPInt(detail::SlowDynamicAPInt(*this) %
-                      detail::SlowDynamicAPInt(O));
-}
-
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt DynamicAPInt::operator-() const {
-  if (LLVM_LIKELY(isSmall())) {
-    if (LLVM_LIKELY(getSmall() != std::numeric_limits<int64_t>::min()))
-      return DynamicAPInt(-getSmall());
-    return DynamicAPInt(-detail::SlowDynamicAPInt(*this));
-  }
-  return DynamicAPInt(-detail::SlowDynamicAPInt(*this));
-}
-
-/// ---------------------------------------------------------------------------
-/// Assignment operators, preincrement, predecrement.
-/// ---------------------------------------------------------------------------
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt &
-DynamicAPInt::operator+=(const DynamicAPInt &O) {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    int64_t Result = getSmall();
-    bool Overflow = AddOverflow(getSmall(), O.getSmall(), Result);
-    if (LLVM_LIKELY(!Overflow)) {
-      getSmall() = Result;
-      return *this;
-    }
-    // Note: this return is not strictly required but
-    // removing it leads to a performance regression.
-    return *this = DynamicAPInt(detail::SlowDynamicAPInt(*this) +
-                                detail::SlowDynamicAPInt(O));
-  }
-  return *this = DynamicAPInt(detail::SlowDynamicAPInt(*this) +
-                              detail::SlowDynamicAPInt(O));
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt &
-DynamicAPInt::operator-=(const DynamicAPInt &O) {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    int64_t Result = getSmall();
-    bool Overflow = SubOverflow(getSmall(), O.getSmall(), Result);
-    if (LLVM_LIKELY(!Overflow)) {
-      getSmall() = Result;
-      return *this;
-    }
-    // Note: this return is not strictly required but
-    // removing it leads to a performance regression.
-    return *this = DynamicAPInt(detail::SlowDynamicAPInt(*this) -
-                                detail::SlowDynamicAPInt(O));
-  }
-  return *this = DynamicAPInt(detail::SlowDynamicAPInt(*this) -
-                              detail::SlowDynamicAPInt(O));
-}
-LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt &
-DynamicAPInt::operator*=(const DynamicAPInt &O) {
-  if (LLVM_LIKELY(isSmall() && O.isSmall())) {
-    int64_t Result = getSmall();
-    bool Overflow = MulOverflow(getSmall(), O.getSmall(), Result);
-    if (LLVM_LIKELY(!Overflow)) {
-      getSmall() = Result;
-      return *this;
-    }
-    // Note: this return is not strictly required but
-    // removing it leads to a performance regression.
-    return *this = DynamicAPInt(detail::SlowDynamicAPInt(*this) *
-                                detail::SlowDynamicAPInt(O));
-  }
-  return *this = DynamicAPInt(detail::SlowDynamicAPInt(*t...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/95244


More information about the Mlir-commits mailing list