[Mlir-commits] [mlir] [mlir][transform] Plumb a simplified form of AffineMin folding into t… (PR #145170)
Nicolas Vasilache
llvmlistbot at llvm.org
Mon Jun 23 03:11:25 PDT 2025
================
@@ -1042,6 +1046,59 @@ simplifyMapWithOperands(AffineMap &map, ArrayRef<Value> operands) {
map.getContext());
}
+/// Assuming `dimOrSym` is a quantity in `map` that is defined by `minOp`,
+/// replaces the patterns:
+/// ```
+/// dimOrSym.ceildiv(cst) * cst
+/// (dimOrSym + cst - 1).floordiv(cst) * cst
+/// ```
+/// by `cst` in `map`.
+/// This simplification is valid iff `minOp` is guaranteed to be nonnegative.
+/// Additionally, allows the caller to pass `affineMinKnownToBeNonNegative` to
+/// inject static information that may not be statically discoverable.
+/// Warning: ValueBoundsConstraintSet::computeConstantBound is needed to check
+/// for the nonnegative case, if `affineMinKnownToBeNonNegative` is false.
+static LogicalResult replaceAffineMinBoundingBoxExpression(
+ AffineMinOp minOp, AffineExpr dimOrSym, AffineMap *map,
+ bool affineMinKnownToBeNonNegative = false) {
+ auto affineMinMap = minOp.getAffineMap();
+ if (!affineMinKnownToBeNonNegative) {
----------------
nicolasvasilache wrote:
I agree, but this will be a much bigger change thatn I am prepared to take on right now, would be a good intro / cleanup task though.
https://github.com/llvm/llvm-project/pull/145170
More information about the Mlir-commits
mailing list