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

Matthias Springer llvmlistbot at llvm.org
Fri Jun 26 04:54:28 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
----------------
matthias-springer wrote:

Tbh, I still don't follow. Maybe a table like the one in `RemSIOpInterface` would help. I'm also wondering why the `maxui` case is not symmetric. (There you require both operands to be non-negative.)

Can you simplify `MinUIOpInterface` and require that both operands are non-negative? Then we can merge this and think about the optimized case separately in a second PR.


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


More information about the Mlir-commits mailing list