[PATCH] D11442: Create a utility function normalizeEdgeWeights() in BranchProbabilityInfo that is used to normalize a list of weights so that the sum of them does not exceed UINT32_MAX.
davidxl at google.com
Thu Jul 23 14:01:26 PDT 2015
davidxl added inline comments.
Comment at: include/llvm/Analysis/BranchProbabilityInfo.h:165
@@ +164,3 @@
+ // If the computed sum fits in 32-bits, we're done.
+ if (Sum <= UINT32_MAX)
+ return 1;
> davidxl wrote:
> > Why not doing normalization unconditionally to avoid precision loss introduced by incremental update (for small weights)?
> The incremental update itself can deal with precision loss, then this function can be called to guarantee that the sum of weights won't exceed UINT32_MAX.
> If we decide to normalize all edge weights with scaling up, we should call this normalization function every time we set or update the edge weight. Have we decided this?
You will be needing this for precision preservation purpose, so this interface needs to take an extra argument to decide if up-scaling needs to be done -- by default it can be off.
More information about the llvm-commits