[Mlir-commits] [mlir] 28f9bfe - [mlir] skip 0-D vector in BubbleUpBitCastForStridedSliceInsert
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Jan 29 20:21:03 PST 2023
Author: Xiang Li
Date: 2023-01-29T23:19:31-05:00
New Revision: 28f9bfe466b066d0d77cb32039e7e299618d0c1a
URL: https://github.com/llvm/llvm-project/commit/28f9bfe466b066d0d77cb32039e7e299618d0c1a
DIFF: https://github.com/llvm/llvm-project/commit/28f9bfe466b066d0d77cb32039e7e299618d0c1a.diff
LOG: [mlir] skip 0-D vector in BubbleUpBitCastForStridedSliceInsert
InsertStridedSliceOp will not get 0-D vector result, so just skip 0-D vector in BubbleUpBitCastForStridedSliceInsert.
Fixes #60214 https://github.com/llvm/llvm-project/issues/60214
Differential Revision: https://reviews.llvm.org/D142319
Added:
Modified:
mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
mlir/test/Dialect/Vector/vector-transforms.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
index 504ea7afe8301..c7aee6d537a80 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
@@ -2462,6 +2462,9 @@ struct BubbleUpBitCastForStridedSliceInsert
VectorType castSrcType = bitcastOp.getSourceVectorType();
VectorType castDstType = bitcastOp.getResultVectorType();
assert(castSrcType.getRank() == castDstType.getRank());
+ // Skip 0-D vector which will not from InsertStridedSliceOp.
+ if (castSrcType.getRank() == 0)
+ return failure();
int64_t castSrcLastDim = castSrcType.getShape().back();
int64_t castDstLastDim = castDstType.getShape().back();
diff --git a/mlir/test/Dialect/Vector/vector-transforms.mlir b/mlir/test/Dialect/Vector/vector-transforms.mlir
index e8f5cf722e876..3f3e17871e4ca 100644
--- a/mlir/test/Dialect/Vector/vector-transforms.mlir
+++ b/mlir/test/Dialect/Vector/vector-transforms.mlir
@@ -525,3 +525,11 @@ func.func @bubble_up_bitcast_in_strided_slice_insert_larger_odd_shape(%dst: vect
%cast = vector.bitcast %0: vector<8xf16> to vector<4xf32>
return %cast: vector<4xf32>
}
+
+// Make sure not crash on 0-D vector.
+// CHECK-LABEL:func.func @vec_0D
+// CHECK-NEXT:vector.bitcast
+func.func @vec_0D(%arg0: vector<f32>) -> vector<i32> {
+ %0 = vector.bitcast %arg0 : vector<f32> to vector<i32>
+ return %0 : vector<i32>
+}
More information about the Mlir-commits
mailing list