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

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 14:03:44 PDT 2016


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.

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). 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





More information about the llvm-commits mailing list