15 #include "llvm/Config/llvm-config.h" 31 double Percent =
rint(((
double)N / D) * 100.0 * 100.0) / 100.0;
32 return OS <<
format(
"0x%08" PRIx32
" / 0x%08" PRIx32
" = %.2f%%", N, D,
36 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 41 assert(Denominator > 0 &&
"Denominator cannot be 0!");
42 assert(Numerator <= Denominator &&
"Probability cannot be bigger than 1!");
47 (Numerator *
static_cast<uint64_t
>(D) + Denominator / 2) / Denominator;
54 uint64_t Denominator) {
55 assert(Numerator <= Denominator &&
"Probability cannot be bigger than 1!");
58 while (Denominator > UINT32_MAX) {
68 template <u
int32_t ConstD>
73 assert(D &&
"divide by 0");
80 uint64_t ProductHigh = (Num >> 32) * N;
81 uint64_t ProductLow = (Num & UINT32_MAX) * N;
84 uint32_t Upper32 = ProductHigh >> 32;
85 uint32_t Lower32 = ProductLow & UINT32_MAX;
86 uint32_t Mid32Partial = ProductHigh & UINT32_MAX;
87 uint32_t Mid32 = Mid32Partial + (ProductLow >> 32);
90 Upper32 += Mid32 < Mid32Partial;
96 uint64_t Rem = (uint64_t(Upper32) << 32) | Mid32;
97 uint64_t UpperQ = Rem / D;
100 if (UpperQ > UINT32_MAX)
103 Rem = ((Rem % D) << 32) | Lower32;
104 uint64_t LowerQ = Rem / D;
105 uint64_t Q = (UpperQ << 32) + LowerQ;
112 return ::scale<D>(Num, N, D);
116 return ::scale<0>(Num, D, N);
This class represents lattice values for constants.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
uint64_t scaleByInverse(uint64_t Num) const
Scale a large integer by the inverse.
static BranchProbability getBranchProbability(uint64_t Numerator, uint64_t Denominator)
uint64_t scale(uint64_t Num) const
Scale a large integer.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_ostream & print(raw_ostream &OS) const
This class implements an extremely fast bulk output stream that can only output to a stream...