[Mlir-commits] [mlir] [MLIR][Presburger] Fix simplify() of IntegerRelation (PR #181469)
Yue Huang
llvmlistbot at llvm.org
Thu Mar 5 08:51:20 PST 2026
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/181469
>From 69a9a3cf07d3aca36ce70acd988256a9d2eb3502 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
---
.../Analysis/Presburger/IntegerRelation.cpp | 2 +-
.../Presburger/IntegerRelationTest.cpp | 21 +++++++++++++++++++
2 files changed, 22 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..a1197466f0da1 100644
--- a/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
@@ -741,6 +741,27 @@ TEST(IntegerRelationTest, simplify) {
EXPECT_TRUE(rel.getNumEqualities() == 2);
}
+TEST(IntegerRelationTest, simplify2) {
+ IntegerRelation rel(PresburgerSpace::getRelationSpace(0, 6));
+ rel.addEquality({-1, 0, 0, 0, 0, 3, 0});
+ rel.addEquality({0, 1, 0, -3, 0, 0, 0});
+ rel.addEquality({0, -1, 0, 0, 2, 0, 0});
+ rel.addInequality({0, 1, 0, 0, 0, 0, -6});
+ rel.addInequality({0, 0, 0, 0, 0, -1, 6});
+ rel.addInequality({0, 1, 0, -3, 0, 0, 0});
+ rel.addInequality({0, -1, 0, 3, 0, 0, 0});
+ rel.addInequality({0, -1, 3, 0, 0, 0, 2});
+ rel.addInequality({0, 1, -3, 0, 0, 0, 0});
+ rel.addInequality({0, 0, -1, 0, 0, 1, -1});
+ EXPECT_FALSE(rel.isIntegerEmpty());
+
+ auto simplified = rel;
+ simplified.simplify();
+ EXPECT_TRUE(rel.isEqual(simplified));
+ simplified.dump();
+ EXPECT_FALSE(simplified.isIntegerEmpty());
+}
+
TEST(IntegerRelationTest, isFullDim) {
IntegerRelation rel = parseRelationFromSet("(x): (1 >= 0)", 1);
EXPECT_TRUE(rel.isFullDim());
More information about the Mlir-commits
mailing list