[mlir] vector::ExtractStridedSliceOp Canonicalize crashes with assertion failed "Iteratees do not have equal length"
MLIR built at commit https://github.com/llvm/llvm-project/commit/0ee6bad6a6725c2913116a8fa7769b067c219f0
Reproduced with:
mlir-opt --canonicalize temp.mlir
temp.mlir:
module {
func.func @func1(%arg0: tensor<7x2xf32>, %arg1: memref<12x7xi1>, %arg2: f32) {
%c4 = arith.constant 4 : index
%c10 = arith.constant 10 : index
%cst_256 = arith.constant 1.000000e+00 : f32
%256 = vector.create_mask %c10, %c4 : vector<12x7xi1>
%261 = vector.extract_strided_slice %256 {offsets = [3], sizes = [5], strides = [1]} : vector<12x7xi1> to vector<5x7xi1>
%262 = vector.fma %261, %261, %261 : vector<5x7xi1>
return
}
}
trace:
Assertion failed: (all_equal({std::distance(adl_begin(t), adl_end(t)), std::distance(adl_begin(u), adl_end(u)), std::distance(adl_begin(args), adl_end(args))...}) && "Iteratees do not have equal length"), function zip_equal, file STLExtras.h, line 893.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: mlir-opt --canonicalize temp.mlir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 mlir-opt 0x000000010290e568 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 72
1 mlir-opt 0x000000010290ea84 PrintStackTraceSignalHandler(void*) + 28
2 mlir-opt 0x000000010290cb34 llvm::sys::RunSignalHandlers() + 148
3 mlir-opt 0x00000001029106f0 SignalHandler(int) + 252
4 libsystem_platform.dylib 0x000000019970d4c4 _sigtramp + 56
5 libsystem_pthread.dylib 0x00000001996f5ee0 pthread_kill + 288
6 libsystem_c.dylib 0x0000000199630340 abort + 168
7 libsystem_c.dylib 0x000000019962f754 err + 0
8 mlir-opt 0x0000000105153e04 llvm::detail::zippy<llvm::detail::zip_first, llvm::SmallVector<long long, 4u>&, llvm::SmallVector<long long, 4u>&, llvm::SmallVector<long long, 4u>&> llvm::zip_equal<llvm::SmallVector<long long, 4u>&, llvm::SmallVector<long long, 4u>&, llvm::SmallVector<long long, 4u>&>(llvm::SmallVector<long long, 4u>&, llvm::SmallVector<long long, 4u>&, llvm::SmallVector<long long, 4u>&) + 272
9 mlir-opt 0x0000000105153848 (anonymous namespace)::StridedSliceConstantMaskFolder::matchAndRewrite(mlir::vector::ExtractStridedSliceOp, mlir::PatternRewriter&) const + 332
10 mlir-opt 0x000000010515368c mlir::detail::OpOrInterfaceRewritePatternBase<mlir::vector::ExtractStridedSliceOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const + 72
11 mlir-opt 0x00000001074f4fcc mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) + 1356
12 mlir-opt 0x000000010680c73c (anonymous namespace)::GreedyPatternRewriteDriver::simplify(llvm::MutableArrayRef<mlir::Region>) + 1640
13 mlir-opt 0x000000010680bf84 mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 240
14 mlir-opt 0x0000000102ff0c74 mlir::applyPatternsAndFoldGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 76
15 mlir-opt 0x00000001066ee150 (anonymous namespace)::Canonicalizer::runOnOperation() + 132
16 mlir-opt 0x0000000106674c58 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 512
17 mlir-opt 0x0000000106675328 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 364
18 mlir-opt 0x000000010667756c mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) + 108
19 mlir-opt 0x0000000106677344 mlir::PassManager::run(mlir::Operation*) + 864
20 mlir-opt 0x000000010665c61c performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) + 560
21 mlir-opt 0x000000010665c1b0 processBuffer(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) + 496
22 mlir-opt 0x000000010665bf78 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const + 204
23 mlir-opt 0x000000010665be8c mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) + 80
24 mlir-opt 0x0000000106867440 llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const + 96
25 mlir-opt 0x0000000106866f24 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) + 128
26 mlir-opt 0x00000001066598cc mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) + 320
27 mlir-opt 0x0000000106659ad4 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool, bool) + 296
28 mlir-opt 0x000000010665a698 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 2912
29 mlir-opt 0x0000000102124f50 main + 148
30 dyld 0x00000001204e1088 start + 516
@llvm/issue-subscribers-mlir
@aartbik if you can help redirecting to a good assignee?
I create a revision https://reviews.llvm.org/D139815 to fix it, please review.
@llvm/issue-subscribers-mlir-vectorops
Thanks for the revision. Is it possible to add the reproducer as test someplace?
I added the test case.
Fixed in https://github.com/llvm/llvm-project/commit/0017dc2d0ff89bd9fb93fd25ba787ba66a4de356.