Skip to content

Fix Loop Transformations to Preserve Block Frequencies #135812

Open
@jdenny-ornl

Description

@jdenny-ornl

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.

Metadata

Metadata

Assignees

Labels

llvmUmbrella label for LLVM issuesloopoptim

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions