diff --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h --- a/mlir/include/mlir/Analysis/Presburger/Simplex.h +++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// // -// Functionality to perform analysis on IntegerPolyhedron. In particular, +// Functionality to perform analysis on an IntegerPolyhedron. In particular, // support for performing emptiness checks and redundancy checks. // //===----------------------------------------------------------------------===// @@ -39,7 +39,7 @@ /// sets. Furthermore, it can find a subset of these constraints that are /// redundant, i.e. a subset of constraints that doesn't constrain the affine /// set further after adding the non-redundant constraints. Simplex can also be -/// constructed from a IntegerPolyhedron object. +/// constructed from an IntegerPolyhedron object. /// /// The implementation of the Simplex and SimplexBase classes, other than the /// functionality for sampling, is based on the paper 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 @@ -503,13 +503,13 @@ } /// Add all the constraints from the given IntegerPolyhedron. -void SimplexBase::intersectIntegerPolyhedron(const IntegerPolyhedron &fac) { - assert(fac.getNumIds() == getNumVariables() && +void SimplexBase::intersectIntegerPolyhedron(const IntegerPolyhedron &poly) { + assert(poly.getNumIds() == getNumVariables() && "IntegerPolyhedron must have same dimensionality as simplex"); - for (unsigned i = 0, e = fac.getNumInequalities(); i < e; ++i) - addInequality(fac.getInequality(i)); - for (unsigned i = 0, e = fac.getNumEqualities(); i < e; ++i) - addEquality(fac.getEquality(i)); + for (unsigned i = 0, e = poly.getNumInequalities(); i < e; ++i) + addInequality(poly.getInequality(i)); + for (unsigned i = 0, e = poly.getNumEqualities(); i < e; ++i) + addEquality(poly.getEquality(i)); } Optional Simplex::computeRowOptimum(Direction direction, @@ -1284,16 +1284,16 @@ void SimplexBase::dump() const { print(llvm::errs()); } -bool Simplex::isRationalSubsetOf(const IntegerPolyhedron &fac) { +bool Simplex::isRationalSubsetOf(const IntegerPolyhedron &poly) { if (isEmpty()) return true; - for (unsigned i = 0, e = fac.getNumInequalities(); i < e; ++i) - if (!isRedundantInequality(fac.getInequality(i))) + for (unsigned i = 0, e = poly.getNumInequalities(); i < e; ++i) + if (!isRedundantInequality(poly.getInequality(i))) return false; - for (unsigned i = 0, e = fac.getNumEqualities(); i < e; ++i) - if (!isRedundantEquality(fac.getEquality(i))) + for (unsigned i = 0, e = poly.getNumEqualities(); i < e; ++i) + if (!isRedundantEquality(poly.getEquality(i))) return false; return true; diff --git a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp --- a/mlir/unittests/Analysis/Presburger/SimplexTest.cpp +++ b/mlir/unittests/Analysis/Presburger/SimplexTest.cpp @@ -476,24 +476,23 @@ EXPECT_TRUE(simplex.isRedundantEquality({-1, 0, 2})); // x = 2. } -static FlatAffineConstraints parseFAC(StringRef str, MLIRContext *context) { - FailureOr fac = parseIntegerSetToFAC(str, context); +static IntegerPolyhedron parsePoly(StringRef str, MLIRContext *context) { + FailureOr poly = parseIntegerSetToFAC(str, context); - EXPECT_TRUE(succeeded(fac)); + EXPECT_TRUE(succeeded(poly)); - return *fac; + return *poly; } TEST(SimplexTest, IsRationalSubsetOf) { MLIRContext context; - FlatAffineConstraints univ = FlatAffineConstraints::getUniverse(1, 0); - FlatAffineConstraints empty = - parseFAC("(x) : (x + 0 >= 0, -x - 1 >= 0)", &context); - FlatAffineConstraints s1 = parseFAC("(x) : ( x >= 0, -x + 4 >= 0)", &context); - FlatAffineConstraints s2 = - parseFAC("(x) : (x - 1 >= 0, -x + 3 >= 0)", &context); + IntegerPolyhedron univ = parsePoly("(x) : ()", &context); + IntegerPolyhedron empty = + parsePoly("(x) : (x + 0 >= 0, -x - 1 >= 0)", &context); + IntegerPolyhedron s1 = parsePoly("(x) : ( x >= 0, -x + 4 >= 0)", &context); + IntegerPolyhedron s2 = parsePoly("(x) : (x - 1 >= 0, -x + 3 >= 0)", &context); Simplex simUniv(univ); Simplex simEmpty(empty);