[Mlir-commits] [llvm] [mlir] [Linalg] Fix crash in vectorizeScalableVectorPrecondition with undersized vector sizes (PR #205493)

Andrzej WarzyƄski llvmlistbot at llvm.org
Thu Jun 25 08:20:20 PDT 2026


================
@@ -2381,6 +2381,18 @@ vectorizeScalableVectorPrecondition(Operation *op,
     return success(isa<linalg::UnPackOp>(op));
   }
 
+  // Ensure that the number of vector sizes and scalable flags provided by the
+  // user does not exceed the number of loops in the target Linalg op.
+  // Accessing iterator types with an out-of-bounds index would cause an
+  // assertion failure (SmallVector::operator[]). This check converts such a
+  // crash into a clean failure, allowing the transform interpreter to report
+  // an error gracefully.
+  // Regression test:
+  // mlir/test/Dialect/Vector/transform-op-vector-to-llvm.mlir
+  if (inputScalableVecDims.size() > linalgOp.getNumLoops() ||
+      inputVectorSizes.size() > linalgOp.getNumLoops())
----------------
banach-space wrote:

Note, we already assert above that `inputVectorSizes.size() == inputScalableVecDims.size()`, so you only need to check that `inputVectorSizes.size() <= linalgOp.getNumLoops()`. However, that is not really a "scalable vectorization" pre-condition, but more of verification for `transform.structured.vectorize`. 

Could you try moving this condition somewhere higher up? If you struggle, I can suggest something specific. Thanks!

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


More information about the Mlir-commits mailing list