Open
Description
In LLVM IR, a loop’s latch block can have branch weight metadata that encodes an estimated trip count that is derived from application profile data. Initially, the loop body’s block frequencies agree with the estimated trip count, as expected. However, sometimes loop transformations adjust those branch weights in a way that correctly maintains the estimated trip count but that corrupts the block frequencies.
This RFC explains the problem in more detail and proposes a solution. It was accepted by the community.
PR #128785 drafts a fix for the LoopPeel case. Solutions for LoopUnroll cases are already under development.