[Mlir-commits] [mlir] b486a9d - [MLIR][Presburger] Move IntegerPolyhedron::reset to FlatAffineConstraints::reset
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Feb 27 09:00:52 PST 2022
Author: Groverkss
Date: 2022-02-27T22:27:28+05:30
New Revision: b486a9de80188e30fbdfecdce99ec262d2619b00
URL: https://github.com/llvm/llvm-project/commit/b486a9de80188e30fbdfecdce99ec262d2619b00
DIFF: https://github.com/llvm/llvm-project/commit/b486a9de80188e30fbdfecdce99ec262d2619b00.diff
LOG: [MLIR][Presburger] Move IntegerPolyhedron::reset to FlatAffineConstraints::reset
This patch moves IntegerPolyhedron::reset to FlatAffineConstraints::reset. This
function is not required in IntegerPolyhedron and creates ambiguity while
shifting implementations to IntegerRelation.
This patch is part of a series of patches to introduce relations in Presburger
library.
Reviewed By: arjunp
Differential Revision: https://reviews.llvm.org/D120628
Added:
Modified:
mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h b/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
index 5f0ae76855049..b4cf2b0f43dbb 100644
--- a/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
+++ b/mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h
@@ -144,16 +144,6 @@ class IntegerPolyhedron : public IntegerRelation {
// Clones this object.
std::unique_ptr<IntegerPolyhedron> clone() const;
- /// Clears any existing data and reserves memory for the specified
- /// constraints.
- virtual void reset(unsigned numReservedInequalities,
- unsigned numReservedEqualities, unsigned numReservedCols,
- unsigned numDims, unsigned numSymbols,
- unsigned numLocals = 0);
-
- void reset(unsigned numDims = 0, unsigned numSymbols = 0,
- unsigned numLocals = 0);
-
/// Appends constraints from `other` into `this`. This is equivalent to an
/// intersection with no simplification of any sort attempted.
void append(const IntegerPolyhedron &other);
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
index 67e565b73d8c8..96406748d2ba6 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
@@ -102,6 +102,15 @@ class FlatAffineConstraints : public presburger::IntegerPolyhedron {
return cst->getKind() == Kind::FlatAffineConstraints;
}
+ /// Clears any existing data and reserves memory for the specified
+ /// constraints.
+ virtual void reset(unsigned numReservedInequalities,
+ unsigned numReservedEqualities, unsigned numReservedCols,
+ unsigned numDims, unsigned numSymbols,
+ unsigned numLocals = 0);
+ void reset(unsigned numDims = 0, unsigned numSymbols = 0,
+ unsigned numLocals = 0);
+
// Clones this object.
std::unique_ptr<FlatAffineConstraints> clone() const;
diff --git a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
index ce24af0d467da..453b2c1f036f8 100644
--- a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
@@ -31,23 +31,6 @@ std::unique_ptr<IntegerPolyhedron> IntegerPolyhedron::clone() const {
return std::make_unique<IntegerPolyhedron>(*this);
}
-void IntegerPolyhedron::reset(unsigned numReservedInequalities,
- unsigned numReservedEqualities,
- unsigned newNumReservedCols, unsigned newNumDims,
- unsigned newNumSymbols, unsigned newNumLocals) {
- assert(newNumReservedCols >= newNumDims + newNumSymbols + newNumLocals + 1 &&
- "minimum 1 column");
- *this = IntegerPolyhedron(numReservedInequalities, numReservedEqualities,
- newNumReservedCols, newNumDims, newNumSymbols,
- newNumLocals);
-}
-
-void IntegerPolyhedron::reset(unsigned newNumDims, unsigned newNumSymbols,
- unsigned newNumLocals) {
- reset(0, 0, newNumDims + newNumSymbols + newNumLocals + 1, newNumDims,
- newNumSymbols, newNumLocals);
-}
-
void IntegerPolyhedron::append(const IntegerPolyhedron &other) {
assert(PresburgerLocalSpace::isEqual(other) && "Spaces must be equal.");
@@ -1796,7 +1779,8 @@ static BoundCmpResult compareBounds(ArrayRef<int64_t> a, ArrayRef<int64_t> b) {
static void getCommonConstraints(const IntegerPolyhedron &a,
const IntegerPolyhedron &b,
IntegerPolyhedron &c) {
- c.reset(a.getNumDimIds(), a.getNumSymbolIds(), a.getNumLocalIds());
+ c = IntegerPolyhedron(a.getNumDimIds(), a.getNumSymbolIds(),
+ a.getNumLocalIds());
// a naive O(n^2) check should be enough here given the input sizes.
for (unsigned r = 0, e = a.getNumInequalities(); r < e; ++r) {
for (unsigned s = 0, f = b.getNumInequalities(); s < f; ++s) {
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index c3cbbd832cab1..30f95dd05fce2 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -233,6 +233,25 @@ FlatAffineValueConstraints::getHyperrectangular(ValueRange ivs, ValueRange lbs,
return res;
}
+void FlatAffineConstraints::reset(unsigned numReservedInequalities,
+ unsigned numReservedEqualities,
+ unsigned newNumReservedCols,
+ unsigned newNumDims, unsigned newNumSymbols,
+ unsigned newNumLocals) {
+ assert(newNumReservedCols >= newNumDims + newNumSymbols + newNumLocals + 1 &&
+ "minimum 1 column");
+ *this = FlatAffineConstraints(numReservedInequalities, numReservedEqualities,
+ newNumReservedCols, newNumDims, newNumSymbols,
+ newNumLocals);
+}
+
+void FlatAffineConstraints::reset(unsigned newNumDims, unsigned newNumSymbols,
+ unsigned newNumLocals) {
+ reset(/*numReservedInequalities=*/0, /*numReservedEqualities=*/0,
+ /*numReservedCols=*/newNumDims + newNumSymbols + newNumLocals + 1,
+ newNumDims, newNumSymbols, newNumLocals);
+}
+
void FlatAffineValueConstraints::reset(unsigned numReservedInequalities,
unsigned numReservedEqualities,
unsigned newNumReservedCols,
More information about the Mlir-commits
mailing list