diff options
author | Easwaran Raman <eraman@google.com> | 2018-08-16 00:26:59 +0000 |
---|---|---|
committer | Easwaran Raman <eraman@google.com> | 2018-08-16 00:26:59 +0000 |
commit | aca738b7424189e4937295de9f297124cc07b10f (patch) | |
tree | 9d3a58d181b262aab095934f965e3d6d6e1f56c0 /llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp | |
parent | bc86a99f780fce86a2a214d896f5bc1afb1c9b74 (diff) | |
download | llvm-aca738b7424189e4937295de9f297124cc07b10f.zip llvm-aca738b7424189e4937295de9f297124cc07b10f.tar.gz llvm-aca738b7424189e4937295de9f297124cc07b10f.tar.bz2 |
[BFI] Use rounding while computing profile counts.
Summary:
Profile count of a block is computed by multiplying its block frequency
by entry count and dividing the result by entry block frequency. Do
rounded division in the last step and update test cases appropriately.
Reviewers: davidxl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D50822
llvm-svn: 339835
Diffstat (limited to 'llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp')
-rw-r--r-- | llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp index 3d09506..9820988 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp @@ -573,7 +573,9 @@ BlockFrequencyInfoImplBase::getProfileCountFromFreq(const Function &F, APInt BlockFreq(128, Freq); APInt EntryFreq(128, getEntryFreq()); BlockCount *= BlockFreq; - BlockCount = BlockCount.udiv(EntryFreq); + // Rounded division of BlockCount by EntryFreq. Since EntryFreq is unsigned + // lshr by 1 gives EntryFreq/2. + BlockCount = (BlockCount + EntryFreq.lshr(1)).udiv(EntryFreq); return BlockCount.getLimitedValue(); } |