[PATCH] Allow 0-weight branches in BranchProbabilityInfo.

Hans Wennborg hans at chromium.org
Wed May 6 10:37:00 PDT 2015


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?



More information about the llvm-commits mailing list