[Mlir-commits] [mlir] [MLIR][Presburger] Fix simplify() of IntegerRelation (PR #181469)

Yue Huang llvmlistbot at llvm.org
Thu Mar 5 08:52:17 PST 2026


https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/181469

>From d967ef27a74ee87ca8a65215915eb4787128439b Mon Sep 17 00:00:00 2001
From: Yue Huang <yh548 at cam.ac.uk>
Date: Wed, 11 Feb 2026 16:35:13 +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..0a4b3baa25d70 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, simplify2) {
+  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