[Mlir-commits] [mlir] [MLIR][Arith] Add ValueBoundsOpInterface for DivSI (PR #137879)

Krzysztof Drewniak llvmlistbot at llvm.org
Tue Apr 29 15:19:10 PDT 2025


================
@@ -75,6 +75,19 @@ struct MulIOpInterface
   }
 };
 
+struct DivSIOpInterface
+    : public ValueBoundsOpInterface::ExternalModel<DivSIOpInterface, DivSIOp> {
+  void populateBoundsForIndexValue(Operation *op, Value value,
+                                   ValueBoundsConstraintSet &cstr) const {
+    auto divSIOp = cast<DivSIOp>(op);
+    assert(value == divSIOp.getResult() && "invalid value");
+
+    AffineExpr lhs = cstr.getExpr(divSIOp.getLhs());
+    AffineExpr rhs = cstr.getExpr(divSIOp.getRhs());
+    cstr.bound(value) == lhs.floorDiv(rhs);
----------------
krzysz00 wrote:

I'm pretty sure there's a way to build round to 0 from round to minus infinity, but I'm not sure about the math there

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


More information about the Mlir-commits mailing list