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

Quinn Dawkins llvmlistbot at llvm.org
Tue Apr 29 15:08:55 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);
----------------
qedawkins wrote:

Oh right, round towards zero... and this doesn't work for divui because affine floor/ceildiv is signed. I can't think of any way to support this then.

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


More information about the Mlir-commits mailing list