[MLIR][Presburger] Fix stale pivot in Smith normal form#189789
Merged
Conversation
Member
|
@llvm/pr-subscribers-mlir-presburger Author: Yue Huang (AdUhTkJm) ChangesThe 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. Full diff: https://github.com/llvm/llvm-project/pull/189789.diff 1 Files Affected:
diff --git a/mlir/lib/Analysis/Presburger/Matrix.cpp b/mlir/lib/Analysis/Presburger/Matrix.cpp
index 6ea04543146b7..94e9eb5792dab 100644
--- a/mlir/lib/Analysis/Presburger/Matrix.cpp
+++ b/mlir/lib/Analysis/Presburger/Matrix.cpp
@@ -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.
|
Member
|
@llvm/pr-subscribers-mlir Author: Yue Huang (AdUhTkJm) ChangesThe 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. Full diff: https://github.com/llvm/llvm-project/pull/189789.diff 1 Files Affected:
diff --git a/mlir/lib/Analysis/Presburger/Matrix.cpp b/mlir/lib/Analysis/Presburger/Matrix.cpp
index 6ea04543146b7..94e9eb5792dab 100644
--- a/mlir/lib/Analysis/Presburger/Matrix.cpp
+++ b/mlir/lib/Analysis/Presburger/Matrix.cpp
@@ -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.
|
superty
approved these changes
Apr 4, 2026
Member
|
Thanks for looking into it! |
zwu-2025
pushed a commit
to zwu-2025/llvm-project
that referenced
this pull request
May 17, 2026
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.