[Mlir-commits] [mlir] [MLIR][Presburger] Fix simplify() of IntegerRelation (PR #181469)
Yue Huang
llvmlistbot at llvm.org
Sat Mar 7 03:26:59 PST 2026
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/181469
>From 5cc26c50dcfd24f0afd3c2c4acb70e6891ecf8ef Mon Sep 17 00:00:00 2001
From: Yue Huang <yh548 at cam.ac.uk>
Date: Thu, 5 Mar 2026 18:39:04 +0000
Subject: [PATCH] [MLIR][Presburger] Fix simplify of IntegerRelation
---
mlir/lib/Analysis/Presburger/IntegerRelation.cpp | 2 +-
.../Analysis/Presburger/IntegerRelationTest.cpp | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
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