summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/BlockFrequency.cpp
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-12-14 02:24:22 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-12-14 02:24:22 +0000
commit8f17dccdcb1dbfceaaf5b14ee1186c76b0584a35 (patch)
tree0eeffa6c2ca025187899327ae58e40b3880833ca /llvm/lib/Support/BlockFrequency.cpp
parent0f7f222c59c8673862aa4272803e84a05d9b925d (diff)
downloadbcm5719-llvm-8f17dccdcb1dbfceaaf5b14ee1186c76b0584a35.tar.gz
bcm5719-llvm-8f17dccdcb1dbfceaaf5b14ee1186c76b0584a35.zip
[block-freq] Add a right shift to BlockFrequency that saturates at 1.
llvm-svn: 197302
Diffstat (limited to 'llvm/lib/Support/BlockFrequency.cpp')
-rw-r--r--llvm/lib/Support/BlockFrequency.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Support/BlockFrequency.cpp b/llvm/lib/Support/BlockFrequency.cpp
index d1f8408dfcb..00cf75bd5cf 100644
--- a/llvm/lib/Support/BlockFrequency.cpp
+++ b/llvm/lib/Support/BlockFrequency.cpp
@@ -145,6 +145,18 @@ BlockFrequency::operator+(const BlockFrequency &Prob) const {
return Freq;
}
+BlockFrequency &BlockFrequency::operator>>=(const unsigned count) {
+ // Frequency can never be 0 by design.
+ assert(Frequency != 0);
+
+ // Shift right by count.
+ Frequency >>= count;
+
+ // Saturate to 1 if we are 0.
+ Frequency |= Frequency == 0;
+ return *this;
+}
+
uint32_t BlockFrequency::scale(const BranchProbability &Prob) {
return scale(Prob.getNumerator(), Prob.getDenominator());
}
OpenPOWER on IntegriCloud