[mlir][vector] Use dyn_cast instead of cast in patterns

This avoids crashes when the pattern is applied to ops with
tensor semantics.

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D113415
This commit is contained in:
Lei Zhang 2021-11-08 12:33:55 -05:00
parent fd9b099906
commit 56ada0f80d
1 changed files with 1 additions and 1 deletions

View File

@ -3579,7 +3579,7 @@ class DropInnerMostUnitDims : public OpRewritePattern<vector::TransferReadOp> {
LogicalResult matchAndRewrite(vector::TransferReadOp readOp,
PatternRewriter &rewriter) const override {
auto srcType = readOp.source().getType().cast<MemRefType>();
auto srcType = readOp.source().getType().dyn_cast<MemRefType>();
if (!srcType || !srcType.hasStaticShape())
return failure();