summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/BranchProbability.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [BranchProbability] Manually round the floating point output.Benjamin Kramer2015-09-261-28/+7
| | | | | | | | | | | llvm::format compiles down to snprintf which has no defined rounding for floating point arguments, and MSVC has implemented it differently from what the BSD libcs and glibc do. Try to emulate the glibc rounding behavior to avoid changing tests. While there simplify code a bit and move trivial methods inline. llvm-svn: 248665
* Use fixed-point representation for BranchProbability.Cong Hou2015-09-251-5/+51
| | | | | | | | | | | | | | | | | | | | BranchProbability now is represented by its numerator and denominator in uint32_t type. This patch changes this representation into a fixed point that is represented by the numerator in uint32_t type and a constant denominator 1<<31. This is quite similar to the representation of BlockMass in BlockFrequencyInfoImpl.h. There are several pros and cons of this change: Pros: 1. It uses only a half space of the current one. 2. Some operations are much faster like plus, subtraction, comparison, and scaling by an integer. Cons: 1. Constructing a probability using arbitrary numerator and denominator needs additional calculations. 2. It is a little less precise than before as we use a fixed denominator. For example, 1 - 1/3 may not be exactly identical to 1 / 3 (this will lead to many BranchProbability unit test failures). This should not matter when we only use it for branch probability. If we use it like a rational value for some precise calculations we may need another construct like ValueRatio. One important reason for this change is that we propose to store branch probabilities instead of edge weights in MachineBasicBlock. We also want clients to use probability instead of weight when adding successors to a MBB. The current BranchProbability has more space which may be a concern. Differential revision: http://reviews.llvm.org/D12603 llvm-svn: 248633
* BranchProb: Simplify printing codeDuncan P. N. Exon Smith2014-04-291-10/+4
| | | | llvm-svn: 207559
* Support: remove unnecessary namespaceDuncan P. N. Exon Smith2014-04-291-5/+1
| | | | llvm-svn: 207545
* Support: Add BranchProbability::scale() and ::scaleByInverse()Duncan P. N. Exon Smith2014-04-291-0/+47
| | | | | | | Add API to `BranchProbability` for scaling big integers. Next job is to rip the logic out of `BlockMass` and `BlockFrequency`. llvm-svn: 207544
* Print branch probabilities as percentages.Benjamin Kramer2011-10-231-3/+3
| | | | | | 50% is much more readable than 5.000000e-01. llvm-svn: 142752
* Add compare operators to BranchProbability and use it to determine if an ↵Benjamin Kramer2011-10-231-7/+0
| | | | | | edge is hot. llvm-svn: 142751
* BranchProbability::print returns void now.Jakub Staszak2011-07-251-2/+1
| | | | llvm-svn: 135994
* Branch profiling: floating-point avoidance.Andrew Trick2011-06-111-0/+44
Patch by: Jakub Staszak! Introduces BranchProbability. Changes unsigned to uint32_t all over and uint64_t only when overflow is expected. llvm-svn: 132867
OpenPOWER on IntegriCloud