[Mlir-commits] [mlir] [MLIR] ValueBoundsOpInterface: slice size from source size (PR #221756)
Matthias Springer
llvmlistbot at llvm.org
Tue Sep 8 04:48:08 PDT 2026
================
@@ -132,6 +132,21 @@ struct ExtractSliceOpInterface
++ctr;
if (ctr == dim) {
cstr.bound(value)[dim] == extractSliceOp.getMixedSizes()[i];
+ int64_t staticStride = extractSliceOp.getStaticStrides()[i];
+ if (staticStride > 0) {
+ // Encode in-bounds slice constraint:
+ OpFoldResult offset = extractSliceOp.getMixedOffsets()[i];
+ AffineExpr offsetExpr = cstr.getExpr(offset);
+ AffineExpr sourceDimExpr =
+ cstr.getExpr(extractSliceOp.getSource(), i);
+ cstr.bound(value)[dim] <=
+ (sourceDimExpr - offsetExpr).ceilDiv(staticStride);
+ // To derive value[dim] <= source[i] - offset:
+ cstr.bound(extractSliceOp.getSource())[i] >= offsetExpr;
----------------
matthias-springer wrote:
Let's do that. To be in line with the interface method description. If we find the need for adding other bounds, we can think about changing the contract/documentation of the interface method.
https://github.com/llvm/llvm-project/pull/221756
More information about the Mlir-commits
mailing list