[Mlir-commits] [mlir] [mlir][affine][Analysis] Add conservative bounds for semi-affine mods (PR #93576)

Kunwar Grover llvmlistbot at llvm.org
Wed May 29 00:31:35 PDT 2024


================
@@ -454,6 +454,20 @@ class IntegerRelation {
     addLocalFloorDiv(getMPIntVec(dividend), MPInt(divisor));
   }
 
+  /// Adds a new local variable as the mod of an affine function of other
+  /// variables. The coefficients of the operands of the mod are provided in
+  /// `lhs` and `rhs` respectively. Three constraints are added to provide a
+  /// conservative bound for the mod:
+  ///  1. rhs > 0 (assumption/precondition)
+  ///  2. lhs % rhs < rhs
+  ///  3. lhs % rhs >= 0
+  /// We ensure the rhs is positive so we can assume the result is positive.
+  void addLocalModConservativeBounds(ArrayRef<MPInt> lhs, ArrayRef<MPInt> rhs);
+  void addLocalModConservativeBounds(ArrayRef<int64_t> lhs,
+                                     ArrayRef<int64_t> rhs) {
+    addLocalModConservativeBounds(getMPIntVec(lhs), getMPIntVec(rhs));
+  }
+
----------------
Groverkss wrote:

This should not be part of IntegerRelation API. IntegerRelation represents exact sets. Building approximations on top of it should be outside it's API. I would recommend putting this in FlatLinearValueConstraints or something outside Presburger.

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


More information about the Mlir-commits mailing list