From: Mehdi Amini Date: Fri, 3 Mar 2023 10:14:17 +0000 (+0100) Subject: Fix crash in ConvertVectorToLLVM.cpp pattern X-Git-Tag: upstream/17.0.6~15947 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=690499882973f5cac997e1074162b3fb31c53ef2;p=platform%2Fupstream%2Fllvm.git Fix crash in ConvertVectorToLLVM.cpp pattern Fixes #61094 --- diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index b73c01a..d1b78bf 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -21,6 +21,7 @@ #include "mlir/IR/TypeUtilities.h" #include "mlir/Target/LLVMIR/TypeToLLVM.h" #include "mlir/Transforms/DialectConversion.h" +#include "llvm/Support/Casting.h" #include using namespace mlir; @@ -820,11 +821,10 @@ public: matchAndRewrite(vector::MaskOp maskOp, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override final { // Match against the maskable operation kind. - Operation *maskableOp = maskOp.getMaskableOp(); - if (!isa(maskableOp)) + auto maskedOp = llvm::dyn_cast_or_null(maskOp.getMaskableOp()); + if (!maskedOp) return failure(); - return matchAndRewriteMaskableOp( - maskOp, cast(maskOp.getMaskableOp()), rewriter); + return matchAndRewriteMaskableOp(maskOp, maskedOp, rewriter); } protected: diff --git a/mlir/test/Conversion/GPUCommon/lower-vector.mlir b/mlir/test/Conversion/GPUCommon/lower-vector.mlir new file mode 100644 index 0000000..44deb45 --- /dev/null +++ b/mlir/test/Conversion/GPUCommon/lower-vector.mlir @@ -0,0 +1,11 @@ +// RUN: mlir-opt %s --gpu-to-llvm | FileCheck %s + +module { + func.func @func(%arg: vector<11xf32>) { + %cst_41 = arith.constant dense : vector<11xi1> + // CHECK: vector.mask + // CHECK-SAME: vector.yield %arg0 + %127 = vector.mask %cst_41 { vector.yield %arg : vector<11xf32> } : vector<11xi1> -> vector<11xf32> + return + } +}