[llvm] [LoopPeel] Fix branch weights' effect on block frequencies (PR #128785)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 30 12:13:15 PDT 2025


================
@@ -7866,6 +7866,17 @@ The attributes in this metadata is added to all followup loops of the
 loop distribution pass. See
 :ref:`Transformation Metadata <transformation-metadata>` for details.
 
+'``llvm.loop.estimated_trip_count``' Metadata
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This metadata records the loop's estimated trip count.  If it is not present, a
+loop's estimated trip count should be computed from any ``branch_weights``
+metadata attached to the latch block's branch instruction.
+
+Thus, this metadata frees loop transformations to compute latch branch weights
+solely for the purpose of maintaining accurate block frequencies instead of
+requiring the branch weights to always serve both roles.
----------------
arsenm wrote:

This reads as more background information rather than a direct description of the meaning of the metadata 

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


More information about the llvm-commits mailing list