[MLIR][Presburger] Fix stale pivot in Smith normal form (#189789)

The pivot used to fix divisibility in Smith normal form is stale. This
will not affect correctness, but can lower efficiency since the outer
loop will be executed more times.

Thanks for @benquike of discovering this.
This commit is contained in:
Yue Huang 2026-04-04 14:17:57 +08:00 committed by GitHub
parent e6e388cff0
commit 38f8945362
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -653,8 +653,6 @@ IntMatrix::computeSmithNormalForm() const {
u.negateRow(i);
}
DynamicAPInt pivot = d(i, i);
// Clear other entries in row i and column i with Euclid's algorithm.
for (unsigned r = i + 1; r < numRows; ++r) {
while (d(r, i) != 0) {
@ -684,7 +682,7 @@ IntMatrix::computeSmithNormalForm() const {
}
}
if (auto row = findNonMultipleRow(d, i + 1, pivot)) {
if (auto row = findNonMultipleRow(d, i + 1, d(i, i))) {
// Add the row (r) to row i. This brings d(r, c) into the i-th row,
// creating a new value at d(i, c) that will be used to reduce the
// pivot size.