[llvm] r184584 - BlockFrequency: Saturate at 1 instead of 0 when multiplying a frequency with a branch probability.

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jun 21 12:54:50 PDT 2013


On Jun 21, 2013, at 12:30 PM, Benjamin Kramer <benny.kra at googlemail.com> wrote:

> Author: d0k
> Date: Fri Jun 21 14:30:05 2013
> New Revision: 184584
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=184584&view=rev
> Log:
> BlockFrequency: Saturate at 1 instead of 0 when multiplying a frequency with a branch probability.
> 
> Zero is used by BlockFrequencyInfo as a special "don't know" value. It also
> causes a sink for frequencies as you can't ever get off a zero frequency with
> more multiplies.
> 
> This recovers a 10% regression on MultiSource/Benchmarks/7zip. A zero frequency
> was propagated into an inner loop causing excessive spilling.
> 
> PR16402.

Thanks, Ben

>   uint32_t n = Prob.getNumerator();
>   uint32_t d = Prob.getDenominator();
> 
> +  // Limit the result to 1; 0 is a sentinel value. This keeps BlockFrequencyInfo
> +  // from getting stuck at zero frequencies just because a value became too
> +  // small to be represented as a BlockFrequency.
> +  Frequency = (n == 0 || Frequency != 0) ? Frequency : 1;

Can branch probabilities be zero? If they can, we probably shouldn’t take that value seriously either.

/jakob





More information about the llvm-commits mailing list