[Mlir-commits] [mlir] 21dc4ad - [MLIR][Presburger] skip IntegerPolyhedrons with LocalIds in coalesce

Arjun P llvmlistbot at llvm.org
Fri Mar 4 08:12:11 PST 2022


Author: Michel Weber
Date: 2022-03-04T16:12:04Z
New Revision: 21dc4ad56aeee09ef36cf0ec25742be93a51a4f8

URL: https://github.com/llvm/llvm-project/commit/21dc4ad56aeee09ef36cf0ec25742be93a51a4f8
DIFF: https://github.com/llvm/llvm-project/commit/21dc4ad56aeee09ef36cf0ec25742be93a51a4f8.diff

LOG: [MLIR][Presburger] skip IntegerPolyhedrons with LocalIds in coalesce

This patch makes coalesce skip the comparison of all pairs of IntegerPolyhedrons with LocalIds rather than crash. The heuristics to handle these cases will be upstreamed later on.

Reviewed By: arjunp

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

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/PresburgerSet.cpp
    mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/PresburgerSet.cpp b/mlir/lib/Analysis/Presburger/PresburgerSet.cpp
index b54b77383a849..ba3c2a592cdf6 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerSet.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerSet.cpp
@@ -523,8 +523,10 @@ coalescePair(unsigned i, unsigned j,
 
   IntegerPolyhedron &a = polyhedrons[i];
   IntegerPolyhedron &b = polyhedrons[j];
-  assert(a.getNumLocalIds() == 0 && b.getNumLocalIds() == 0 &&
-         "Locals are not yet supported!");
+  /// Handling of local ids is not yet implemented, so these cases are skipped.
+  /// TODO: implement local id support.
+  if (a.getNumLocalIds() != 0 || b.getNumLocalIds() != 0)
+    return failure();
   Simplex &simpA = simplices[i];
   Simplex &simpB = simplices[j];
 

diff  --git a/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp b/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
index ca57706ac2e87..7a79c98df0459 100644
--- a/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
+++ b/mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
@@ -645,6 +645,25 @@ TEST(SetTest, coalesceDoubleIncrement) {
   expectCoalesce(3, set);
 }
 
+TEST(SetTest, coalesceDiv) {
+  PresburgerSet set =
+      parsePresburgerSetFromPolyStrings(1, {
+                                               "(x) : (x floordiv 2 == 0)",
+                                               "(x) : (x floordiv 2 - 1 == 0)",
+                                           });
+  expectCoalesce(2, set);
+}
+
+TEST(SetTest, coalesceDivOtherContained) {
+  PresburgerSet set =
+      parsePresburgerSetFromPolyStrings(1, {
+                                               "(x) : (x floordiv 2 == 0)",
+                                               "(x) : (x == 0)",
+                                               "(x) : (x >= 0, -x + 1 >= 0)",
+                                           });
+  expectCoalesce(2, set);
+}
+
 static void
 expectComputedVolumeIsValidOverapprox(const PresburgerSet &set,
                                       Optional<uint64_t> trueVolume,


        


More information about the Mlir-commits mailing list