[Mlir-commits] [mlir] [mlir][ArmSME] Replace use of `isa` with `isa_and_present` (PR #82798)
Benjamin Maxwell
llvmlistbot at llvm.org
Fri Feb 23 09:25:14 PST 2024
https://github.com/MacDue created https://github.com/llvm/llvm-project/pull/82798
`op` can be null here, in which case this should just return a null value back.
>From 7fd1833fa07b027617d65aa423d5d7de0f7fdd63 Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: Fri, 23 Feb 2024 17:18:57 +0000
Subject: [PATCH] [mlir][ArmSME] Replace use of `isa` with `isa_and_present`
`op` can be null here, in which case this should just return a null
value back.
---
.../Dialect/ArmSME/Transforms/VectorLegalization.cpp | 2 +-
mlir/test/Dialect/ArmSME/vector-legalization.mlir | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp b/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
index 26dfb38263372b..11f8bc04b21844 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
@@ -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 {};
}
diff --git a/mlir/test/Dialect/ArmSME/vector-legalization.mlir b/mlir/test/Dialect/ArmSME/vector-legalization.mlir
index 11888c675f0b04..bf0b58ff4cf073 100644
--- a/mlir/test/Dialect/ArmSME/vector-legalization.mlir
+++ b/mlir/test/Dialect/ArmSME/vector-legalization.mlir
@@ -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>
+}
More information about the Mlir-commits
mailing list