<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107812>107812</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] [affine] -affine-loop-unroll crashes in T llvm::divideCeilSigned(U, V) [U = long, V = long, T = long]: Assertion `Denominator && "Division by zero"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
axeabc
</td>
</tr>
</table>
<pre>
git version: 0f5033053a3d4
system: `Ubuntu 18.04.6 LTS`
reproduce with: `mlir-opt -affine-loop-unroll a.mlir`
a.mlir:
```
func.func @test_vectorize_unpack_no_masks(%source : memref<8xf16>, %dest: memref<8x16xf16>) {
affine.for %arg1 = 0 to 8 step 4 {
affine.for %arg2 = 0 to 8 step 0 {
%0 = affine.load %source[%arg2] : memref<8xf16>
%1 = affine.load %source[%arg2] : memref<8xf16>
%2 = arith.addf %0, %1 : f16
affine.store %2, %dest[%arg1, %arg2] : memref<8x16xf16>
}
}
return
}
```
stack trace:
```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/llvm/include/llvm/Support/MathExtras.h:427: T llvm::divideCeilSigned(U, V) [U = long, V = long, T = long]: Assertion `Denominator && "Division by zero"' 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/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -affine-loop-unroll a.mlir
#0 0x000055a73171eff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d3ff8)
#1 0x000055a73171cb0e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d1b0e)
#2 0x000055a73171f98d SignalHandler(int) Signals.cpp:0:0
#3 0x00007f7f3e466420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f7f3daa300b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f7f3da82859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f7f3da82729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007f7f3da82729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007f7f3da93fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x000055a7347ab4fc (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41604fc)
#10 0x000055a7347ab53f mlir::affine::getConstantTripCount(mlir::affine::AffineForOp) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x416053f)
#11 0x000055a731864205 mlir::affine::loopUnrollByFactor(mlir::affine::AffineForOp, unsigned long, llvm::function_ref<void (unsigned int, mlir::Operation*, mlir::OpBuilder)>, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1219205)
#12 0x000055a73183bae3 (anonymous namespace)::LoopUnroll::runOnOperation() LoopUnroll.cpp:0:0
#13 0x000055a73480be26 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c0e26)
#14 0x000055a73480c790 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c1790)
#15 0x000055a734811b4e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#16 0x000055a73480de6b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c2e6b)
#17 0x000055a73480bf78 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c0f78)
#18 0x000055a73480c790 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c1790)
#19 0x000055a73480edd2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c3dd2)
#20 0x000055a734807601 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#21 0x000055a73480725b llvm::LogicalResult llvm::function_ref<llvm::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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#22 0x000055a7348b3ef5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4268ef5)
#23 0x000055a734802685 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41b7685)
#24 0x000055a73480292f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41b792f)
#25 0x000055a734802c5e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41b7c5e)
#26 0x000055a7316ffc37 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10b4c37)
#27 0x00007f7f3da84083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#28 0x000055a7316ff7be _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10b47be)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWd1z4ygS_2vICxUXQt8PfnDsuG6qkkpqkrlXFQIkcyODDlA23r_-CiR_SHF2Mntx7dxHatcjREP379dN0wJijKgl53MQ34B4dUU6u1F6Tl45KelVqdhuXgsLX7g2QkkQLiCqYhSGKA5JyCKAVgAt-l-zM5ZvnQhI0Leyk7aDQTZD0SyBd89PIEGn0pq3WrGOcvibsJth1LYR-lq1Fl6TqhKSXzdKtded1KppIJm57sk0w8twaLpe_x_s27DqJJ25HwgiZLmxxQunVmnxOy862RL6vZCq2BLz3QCcARwb1WnKoTNoy7eaVyBcZq9VkIDwFuAlBDhm3NhJf5AcRHII0ptBu__rocwqpd1gousAgnAFEbQKZtBY3sLoZMwbcfxGHE1Vu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