summaryrefslogtreecommitdiff
path: root/include/llvm/Support/BlockFrequency.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-06-21 19:30:05 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-06-21 19:30:05 +0000
commit93702a3b0754052d926c75082abf7ca156b80c45 (patch)
tree10b032704125296644321d26cc84d3053da88dc7 /include/llvm/Support/BlockFrequency.h
parent65af4b5333f539b9e572ebb9c4d4e97a897e5130 (diff)
downloadllvm-93702a3b0754052d926c75082abf7ca156b80c45.tar.gz
llvm-93702a3b0754052d926c75082abf7ca156b80c45.tar.bz2
llvm-93702a3b0754052d926c75082abf7ca156b80c45.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/BlockFrequency.h')
-rw-r--r--include/llvm/Support/BlockFrequency.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/Support/BlockFrequency.h b/include/llvm/Support/BlockFrequency.h
index 839cf93712..257888f8d0 100644
--- a/include/llvm/Support/BlockFrequency.h
+++ b/include/llvm/Support/BlockFrequency.h
@@ -30,12 +30,20 @@ class BlockFrequency {
public:
BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }
+ /// \brief Returns the frequency of the entry block of the function.
static uint64_t getEntryFrequency() { return ENTRY_FREQ; }
+
+ /// \brief Returns the frequency as a fixpoint number scaled by the entry
+ /// frequency.
uint64_t getFrequency() const { return Frequency; }
+ /// \brief Multiplies with a branch probability. The computation will never
+ /// overflow. If the result is equal to zero but the input wasn't this method
+ /// will return a frequency of one.
BlockFrequency &operator*=(const BranchProbability &Prob);
const BlockFrequency operator*(const BranchProbability &Prob) const;
+ /// \brief Adds another block frequency using saturating arithmetic.
BlockFrequency &operator+=(const BlockFrequency &Freq);
const BlockFrequency operator+(const BlockFrequency &Freq) const;