[Mlir-commits] [mlir] [MLIR][Presburger] Fix full dimension check (PR #175422)

Yue Huang llvmlistbot at llvm.org
Sun Jan 11 01:43:36 PST 2026


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

>From a30387be92c337bda22e313ae383d467c9ca7ece Mon Sep 17 00:00:00 2001
From: Yue Huang <yh548 at cam.ac.uk>
Date: Sun, 11 Jan 2026 17:43:16 +0800
Subject: [PATCH] [MLIR][Presburger] Fix full dimensionality check

---
 mlir/lib/Analysis/Presburger/IntegerRelation.cpp          | 8 ++++++--
 .../unittests/Analysis/Presburger/IntegerRelationTest.cpp | 8 ++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index 26197ce7da374..cf93fbd9a0dc7 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -2643,8 +2643,12 @@ bool IntegerRelation::isFullDim() {
   if (getNumEqualities() > 0)
     return false;
 
-  // The polytope is full-dimensional iff it is not flat along any of the
-  // inequality directions.
+  // The polytope is full-dimensional iff it is not flat along every
+  // inequality directions that involve at least one variable.
+  //
+  // To check this, we first remove inequalities involving no variables,
+  // which is done in the following function.
+  removeTrivialRedundancy();
   Simplex simplex(*this);
   return llvm::none_of(llvm::seq<int>(getNumInequalities()), [&](int i) {
     return simplex.isFlatAlong(getInequality(i));
diff --git a/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp b/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
index 599db4cc74983..b94b86057b650 100644
--- a/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/IntegerRelationTest.cpp
@@ -740,3 +740,11 @@ TEST(IntegerRelationTest, simplify) {
   // It can be obtained from 2 times the first equality minus the second.
   EXPECT_TRUE(rel.getNumEqualities() == 2);
 }
+
+TEST(IntegerRelationTest, isFullDim) {
+  IntegerRelation rel = parseRelationFromSet("(x): (1 >= 0)", 1);
+  EXPECT_TRUE(rel.isFullDim());
+
+  rel = parseRelationFromSet("(x): (-1 >= 0)", 1);
+  EXPECT_FALSE(rel.isFullDim());
+}



More information about the Mlir-commits mailing list