@@ -7869,13 +7869,31 @@ loop distribution pass. See
7869
7869
'``llvm.loop.estimated_trip_count``' Metadata
7870
7870
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7871
7871
7872
- This metadata records the loop's estimated trip count. If it is not present, a
7873
- loop's estimated trip count should be computed from any ``branch_weights``
7874
- metadata attached to the latch block's branch instruction.
7872
+ This metadata records the loop's estimated trip count. The first
7873
+ operand is the string ``llvm.loop.estimated_trip_count`` and the
7874
+ second operand is an integer specifying the count. For example:
7875
7875
7876
- Thus, this metadata frees loop transformations to compute latch branch weights
7877
- solely for the purpose of maintaining accurate block frequencies instead of
7878
- requiring the branch weights to always serve both roles.
7876
+ .. code-block:: llvm
7877
+
7878
+ !0 = !{!"llvm.loop.estimated_trip_count", i32 8}
7879
+
7880
+ A loop's estimated trip count is an estimate of the average number of
7881
+ loop iterations (specifically, the number of times the loop's header
7882
+ executes) each time execution reaches the loop. It is usually only an
7883
+ estimate based on, for example, profile data. The actual number of
7884
+ iterations might vary widely.
7885
+
7886
+ The estimated trip count serves as a parameter for various loop
7887
+ transformations and typically helps estimate transformation cost. For
7888
+ example, it can help determine how many iterations to peel or how
7889
+ aggressively to unroll.
7890
+
7891
+ If this metadata is not present, such passes compute the estimated
7892
+ trip count from any ``branch_weights`` metadata attached to the latch
7893
+ block's branch instruction. Thus, this metadata frees loop
7894
+ transformations to compute latch branch weights solely for the purpose
7895
+ of maintaining accurate block frequencies instead of requiring the
7896
+ branch weights to always serve both roles.
7879
7897
7880
7898
'``llvm.licm.disable``' Metadata
7881
7899
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments