diff --git a/mlir/lib/Analysis/Presburger/Simplex.cpp b/mlir/lib/Analysis/Presburger/Simplex.cpp --- a/mlir/lib/Analysis/Presburger/Simplex.cpp +++ b/mlir/lib/Analysis/Presburger/Simplex.cpp @@ -18,6 +18,19 @@ const int nullIndex = std::numeric_limits::max(); +// Return a + scale*b; +#ifndef NDEBUG +static SmallVector +scaleAndAddForAssert(ArrayRef a, int64_t scale, ArrayRef b) { + assert(a.size() == b.size()); + SmallVector res; + res.reserve(a.size()); + for (unsigned i = 0, e = a.size(); i < e; ++i) + res.push_back(a[i] + scale * b[i]); + return res; +} +#endif + SimplexBase::SimplexBase(unsigned nVar, bool mustUseBigM, unsigned symbolOffset, unsigned nSymbol) : usingBigM(mustUseBigM), nRow(0), nCol(getNumFixedCols() + nVar), @@ -1717,17 +1730,6 @@ SmallVector snapshotStack; }; -// Return a + scale*b; -static SmallVector scaleAndAdd(ArrayRef a, int64_t scale, - ArrayRef b) { - assert(a.size() == b.size()); - SmallVector res; - res.reserve(a.size()); - for (unsigned i = 0, e = a.size(); i < e; ++i) - res.push_back(a[i] + scale * b[i]); - return res; -} - /// Reduce the basis to try and find a direction in which the polytope is /// "thin". This only works for bounded polytopes. /// @@ -1845,11 +1847,11 @@ // computed value of u is really the minimizer. // Check the value at u - 1. - assert(gbrSimplex.computeWidth(scaleAndAdd( + assert(gbrSimplex.computeWidth(scaleAndAddForAssert( basis.getRow(i + 1), -1, basis.getRow(i))) >= widthI[j] && "Computed u value does not minimize the width!"); // Check the value at u + 1. - assert(gbrSimplex.computeWidth(scaleAndAdd( + assert(gbrSimplex.computeWidth(scaleAndAddForAssert( basis.getRow(i + 1), +1, basis.getRow(i))) >= widthI[j] && "Computed u value does not minimize the width!");