summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-04-29 16:20:05 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-04-29 16:20:05 +0000
commit6919443535aad0df04be44252d6f4a0b6added43 (patch)
treec5b4b498526d796b4b0f5e301ad1e1ee1886087f /include
parent81566c52fd1b5f9214fb826f171eb29cee14507d (diff)
downloadllvm-6919443535aad0df04be44252d6f4a0b6added43.tar.gz
llvm-6919443535aad0df04be44252d6f4a0b6added43.tar.bz2
llvm-6919443535aad0df04be44252d6f4a0b6added43.tar.xz
blockfreq: Defer to BranchProbability::scale()
`BlockMass` can now defer to `BranchProbability::scale()`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207547 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/BlockFrequencyInfoImpl.h29
1 files changed, 4 insertions, 25 deletions
diff --git a/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index e12bfd9cb7..7f7d266f7b 100644
--- a/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -758,31 +758,10 @@ public:
return *this;
}
- /// \brief Multiply by a branch probability.
- ///
- /// Multiply by P. Guarantees full precision.
- ///
- /// This could be naively implemented by multiplying by the numerator and
- /// dividing by the denominator, but in what order? Multiplying first can
- /// overflow, while dividing first will lose precision (potentially, changing
- /// a non-zero mass to zero).
- ///
- /// The implementation mixes the two methods. Since \a BranchProbability
- /// uses 32-bits and \a BlockMass 64-bits, shift the mass as far to the left
- /// as there is room, then divide by the denominator to get a quotient.
- /// Multiplying by the numerator and right shifting gives a first
- /// approximation.
- ///
- /// Calculate the error in this first approximation by calculating the
- /// opposite mass (multiply by the opposite numerator and shift) and
- /// subtracting both from teh original mass.
- ///
- /// Add to the first approximation the correct fraction of this error value.
- /// This time, multiply first and then divide, since there is no danger of
- /// overflow.
- ///
- /// \pre P represents a fraction between 0.0 and 1.0.
- BlockMass &operator*=(const BranchProbability &P);
+ BlockMass &operator*=(const BranchProbability &P) {
+ Mass = P.scale(Mass);
+ return *this;
+ }
bool operator==(const BlockMass &X) const { return Mass == X.Mass; }
bool operator!=(const BlockMass &X) const { return Mass != X.Mass; }