From ef32d0132d6c94259f0b0f24ce80f99069e42934 Mon Sep 17 00:00:00 2001 From: Longsheng Mou Date: Wed, 2 Apr 2025 16:17:13 +0800 Subject: [PATCH 1/2] [mlir] Use `dyn_cast` instead of `cast` --- .../test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp b/mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp index 1e45ab57ebcc7..8a01a0af59b22 100644 --- a/mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp +++ b/mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp @@ -25,7 +25,7 @@ namespace { /// according to LLVM's encoding: /// https://lists.llvm.org/pipermail/llvm-dev/2020-October/145850.html static std::pair legalizeVectorType(const Type &type) { - VectorType vt = cast(type); + VectorType vt = dyn_cast(type); // To simplify test pass, avoid multi-dimensional vectors. if (!vt || vt.getRank() != 1) return {0, nullptr}; From 3a17f5c39535554d037e96b0a38681177da9a773 Mon Sep 17 00:00:00 2001 From: Longsheng Mou Date: Wed, 2 Apr 2025 16:18:44 +0800 Subject: [PATCH 2/2] add test --- mlir/test/Conversion/MathToVCIX/math-to-vcix.mlir | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mlir/test/Conversion/MathToVCIX/math-to-vcix.mlir b/mlir/test/Conversion/MathToVCIX/math-to-vcix.mlir index 3563b2c1cf810..9d4bf7bdb5655 100644 --- a/mlir/test/Conversion/MathToVCIX/math-to-vcix.mlir +++ b/mlir/test/Conversion/MathToVCIX/math-to-vcix.mlir @@ -191,3 +191,14 @@ func.func @log_fixed(%a: vector<8 x f32>, %rvl: i64) -> vector<8 x f32> { %res = math.log %a : vector<8 x f32> return %res : vector<8 x f32> } + +// ----- + +// Ensure this case exit gracefully + +// CHECK-LABEL: func.func @no_vector_type +// CHECK: math.cos +func.func @no_vector_type(%arg0: f32) -> f32 { + %0 = math.cos %arg0 : f32 + return %0 : f32 +}