[PATCH] D79396: [BrachProbablityInfo] Set edge probabilities at once.

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 17 23:57:21 PDT 2020


yrouban marked an inline comment as done.
yrouban added inline comments.


================
Comment at: llvm/lib/Analysis/BranchProbabilityInfo.cpp:369
     // the difference between reachable blocks.
-    if (ToDistribute > BranchProbability::getZero()) {
-      BranchProbability PerEdge = ToDistribute / ReachableIdxs.size();
+    BranchProbability PerEdge = ToDistribute / ReachableIdxs.size();
+    if (PerEdge > BranchProbability::getZero())
----------------
TODO: This spreads //ToDistribute// evenly upon the reachable edges. A better distribution would be proportional. So the relation between weights of the reachable edges would be kept unchanged:

For any reachable edges i and j:
newBP[i] / newBP[j] == oldBP[i] / oldBP[j]
newBP[i] / oldBP[i] == newBP[j] / oldBP[j] == Denominator / (Denominator - ToDistribute)
newBP[i] = oldBP[i] * Denominator / (Denominator - ToDistribute)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79396/new/

https://reviews.llvm.org/D79396





More information about the llvm-commits mailing list