[PATCH] D32124: [BPI] Move tail computation out of the loop. NFC

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 20 21:02:54 PDT 2017


skatkov added a comment.

In https://reviews.llvm.org/D32124#733015, @chandlerc wrote:

> In https://reviews.llvm.org/D32124#732170, @skatkov wrote:
>
> > BTW, probably we should not add the tail to any edge at all... It might be that the information that two edges have exactly the same probability is mot important than the requirement that the sum of all probabilities should be 1. it seems that sum == 1 is not a strict requirement. For example, if we have three edges with the same weight then as a result the sum of probabilities will not be equal to one.  What do you think?
>
>
> I think we already handle this kind of case in a few places in BPI and we should be consistent there. I can go digging for it but you may already know where it is...


Hi Chandler, I'm not sure what exactly you mean but take a look into the last test @test_unreachable_with_switch_prof4 in test/Analysis/BranchProbabilityInfo/basic.ll:
For the five unreachable edges with the same weight we generate the following probability
; CHECK: edge entry -> case_a probability is 0x1999999a / 0x80000000 = 20.00%
; CHECK: edge entry -> case_b probability is 0x1999999a / 0x80000000 = 20.00%
; CHECK: edge entry -> case_c probability is 0x1999999a / 0x80000000 = 20.00%
; CHECK: edge entry -> case_d probability is 0x1999999a / 0x80000000 = 20.00%
; CHECK: edge entry -> case_e probability is 0x1999999a / 0x80000000 = 20.00%

and 0x1999999a * 5 = 0x80000002 > 0x80000000, so the sum of probabilities is greater than 1.


https://reviews.llvm.org/D32124





More information about the llvm-commits mailing list