[llvm] [NFC] update doc comment on `setLoopEstimatedTripCount` (PR #178091)

Joel E. Denny via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 28 09:43:51 PST 2026


================
@@ -359,7 +359,19 @@ getLoopEstimatedTripCount(Loop *L,
 /// - Set the branch weight metadata of \p L to reflect that \p L has an
 ///   estimated \p EstimatedTripCount iterations and has
 ///   \c *EstimatedLoopInvocationWeight exit weight through the loop's latch.
-/// - If \p EstimatedTripCount is zero, zero the branch weights.
+/// - If \p EstimatedTripCount is zero, set the backedge weight to 0 and exit
+/// edge to 1. The \EstimatedTripCount is relative to the function entry, but
----------------
jdenny-ornl wrote:

The estimated trip count is not generally relative to function entry, or it would be affected by the path from function entry to original loop entry.  Instead, it is relative to original loop entry.  That is definitely true before the original loop is transformed because it's based solely on the original latch branch weights.  I argue it remains relative to *original* loop entry even after transformation.  LoopPeel is an easy example: peel 2 iterations from an estimated trip count of 10 and the remaining loop has 8 even though its branch weights still indicate 10, as discussed in the [RFC](https://discourse.llvm.org/t/rfc-fix-loop-transformations-to-preserve-block-frequencies/85785).



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


More information about the llvm-commits mailing list