[PATCH] D30633: [BPI] Reduce the probability of unreachable edge to minimal value greater than 0

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 11:02:35 PDT 2017


skatkov added a comment.

In https://reviews.llvm.org/D30633#756320, @dexonsmith wrote:

> The testcase updates look good to me, and demonstrate the patch is doing what's intended.  It might be worth adding a couple of tests for multiple branch targets (switch statements), since I'm not convinced everything adds up to 1 right now.


The test @test2 represents the case with switch or you are talking about case when sum of probabilities is not equal to 1?



================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:202-206
+  auto UnreachableProb = UR_TAKEN_PROB;
+  auto ReachableProb =
+      (BranchProbability::getOne() - UR_TAKEN_PROB * UnreachableEdges.size()) /
+      ReachableEdges.size();
 
----------------
dexonsmith wrote:
> This doesn't look to me like it will add up to `BranchProbability::getOne()` in the end.  Is that a problem?
The sum of probabilities might be different than 1 and this consistent with all other heuristics in this file.
It seems that it was not considered as problem before.

If you think it should be fixed I can come up with a follow-up patch fixing all cases. The question is actually where to add the remainder.


https://reviews.llvm.org/D30633





More information about the llvm-commits mailing list