[MLIR][Presburger] Deduplicate and move getNegatedCoeffs and getComplementIneq into...
authorArjun P <arjunpitchanathan@gmail.com>
Fri, 18 Mar 2022 14:51:00 +0000 (14:51 +0000)
committerArjun P <arjunpitchanathan@gmail.com>
Mon, 21 Mar 2022 19:29:11 +0000 (19:29 +0000)
mlir/include/mlir/Analysis/Presburger/Utils.h
mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
mlir/lib/Analysis/Presburger/Utils.cpp

index 1f5b571..06298f6 100644 (file)
@@ -130,6 +130,16 @@ void removeDuplicateDivs(
     SmallVectorImpl<unsigned> &denoms, unsigned localOffset,
     llvm::function_ref<bool(unsigned i, unsigned j)> merge);
 
+/// Return `coeffs` with all the elements negated.
+SmallVector<int64_t, 8> getNegatedCoeffs(ArrayRef<int64_t> coeffs);
+
+/// Return the complement of the given inequality.
+///
+/// The complement of a_1 x_1 + ... + a_n x_ + c >= 0 is
+/// a_1 x_1 + ... + a_n x_ + c < 0, i.e., -a_1 x_1 - ... - a_n x_ - c - 1 >= 0,
+/// since all the variables are constrained to be integers.
+SmallVector<int64_t, 8> getComplementIneq(ArrayRef<int64_t> ineq);
+
 } // namespace presburger
 } // namespace mlir
 
index 1b5aa0f..6f035aa 100644 (file)
@@ -107,29 +107,6 @@ PresburgerRelation::intersect(const PresburgerRelation &set) const {
   return result;
 }
 
-/// Return `coeffs` with all the elements negated.
-static SmallVector<int64_t, 8> getNegatedCoeffs(ArrayRef<int64_t> coeffs) {
-  SmallVector<int64_t, 8> negatedCoeffs;
-  negatedCoeffs.reserve(coeffs.size());
-  for (int64_t coeff : coeffs)
-    negatedCoeffs.emplace_back(-coeff);
-  return negatedCoeffs;
-}
-
-/// Return the complement of the given inequality.
-///
-/// The complement of a_1 x_1 + ... + a_n x_ + c >= 0 is
-/// a_1 x_1 + ... + a_n x_ + c < 0, i.e., -a_1 x_1 - ... - a_n x_ - c - 1 >= 0,
-/// since all the variables are constrained to be integers.
-static SmallVector<int64_t, 8> getComplementIneq(ArrayRef<int64_t> ineq) {
-  SmallVector<int64_t, 8> coeffs;
-  coeffs.reserve(ineq.size());
-  for (int64_t coeff : ineq)
-    coeffs.emplace_back(-coeff);
-  --coeffs.back();
-  return coeffs;
-}
-
 /// Return the set difference b \ s and accumulate the result into `result`.
 /// `simplex` must correspond to b.
 ///
index 96fcafa..4cd7670 100644 (file)
@@ -303,3 +303,20 @@ void presburger::removeDuplicateDivs(
     }
   }
 }
+
+SmallVector<int64_t, 8> presburger::getNegatedCoeffs(ArrayRef<int64_t> coeffs) {
+  SmallVector<int64_t, 8> negatedCoeffs;
+  negatedCoeffs.reserve(coeffs.size());
+  for (int64_t coeff : coeffs)
+    negatedCoeffs.emplace_back(-coeff);
+  return negatedCoeffs;
+}
+
+SmallVector<int64_t, 8> presburger::getComplementIneq(ArrayRef<int64_t> ineq) {
+  SmallVector<int64_t, 8> coeffs;
+  coeffs.reserve(ineq.size());
+  for (int64_t coeff : ineq)
+    coeffs.emplace_back(-coeff);
+  --coeffs.back();
+  return coeffs;
+}