[Mlir-commits] [mlir] [mlir][transform] Plumb a simplified form of AffineMin folding into t… (PR #145170)

Kunwar Grover llvmlistbot at llvm.org
Mon Jun 23 03:03:12 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.
----------------
Groverkss wrote:

I think the discription is incomplete. The simplification we are doing is:

```
dimOrSym = affine.min(exprs..., cst)
GIVEN: exprs > 0
dimOrSym.ceildiv(cst) * cst -> cst
```

I think we can do a sub simplification here too:

```
dimOrSym = affine.min(exprs..., cst)
GIVEN: exprs > 0
dimOrSym.ceildiv(cst) -> 1
```

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


More information about the Mlir-commits mailing list