summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-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