llvm-project
llvm-project copied to clipboard
[mlir] SCF-for-loop-peeling tiggers Assertion Failure " (lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant())"
MLIR built at commit https://github.com/llvm/llvm-project/commit/159cac50 Reproduced with:
mlir-opt --scf-for-loop-peeling temp.mlir
temp.mlir:
func.func @func(%arg0: memref<i64>, %arg1: index) {
%c0 = arith.constant 0 : index
%0 = affine.apply affine_map<()[s0] -> (s0 * s0)>()[%arg1]
scf.for %arg2 = %c0 to %0 step %arg1 {
%1 = affine.min affine_map<(d0)[s0] -> (s0, -d0 + s0 * s0)>(%arg2)[%arg1] // pass succeed if remove this line
%2 = arith.index_cast %0 : index to i64
memref.store %2, %arg0[] : memref<i64>
}
return
}
trace:
Assertion failed: (lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant()), function simplifyMul, file AffineExpr.cpp, line 673.
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 --scf-for-loop-peeling 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 0x000000010491c818 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 mlir-opt 0x000000010491b880 llvm::sys::RunSignalHandlers() + 112
2 mlir-opt 0x000000010491ceb0 SignalHandler(int) + 344
3 libsystem_platform.dylib 0x00000001aad414c4 _sigtramp + 56
4 libsystem_pthread.dylib 0x00000001aad29ee0 pthread_kill + 288
5 libsystem_c.dylib 0x00000001aac64340 abort + 168
6 libsystem_c.dylib 0x00000001aac63754 err + 0
7 mlir-opt 0x000000010666a1c8 mlir::AffineExpr::operator%(mlir::AffineExpr) const (.cold.1) + 0
8 mlir-opt 0x0000000105f99e7c mlir::AffineExpr::floorDiv(mlir::AffineExpr) const + 0
9 mlir-opt 0x0000000105f99b54 mlir::getAffineBinaryOpExpr(mlir::AffineExprKind, mlir::AffineExpr, mlir::AffineExpr) + 108
10 mlir-opt 0x0000000105f9a4e4 mlir::AffineExpr::replaceDimsAndSymbols(llvm::ArrayRef<mlir::AffineExpr>, llvm::ArrayRef<mlir::AffineExpr>) const + 180
11 mlir-opt 0x0000000105f9a4c4 mlir::AffineExpr::replaceDimsAndSymbols(llvm::ArrayRef<mlir::AffineExpr>, llvm::ArrayRef<mlir::AffineExpr>) const + 148
12 mlir-opt 0x0000000105f9a4a8 mlir::AffineExpr::replaceDimsAndSymbols(llvm::ArrayRef<mlir::AffineExpr>, llvm::ArrayRef<mlir::AffineExpr>) const + 120
13 mlir-opt 0x0000000105fa2350 mlir::AffineMap::replaceDimsAndSymbols(llvm::ArrayRef<mlir::AffineExpr>, llvm::ArrayRef<mlir::AffineExpr>, unsigned int, unsigned int) const + 200
14 mlir-opt 0x00000001049277f0 mlir::alignAffineMapWithValues(mlir::AffineMap, mlir::ValueRange, mlir::ValueRange, mlir::ValueRange, llvm::SmallVector<mlir::Value, 6u>*) + 1060
15 mlir-opt 0x0000000104936900 alignAndAddBound(mlir::FlatAffineValueConstraints&, mlir::presburger::IntegerRelation::BoundType, unsigned int, mlir::AffineMap, mlir::ValueRange) + 288
16 mlir-opt 0x0000000104935d78 mlir::simplifyConstrainedMinMaxOp(mlir::Operation*, mlir::FlatAffineValueConstraints) + 456
17 mlir-opt 0x00000001054291d8 canonicalizeMinMaxOp(mlir::RewriterBase&, mlir::Operation*, mlir::FlatAffineValueConstraints) + 332
18 mlir-opt 0x0000000105429608 mlir::scf::rewritePeeledMinMaxOp(mlir::RewriterBase&, mlir::Operation*, mlir::Value, mlir::Value, mlir::Value, bool) + 816
19 mlir-opt 0x0000000105419348 mlir::WalkResult llvm::function_ref<mlir::WalkResult (mlir::Operation*)>::callback_fn<rewriteAffineOpAfterPeeling(mlir::RewriterBase&, mlir::scf::ForOp, mlir::scf::ForOp, mlir::Value)::$_1>(long, mlir::Operation*) + 68
20 mlir-opt 0x0000000106057c90 mlir::detail::walk(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) + 160
21 mlir-opt 0x0000000105418c94 mlir::scf::peelAndCanonicalizeForLoop(mlir::RewriterBase&, mlir::scf::ForOp, mlir::scf::ForOp&) + 1140
22 mlir-opt 0x000000010541ac18 (anonymous namespace)::ForLoopPeelingPattern::matchAndRewrite(mlir::scf::ForOp, mlir::PatternRewriter&) const + 160
23 mlir-opt 0x00000001061cd010 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&)>) + 1420
24 mlir-opt 0x0000000105f81544 mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 3976
25 mlir-opt 0x000000010541a8f0 (anonymous namespace)::ForLoopPeeling::runOnOperation() + 764
26 mlir-opt 0x0000000105f326c4 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 428
27 mlir-opt 0x0000000105f32bf4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 320
28 mlir-opt 0x0000000105f34570 mlir::PassManager::run(mlir::Operation*) + 1148
29 mlir-opt 0x0000000105f2d934 performActions(llvm::raw_ostream&, bool, bool, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) + 504
30 mlir-opt 0x0000000105f2d504 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&) + 704
31 mlir-opt 0x0000000105f989a0 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) + 656
32 mlir-opt 0x0000000105f2b92c 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) + 216
33 mlir-opt 0x0000000105f2be20 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 1208
34 mlir-opt 0x00000001047bf41c main + 108
35 dyld 0x0000000109815088 start + 516
@llvm/issue-subscribers-mlir
@matthias-springer is this your code?
This is a bug in loop peeling. Here is a fix: https://reviews.llvm.org/D142136