[Mlir-commits] [mlir] [mlir][arith] Implement ValueBoundsOpInterface for IndexCastUI and ExtSI ops (PR #204476)
Matthias Springer
llvmlistbot at llvm.org
Wed Jun 24 05:09:28 PDT 2026
================
@@ -17,6 +17,43 @@ namespace mlir {
namespace arith {
namespace {
+struct ConstantOpInterface
+ : public ValueBoundsOpInterface::ExternalModel<ConstantOpInterface,
+ ConstantOp> {
+ void populateBoundsForIndexValue(Operation *op, Value value,
+ ValueBoundsConstraintSet &cstr) const {
+ auto constantOp = cast<ConstantOp>(op);
+ assert(value == constantOp.getResult() && "invalid value");
+
+ if (auto attr = llvm::dyn_cast<IntegerAttr>(constantOp.getValue()))
+ cstr.bound(value) == attr.getInt();
+ }
+};
+
+struct IndexCastUIOpInterface
+ : public ValueBoundsOpInterface::ExternalModel<IndexCastUIOpInterface,
+ IndexCastUIOp> {
+ void populateBoundsForIndexValue(Operation *op, Value value,
+ ValueBoundsConstraintSet &cstr) const {
+ auto indexCastOp = cast<IndexCastUIOp>(op);
+ assert(value == indexCastOp.getOut() && "invalid value");
+ cstr.bound(value) >= 0;
----------------
matthias-springer wrote:
I would remove the model entirely and revisit when there's an actual use case for this.
https://github.com/llvm/llvm-project/pull/204476
More information about the Mlir-commits
mailing list