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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Feb 13 11:44:28 PST 2026


Author: Yue Huang
Date: 2026-02-13T19:44:23Z
New Revision: 375f1995224ce8bd52e97c7898a22564bee15056

URL: https://github.com/llvm/llvm-project/commit/375f1995224ce8bd52e97c7898a22564bee15056
DIFF: https://github.com/llvm/llvm-project/commit/375f1995224ce8bd52e97c7898a22564bee15056.diff

LOG: [MLIR][Presburger] Fix full dimension check (#175422)

Currently, the code mistakenly thinks `(x): (1 >= 0)` as
non-full-dimensional.

The code determines full-dimensionality by testing whether an inequality
is flat, i.e. takes the same value regardless of variable assignments.
However, `1 >= 0` is obviously flat, and this case should be ignored
since it didn't involve any variables.

To remove these inequalities, we can call `removeTrivialRedundancy`.

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 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