[Mlir-commits] [mlir] [mlir][CSE] Delete dead code immediately in CSE pass (PR #190926)

lonely eagle llvmlistbot at llvm.org
Thu Apr 9 02:55:38 PDT 2026


linuxlonelyeagle wrote:

> Hi, this patch is causing compiler crash in CSE, can it be reverted?
> 
> Here is a simple reproducer:
> 
> ```
> func.func @test(%arg0: i1) {
>   %c0_i32 = arith.constant 0 : i32
>   %0 = arith.select %arg0, %c0_i32, %c0_i32 : i32
>   %1 = scf.if %arg0 -> (i32) {
>     %c0_i32_0 = arith.constant 0 : i32
>     scf.yield %c0_i32_0 : i32
>   } else {
>     %c0_i32_0 = arith.constant 0 : i32
>     scf.yield %c0_i32_0 : i32
>   }
>   return
> }
> ```
> 
> With `mlir-opt -cse`
> 
> ```
> mlir-opt: mlir/lib/IR/PatternMatch.cpp:156: virtual void mlir::RewriterBase::eraseOp(mlir::Operation*): Assertion `op->use_empty() && "expected 'op' to have no uses"' failed.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
> Stack dump:
> 0.	Program arguments: mlir-opt -cse -o - pure_repro.mlir
>  #0 0x0000000005651438 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (mlir-opt+0x5651438)
>  #1 0x000000000564e264 llvm::sys::RunSignalHandlers() (mlir-opt+0x564e264)
>  #2 0x000000000564e3df SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
>  #3 0x00007f1268e2d990 __restore_rt (/lib64/libpthread.so.0+0x12990)
>  #4 0x00007f1267e495af raise (/lib64/libc.so.6+0x4e5af)
>  #5 0x00007f1267e1cee5 abort (/lib64/libc.so.6+0x21ee5)
>  #6 0x00007f1267e1cdb9 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21db9)
>  #7 0x00007f1267e41f06 (/lib64/libc.so.6+0x46f06)
>  #8 0x000000000d518420 mlir::QuantStorageTypeInterface::shouldDefaultToSigned() const (mlir-opt+0xd518420)
>  #9 0x000000000d0676d1 (anonymous namespace)::CSEDriver::simplify(mlir::Operation*, bool*) CSE.cpp:0:0
> #10 0x000000000d067b59 (anonymous namespace)::CSE::runOnOperation() CSE.cpp:0:0
> ```

Thanks for submitting the test case and revert it. I believe https://github.com/llvm/llvm-project/pull/191135 should fix it, though I haven't pinpointed the exact root cause of the crash yet. I'll need to investigate further.❤️

https://github.com/llvm/llvm-project/pull/190926


More information about the Mlir-commits mailing list