10
10
#include " mlir/Analysis/Presburger/Matrix.h"
11
11
#include " mlir/Support/MathExtras.h"
12
12
#include " llvm/ADT/Optional.h"
13
+ #include " llvm/Support/Compiler.h"
13
14
14
15
using namespace mlir ;
15
16
using namespace presburger ;
@@ -18,6 +19,18 @@ using Direction = Simplex::Direction;
18
19
19
20
const int nullIndex = std::numeric_limits<int >::max();
20
21
22
+ // Return a + scale*b;
23
+ LLVM_ATTRIBUTE_UNUSED
24
+ static SmallVector<int64_t , 8 >
25
+ scaleAndAddForAssert (ArrayRef<int64_t > a, int64_t scale, ArrayRef<int64_t > b) {
26
+ assert (a.size () == b.size ());
27
+ SmallVector<int64_t , 8 > res;
28
+ res.reserve (a.size ());
29
+ for (unsigned i = 0 , e = a.size (); i < e; ++i)
30
+ res.push_back (a[i] + scale * b[i]);
31
+ return res;
32
+ }
33
+
21
34
SimplexBase::SimplexBase (unsigned nVar, bool mustUseBigM, unsigned symbolOffset,
22
35
unsigned nSymbol)
23
36
: usingBigM(mustUseBigM), nRow(0 ), nCol(getNumFixedCols() + nVar),
@@ -1717,17 +1730,6 @@ class presburger::GBRSimplex {
1717
1730
SmallVector<unsigned , 8 > snapshotStack;
1718
1731
};
1719
1732
1720
- // Return a + scale*b;
1721
- static SmallVector<int64_t , 8 > scaleAndAdd (ArrayRef<int64_t > a, int64_t scale,
1722
- ArrayRef<int64_t > b) {
1723
- assert (a.size () == b.size ());
1724
- SmallVector<int64_t , 8 > res;
1725
- res.reserve (a.size ());
1726
- for (unsigned i = 0 , e = a.size (); i < e; ++i)
1727
- res.push_back (a[i] + scale * b[i]);
1728
- return res;
1729
- }
1730
-
1731
1733
// / Reduce the basis to try and find a direction in which the polytope is
1732
1734
// / "thin". This only works for bounded polytopes.
1733
1735
// /
@@ -1845,11 +1847,11 @@ void Simplex::reduceBasis(Matrix &basis, unsigned level) {
1845
1847
// computed value of u is really the minimizer.
1846
1848
1847
1849
// Check the value at u - 1.
1848
- assert (gbrSimplex.computeWidth (scaleAndAdd (
1850
+ assert (gbrSimplex.computeWidth (scaleAndAddForAssert (
1849
1851
basis.getRow (i + 1 ), -1 , basis.getRow (i))) >= widthI[j] &&
1850
1852
" Computed u value does not minimize the width!" );
1851
1853
// Check the value at u + 1.
1852
- assert (gbrSimplex.computeWidth (scaleAndAdd (
1854
+ assert (gbrSimplex.computeWidth (scaleAndAddForAssert (
1853
1855
basis.getRow (i + 1 ), +1 , basis.getRow (i))) >= widthI[j] &&
1854
1856
" Computed u value does not minimize the width!" );
1855
1857
0 commit comments