[llvm] [ARM] Pattern match Low Overhead Loops pseudos (NFC) (PR #168209)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 11:51:37 PST 2025


s-barannikov wrote:

Simple repro:
```
$ cat reduced.ll
```
```
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv8.1m.main-unknown-linux-gnueabihf"

define i32 @_Z19arm_mat_inverse_f64PK23arm_matrix_instance_f64PS_(i16 %0) {
  %2 = zext i16 %0 to i32
  %3 = icmp eq i16 %0, 0
  br i1 %3, label %.critedge, label %5

4:                                                ; preds = %5
  br i1 %3, label %.critedge, label %9

5:                                                ; preds = %5, %1
  %6 = phi i32 [ %7, %5 ], [ 0, %1 ]
  %7 = add i32 %6, 1
  %8 = icmp eq i32 %7, %2
  br i1 %8, label %4, label %5

9:                                                ; preds = %9, %4
  %10 = phi i32 [ %11, %9 ], [ 0, %4 ]
  %11 = add i32 %10, 1
  %12 = icmp eq i32 %11, %2
  br i1 %12, label %.critedge, label %9

.critedge:                                        ; preds = %9, %4, %1
  ret i32 0
}
```
```
$ llc reduced.ll
```
```
llc: ../llvm/include/llvm/CodeGen/MachineOperand.h:572: llvm::MachineBasicBlock *llvm::MachineOperand::getMBB() const: Assertion `isMBB() && "Wrong MachineOperand accessor"' 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: cmake-build-release/bin/llc reduced.ll
1.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.	Running pass 'ARM block placement' on function '@_Z19arm_mat_inverse_f64PK23arm_matrix_instance_f64PS_'
 #0 0x00007a82baa453e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMSupport.so.22.0git+0x2453e7)
 #1 0x00007a82baa42ae5 llvm::sys::RunSignalHandlers() (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMSupport.so.22.0git+0x242ae5)
 #2 0x00007a82baa46255 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007a82ba042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007a82ba0969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007a82ba0969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007a82ba0969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007a82ba042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007a82ba0287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007a82ba02871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007a82ba039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007a82c24ee089 llvm::ARMBlockPlacement::fixBackwardsWLS(llvm::MachineLoop*) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMARMCodeGen.so.22.0git+0x2ee089)
#12 0x00007a82c24ee544 llvm::ARMBlockPlacement::processPostOrderLoops(llvm::MachineLoop*) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMARMCodeGen.so.22.0git+0x2ee544)
#13 0x00007a82c24ee83b llvm::ARMBlockPlacement::runOnMachineFunction(llvm::MachineFunction&) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMARMCodeGen.so.22.0git+0x2ee83b)
#14 0x00007a82bca63ca8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMCodeGen.so.22.0git+0x663ca8)
#15 0x00007a82bb0aacd5 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMCore.so.22.0git+0x4aacd5)
#16 0x00007a82bb0b2b61 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMCore.so.22.0git+0x4b2b61)
#17 0x00007a82bb0ab70c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/sergei/Projects/llvm-project/cmake-build-release/bin/../lib/libLLVMCore.so.22.0git+0x4ab70c)
#18 0x00006227ff27e5e4 compileModule(char**, llvm::LLVMContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) llc.cpp:0:0
#19 0x00006227ff27b8c0 main (cmake-build-release/bin/llc+0x1b8c0)
#20 0x00007a82ba029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#21 0x00007a82ba029e40 call_init ./csu/../csu/libc-start.c:128:20
#22 0x00007a82ba029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#23 0x00006227ff2773c5 _start (cmake-build-release/bin/llc+0x173c5)
Aborted (core dumped)
```


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


More information about the llvm-commits mailing list