[Mlir-commits] [mlir] aefd6b9 - [MLIR][Presburger][NFC] Refactor redundant code in fourierMotzkinEliminate
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Feb 25 02:24:11 PST 2022
Author: Groverkss
Date: 2022-02-25T15:40:38+05:30
New Revision: aefd6b9f5a9c7d06928f035abd92573431c91bef
URL: https://github.com/llvm/llvm-project/commit/aefd6b9f5a9c7d06928f035abd92573431c91bef
DIFF: https://github.com/llvm/llvm-project/commit/aefd6b9f5a9c7d06928f035abd92573431c91bef.diff
LOG: [MLIR][Presburger][NFC] Refactor redundant code in fourierMotzkinEliminate
This patch removes redundant code from fourierMotzkinEliminate implementation
using existing functions in IntegerPolyhedron.
Reviewed By: arjunp
Differential Revision: https://reviews.llvm.org/D120502
Added:
Modified:
mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
index 2380a214c0f2b..e87c8bc672727 100644
--- a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp
@@ -1633,25 +1633,6 @@ void IntegerPolyhedron::removeTrivialRedundancy() {
// the savings.
}
-static std::pair<unsigned, unsigned>
-getNewNumDimsSymbols(unsigned pos, const IntegerPolyhedron &cst) {
- unsigned numDims = cst.getNumDimIds();
- unsigned numSymbols = cst.getNumSymbolIds();
- unsigned newNumDims, newNumSymbols;
- if (pos < numDims) {
- newNumDims = numDims - 1;
- newNumSymbols = numSymbols;
- } else if (pos < numDims + numSymbols) {
- assert(numSymbols >= 1);
- newNumDims = numDims;
- newNumSymbols = numSymbols - 1;
- } else {
- newNumDims = numDims;
- newNumSymbols = numSymbols;
- }
- return {newNumDims, newNumSymbols};
-}
-
#undef DEBUG_TYPE
#define DEBUG_TYPE "fm"
@@ -1722,12 +1703,7 @@ void IntegerPolyhedron::fourierMotzkinEliminate(unsigned pos, bool darkShadow,
gcdTightenInequalities();
// Check if the identifier appears at all in any of the inequalities.
- unsigned r, e;
- for (r = 0, e = getNumInequalities(); r < e; r++) {
- if (atIneq(r, pos) != 0)
- break;
- }
- if (r == getNumInequalities()) {
+ if (isColZero(pos)) {
// If it doesn't appear, just remove the column and return.
// TODO: refactor removeColumns to use it from here.
removeId(pos);
@@ -1760,16 +1736,19 @@ void IntegerPolyhedron::fourierMotzkinEliminate(unsigned pos, bool darkShadow,
}
}
- // Set the number of dimensions, symbols in the resulting system.
- const auto &dimsSymbols = getNewNumDimsSymbols(pos, *this);
- unsigned newNumDims = dimsSymbols.first;
- unsigned newNumSymbols = dimsSymbols.second;
+ // Set the number of dimensions, symbols, locals in the resulting system.
+ unsigned newNumDims =
+ getNumDimIds() - getIdKindOverlap(IdKind::SetDim, pos, pos + 1);
+ unsigned newNumSymbols =
+ getNumSymbolIds() - getIdKindOverlap(IdKind::Symbol, pos, pos + 1);
+ unsigned newNumLocals =
+ getNumLocalIds() - getIdKindOverlap(IdKind::Local, pos, pos + 1);
/// Create the new system which has one identifier less.
- IntegerPolyhedron newPoly(
- lbIndices.size() * ubIndices.size() + nbIndices.size(),
- getNumEqualities(), getNumCols() - 1, newNumDims, newNumSymbols,
- /*numLocals=*/getNumIds() - 1 - newNumDims - newNumSymbols);
+ IntegerPolyhedron newPoly(lbIndices.size() * ubIndices.size() +
+ nbIndices.size(),
+ getNumEqualities(), getNumCols() - 1, newNumDims,
+ newNumSymbols, newNumLocals);
// This will be used to check if the elimination was integer exact.
unsigned lcmProducts = 1;
More information about the Mlir-commits
mailing list