[Mlir-commits] [mlir] [mlir][LinalgBlockPackMatmul] Add support for scalable block factors (PR #211354)

Adam Siemieniuk llvmlistbot at llvm.org
Thu Jul 23 01:47:49 PDT 2026


================
@@ -161,8 +163,35 @@ linalg::blockPackMatmul(RewriterBase &rewriter, linalg::LinalgOp linalgOp,
   if (options->blockFactors.size() != 3)
     return rewriter.notifyMatchFailure(linalgOp, "require 3 tile factors");
 
-  SmallVector<OpFoldResult> mnkTiles =
-      getAsOpFoldResult(rewriter.getI64ArrayAttr(options->blockFactors));
+  bool hasScalable = !options->scalableBlockFactors.empty();
+  if (hasScalable && options->scalableBlockFactors.size() != 3)
+    return rewriter.notifyMatchFailure(
+        linalgOp, "scalableBlockFactors must be empty or have 3 elements");
+
+  // Scalable tile sizes are non-constant at compile time, so they can never
+  // satisfy the full-tile divisibility check. Reject early before creating
+  // any ops to avoid modifying IR before returning notifyMatchFailure.
+  if (!options->allowPadding && hasScalable)
+    return rewriter.notifyMatchFailure(
+        linalgOp, "scalable block factors require allow-padding=true");
+
+  // Build OpFoldResult tile sizes. Scalable dimensions are emitted as
+  // arith.constant N : index multiplied by vector.vscale.
+  SmallVector<OpFoldResult> mnkTiles;
+  for (auto [i, factor] : llvm::enumerate(options->blockFactors)) {
----------------
adam-smnk wrote:

```suggestion
  for (auto [idx, factor] : llvm::enumerate(options->blockFactors)) {
```

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


More information about the Mlir-commits mailing list