Skip to content

Commit 7d441d9

Browse files
authored
[mlir] Use dyn_cast instead of cast in MathToVCIX conversion (#134047)
Fixes #131093.
1 parent 2426ac6 commit 7d441d9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mlir/test/Conversion/MathToVCIX/math-to-vcix.mlir

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,14 @@ func.func @log_fixed(%a: vector<8 x f32>, %rvl: i64) -> vector<8 x f32> {
191191
%res = math.log %a : vector<8 x f32>
192192
return %res : vector<8 x f32>
193193
}
194+
195+
// -----
196+
197+
// Ensure this case exit gracefully
198+
199+
// CHECK-LABEL: func.func @no_vector_type
200+
// CHECK: math.cos
201+
func.func @no_vector_type(%arg0: f32) -> f32 {
202+
%0 = math.cos %arg0 : f32
203+
return %0 : f32
204+
}

mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace {
2525
/// according to LLVM's encoding:
2626
/// https://lists.llvm.org/pipermail/llvm-dev/2020-October/145850.html
2727
static std::pair<unsigned, VectorType> legalizeVectorType(const Type &type) {
28-
VectorType vt = cast<VectorType>(type);
28+
VectorType vt = dyn_cast<VectorType>(type);
2929
// To simplify test pass, avoid multi-dimensional vectors.
3030
if (!vt || vt.getRank() != 1)
3131
return {0, nullptr};

0 commit comments

Comments
 (0)