1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

14 Commits

Author SHA1 Message Date
Michael Gottesman
2e697ee084 [block-freq] Add a right shift to BlockFrequency that saturates at 1.
llvm-svn: 197302
2013-12-14 02:24:22 +00:00
Michael Gottesman
48849e11df [block-freq] Remove old BlockFrequency entry frequency and printing code.
llvm-svn: 197297
2013-12-14 00:57:18 +00:00
Michael Gottesman
e011e8ef82 [block-freq] Add BlockFrequency::scale that returns a remainder from the division and make the private scale in BlockFrequency more performant.
This change is the first in a series of changes improving LLVM's Block
Frequency propogation implementation to not lose probability mass in
branchy code when propogating block frequency information from a basic
block to its successors. This patch is a simple infrastructure
improvement that does not actually modify the block frequency
algorithm. The specific changes are:

1. Changes the division algorithm used when scaling block frequencies by
branch probabilities to a short division algorithm. This gives us the
remainder for free as well as provides a nice speed boost. When I
benched the old routine and the new routine on a Sandy Bridge iMac with
disabled turbo mode performing 8192 iterations on an array of length
32768, I saw ~600% increase in speed in mean/median performance.

2. Exposes a scale method that returns a remainder. This is important so
we can ensure that when we scale a block frequency by some branch
probability BP = N/D, the remainder from the division by D can be
retrieved and propagated to other children to ensure no probability mass
is lost (more to come on this).

llvm-svn: 194950
2013-11-17 03:25:24 +00:00
Jakob Stoklund Olesen
e4b031bd1a Fix a bad overflow check pointed out by Ben.
llvm-svn: 185226
2013-06-28 21:51:18 +00:00
Jakob Stoklund Olesen
0057eee43d Eliminate an assortment of undefined behavior.
Hopefully, this fixes the PPC64 buildbots.

llvm-svn: 185218
2013-06-28 21:10:25 +00:00
Jakob Stoklund Olesen
e7114f33aa Stylistic cleanups, no functional change.
- Use static functions instead of anonymous namespace.
- Appease the Doxygen lobby.
- Use 0-based induction variable.

llvm-svn: 185185
2013-06-28 18:33:19 +00:00
Jakob Stoklund Olesen
a9465b9413 Add a division operator to BlockFrequency.
Allow a BlockFrequency to be divided by a non-zero BranchProbability
with saturating arithmetic. This will be used to compute the frequency
of a loop header given the probability of leaving the loop.

Our long division algorithm already saturates on overflow, so that was a
freebie.

llvm-svn: 185184
2013-06-28 18:23:42 +00:00
Jakob Stoklund Olesen
a4ca837638 Print block frequencies in decimal form.
This is easier to read than the internal fixed-point representation.

If anybody knows the correct algorithm for converting fixed-point
numbers to base 10, feel free to fix it.

llvm-svn: 184881
2013-06-25 21:57:38 +00:00
Benjamin Kramer
30c35d5305 Revert "BlockFrequency: Saturate at 1 instead of 0 when multiplying a frequency with a branch probability."
This reverts commit r184584. Breaks PPC selfhost.

llvm-svn: 184590
2013-06-21 20:20:27 +00:00
Benjamin Kramer
3315e168ee BlockFrequency: Saturate at 1 instead of 0 when multiplying a frequency with a branch probability.
Zero is used by BlockFrequencyInfo as a special "don't know" value. It also
causes a sink for frequencies as you can't ever get off a zero frequency with
more multiplies.

This recovers a 10% regression on MultiSource/Benchmarks/7zip. A zero frequency
was propagated into an inner loop causing excessive spilling.

PR16402.

llvm-svn: 184584
2013-06-21 19:30:05 +00:00
Benjamin Kramer
ad2fb4eeb5 BlockFrequency: Use a smarter overflow check.
This trades one 64 bit div for one 64 bit mul and some arithmetic.

llvm-svn: 143106
2011-10-27 16:38:50 +00:00
Jakub Staszak
760b5d7506 Optimize 96-bit division a little bit.
llvm-svn: 136222
2011-07-27 16:00:40 +00:00
Jakub Staszak
29ef880b52 Move static methods to the anonymous namespace.
llvm-svn: 136221
2011-07-27 15:51:51 +00:00
Jakub Staszak
b4bffb255a Add BlockFrequency class.
llvm-svn: 135992
2011-07-25 22:24:51 +00:00