[LLVMdev] [llvm-commits] Branch Probability

Andrew Trick atrick at apple.com
Thu Jun 9 09:54:00 PDT 2011


On Jun 5, 2011, at 11:01 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi Andrew,
> 
>> Representation: 32-bit unsigned int stored in IR meta-data.
> 
> why store it in the IR, and not just have it be an analysis that you can query
> for branch probabilities?  If you store it in the IR then it may well get out
> of date (eg: when an optimizer realizes that some branches is dead and deletes
> it, resulting in probabilities that don't add up to 1 on the other branches).
> This happens all the time in GCC and is kind of annoying.
> 
> Ciao, Duncan.
> ______________________________

Sorry, my response may not be timely if I'm not copied on the message. 

At the IR level, the only things in meta-data are those that cannot be recomputed because they originate from an external source. Such as builtin expect. 

Nonetheless, probabilities will always sum to one because they are always computed on the fly from the sum of branch weights. So removing a branch target automatically increases the probability of the remaining targets. 

Andy



More information about the llvm-dev mailing list