[Mlir-commits] [mlir] [MLIR][Presburger][WIP] Implement vertex enumeration and chamber decomposition for polytope generating function computation. (PR #78987)

Arjun P llvmlistbot at llvm.org
Tue Jan 23 12:13:39 PST 2024


================
@@ -2498,6 +2498,51 @@ void IntegerRelation::printSpace(raw_ostream &os) const {
   os << getNumConstraints() << " constraints\n";
 }
 
+void IntegerRelation::removeTrivialEqualities() {
+  std::vector<bool> isTrivialEquality;
+  for (int i = 0, e = getNumEqualities(); i < e; ++i) {
+    bool currentIsTrivial =
+        llvm::all_of(getEquality(i), [&](MPInt n) -> bool { return (n == 0); });
+    isTrivialEquality.push_back(currentIsTrivial);
+  }
+
+  unsigned pos = 0;
+  for (unsigned r = 0, e = getNumEqualities(); r < e; r++)
+    if (!isTrivialEquality[r])
+      equalities.copyRow(r, pos++);
+
+  equalities.resizeVertically(pos);
+}
+
+bool IntegerRelation::isFullDim() {
+  // If there is a non-trivial equality, the space cannot be full-dimensional.
+  removeTrivialEqualities();
+  if (getNumEqualities() > 0)
+    return false;
+
+  // If along the direction of any of the inequalities, the upper and lower
+  // optima are the same, then the region is not full-dimensional.
+  Simplex simplex(*this);
----------------
Superty wrote:

what if the set is empty?

https://github.com/llvm/llvm-project/pull/78987


More information about the Mlir-commits mailing list