[Mlir-commits] [mlir] [mlir][VectorToLLVM] Add support for unrolling and lowering multi-dim… (PR #160405)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 24 02:58:30 PDT 2025


================
@@ -431,27 +431,51 @@ vector::unrollVectorValue(TypedValue<VectorType> vector,
 }
 
 LogicalResult vector::unrollVectorOp(Operation *op, PatternRewriter &rewriter,
-                                     vector::UnrollVectorOpFn unrollFn) {
-  assert(op->getNumResults() == 1 && "expected single result");
-  assert(isa<VectorType>(op->getResult(0).getType()) && "expected vector type");
-  VectorType resultTy = cast<VectorType>(op->getResult(0).getType());
-  if (resultTy.getRank() < 2)
+                                     vector::UnrollVectorOpFn unrollFn,
+                                     VectorType vectorTy) {
+  // If vector type is not provided, get it from the result
+  if (!vectorTy) {
+    if (op->getNumResults() != 1)
+      return rewriter.notifyMatchFailure(
+          op, "expected single result when vector type not provided");
+
+    vectorTy = dyn_cast<VectorType>(op->getResult(0).getType());
+    if (!vectorTy)
+      return rewriter.notifyMatchFailure(op, "expected vector type");
+  }
----------------
tyb0807 wrote:

No, when `vectorTy` is provided, it is because there's no result so `unrollVectorOp` cannot infer the vector type. Let me add this to the function docstring.

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


More information about the Mlir-commits mailing list