[all-commits] [llvm/llvm-project] 13d1fb: [PGO] Add `llvm.loop.estimated_trip_count` metadata
Joel E. Denny via All-commits
all-commits at lists.llvm.org
Mon Jul 14 19:16:24 PDT 2025
Branch: refs/heads/users/jdenny-ornl/pgo-estimated-trip-count
Home: https://github.com/llvm/llvm-project
Commit: 13d1fbbbac1ea171f99175ab7278454f462d1710
https://github.com/llvm/llvm-project/commit/13d1fbbbac1ea171f99175ab7278454f462d1710
Author: Joel E. Denny <jdenny.ornl at gmail.com>
Date: 2025-07-14 (Mon, 14 Jul 2025)
Changed paths:
M llvm/docs/LangRef.rst
M llvm/include/llvm/Analysis/LoopInfo.h
A llvm/include/llvm/Transforms/Instrumentation/PGOEstimateTripCounts.h
M llvm/include/llvm/Transforms/Utils/LoopUtils.h
M llvm/lib/Analysis/LoopInfo.cpp
M llvm/lib/Passes/PassBuilder.cpp
M llvm/lib/Passes/PassBuilderPipelines.cpp
M llvm/lib/Passes/PassRegistry.def
M llvm/lib/Transforms/Instrumentation/CMakeLists.txt
A llvm/lib/Transforms/Instrumentation/PGOEstimateTripCounts.cpp
M llvm/lib/Transforms/Utils/LoopUtils.cpp
M llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
M llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
M llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
M llvm/test/Transforms/LoopVectorize/AArch64/check-prof-info.ll
M llvm/test/Transforms/LoopVectorize/X86/pr81872.ll
M llvm/test/Transforms/LoopVectorize/branch-weights.ll
A llvm/test/Transforms/PGOProfile/pgo-estimate-trip-counts.ll
Log Message:
-----------
[PGO] Add `llvm.loop.estimated_trip_count` metadata
This patch implements the `llvm.loop.estimated_trip_count` metadata
discussed in [[RFC] Fix Loop Transformations to Preserve Block
Frequencies](https://discourse.llvm.org/t/rfc-fix-loop-transformations-to-preserve-block-frequencies/85785).
As [suggested in the RFC
comments](https://discourse.llvm.org/t/rfc-fix-loop-transformations-to-preserve-block-frequencies/85785/4),
it adds the new metadata to all loops at the time of profile ingestion
and estimates each trip count from the loop's `branch_weights`
metadata. As [suggested in the PR#128785
review](https://github.com/llvm/llvm-project/pull/128785#discussion_r2151091036),
it does so via a `PGOEstimateTripCountsPass` pass, which creates the
new metadata for the loop but omits the value if it cannot estimate a
trip count due to the loop's form.
An important observation not previously discussed is that
`PGOEstimateTripCountsPass` *often* cannot estimate a loop's trip
count but later passes can transform the loop in a way that makes it
possible. Currently, such passes do not necessarily update the
metadata, but eventually that should be fixed. Until then, if the new
metadata has no value, `llvm::getLoopEstimatedTripCount` disregards it
and tries again to estimate the trip count from the loop's
`branch_weights` metadata.
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