[Mlir-commits] [mlir] Fix VectorEmulateNarrowType asserting on scalar type vs vector type. (PR #91613)

Benoit Jacob llvmlistbot at llvm.org
Thu May 9 09:02:46 PDT 2024


https://github.com/bjacob created https://github.com/llvm/llvm-project/pull/91613

None

>From e47bf813319e930783ce95c69ffefe6b6e8996d6 Mon Sep 17 00:00:00 2001
From: Benoit Jacob <jacob.benoit.1 at gmail.com>
Date: Thu, 9 May 2024 11:57:07 -0400
Subject: [PATCH] dyn-cast-emulate-narrow-types

---
 .../Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
index a301b919dc523..6025c4ad7c145 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
@@ -1119,8 +1119,9 @@ struct RewriteAlignedSubByteIntExt : OpRewritePattern<ConversionOpType> {
                                 PatternRewriter &rewriter) const override {
     // Verify the preconditions.
     Value srcValue = conversionOp.getIn();
-    auto srcVecType = cast<VectorType>(srcValue.getType());
-    auto dstVecType = cast<VectorType>(conversionOp.getType());
+    auto srcVecType = dyn_cast<VectorType>(srcValue.getType());
+    auto dstVecType = dyn_cast<VectorType>(conversionOp.getType());
+
     if (failed(
             commonConversionPrecondition(rewriter, dstVecType, conversionOp)))
       return failure();



More information about the Mlir-commits mailing list