Issue 128343
Summary [MLIR]`-test-constant-fold --test-loop-unrolling=unroll-factor=2` triggers Assertion failure `lbCst >= 0 && ubCst >= 0 && stepCst > 0 && "expected positive loop bounds and step"'
Labels mlir
Assignees
Reporter xisang0
    Test on commit: https://github.com/llvm/llvm-project/commit/1d070988d9172965dee227e5629fa886845b815f
steps to reproduce:
```
mlir-opt test.mlir --test-constant-fold --test-loop-unrolling=unroll-factor=2
```
test case:
```
module attributes {llvm.data_layout = "p:32:32:32"} {
  func.func @zero_step(%arg0: memref<i64>) {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : index
    %foldto0 = arith.subi %c1, %c1 : index
 scf.for %arg2 = %c0 to %c1 step %foldto0 {
      %2 = arith.index_cast %arg2 : index to i64
      memref.store %2, %arg0[] : memref<i64>
    }
 return
  }
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/mlir/lib/Dialect/SCF/Utils/Utils.cpp:315: std::optional<int64_t> getConstantTripCount(scf::ForOp): Assertion `lbCst >= 0 && ubCst >= 0 && stepCst > 0 && "expected positive loop bounds and step"' failed.
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 /home/workdir/test.mlir --test-constant-fold --test-loop-unrolling=unroll-factor=2
 #0 0x00005bc4779982b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x10b62b8)
 #1 0x00005bc477995dde llvm::sys::RunSignalHandlers() (./mlir-opt+0x10b3dde)
 #2 0x00005bc477998cc8 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007cd2f834c520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007cd2f83a09fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007cd2f834c476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007cd2f83327f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007cd2f833271b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007cd2f8343e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00005bc47980c36d (./mlir-opt+0x2f2a36d)
#10 0x00005bc47980acf2 mlir::loopUnrollByFactor(mlir::scf::ForOp, unsigned long, llvm::function_ref<void (unsigned int, mlir::Operation*, mlir::OpBuilder)>) (./mlir-opt+0x2f28cf2)
#11 0x00005bc47a81983d (anonymous namespace)::TestLoopUnrollingPass::runOnOperation() TestLoopUnrolling.cpp:0:0
#12 0x00005bc47ad8e64f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x44ac64f)
#13 0x00005bc47ad8edd2 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x44acdd2)
#14 0x00005bc47ad9155e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x44af55e)
#15 0x00005bc47ad8a0ab performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#16 0x00005bc47ad89d03 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
#17 0x00005bc47ae33465 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) (./mlir-opt+0x4551465)
#18 0x00005bc47ad83962 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x44a1962)
#19 0x00005bc47ad83c13 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x44a1c13)
#20 0x00005bc47ad83e22 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x44a1e22)
#21 0x00005bc4779774d7 main (./mlir-opt+0x10954d7)
#22 0x00007cd2f8333d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x00007cd2f8333e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x00005bc477977045 _start (./mlir-opt+0x1095045)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to