[llvm-branch-commits] [llvm] [LoopUnroll] Fix block frequencies for epilogue (PR #159163)

Joel E. Denny via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Oct 14 08:57:09 PDT 2025


================
@@ -111,3 +111,10 @@ uint64_t BranchProbability::scale(uint64_t Num) const {
 uint64_t BranchProbability::scaleByInverse(uint64_t Num) const {
   return ::scale<0>(Num, D, N);
 }
+
+BranchProbability BranchProbability::pow(unsigned N) const {
+  BranchProbability Res = BranchProbability::getOne();
----------------
jdenny-ornl wrote:

What is an example that would cause overflow here, and why would the `operator*=` used here not already handle it?  Keep in mind that `BranchProbability` represents a value from 0 to 1, so the result should always be a value that is also in that range.

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


More information about the llvm-branch-commits mailing list