[Mlir-commits] [mlir] [NFC][mlir][vector] Handle potential static cast assertion. (PR #152957)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Aug 10 23:22:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Md Asghar Ahmad Shahid (shahidact)

<details>
<summary>Changes</summary>

In FoldArithToVectorOuterProduct pattern, static cast to vector type causes assertion when a scalar type was encountered. It seems the author meant to have a dyn_cast instead.

This NFC patch handles it by using dyn_cast.

---
Full diff: https://github.com/llvm/llvm-project/pull/152957.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp (+1-1) 


``````````diff
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
index 2269a40ec8ef1..023c4da7dffdf 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
@@ -2274,7 +2274,7 @@ struct FoldArithToVectorOuterProduct : public OpRewritePattern<MulOpType> {
 
   LogicalResult matchAndRewrite(MulOpType mulOp,
                                 PatternRewriter &rewriter) const override {
-    auto resType = llvm::cast<VectorType>(mulOp.getResult().getType());
+    auto resType = llvm::dyn_cast<VectorType>(mulOp.getResult().getType());
     if (!resType)
       return failure();
     if (resType.getRank() != 2)

``````````

</details>


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


More information about the Mlir-commits mailing list