[Mlir-commits] [mlir] da8d1b5 - [MLIR][Presburger] Fix simplify() of IntegerRelation (#181469)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Mar 8 04:21:23 PDT 2026
Author: Yue Huang
Date: 2026-03-08T11:21:18Z
New Revision: da8d1b52d0d344068a8bd3e46a8af3a692d2efc2
URL: https://github.com/llvm/llvm-project/commit/da8d1b52d0d344068a8bd3e46a8af3a692d2efc2
DIFF: https://github.com/llvm/llvm-project/commit/da8d1b52d0d344068a8bd3e46a8af3a692d2efc2.diff
LOG: [MLIR][Presburger] Fix simplify() of IntegerRelation (#181469)
In `simplify()`, we currently skip all columns from 0 to `firstVar` (the
column of the pivot) when we eliminate inequalities. This is invalid,
because unlike equalities, it is not guaranteed that these columns
contain only zeroes, and a scale by `rowMultiplier` cannot be ignored.
We must not skip any columns for inequalities.
Added:
Modified:
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index cf93fbd9a0dc7..93a725571078e 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -1162,7 +1162,7 @@ bool IntegerRelation::gaussianEliminate() {
equalities.normalizeRow(i);
}
for (unsigned i = 0, ineqs = getNumInequalities(); i < ineqs; ++i) {
- eliminateFromConstraint(this, i, *pivotRow, firstVar, 0, false);
+ eliminateFromConstraint(this, i, *pivotRow, firstVar, firstVar, false);
inequalities.normalizeRow(i);
}
gcdTightenInequalities();
diff --git a/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp b/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
index b94b86057b650..90753d502d12c 100644
--- a/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
@@ -741,6 +741,16 @@ TEST(IntegerRelationTest, simplify) {
EXPECT_TRUE(rel.getNumEqualities() == 2);
}
+TEST(IntegerRelationTest, simplifyRegression) {
+ IntegerRelation rel = parseRelationFromSet("(x, y, z): (2*x + z >= 5, "
+ "x + 3*z >= 7, 3*x + y >= 9)",
+ 3);
+
+ auto simplified = rel;
+ simplified.simplify();
+ EXPECT_TRUE(rel.isEqual(simplified));
+}
+
TEST(IntegerRelationTest, isFullDim) {
IntegerRelation rel = parseRelationFromSet("(x): (1 >= 0)", 1);
EXPECT_TRUE(rel.isFullDim());
More information about the Mlir-commits
mailing list