[PATCH] Allow 0-weight branches in BranchProbabilityInfo.

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed May 6 10:44:15 PDT 2015


> On 2015 May 6, at 13:37, Hans Wennborg <hans at chromium.org> wrote:
> 
> On Wed, May 6, 2015 at 10:09 AM, Duncan P. N. Exon Smith
> <dexonsmith at apple.com> wrote:
>>>       assert(Weight <= UINT32_MAX / SI.getNumSuccessors());
>> 
>> Hmm.  I don't think BPI should guarantee this anymore.  This is
>> unnecessary for keeping the sum under `UINT32_MAX`.
> 
> It's useful to know that the sum of the weights for an arbitrary set
> of successors won't overflow. For example, switch lowering will merge
> adjacent cases with the same successors into clusters and just add the
> weights, without having to worry about overflow.
> 
> Are you saying you don't want to guarantee that anymore, or that
> forcing each weight <= UINT32_MAX / SI.getNumSuccessors() is
> unnecessarily strict?

No, just loosening it to a guarantee that summing doesn't overflow.
I outlined a cheap way to do that here:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150427/274432.html



More information about the llvm-commits mailing list