Skip to content

Commit

Permalink
[mlir][ArmSME] Replace use of isa with isa_and_present (#82798)
Browse files Browse the repository at this point in the history
`op` can be null here, in which case this should just return a null
value back.
  • Loading branch information
MacDue authored Feb 26, 2024
1 parent cb2dd02 commit 8cfb716
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ struct LiftIllegalVectorTransposeToMemory
}

static Value getExtensionSource(Operation *op) {
if (isa<arith::ExtSIOp, arith::ExtUIOp, arith::ExtFOp>(op))
if (isa_and_present<arith::ExtSIOp, arith::ExtUIOp, arith::ExtFOp>(op))
return op->getOperand(0);
return {};
}
Expand Down
11 changes: 11 additions & 0 deletions mlir/test/Dialect/ArmSME/vector-legalization.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,14 @@ func.func @lift_illegal_transpose_to_memory_with_in_bounds_attr(%a: index, %b: i
%legalType = vector.transpose %illegalRead, [1, 0] : vector<[8]x4xf32> to vector<4x[8]xf32>
return %legalType : vector<4x[8]xf32>
}

// -----

// The pass should do nothing (and not crash).
// CHECK-LABEL: @illegal_transpose_no_defining_source_op
func.func @illegal_transpose_no_defining_source_op(%vec: vector<[4]x1xf32>) -> vector<1x[4]xf32>
{
// CHECK: vector.transpose
%0 = vector.transpose %vec, [1, 0] : vector<[4]x1xf32> to vector<1x[4]xf32>
return %0 : vector<1x[4]xf32>
}

0 comments on commit 8cfb716

Please sign in to comment.