Skip to content

Commit 37bad56

Browse files
committed
Revert "[MLIR][Presburger] Use SmallVector instead of std::vector in getLocalRepr"
This reverts commit 3cc5447. SmallVector inside SmallVector are not optimized. Reviewed By: arjunp Differential Revision: https://reviews.llvm.org/D119005
1 parent d36bd08 commit 37bad56

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

mlir/include/mlir/Analysis/Presburger/IntegerPolyhedron.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,12 @@ class IntegerPolyhedron {
285285
/// and the denominators in `denominators`. If no explicit representation
286286
/// could be found for the `i^th` local identifier, `denominators[i]` is set
287287
/// to 0.
288-
void
289-
getLocalReprs(SmallVectorImpl<SmallVector<int64_t, 8>> &dividends,
290-
SmallVectorImpl<unsigned> &denominators,
291-
SmallVectorImpl<presburger_utils::MaybeLocalRepr> &repr) const;
292-
void
293-
getLocalReprs(SmallVectorImpl<presburger_utils::MaybeLocalRepr> &repr) const;
294-
void getLocalReprs(SmallVectorImpl<SmallVector<int64_t, 8>> &dividends,
295-
SmallVectorImpl<unsigned> &denominators) const;
288+
void getLocalReprs(std::vector<SmallVector<int64_t, 8>> &dividends,
289+
SmallVector<unsigned, 4> &denominators,
290+
std::vector<presburger_utils::MaybeLocalRepr> &repr) const;
291+
void getLocalReprs(std::vector<presburger_utils::MaybeLocalRepr> &repr) const;
292+
void getLocalReprs(std::vector<SmallVector<int64_t, 8>> &dividends,
293+
SmallVector<unsigned, 4> &denominators) const;
296294

297295
/// The type of bound: equal, lower bound or upper bound.
298296
enum BoundType { EQ, LB, UB };

mlir/include/mlir/Analysis/Presburger/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ MaybeLocalRepr computeSingleVarRepr(const IntegerPolyhedron &cst,
6565
/// the divisions are not merged. `merge` can also do side effects, For example
6666
/// it can merge the local identifiers in IntegerPolyhedron.
6767
void removeDuplicateDivs(
68-
SmallVectorImpl<SmallVector<int64_t, 8>> &divs,
68+
std::vector<SmallVector<int64_t, 8>> &divs,
6969
SmallVectorImpl<unsigned> &denoms, unsigned localOffset,
7070
llvm::function_ref<bool(unsigned i, unsigned j)> merge);
7171

mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -829,24 +829,23 @@ bool IntegerPolyhedron::containsPoint(ArrayRef<int64_t> point) const {
829829
return true;
830830
}
831831

832-
void IntegerPolyhedron::getLocalReprs(
833-
SmallVectorImpl<MaybeLocalRepr> &repr) const {
834-
SmallVector<SmallVector<int64_t, 8>> dividends(getNumLocalIds());
832+
void IntegerPolyhedron::getLocalReprs(std::vector<MaybeLocalRepr> &repr) const {
833+
std::vector<SmallVector<int64_t, 8>> dividends(getNumLocalIds());
835834
SmallVector<unsigned, 4> denominators(getNumLocalIds());
836835
getLocalReprs(dividends, denominators, repr);
837836
}
838837

839838
void IntegerPolyhedron::getLocalReprs(
840-
SmallVectorImpl<SmallVector<int64_t, 8>> &dividends,
841-
SmallVectorImpl<unsigned> &denominators) const {
842-
SmallVector<MaybeLocalRepr> repr(getNumLocalIds());
839+
std::vector<SmallVector<int64_t, 8>> &dividends,
840+
SmallVector<unsigned, 4> &denominators) const {
841+
std::vector<MaybeLocalRepr> repr(getNumLocalIds());
843842
getLocalReprs(dividends, denominators, repr);
844843
}
845844

846845
void IntegerPolyhedron::getLocalReprs(
847-
SmallVectorImpl<SmallVector<int64_t, 8>> &dividends,
848-
SmallVectorImpl<unsigned> &denominators,
849-
SmallVectorImpl<MaybeLocalRepr> &repr) const {
846+
std::vector<SmallVector<int64_t, 8>> &dividends,
847+
SmallVector<unsigned, 4> &denominators,
848+
std::vector<MaybeLocalRepr> &repr) const {
850849

851850
repr.resize(getNumLocalIds());
852851
dividends.resize(getNumLocalIds());
@@ -1104,7 +1103,7 @@ void IntegerPolyhedron::mergeLocalIds(IntegerPolyhedron &other) {
11041103
polyB.insertLocalId(0, initLocals);
11051104

11061105
// Get division representations from each poly.
1107-
SmallVector<SmallVector<int64_t, 8>> divsA, divsB;
1106+
std::vector<SmallVector<int64_t, 8>> divsA, divsB;
11081107
SmallVector<unsigned, 4> denomsA, denomsB;
11091108
polyA.getLocalReprs(divsA, denomsA);
11101109
polyB.getLocalReprs(divsB, denomsB);

mlir/lib/Analysis/Presburger/PresburgerSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static void subtractRecursively(IntegerPolyhedron &b, Simplex &simplex,
213213

214214
// Find out which inequalities of sI correspond to division inequalities for
215215
// the local variables of sI.
216-
SmallVector<MaybeLocalRepr> repr(sI.getNumLocalIds());
216+
std::vector<MaybeLocalRepr> repr(sI.getNumLocalIds());
217217
sI.getLocalReprs(repr);
218218

219219
// Add sI's locals to b, after b's locals. Also add b's locals to sI, before

mlir/lib/Analysis/Presburger/Utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ static LogicalResult getDivRepr(const IntegerPolyhedron &cst, unsigned pos,
160160

161161
// Extract divisor, the divisor can be negative and hence its sign information
162162
// is stored in `signDiv` to reverse the sign of dividend's coefficients.
163-
// Equality must involve the pos-th variable and hence `tempDiv` != 0.
164-
int64_t tempDiv = cst.atEq(eqInd, pos);
165-
if (tempDiv == 0)
163+
// Equality must involve the pos-th variable and hence `temp_div` != 0.
164+
int64_t temp_div = cst.atEq(eqInd, pos);
165+
if (temp_div == 0)
166166
return failure();
167-
int64_t signDiv = tempDiv < 0 ? -1 : 1;
167+
int64_t signDiv = temp_div < 0 ? -1 : 1;
168168

169169
// The divisor is always a positive integer.
170-
divisor = tempDiv * signDiv;
170+
divisor = temp_div * signDiv;
171171

172172
expr.resize(cst.getNumCols(), 0);
173173
for (unsigned i = 0, e = cst.getNumIds(); i < e; ++i)
@@ -254,7 +254,7 @@ MaybeLocalRepr presburger_utils::computeSingleVarRepr(
254254
}
255255

256256
void presburger_utils::removeDuplicateDivs(
257-
SmallVectorImpl<SmallVector<int64_t, 8>> &divs,
257+
std::vector<SmallVector<int64_t, 8>> &divs,
258258
SmallVectorImpl<unsigned> &denoms, unsigned localOffset,
259259
llvm::function_ref<bool(unsigned i, unsigned j)> merge) {
260260

mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static void checkDivisionRepresentation(
624624
const std::vector<SmallVector<int64_t, 8>> &expectedDividends,
625625
const SmallVectorImpl<unsigned> &expectedDenominators) {
626626

627-
SmallVector<SmallVector<int64_t, 8>> dividends;
627+
std::vector<SmallVector<int64_t, 8>> dividends;
628628
SmallVector<unsigned, 4> denominators;
629629

630630
poly.getLocalReprs(dividends, denominators);

0 commit comments

Comments
 (0)