History log of /external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
1a710fdde197b00107ef55df51054925b9a5d2a2 24-Aug-2012 Manman Ren <mren@apple.com> BranchProb: modify the definition of an edge in BranchProbabilityInfo to handle
the case of multiple edges from one block to another.

A simple example is a switch statement with multiple values to the same
destination. The definition of an edge is modified from a pair of blocks to
a pair of PredBlock and an index into the successors.

Also set the weight correctly when building SelectionDAG from LLVM IR,
especially when converting a Switch.
IntegersSubsetMapping is updated to calculate the weight for each cluster.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162572 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
0c34ae88bfe6ab40fc30784f131510992438ea43 15-Aug-2012 Bill Wendling <isanbard@gmail.com> Set the branch probability of branching to the 'normal' destination of an invoke
instruction to something absurdly high, while setting the probability of
branching to the 'unwind' destination to the bare minimum. This should set cause
the normal destination's invoke blocks to be moved closer to the invoke.

PR13612


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161944 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
51f40a725b4d0bb9ee7a59edc3d2b2392ae9e852 22-Dec-2011 Chandler Carruth <chandlerc@gmail.com> Make the unreachable probability much much heavier. The previous
probability wouldn't be considered "hot" in some weird loop structures
or other compounding probability patterns. This makes it much harder to
confuse, but isn't really a principled fix. I'd actually like it if we
could model a zero probability, as it would make this much easier to
reason about. Suggestions for how to do this better are welcome.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147142 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
a7b0cb759433c715065440ee2a963a04db7f2b0b 15-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Remove all remaining uses of Value::getNameStr().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144648 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
45baf6bb85ee0d61e18213979a4efbd2f16eb338 25-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Fix the API usage in loop probability heuristics. It was incorrectly
classifying many edges as exiting which were in fact not. These mainly
formed edges into sub-loops. It was also not correctly classifying all
returning edges out of loops as leaving the loop. With this match most
of the loop heuristics are more rational.

Several serious regressions on loop-intesive benchmarks like perlbench's
loop tests when built with -enable-block-placement are fixed by these
updated heuristics. Unfortunately they in turn uncover some other
regressions. There are still several improvemenst that should be made to
loop heuristics including trip-count, and early back-edge management.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142917 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
de1c9bb45017e25b5fc2b77e15d3c377f6572075 24-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Remove return heuristics from the static branch probabilities, and
introduce no-return or unreachable heuristics.

The return heuristics from the Ball and Larus paper don't work well in
practice as they pessimize early return paths. The only good hitrate
return heuristics are those for:
- NULL return
- Constant return
- negative integer return

Only the last of these three can possibly require significant code for
the returning block, and even the last is fairly rare and usually also
a constant. As a consequence, even for the cold return paths, there is
little code on that return path, and so little code density to be gained
by sinking it. The places where sinking these blocks is valuable (inner
loops) will already be weighted appropriately as the edge is a loop-exit
branch.

All of this aside, early returns are nearly as common as all three of
these return categories, and should actually be predicted as taken!
Rather than muddy the waters of the static predictions, just remain
silent on returns and let the CFG itself dictate any layout or other
issues.

However, the return heuristic was flagging one very important case:
unreachable. Unfortunately it still gave a 1/4 chance of the
branch-to-unreachable occuring. It also didn't do a rigorous job of
finding those blocks which post-dominate an unreachable block.

This patch builds a more powerful analysis that should flag all branches
to blocks known to then reach unreachable. It also has better worst-case
runtime complexity by not looping through successors for each block. The
previous code would perform an N^2 walk in the event of a single entry
block branching to N successors with a switch where each successor falls
through to the next and they finally fall through to a return.

Test case added for noreturn heuristics. Also doxygen comments improved
along the way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142793 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
b068bbbaecf338f481124551a5e6f37484fad800 24-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Simplify the design of BranchProbabilityInfo by collapsing it into
a single class. Previously it was split between two classes, one
internal and one external. The concern seemed to center around exposing
the weights used, but those can remain confined to the implementation
file.

Having a single class to maintain the state and analyses in use will
also simplify several of the enhancements I want to make to our static
heuristics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142783 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
22c8946239de6d0cd6c51eeea245498e3c95ed87 24-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Tidy up a loop to be more idiomatic for LLVM's codebase, and remove some
extraneous whitespace. Trying to clean-up this pass as much as I can
before I start making functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142780 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
14edd314af99ccaad194d071f23e437a1371f176 23-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Teach the BranchProbabilityInfo pass to print its results, and use that
to bring it under direct test instead of merely indirectly testing it in
the BlockFrequencyInfo pass.

The next step is to start adding tests for the various heuristics
employed, and to start fixing those heuristics once they're under test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142778 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
341473c86d19cad5f3be432533ecdb42d9e07044 23-Oct-2011 Benjamin Kramer <benny.kra@googlemail.com> Add compare operators to BranchProbability and use it to determine if an edge is hot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142751 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
675c02b0b9967f286b4d5aa8c3f7d8fc9e7988c4 21-Oct-2011 Benjamin Kramer <benny.kra@googlemail.com> Extend the floating point heuristic to consider NaN checks unlikely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142687 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
c888aa47bdf4b5766f30e4d1a2c3c2d4e06a18b5 21-Oct-2011 Benjamin Kramer <benny.kra@googlemail.com> BranchProbabilityInfo: floating point equality is unlikely.

This is from the same paper from Ball and Larus as the rest of the currently implemented heuristics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142677 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
941aa7b1e8c1b77544d643e8b23ff07f7f83f281 19-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Generalize the reading of probability metadata to work for both branches
and switches, with arbitrary numbers of successors. Still optimized for
the common case of 2 successors for a conditional branch.

Add a test case for switch metadata showing up in the BlockFrequencyInfo pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142493 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
99d01c54a0fd790a48d5aa02bfeb4cc08388b8fa 19-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Teach the BranchProbabilityInfo analysis pass to read any metadata
encoding of probabilities. In the absense of metadata, it continues to
fall back on static heuristics.

This allows __builtin_expect, after lowering through llvm.expect
a branch instruction's metadata, to actually enter the branch
probability model. This is one component of resolving PR2577.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142492 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
7a34c8b602e52a2cc71a897131ec74b85c86bb43 17-Oct-2011 Chandler Carruth <chandlerc@gmail.com> Delete a dead member. Dunno if this was ever used, but the current code
directly manipulates the weights inside of the BranchProbabilityInfo
that is passed in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142163 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
26eb870d7e0e28ecb25a0cd77e6cdc0490707eff 05-Sep-2011 Benjamin Kramer <benny.kra@googlemail.com> Use canonical forms for the branch probability zero heutistic.

- Drop support for X >u 0, it's equivalent to X != 0 and should be canonicalized into the latter.
- Add X < 1 -> unlikely, which is what instcombine canonicalizes X <= 0 into.
- Add X > -1 -> likely, which is what instcombine canonicalizes X >= 0 into.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139110 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
b137f16936a3f3b5a3463eff6cd433e99ac37cb6 01-Aug-2011 Jakub Staszak <jstaszak@apple.com> Change SmallVector to SmallPtrSet in BranchProbabilityInfo. Handle cases where
one than one successor goes to the same block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136638 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
6762dc1fb38f7579b33143c80f057319e1537678 31-Jul-2011 Jakub Staszak <jstaszak@apple.com> Do not handle cases with >= and <= predicates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136588 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
4faf553d508f4bc657563ca538392108a3858483 31-Jul-2011 Jakub Staszak <jstaszak@apple.com> Remove untrue comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136587 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
a385c20d427d8ec1a91ce8bf34612bf4c87cc34f 31-Jul-2011 Jakub Staszak <jstaszak@apple.com> Do not handle case where LHS is equal to zero, because InstCombiner always moves
it to RHS anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136586 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
a5dd5505883aa90d01d442e3a5db5aedc2277f9e 31-Jul-2011 Jakub Staszak <jstaszak@apple.com> Add Zero Heurestics to BranchProbabilityInfo. If we compare value to zero we
decide whether condition is likely to be true this way:

x == 0 -> false
x < 0 -> false
x <= 0 -> false
x != 0 -> true
x > 0 -> true
x >= 0 -> true


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136583 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
6f6baf1bdd7531da5ddb925ffcfcf38724e9e4aa 29-Jul-2011 Jakub Staszak <jstaszak@apple.com> Add more constantness in BranchProbabilityInfo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136502 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
e0058b4b0c4d162a3b3ff2ad8a87c979928ba016 29-Jul-2011 Jakub Staszak <jstaszak@apple.com> Remove incEdgeWeight and decEdgeWeight. Set edge weight directly to avoid
rounding errors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136456 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
3d8b15ea709ec7fc84e6de191d4eb9858b0b4edf 29-Jul-2011 Jakub Staszak <jstaszak@apple.com> Change LBH_TAKEN_WEIGHT to 124 (from 128). Right now, sum of
LBH_TAKEN_WEIGHT + LBH_NONTAKEN_WEIGHT = 128 which in _most_ cases reduce
number of rounding errors.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136428 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
7241caf7b841db57a21a44f64415e3d1a3398a9c 28-Jul-2011 Jakub Staszak <jstaszak@apple.com> Heuristics are in descending priority now. If we use one of them, skip the rest.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136402 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
fa44725233aa622b61942ec099b1c46806140b72 28-Jul-2011 Jakub Staszak <jstaszak@apple.com> Add InEdges (edges from header to the loop) in Loop Branch Heuristics, so
there is no frequency difference whether condition is in the header or in
the latch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136398 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
12af93ae86cb4a517d1b67f9363fbf21f24f583b 16-Jul-2011 Jakub Staszak <jstaszak@apple.com> Remove "LoopInfo.h" include from BranchProbabilityInfo.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135353 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
d7932ca9627cdd9f913a37ee51f410819aa83cf3 15-Jul-2011 Jakub Staszak <jstaszak@apple.com> Fix pointer heuristic. Check whether predicator is ICMP_NE instead of if it is
not isEquality().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135296 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
66dddd1da3e036d05f94df82221a97b7d26e3498 24-Jun-2011 Jakub Staszak <jstaszak@apple.com> Calculate backedge probability correctly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133776 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
44eb49c2a191108df801977c8e3dc03466c6c02a 23-Jun-2011 Jakub Staszak <jstaszak@apple.com> Introduce BlockFrequency analysis for BasicBlocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133766 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
7cc2b07437a1243c33324549a1904fefc5f1845e 16-Jun-2011 Jakub Staszak <jstaszak@apple.com> Introduce MachineBranchProbabilityInfo class, which has similar API to
BranchProbabilityInfo (expect setEdgeWeight which is not available here).
Branch Weights are kept in MachineBasicBlocks. To turn off this analysis
set -use-mbpi=false.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133184 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
afa88eaf659a6151624fd11a61d038864339e8e4 13-Jun-2011 Benjamin Kramer <benny.kra@googlemail.com> Move class into an anonymous namespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132925 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
f289df2d9544bd3a0934651daa20e589544413ba 11-Jun-2011 Andrew Trick <atrick@apple.com> Branch profiling: floating-point avoidance.

Patch by: Jakub Staszak!

Introduces BranchProbability. Changes unsigned to uint32_t all over and
uint64_t only when overflow is expected.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132867 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
404b53e38ca7a77c6e86596ace68f3167cd33922 04-Jun-2011 Nick Lewycky <nicholas@mxc.ca> Fold assert-only-used variable into the assert.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132620 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
b4528c3d7ee14a42e86ebaa228c556ea81412eca 04-Jun-2011 Andrew Trick <atrick@apple.com> Missing include of climits in the new BranchProbability pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132616 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp
9e76422b963a65f243fdbee0abed61068b82dd98 04-Jun-2011 Andrew Trick <atrick@apple.com> New BranchProbabilityInfo analysis. Patch by Jakub Staszak!

BranchProbabilityInfo provides an interface for IR passes to query the
likelihood that control follows a CFG edge. This patch provides an
initial implementation of static branch predication that will populate
BranchProbabilityInfo for branches with no external profile
information using very simple heuristics. It currently isn't hooked up
to any external profile data, so static prediction does all the work.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132613 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Analysis/BranchProbabilityInfo.cpp