Skip to content

Commit 01f6c4a

Browse files
committed
[MLIR][Presburger] Fix Gaussian elimination
1 parent 48a99ad commit 01f6c4a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

mlir/lib/Analysis/Presburger/Barvinok.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ mlir::presburger::detail::solveParametricEquations(FracMatrix equations) {
178178
for (unsigned i = 0; i < d; ++i) {
179179
// First ensure that the diagonal element is nonzero, by swapping
180180
// it with a row that is non-zero at column i.
181-
if (equations(i, i) != 0)
182-
continue;
183-
for (unsigned j = i + 1; j < d; ++j) {
184-
if (equations(j, i) == 0)
185-
continue;
186-
equations.swapRows(j, i);
187-
break;
181+
if (equations(i, i) == 0) {
182+
for (unsigned j = i + 1; j < d; ++j) {
183+
if (equations(j, i) == 0)
184+
continue;
185+
equations.swapRows(j, i);
186+
break;
187+
}
188188
}
189189

190190
Fraction diagElement = equations(i, i);

mlir/lib/Analysis/Presburger/IntegerRelation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,10 @@ bool IntegerRelation::gaussianEliminate() {
11421142
inequalities.normalizeRow(i);
11431143
}
11441144
gcdTightenInequalities();
1145+
1146+
// The column is finished. Tell the next iteration to start at the next
1147+
// column.
1148+
firstVar++;
11451149
}
11461150

11471151
// No redundant rows.

0 commit comments

Comments
 (0)