[all-commits] [llvm/llvm-project] 24557c: [LoopUnroll] Fix block frequencies when no runtime...
Joel E. Denny via All-commits
all-commits at lists.llvm.org
Fri Oct 31 07:44:49 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 24557cce40b7d90c289b4a537ed95eaf6522f53c
https://github.com/llvm/llvm-project/commit/24557cce40b7d90c289b4a537ed95eaf6522f53c
Author: Joel E. Denny <jdenny.ornl at gmail.com>
Date: 2025-10-31 (Fri, 31 Oct 2025)
Changed paths:
M llvm/lib/Transforms/Utils/LoopUnroll.cpp
A llvm/test/Transforms/LoopUnroll/branch-weights-freq/peel.ll
A llvm/test/Transforms/LoopUnroll/branch-weights-freq/unroll-partial.ll
R llvm/test/Transforms/LoopUnroll/peel-branch-weights-freq.ll
M llvm/test/Transforms/LoopUnroll/runtime-loop-branchweight.ll
M llvm/test/Transforms/LoopUnroll/unroll-heuristics-pgo.ll
Log Message:
-----------
[LoopUnroll] Fix block frequencies when no runtime (#157754)
This patch implements the LoopUnroll changes discussed in [[RFC] Fix
Loop Transformations to Preserve Block
Frequencies](https://discourse.llvm.org/t/rfc-fix-loop-transformations-to-preserve-block-frequencies/85785)
and is thus another step in addressing issue #135812.
In summary, for the case of partial loop unrolling without a remainder
loop, this patch changes LoopUnroll to:
- Maintain branch weights consistently with the original loop for the
sake of preserving the total frequency of the original loop body.
- Store the new estimated trip count in the
`llvm.loop.estimated_trip_count` metadata, introduced by PR #148758.
- Correct the new estimated trip count (e.g., 3 instead of 2) when the
original estimated trip count (e.g., 10) divided by the unroll count
(e.g., 4) leaves a remainder (e.g., 2).
There are loop unrolling cases this patch does not fully fix, such as
partial unrolling with a remainder loop and complete unrolling, and
there are two associated tests whose branch weights this patch adversely
affects. They will be addressed in future patches that should land with
this patch.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list