[Mlir-commits] [mlir] 9615d71 - [MLIR][Presburger] IntegerRelation::truncate: fix bug when truncating equalities

Arjun P llvmlistbot at llvm.org
Thu Mar 31 07:16:28 PDT 2022


Author: Arjun P
Date: 2022-03-31T15:16:30+01:00
New Revision: 9615d717d12f3daf18f62236b911b159659ab363

URL: https://github.com/llvm/llvm-project/commit/9615d717d12f3daf18f62236b911b159659ab363
DIFF: https://github.com/llvm/llvm-project/commit/9615d717d12f3daf18f62236b911b159659ab363.diff

LOG: [MLIR][Presburger] IntegerRelation::truncate: fix bug when truncating equalities

This was truncating inequalities instead of equalities.

Reviewed By: Groverkss

Differential Revision: https://reviews.llvm.org/D122811

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/IntegerRelation.cpp
    mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index 50ced2af42613..de95511dec6d2 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -142,7 +142,7 @@ void IntegerRelation::truncate(const CountsSnapshot &counts) {
   truncateIdKind(IdKind::Symbol, counts);
   truncateIdKind(IdKind::Local, counts);
   removeInequalityRange(counts.getNumIneqs(), getNumInequalities());
-  removeInequalityRange(counts.getNumEqs(), getNumEqualities());
+  removeEqualityRange(counts.getNumEqs(), getNumEqualities());
 }
 
 unsigned IntegerRelation::insertId(IdKind kind, unsigned pos, unsigned num) {

diff  --git a/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp b/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp
index e7bbac3fc8ea0..4d55036e5fbf7 100644
--- a/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/IntegerPolyhedronTest.cpp
@@ -1202,3 +1202,13 @@ TEST(IntegerPolyhedronTest, containsPointNoLocal) {
   EXPECT_TRUE(poly3.containsPointNoLocal({0, 0}));
   EXPECT_FALSE(poly3.containsPointNoLocal({1, 0}));
 }
+
+TEST(IntegerPolyhedronTest, truncateEqualityRegressionTest) {
+  // IntegerRelation::truncate was truncating inequalities to the number of
+  // equalities.
+  IntegerRelation set(1);
+  IntegerRelation::CountsSnapshot snapshot = set.getCounts();
+  set.addEquality({1, 0});
+  set.truncate(snapshot);
+  EXPECT_EQ(set.getNumEqualities(), 0u);
+}


        


More information about the Mlir-commits mailing list