[llvm] [LoopUnroll] Use branch probability in multi-exit loop unrolling (PR #164799)

Joel E. Denny via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 7 11:46:10 PST 2026


================
@@ -482,10 +482,53 @@ CloneLoopBlocks(Loop *L, Value *NewIter, const bool UseEpilogRemainder,
   return NewLoop;
 }
 
+// Calculates the edge probability from Src to Dst.
+// Dst has to be a successor to Src.
+// This uses branch_probability metadata directly. If data are missing or
+// probability cannot be computed, then std::nullopt is returned.
+// This does not use BranchProbabilityInfo and the values computed by this
+// will vary from BPI because BPI has its own more advanced heuristics to
+// determine probabilities without metadata.
+static std::optional<BranchProbability>
----------------
jdenny-ornl wrote:

`BranchProbability` supports an unknown state, so `std::optional` should not be necessary.

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


More information about the llvm-commits mailing list