[Mlir-commits] [mlir] 9d6a6fb - [MLIR][Presburger] remove redundant constraints in coalesce

Arjun P llvmlistbot at llvm.org
Sun Mar 20 06:00:07 PDT 2022


Author: Michel Weber
Date: 2022-03-20T13:00:12Z
New Revision: 9d6a6fbbbde983aede6805b8c9dedf410b9dfaad

URL: https://github.com/llvm/llvm-project/commit/9d6a6fbbbde983aede6805b8c9dedf410b9dfaad
DIFF: https://github.com/llvm/llvm-project/commit/9d6a6fbbbde983aede6805b8c9dedf410b9dfaad.diff

LOG: [MLIR][Presburger] remove redundant constraints in coalesce

This patch improves the representation size of individual
`IntegerRelation`s by calling the function
`IntegerRelation::removeRedundantConstraints`. While this is only a
slight optimization in the current version, it will be necessary for
patches to come.

Reviewed By: arjunp

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

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/PresburgerRelation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
index 4c1d3006a0cd6..1b5aa0ff42420 100644
--- a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
@@ -437,9 +437,9 @@ class presburger::SetCoalescer {
   /// within `a`.
   bool isFacetContained(ArrayRef<int64_t> ineq, Simplex &simp);
 
-  /// Adds `disjunct` to `disjuncts` and removes the disjuncts at position `i`
-  /// and `j`. Updates `simplices` to reflect the changes. `i` and `j` cannot
-  /// be equal.
+  /// Removes redundant constraints from `disjunct`, adds it to `disjuncts` and
+  /// removes the disjuncts at position `i` and `j`. Updates `simplices` to
+  /// reflect the changes. `i` and `j` cannot be equal.
   void addCoalescedDisjunct(unsigned i, unsigned j,
                             const IntegerRelation &disjunct);
 
@@ -488,6 +488,7 @@ SetCoalescer::SetCoalescer(const PresburgerRelation &s) {
   simplices.reserve(s.getNumDisjuncts());
   // Note that disjuncts.size() changes during the loop.
   for (unsigned i = 0; i < disjuncts.size();) {
+    disjuncts[i].removeRedundantConstraints();
     Simplex simp(disjuncts[i]);
     if (simp.isEmpty()) {
       disjuncts[i] = disjuncts[disjuncts.size() - 1];
@@ -569,10 +570,11 @@ void SetCoalescer::addCoalescedDisjunct(unsigned i, unsigned j,
     disjuncts[i] = disjuncts[n - 2];
     disjuncts.pop_back();
     disjuncts[n - 2] = disjunct;
+    disjuncts[n - 2].removeRedundantConstraints();
 
     simplices[i] = simplices[n - 2];
     simplices.pop_back();
-    simplices[n - 2] = Simplex(disjunct);
+    simplices[n - 2] = Simplex(disjuncts[n - 2]);
 
   } else {
     // Other possible edge cases are correct since for `j` or `i` == `n` -
@@ -584,11 +586,12 @@ void SetCoalescer::addCoalescedDisjunct(unsigned i, unsigned j,
     disjuncts[j] = disjuncts[n - 2];
     disjuncts.pop_back();
     disjuncts[n - 2] = disjunct;
+    disjuncts[n - 2].removeRedundantConstraints();
 
     simplices[i] = simplices[n - 1];
     simplices[j] = simplices[n - 2];
     simplices.pop_back();
-    simplices[n - 2] = Simplex(disjunct);
+    simplices[n - 2] = Simplex(disjuncts[n - 2]);
   }
 }
 


        


More information about the Mlir-commits mailing list