<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/75770>75770</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] --convert-tensor-to-spirv crashed in "mlir::affine::AffineForOp::fold" with assertion failure "lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant()".
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
anonymousMCS
</td>
</tr>
</table>
<pre>
git version: 0ca95b269ff90afb706e2cf4c4a59d7c3afe6c65
system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```
reproduced with: ```mlir-opt --convert-tensor-to-spirv a.mlir```
a.mlir:
```
#map7 = affine_map<(d0)[s0] -> (d0 * s0)>
#map9 = affine_map<()[s0, s1, s2] -> (((s0 * (s1 * (s0 * s2))) floordiv 4) * 4)>
#map10 = affine_map<()[s0, s1] -> (s1 * s0)>
func.func private @func2() {
%10 = arith.constant 15 : i64
// If the following line is changed to "%36 = arith.constant 15 : index", the crash will disappear.
// Maybe the crash is caused by "builtin.unrealized_conversion_cast".
%36 = builtin.unrealized_conversion_cast %10 : i64 to index
%145 = affine.apply #map7(%36)[%36]
%147 = affine.apply #map7(%36)[%145]
affine.for %arg0 = #map9()[%36, %145, %36] to #map10()[%36, %147] {
}
return
}
```
trace:
```
mlir-opt: /data/bin/llvm-project/mlir/lib/IR/AffineExpr.cpp:762: mlir::AffineExpr simplifyMul(mlir::AffineExpr, mlir::AffineExpr): Assertion `lhs.isSymbolicOrConstant() || rhs.isSymbolicOrConstant()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /data/bin/llvm-project/build/bin/mlir-opt --convert-tensor-to-spirv a.mlir
#0 0x000055f70c5f1ccf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x1676ccf)
#1 0x000055f70c5eed24 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f2fa4b0c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f2fa45f700b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f2fa45d6859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f2fa45d6729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f2fa45e7fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055f70f3cb1ab mlir::AffineExpr::operator*(mlir::AffineExpr) const (/data/bin/llvm-project/build/bin/mlir-opt+0x44501ab)
#8 0x000055f70f3cc30a mlir::AffineExpr::replace(llvm::DenseMap<mlir::AffineExpr, mlir::AffineExpr, llvm::DenseMapInfo<mlir::AffineExpr, void>, llvm::detail::DenseMapPair<mlir::AffineExpr, mlir::AffineExpr>> const&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x445130a)
#9 0x000055f70f3cc1ef mlir::AffineExpr::replace(llvm::DenseMap<mlir::AffineExpr, mlir::AffineExpr, llvm::DenseMapInfo<mlir::AffineExpr, void>, llvm::detail::DenseMapPair<mlir::AffineExpr, mlir::AffineExpr>> const&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x44511ef)
#10 0x000055f70f3cc52f mlir::AffineExpr::replace(mlir::AffineExpr, mlir::AffineExpr) const (/data/bin/llvm-project/build/bin/mlir-opt+0x445152f)
#11 0x000055f70f3d73c6 mlir::AffineMap::replace(mlir::AffineExpr, mlir::AffineExpr, unsigned int, unsigned int) const (/data/bin/llvm-project/build/bin/mlir-opt+0x445c3c6)
#12 0x000055f70c6e8543 composeAffineMapAndOperands(mlir::AffineMap*, llvm::SmallVectorImpl<mlir::Value>*) (.part.0) AffineOps.cpp:0:0
#13 0x000055f70c6e9e59 mlir::affine::AffineForOp::fold(mlir::affine::AffineForOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x176ee59)
#14 0x000055f70c6ea272 mlir::LogicalResult llvm::detail::UniqueFunctionBase<mlir::LogicalResult, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&>::CallImpl<mlir::Op<mlir::affine::AffineForOp, mlir::OpTrait::OneRegion, mlir::OpTrait::VariadicResults, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::VariadicOperands, mlir::OpTrait::AttrSizedOperandSegments, mlir::OpTrait::SingleBlock, mlir::OpTrait::SingleBlockImplicitTerminator<mlir::affine::AffineYieldOp>::Impl, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::OpTrait::AutomaticAllocationScope, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::HasRecursiveMemoryEffects, mlir::LoopLikeOpInterface::Trait, mlir::RegionBranchOpInterface::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const>(void*, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x176f272)
#15 0x000055f70c6f9dc6 mlir::RegisteredOperationName::Model<mlir::affine::AffineForOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x177edc6)
#16 0x000055f70f4e1fe2 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4566fe2)
#17 0x000055f70f4e2328 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4567328)
#18 0x000055f70f4116fa mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x44966fa)
#19 0x000055f70f37c62b (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#20 0x000055f70f37d0e7 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#21 0x000055f70f37f554 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/data/bin/llvm-project/build/bin/mlir-opt+0x4404554)
#22 0x000055f70ebd8783 (anonymous namespace)::ConvertTensorToSPIRVPass::runOnOperation() TensorToSPIRVPass.cpp:0:0
#23 0x000055f70f2d4d6e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x4359d6e)
#24 0x000055f70f2d524a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x435a24a)
#25 0x000055f70f2d5a14 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x435aa14)
#26 0x000055f70f2c68f3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x000055f70f2c7dc4 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#28 0x000055f70f2c7f74 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#29 0x000055f70f3c7364 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x444c364)
#30 0x000055f70f2c07d7 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x43457d7)
#31 0x000055f70f2c80c1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x434d0c1)
#32 0x000055f70f2c8526 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x434d526)
#33 0x000055f70c5282b3 main (/data/bin/llvm-project/build/bin/mlir-opt+0x15ad2b3)
#34 0x00007f2fa45d8083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x000055f70c5c123e _start (/data/bin/llvm-project/build/bin/mlir-opt+0x164623e)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl9v47gR_zTKCxFDov76IQ9Osu4F2DRBnFugfTEocuSwS4sqSWXX9-kLUrIjKrbXuaR3e0UPOa9lDofzm3-coUi05qsa4CJIL4P0-oy05kmqC1LLerOWrb69WpyVkm0uVtygZ1CayzqIZyikZJqWOJtW1TQkVZmHGWBaJTQh6ZTlNCYVZDRLg_A6CGfdp95oA2s7O8jC7u_Xsq1Ni3A4CZNJhj4_LlCAi7mkRKC51JoEeLojHvJS0CjJWgoMfePmyWO6Flydy8ag83Mq62dQ5txAraU6N_JcN1w9IzKxRHs590Nx_zimwfGaNDkK4mtEqorXsFyTJoivAlyw0EqbXuowSK_ReRB_Qu5XFOAZ0m4w_jRkM93LZscEXyEduU88ZNj96Y6t_RbtvvVLYcvC_aFKSKkYf0aJfbKjyWs5ovAUQQYi9Ev6mKq2phP7gRrFn4kBFCShfcYdL4SC_LIjRSjA6XZVxc3ThMpaG1IbFKXIGpNnyQvpPMBzdFMh8wSokkLIb7xeIcFrQFwj-kTqFTBkJAowDnAaZ8cY1wy-O7orx48qop_QNy4EYlyTpgGiJqOlb8mmhAG1XZS0GhgqN3bNsuXC8HrS1gqI4L8BW3aOZ6NlSYk2AcYDplsJfzxvpyenEQuxk3-gxSQdGG9CmkZYmZyXOr2ncdYZsvuaXnuT89MnR0n6MrufUUll-RC16ozZ-_XOeXoOV72k_TcnRmevzv0O0OeW7MVpgnwnuwLTqrr34e3Pe8O5-zSKUDgU09t84ZIInjNiSIDnJa8DPBfieX3eKPkvoCbAc5ca8FzwMsDzm4cAz2dOEZ--N2pCmyaIZ3mGLaNtEolnLxRI83UjeLW5bUWAi30kFvv-36eW60xrUIbL2mY78aQnXC8261IKTu_UVe_qfbgF-VWQXyF1lCrAOaoIF8B6_7z__Gm2-IR0W665QQSV7QopaKQy1mBPxj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