[Mlir-commits] [mlir] [mlir][arith] Add ValueBoundsOpInterface external models for the arith integer CeilDiv, RemSI, RemUI, MaxUI, MinUI. (PR #204966)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jun 24 06:27:31 PDT 2026


================
@@ -190,6 +258,55 @@ struct MaxSIOpInterface
     cstr.bound(value) >= rhs;
   }
 };
+
+struct MinUIOpInterface
+    : public ValueBoundsOpInterface::ExternalModel<MinUIOpInterface,
+                                                   arith::MinUIOp> {
+  void populateBoundsForIndexValue(Operation *op, Value value,
+                                   ValueBoundsConstraintSet &cstr) const {
+    auto minOp = cast<arith::MinUIOp>(op);
+    assert(value == minOp.getResult() && "invalid value");
+
+    // ValueBoundsConstraintSet models values as signed integers (e.g. an i8
+    // 0xff is treated as -1, not 255). For an unsigned minimum it is enough
+    // that a single operand is provably non-negative: minui(x, y) is in
----------------
nirhersh wrote:

As i understood the ValueBoundsConstraintSet works, with i8 values:

x = -1 (unsigned value `255`)
y = 5

Then minui(x, y) = 5, so the result is in [0, 5].
All inequalities added are signed inequalities.
If ValueBoundsConstraintSet "sees" that minui(x,y) = -1 in such case than my implementation here is incorrect

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


More information about the Mlir-commits mailing list