[llvm] [LoopUnroll] Fix freqs for unconditional latches: N>2, uniform (PR #182405)

Aleksandr Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 03:36:21 PDT 2026


aleks-tmb wrote:

Hi @jdenny-ornl, it looks like this PR introduces an assertion failure that is reliably triggered by hot loops with realistic branch weights. 
Here is a reproducer: https://godbolt.org/z/na5v4zEY9 
It crashes any assertions-enabled build containing this commit.

`-passes=loop-unroll -unroll-count=2`
```llvm
declare void @f(i32)

define void @test() {
entry:
  br label %do.body

do.body:
  %i = phi i32 [ 0, %entry ], [ %next, %do.body ]
  call void @f(i32 %i)
  %next = add i32 %i, 1
  %c = icmp ne i32 %next, 5
  br i1 %c, label %do.body, label %do.end, !prof !0

do.end:
  ret void
}

!0 = !{!"branch_weights", i32 1073741824, i32 1}
```


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


More information about the llvm-commits mailing list