[PATCH] D19435: [LowerExpectIntrinsic] pin default likely/unlikely weights to min/max values

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 14:12:05 PDT 2016


On Mon, Apr 25, 2016 at 2:03 PM, Sanjay Patel <spatel at rotateright.com>
wrote:

> spatel added a comment.
>
> In http://reviews.llvm.org/D19435#411143, @davidxl wrote:
>
> > What is the motivation for this change? Current weight distribution 64:4
> is not strong enough for if conversion to not generate cmov?
>
>
> Yes - 4:64 is 5.88%. I don't think we can safely convert to a branch in
> that case. We would have to consider mispredict penalty at that point.
> Please see http://reviews.llvm.org/D19488.
>

I will take a look at at patch.


>
> But that is not the only reason: builtin_expect() is a programmer override
> that should affect BB placement too (although this doesn't work today
> AFAIK).


It should work as the BB layout uses 80% as the threshold to follow
successors. Do you have evidence that it does not work for block layout?

David



> We should set the weights to the extreme values to ensure that happens
> regardless of other weights that are based on profile data or heuristics. I
> noticed this could be a problem while looking at
> test/Transforms/LoopUnswitch/cold-loop.ll (notice the "100000000" branch
> weight).
>
>
> http://reviews.llvm.org/D19435
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160425/328c68c4/attachment.html>


More information about the llvm-commits mailing list