[Mlir-commits] [mlir] 8cfb716 - [mlir][ArmSME] Replace use of `isa` with `isa_and_present` (#82798)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Feb 26 01:44:30 PST 2024


Author: Benjamin Maxwell
Date: 2024-02-26T09:44:26Z
New Revision: 8cfb71613c452dd45a84a74affe8464bfd33de02

URL: https://github.com/llvm/llvm-project/commit/8cfb71613c452dd45a84a74affe8464bfd33de02
DIFF: https://github.com/llvm/llvm-project/commit/8cfb71613c452dd45a84a74affe8464bfd33de02.diff

LOG: [mlir][ArmSME] Replace use of `isa` with `isa_and_present` (#82798)

`op` can be null here, in which case this should just return a null
value back.

Added: 
    

Modified: 
    mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp
    mlir/test/Dialect/ArmSME/vector-legalization.mlir

Removed: 
    


################################################################################
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