summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/Support/BranchProbability.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/Support/BranchProbability.h')
-rw-r--r--llvm/include/llvm/Support/BranchProbability.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/llvm/include/llvm/Support/BranchProbability.h b/llvm/include/llvm/Support/BranchProbability.h
index 3620d4d5d77..2548384f346 100644
--- a/llvm/include/llvm/Support/BranchProbability.h
+++ b/llvm/include/llvm/Support/BranchProbability.h
@@ -53,6 +53,9 @@ public:
// Create a BranchProbability object with the given numerator and 1<<31
// as denominator.
static BranchProbability getRaw(uint32_t N) { return BranchProbability(N); }
+ // Create a BranchProbability object from 64-bit integers.
+ static BranchProbability getBranchProbability(uint64_t Numerator,
+ uint64_t Denominator);
// Normalize given probabilties so that the sum of them becomes approximate
// one.
@@ -131,10 +134,30 @@ public:
bool operator==(BranchProbability RHS) const { return N == RHS.N; }
bool operator!=(BranchProbability RHS) const { return !(*this == RHS); }
- bool operator<(BranchProbability RHS) const { return N < RHS.N; }
- bool operator>(BranchProbability RHS) const { return RHS < *this; }
- bool operator<=(BranchProbability RHS) const { return !(RHS < *this); }
- bool operator>=(BranchProbability RHS) const { return !(*this < RHS); }
+
+ bool operator<(BranchProbability RHS) const {
+ assert(N != UnknownN && RHS.N != UnknownN &&
+ "Unknown probability cannot participate in comparisons.");
+ return N < RHS.N;
+ }
+
+ bool operator>(BranchProbability RHS) const {
+ assert(N != UnknownN && RHS.N != UnknownN &&
+ "Unknown probability cannot participate in comparisons.");
+ return RHS < *this;
+ }
+
+ bool operator<=(BranchProbability RHS) const {
+ assert(N != UnknownN && RHS.N != UnknownN &&
+ "Unknown probability cannot participate in comparisons.");
+ return !(RHS < *this);
+ }
+
+ bool operator>=(BranchProbability RHS) const {
+ assert(N != UnknownN && RHS.N != UnknownN &&
+ "Unknown probability cannot participate in comparisons.");
+ return !(*this < RHS);
+ }
};
inline raw_ostream &operator<<(raw_ostream &OS, BranchProbability Prob) {
OpenPOWER on IntegriCloud