[llvm] r255595 - Let operator/ with uint32_t rhs operand be a member of BranchProbability and add a new operator /=. NFC.
Cong Hou via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 14 17:21:14 PST 2015
Author: conghou
Date: Mon Dec 14 19:21:14 2015
New Revision: 255595
URL: http://llvm.org/viewvc/llvm-project?rev=255595&view=rev
Log:
Let operator/ with uint32_t rhs operand be a member of BranchProbability and add a new operator /=. NFC.
Modified:
llvm/trunk/include/llvm/Support/BranchProbability.h
Modified: llvm/trunk/include/llvm/Support/BranchProbability.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/BranchProbability.h?rev=255595&r1=255594&r2=255595&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/BranchProbability.h (original)
+++ llvm/trunk/include/llvm/Support/BranchProbability.h Mon Dec 14 19:21:14 2015
@@ -117,6 +117,14 @@ public:
return *this;
}
+ BranchProbability &operator/=(uint32_t RHS) {
+ assert(N != UnknownN &&
+ "Unknown probability cannot participate in arithmetics.");
+ assert(RHS > 0 && "The divider cannot be zero.");
+ N /= RHS;
+ return *this;
+ }
+
BranchProbability operator+(BranchProbability RHS) const {
BranchProbability Prob(*this);
return Prob += RHS;
@@ -132,6 +140,11 @@ public:
return Prob *= RHS;
}
+ BranchProbability operator/(uint32_t RHS) const {
+ BranchProbability Prob(*this);
+ return Prob /= RHS;
+ }
+
bool operator==(BranchProbability RHS) const { return N == RHS.N; }
bool operator!=(BranchProbability RHS) const { return !(*this == RHS); }
@@ -164,12 +177,6 @@ inline raw_ostream &operator<<(raw_ostre
return Prob.print(OS);
}
-inline BranchProbability operator/(BranchProbability LHS, uint32_t RHS) {
- assert(LHS != BranchProbability::getUnknown() &&
- "Unknown probability cannot participate in arithmetics.");
- return BranchProbability::getRaw(LHS.getNumerator() / RHS);
-}
-
template <class ProbabilityIter>
void BranchProbability::normalizeProbabilities(ProbabilityIter Begin,
ProbabilityIter End) {
More information about the llvm-commits
mailing list