aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/BranchProbability.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/BranchProbability.cpp')
-rw-r--r--lib/Support/BranchProbability.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/Support/BranchProbability.cpp b/lib/Support/BranchProbability.cpp
index 49d04ed83653..e8b83e59802d 100644
--- a/lib/Support/BranchProbability.cpp
+++ b/lib/Support/BranchProbability.cpp
@@ -13,24 +13,17 @@
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-BranchProbability::BranchProbability(uint32_t n, uint32_t d) {
- assert(d > 0 && "Denomiator cannot be 0!");
- assert(n <= d && "Probability cannot be bigger than 1!");
- N = n;
- D = d;
-}
-
void BranchProbability::print(raw_ostream &OS) const {
- OS << N << " / " << D << " = " << ((double)N / D);
+ OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
}
void BranchProbability::dump() const {
- print(dbgs());
- dbgs() << "\n";
+ dbgs() << *this << '\n';
}
namespace llvm {