History log of /external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
cddc3e03e4ec99c0268c03a126195173e519ed58 04-Mar-2016 Pirama Arumuga Nainar <pirama@google.com> Update aosp/master LLVM for rebase to r256229

http://b/26987366

(cherry picked from commit f3ef5332fa3f4d5ec72c178a2b19dac363a19383)

Change-Id: Ic75dcb63191d65df1b69724576392c0aaeb47728
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6948897e478cbd66626159776a8017b3c18579b9 01-Jul-2015 Pirama Arumuga Nainar <pirama@google.com> Update aosp/master LLVM for rebase to r239765

Bug: 20140355: This rebase pulls the upstream fix for the spurious
warnings mentioned in the bug.

Change-Id: I7fd24253c50f4d48d900875dcf43ce3f1721a3da
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0c7f116bb6950ef819323d855415b2f2b0aad987 06-May-2015 Pirama Arumuga Nainar <pirama@google.com> Update aosp/master LLVM for rebase to r235153

Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4c5e43da7792f75567b693105cc53e3f1992ad98 08-Apr-2015 Pirama Arumuga Nainar <pirama@google.com> Update aosp/master llvm for rebase to r233350

Change-Id: I07d935f8793ee8ec6b7da003f6483046594bca49
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ebe69fe11e48d322045d5949c83283927a0d790b 23-Mar-2015 Stephen Hines <srhines@google.com> Update aosp/master LLVM for rebase to r230699.

Change-Id: I2b5be30509658cb8266be782de0ab24f9099f9b9
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
37ed9c199ca639565f6ce88105f9e39e898d82d0 01-Dec-2014 Stephen Hines <srhines@google.com> Update aosp/master LLVM for rebase to r222494.

Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c6a4f5e819217e1e12c458aed8e7b122e23a3a58 21-Jul-2014 Stephen Hines <srhines@google.com> Update LLVM for rebase to r212749.

Includes a cherry-pick of:
r212948 - fixes a small issue with atomic calls

Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dce4a407a24b04eebc6a376f8e62b41aaa7b071f 29-May-2014 Stephen Hines <srhines@google.com> Update LLVM for 3.5 rebase (r209712).

Change-Id: I149556c940fb7dc92d075273c87ff584f400941f
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
36b56886974eae4f9c5ebc96befd3e7bfe5de338 24-Apr-2014 Stephen Hines <srhines@google.com> Update to LLVM 3.5a.

Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f3bd3ea3fe1abf414d3a38a684f3df7382a1a8d5 12-Nov-2013 Nadav Rotem <nrotem@apple.com> FoldBranchToCommonDest merges branches into a single branch with or/and of the condition. It has a heuristics for estimating when some of the dependencies are processed by out-of-order processors. This patch adds another rule to the heuristics that says that if the "BonusInstruction" that we speculatively execute is used by the condition of the second branch then it is okay to hoist it. This change exposes more opportunities for other passes to transform the code. It does not matter that much that we if-convert the code because the selectiondag builder splits or/and branches into multiple branches when profitable.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194524 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f681437cb082bf6fb5da43c8acd4e1313ba3b213 12-Nov-2013 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Use existing constant folding logic when forming switch tables.

Both simpler and more powerful than the hand-rolled folding logic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194475 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
30150a128c7b2488225331417153ccec75bac65c 10-Nov-2013 Nadav Rotem <nrotem@apple.com> SimplifyCFG has a heuristics for out-of-order processors that decides when it is worthwhile to merge branches. It tries to estimate if the operands of the instruction that we want to hoist are ready. This commit marks function arguments as 'ready' because they require no calculation. This boosts libquantum and a few other workloads from the testsuite.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194346 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f2089e1dd810236f716c1a45fa1e561dce5074e8 21-Oct-2013 Tom Stellard <thomas.stellard@amd.com> SimplifyCFG: Don't duplicate calls to functions marked noduplicate v2

v2:
- Use CI->cannotDuplicate()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193115 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
79de3d7b3aae9c7cc1038a3223dc96dbdafbeb3f 21-Oct-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Teach SimplifyCFG about address spaces

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193104 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6701bb7283747b00bc814b1db784fdbbe03644a1 21-Oct-2013 Michael Gottesman <mgottesman@apple.com> Fix the predecessor removal logic in r193045.

Additionally some small comment/stylistic fixes are included as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193068 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0b5fad68b296087b4d0132dcd19690d2cdce2c77 20-Oct-2013 Michael Gottesman <mgottesman@apple.com> Teach simplify-cfg how to correctly create covered lookup tables for switches on iN with N >= 3.

One optimization simplify-cfg performs is the converting of switches to
lookup tables if the switch has > 4 cases. This is done by:

1. Finding the max/min case value and calculating the switch case range.
2. Create a lookup table basic block.
3. Perform a check in the switch's BB to see if the input value is in
the switch's case range. If the input value satisfies said predicate
branch to the lookup table BB, otherwise branch to the switch's default
destination BB using the default value as the result.

The conditional check consists of subtracting the min case value of the
table from any input iN value and then ensuring that said value is
unsigned less than the size of the lookup table represented as an iN
value.

If the lookup table is a covered lookup table, the size of the table will be N
which is 0 as an iN value. Thus the comparison will be an `icmp ult` of an iN
value against 0 which is always false yielding the incorrect result.

This patch fixes this problem by recognizing if we have a covered lookup table
and if we do, unconditionally jumps to the lookup table BB since the covering
property of the lookup table implies no input values could not be handled by
said BB.

rdar://15268442

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193045 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0d293e45b66c742fdbc3998209bb20ed6c5806bf 22-Sep-2013 Benjamin Kramer <benny.kra@googlemail.com> Provide basic type safety for array_pod_sort comparators.

This makes using array_pod_sort significantly safer. The implementation relies
on function pointer casting but that should be safe as we're dealing with void*
here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191175 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4598bd53ab89c3d120ad8249abbfdc7e2d64d291 06-Sep-2013 Matt Arsenault <Matthew.Arsenault@amd.com> Use type helper functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190113 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
01d7203ef8316fdd71c3cec59f8e68fb869e0dbf 06-Aug-2013 Tom Stellard <thomas.stellard@amd.com> Factor FlattenCFG out from SimplifyCFG

Patch by: Mei Ye

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187764 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e393b738081104c86d34e4e70e8302474a19a45b 02-Aug-2013 Alexey Samsonov <samsonov@google.com> Fix dereferencing end iterator in SimplifyCFG. Patch by Ye Mei.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187646 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
15658b290817d6f198ab08910a2d754ba11164d1 29-Jul-2013 Rafael Espindola <rafael.espindola@gmail.com> Fix -Wdocumentation warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187336 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
57e6b2d1f3de0bf459e96f7038e692d624f7e580 27-Jul-2013 Tom Stellard <thomas.stellard@amd.com> SimplifyCFG: Use parallel-and and parallel-or mode to consolidate branch conditions

Merge consecutive if-regions if they contain identical statements.
Both transformations reduce number of branches. The transformation
is guarded by a target-hook, and is currently enabled only for +R600,
but the correctness has been tested on X86 target using a variety of
CPU benchmarks.

Patch by: Mei Ye

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187278 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a0ec3f9b7b826b9b40b80199923b664bad808cce 14-Jul-2013 Craig Topper <craig.topper@gmail.com> Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186274 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
32d15d90c41c79b0f343c928b1a2d4aa2d4142ef 04-Jul-2013 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Teach switch generation some patterns that instcombine forms.

This allows us to create switches even if instcombine has munged two of the
incombing compares into one and some bit twiddling. This was motivated by enum
compares that are common in clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185632 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
babae05237cb1914be0b2a25c56754ccc92084ee 04-Jun-2013 Rafael Espindola <rafael.espindola@gmail.com> Second part of pr16069

The problem this time seems to be a thinko. We were assuming that in the CFG

A
| \
| B
| /
C

speculating the basic block B would cause only the phi value for the B->C edge
to be speculated. That is not true, the phi's are semantically in the edges, so
if the A->B->C path is taken, any code needed for A->C is not executed and we
have to consider it too when deciding to speculate B.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183226 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
deb2e9c42f23b25dcbffa0a34b15c5d1b15f26a5 04-Jun-2013 Hans Wennborg <hans@hanshq.net> Typo: s/caes/cases/ in SimplifyCFG

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183219 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3931bdb788774e33dd623d6b9142ae69542c33aa 03-Jun-2013 David Majnemer <david.majnemer@gmail.com> SimplifyCFG: Do not transform PHI to select if doing so would be unsafe

PR16069 is an interesting case where an incoming value to a PHI is a
trap value while also being a 'ConstantExpr'.

We do not consider this case when performing the 'HoistThenElseCodeToIf'
optimization.

Instead, make our modifications more conservative if we detect that we
cannot transform the PHI to a select.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
404fa7257fae8e4252cd4d01017e97ab6062ab27 03-Jun-2013 David Majnemer <david.majnemer@gmail.com> SimplifyCFG: Small cleanup, use ICmpInst::isEquality()


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183151 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f7dad7833c6dc64e39dd5d4c633da4923478655a 01-Jun-2013 David Majnemer <david.majnemer@gmail.com> SimplifyCFG: Fix typo in comment for ComputeSpeculationCost


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183078 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
603100d3de4ba34bf5a7274acf7942083a1e2641 23-May-2013 Benjamin Kramer <benny.kra@googlemail.com> More symbols that should be static.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182590 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8228ffe72d726978d0265c3c407172f1b9851502 29-Apr-2013 Arnold Schwaighofer <aschwaighofer@apple.com> SimplifyCFG: If convert single conditional stores

This resurrects r179957, but adds code that makes sure we don't touch
atomic/volatile stores:

This transformation will transform a conditional store with a preceeding
uncondtional store to the same location:

a[i] =
may-alias with a[i] load
if (cond)
a[i] = Y

into an unconditional store.

a[i] = X
may-alias with a[i] load
tmp = cond ? Y : X;
a[i] = tmp

We assume that on average the cost of a mispredicted branch is going to be
higher than the cost of a second store to the same location, and that the
secondary benefits of creating a bigger basic block for other optimizations to
work on outway the potential case where the branch would be correctly predicted
and the cost of the executing the second store would be noticably reflected in
performance.

hmmer's execution time improves by 30% on an imac12,2 on ref data sets. With
this change we are on par with gcc's performance (gcc also performs this
transformation). There was a 1.2 % performance improvement on a ARM swift chip.
Other tests in the test-suite+external seem to be mostly uninfluenced in my
experiments:
This optimization was triggered on 41 tests such that the executable was
different before/after the patch. Only 1 out of the 40 tests (dealII) was
reproducable below 100% (by about .4%). Given that hmmer benefits so much I
believe this to be a fair trade off.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180731 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
54d9a3e2df7055bd4d31a18b29f37c4541653efc 21-Apr-2013 Arnold Schwaighofer <aschwaighofer@apple.com> Revert "SimplifyCFG: If convert single conditional stores"

There is the temptation to make this tranform dependent on target information as
it is not going to be beneficial on all (sub)targets. Therefore, we should
probably do this in MI Early-Ifconversion.

This reverts commit r179957. Original commit message:

"SimplifyCFG: If convert single conditional stores

This transformation will transform a conditional store with a preceeding
uncondtional store to the same location:

a[i] =
may-alias with a[i] load
if (cond)
a[i] = Y
into an unconditional store.

a[i] = X
may-alias with a[i] load
tmp = cond ? Y : X;
a[i] = tmp

We assume that on average the cost of a mispredicted branch is going to be
higher than the cost of a second store to the same location, and that the
secondary benefits of creating a bigger basic block for other optimizations to
work on outway the potential case were the branch would be correctly predicted
and the cost of the executing the second store would be noticably reflected in
performance.

hmmer's execution time improves by 30% on an imac12,2 on ref data sets. With
this change we are on par with gcc's performance (gcc also performs this
transformation). There was a 1.2 % performance improvement on a ARM swift chip.
Other tests in the test-suite+external seem to be mostly uninfluenced in my
experiments:
This optimization was triggered on 41 tests such that the executable was
different before/after the patch. Only 1 out of the 40 tests (dealII) was
reproducable below 100% (by about .4%). Given that hmmer benefits so much I
believe this to be a fair trade off.

I am going to watch performance numbers across the builtbots and will revert
this if anything unexpected comes up."

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179980 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f7af1987ddcec768d8608d608ce187115510b21d 20-Apr-2013 Arnold Schwaighofer <aschwaighofer@apple.com> SimplifyCFG: If convert single conditional stores

This transformation will transform a conditional store with a preceeding
uncondtional store to the same location:

a[i] =
may-alias with a[i] load
if (cond)
a[i] = Y

into an unconditional store.

a[i] = X
may-alias with a[i] load
tmp = cond ? Y : X;
a[i] = tmp

We assume that on average the cost of a mispredicted branch is going to be
higher than the cost of a second store to the same location, and that the
secondary benefits of creating a bigger basic block for other optimizations to
work on outway the potential case were the branch would be correctly predicted
and the cost of the executing the second store would be noticably reflected in
performance.

hmmer's execution time improves by 30% on an imac12,2 on ref data sets. With
this change we are on par with gcc's performance (gcc also performs this
transformation). There was a 1.2 % performance improvement on a ARM swift chip.
Other tests in the test-suite+external seem to be mostly uninfluenced in my
experiments:
This optimization was triggered on 41 tests such that the executable was
different before/after the patch. Only 1 out of the 40 tests (dealII) was
reproducable below 100% (by about .4%). Given that hmmer benefits so much I
believe this to be a fair trade off.

I am going to watch performance numbers across the builtbots and will revert
this if anything unexpected comes up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179957 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a121e24c541097b51309a06297005ac257b6728f 16-Apr-2013 Hans Wennborg <hans@hanshq.net> simplifycfg: Fix integer overflow converting switch into icmp.

If a switch instruction has a case for every possible value of its type,
with the same successor, SimplifyCFG would replace it with an icmp ult,
but the computation of the bound overflows in that case, which inverts
the test.

Patch by Jed Davis!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179587 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d5bb20805e03cff03bfa3f85f189cbc8fb4a769a 11-Mar-2013 Bill Wendling <isanbard@gmail.com> Don't remove a landing pad if the invoke requires a table entry.

An invoke may require a table entry. For instance, when the function it calls
is expected to throw.
<rdar://problem/13360379>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176827 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
119003f2a22ee7c4f78fed5710f98edb36b237b5 07-Mar-2013 Andrew Trick <atrick@apple.com> SimplifyCFG fix for volatile load/store.

Fixes rdar:13349374.

Volatile loads and stores need to be preserved even if the language
standard says they are undefined. "volatile" in this context means "get
out of the way compiler, let my platform handle it".

Additionally, this is the only way I know of with llvm to write to the
first page (when hardware allows) without dropping to assembly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176599 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
455151e4f7b6dc264183ecc892a2f9678ff5fe46 27-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Re-revert r173342, without losing the compile time improvements, flat
out bug fixes, or functionality preserving refactorings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173610 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
baf868b9b8d187744d183d57ef3cbb2a44ca047a 25-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Switch this code away from Value::isUsedInBasicBlock. That code either
loops over instructions in the basic block or the use-def list of the
value, neither of which are really efficient when repeatedly querying
about values in the same basic block.

What's more, we already know that the CondBB is small, and so we can do
a much more efficient test by counting the uses in CondBB, and seeing if
those account for all of the uses.

Finally, we shouldn't blanket fail on any such instruction, instead we
should conservatively assume that those instructions are part of the
cost.

Note that this actually fixes a bug in the pass because
isUsedInBasicBlock has a really terrible bug in it. I'll fix that in my
next commit, but the fix for it would make this code suddenly take the
compile time hit I thought it already was taking, so I wanted to go
ahead and migrate this code to a faster & better pattern.

The bug in isUsedInBasicBlock was also causing other tests to test the
wrong thing entirely: for example we weren't actually disabling
speculation for floating point operations as intended (and tested), but
the test passed because we failed to speculate them due to the
isUsedInBasicBlock failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173417 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d5a80c7358d01cde9e166bebc8a3ffa0eca3aa54 24-Jan-2013 Benjamin Kramer <benny.kra@googlemail.com> Reapply chandlerc's r173342 now that the miscompile it was triggering is fixed.

Original commit message:
Plug TTI into the speculation logic, giving it a real cost interface
that can be specialized by targets.

The goal here is not to be more aggressive, but to just be more accurate
with very obvious cases. There are instructions which are known to be
truly free and which were not being modeled as such in this code -- see
the regression test which is distilled from an inner loop of zlib.

Everywhere the TTI cost model is insufficiently conservative I've added
explicit checks with FIXME comments to go add proper modelling of these
cost factors.

If this causes regressions, the likely solution is to make TTI even more
conservative in its cost estimates, but test cases will help here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173357 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
eacef325c6412820a377fe4f853eb9c7c23db9ee 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Revert r173342 temporarily. It appears to cause a very late miscompile
of stage2 in a bootstrap. Still investigating....

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173343 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1f255419d424c85bc5dbb77f530561d46e5197cc 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Plug TTI into the speculation logic, giving it a real cost interface
that can be specialized by targets.

The goal here is not to be more aggressive, but to just be more accurate
with very obvious cases. There are instructions which are known to be
truly free and which were not being modeled as such in this code -- see
the regression test which is distilled from an inner loop of zlib.

Everywhere the TTI cost model is insufficiently conservative I've added
explicit checks with FIXME comments to go add proper modelling of these
cost factors.

If this causes regressions, the likely solution is to make TTI even more
conservative in its cost estimates, but test cases will help here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173342 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
47d8f6dca5a64f642a82d24b9e3cf882b56c5c3e 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Address a large chunk of this FIXME by accumulating the cost for
unfolded constant expressions rather than checking each one
independently.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173341 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
681add7a63b44249fd0fd38e63f10f18d6e99e38 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Switch the constant expression speculation cost evaluation away from
a cost fuction that seems both a bit ad-hoc and also poorly suited to
evaluating constant expressions.

Notably, it is missing any support for trivial expressions such as
'inttoptr'. I could fix this routine, but it isn't clear to me all of
the constraints its other users are operating under.

The core protection that seems relevant here is avoiding the formation
of a select instruction wich a further chain of select operations in
a constant expression operand. Just explicitly encode that constraint.

Also, update the comments and organization here to make it clear where
this needs to go -- this should be driven off of real cost measurements
which take into account the number of constants expressions and the
depth of the constant expression tree.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173340 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2c107a80206056cdc8c2c7cb715ff9e1db64add9 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Rephrase the speculating scan of the conditional BB to be phrased in
terms of cost rather than hoisting a single instruction.

This does *not* change the cost model! We still set the cost threshold
at 1 here, it's just that we track it by accumulating cost rather than
by storing an instruction.

The primary advantage is that we no longer leave no-op intrinsics in the
basic block. For example, this will now move both debug info intrinsics
and a single instruction, instead of only moving the instruction and
leaving a basic block with nothing bug debug info intrinsics in it, and
those intrinsics now no longer ordered correctly with the hoisted value.

Instead, we now splice the entire conditional basic block's instruction
sequence.

This also places the code for checking the safety of hoisting next to
the code computing the cost.

Currently, the only observable side-effect of this change is that debug
info intrinsics are no longer abandoned. I'm not sure how to craft
a test case for this, and my real goal was the refactoring, but I'll
talk to Dave or Eric about how to add a test case for this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173339 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0afa33115c5f0bce263ef370886f53bc845ab7c1 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Simplify the PHI node operand rewriting.

Previously, the code would scan the PHI nodes and build up a small
setvector of candidate value pairs in phi nodes to go and rewrite. Once
certain the rewrite could be performed, the code walks the set, and for
each one re-scans the entire PHI node list looking for nodes to rewrite
operands.

Instead, scan the PHI nodes once to check for hazards, and then scan it
a second time to rewrite the operands to selects. No set vector, and
a max of two scans.

The only downside is that we might form identical selects, but
instcombine or anything else should fold those easily, and it seems
unlikely to happen often.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173337 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6cf7a91d12fe208a41223daa4aa9c603c390e0ce 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Give the basic block variables here names based on the if-then-end
structure being analyzed. No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173334 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9e620952617b90992e50dcf9bca8078c535cbaef 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Lift a cheap early exit test above loops and other complex early exit
tests. No need to pay the high cost when we're never going to do
anything.

No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173331 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c61bc7a90c65bf220a113f31ea26f45e0f4c1413 24-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Spiff up the comment on this method, making the example a bit more
pretty in doxygen, adding some of the details actually present in
a classic example where this matters (a loop from gzip and many other
compression algorithms), and a cautionary note about the risks inherent
in the transform. This has come up on the mailing lists recently, and
I suspect folks reading this code could benefit from going and looking
at the MI pass that can really deal with these issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173329 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
70465616c29538e21e4dc3e0a70d8edb4b93bf5f 23-Jan-2013 Duncan Sands <baldrick@free.fr> Initialize the components of this class. Otherwise GCC thinks that Array may be
used uninitialized, since it fails to understand that Array is only used when
SingleValue is not, and outputs a warning. It also seems generally safer given
that the constructor is non-trivial and has plenty of early exits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173242 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5f46c3c2e8d13c6ac8d3863d84e887f84c73f27a 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Make SimplifyCFG simply depend upon TargetTransformInfo and pass it
through as a reference rather than a pointer. There is always *some*
implementation of this available, so this simplifies code by not having
to test for whether it is available or not.

Further, it turns out there were piles of places where SimplifyCFG was
recursing and not passing down either TD or TTI. These are fixed to be
more pedantically consistent even though I don't have any particular
cases where it would matter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171691 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
be04929f7fd76a921540e9901f24563e51dc1219 07-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move TargetTransformInfo to live under the Analysis library. This no
longer would violate any dependency layering and it is in fact an
analysis. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171686 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b8f6cb7c49e26122cdea2270de57449aa52f389f 05-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Switch SimplifyCFG over to the TargetTransformInfo interface rather than
the ScalarTargetTransformInfo interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171617 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0b8c9a80f20772c3793201ab5b251d3520b9cea3 02-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d04a8d4b33ff316ca4cf961e06c9e312eff8e64f 03-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Use the new script to sort the includes of every file under lib.

Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
66ea2f99867ffc8606737199e359516fd1cfc67c 30-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Fix non-determinism introduced in r168970 and pointed out by Duncan.

We're iterating over a non-deterministically ordered container looking
for two saturating flags. To do this correctly, we have to saturate
both, and only stop looping if both saturate to their final value.
Otherwise, which flag we see first changes the result.

This is also a micro-optimization of the previous version as now we
don't go into the (possibly expensive) test logic once the first
violation of either constraint is detected.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168989 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
06ec7211c17a4b45a943c36e0fb3d6715aa2453d 30-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Rearrange the comments, control flow, and variable names; no
functionality changed.

Evan's commit r168970 moved the code that the primary comment in this
function referred to to the other end of the function without moving the
comment, and there has been a steady creep of "boolean" logic in it that
is simpler if handled via early exit. That way each special case can
have its own comments. I've also made the variable name a bit more
explanatory than "AllFit". This is in preparation to fix the
non-deterministic output of this function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168988 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
40eef5fe361d8c528f764f66e311359d0da4d5b2 30-Nov-2012 Evan Cheng <evan.cheng@apple.com> Fix logic to determine whether to turn a switch into a lookup table. When
the tables cannot fit in registers (i.e. bitmap), do not emit the table
if it's using an illegal type.

rdar://12779436


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168970 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6eac2ba4de0b293a627e20f5ef44d696f410b9dc 16-Nov-2012 Hans Wennborg <hans@hanshq.net> SimplifyCFG: Don't assume non-null ScalarTargetTransformInfo.

Patch by Pekka Jääskeläinen!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168176 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c2aa0035a6c0bd69e4f46620a270451fe585f8cd 15-Nov-2012 Andrew Trick <atrick@apple.com> misspell

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168058 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
df523d456c3e691f1b5cf0bfb74bd4baedd88009 15-Nov-2012 Andrew Trick <atrick@apple.com> whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168057 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b0319962cfdb18da38ef47da621f148fe144b092 07-Nov-2012 Hans Wennborg <hans@hanshq.net> Only do switch-to-lookup table transformation when TargetTransformInfo
is available.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167552 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ece6c6bb6329748b92403c06ac87f45c43485911 01-Nov-2012 Chandler Carruth <chandlerc@gmail.com> Revert the series of commits starting with r166578 which introduced the
getIntPtrType support for multiple address spaces via a pointer type,
and also introduced a crasher bug in the constant folder reported in
PR14233.

These commits also contained several problems that should really be
addressed before they are re-committed. I have avoided reverting various
cleanups to the DataLayout APIs that are reasonable to have moving
forward in order to reduce the amount of churn, and minimize the number
of commits that were reverted. I've also manually updated merge
conflicts and manually arranged for the getIntPtrType function to stay
in DataLayout and to be defined in a plausible way after this revert.

Thanks to Duncan for working through this exact strategy with me, and
Nick Lewycky for tracking down the really annoying crasher this
triggered. (Test case to follow in its own commit.)

After discussing with Duncan extensively, and based on a note from
Micah, I'm going to continue to back out some more of the more
problematic patches in this series in order to ensure we go into the
LLVM 3.2 branch with a reasonable story here. I'll send a note to
llvmdev explaining what's going on and why.

Summary of reverted revisions:

r166634: Fix a compiler warning with an unused variable.
r166607: Add some cleanup to the DataLayout changes requested by
Chandler.
r166596: Revert "Back out r166591, not sure why this made it through
since I cancelled the command. Bleh, sorry about this!
r166591: Delete a directory that wasn't supposed to be checked in yet.
r166578: Add in support for getIntPtrType to get the pointer type based
on the address space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
eb3e089fb686e506647a4d8cfdc1d51869489801 31-Oct-2012 Hans Wennborg <hans@hanshq.net> Remove fixme about unreachable cases from SwitchToLookupTable

SimplifyCFG will have removed those cases for us.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167132 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
daf4cfc8d890c7f17241ff7127b64c13ed2cb4d4 31-Oct-2012 Hans Wennborg <hans@hanshq.net> Address Duncan's comments on r167121.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167130 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ef026f1b5e4d52e11c67a1a5ad01eadffcfa4d8e 31-Oct-2012 Hans Wennborg <hans@hanshq.net> Address Duncan's comments on r167115

- Use 0 instead of NULL
- Helper function for "dyn_cast, else lookup in the constant pool".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167121 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
28578661385dc165ffe5171f2b9dad26f0a13cf9 31-Oct-2012 Hans Wennborg <hans@hanshq.net> Fix false -> NULL conversion from r167115 spotted by Benjamin Kramer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167117 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e03d9e4ec7037526b94ce91985e7ff82ebc069fa 31-Oct-2012 Hans Wennborg <hans@hanshq.net> Do simple constant propagation in lookup table formation for switches

By propagating the value for the switch condition, LLVM can now build
lookup tables for code such as:

switch (x) {
case 1: return 5;
case 2: return 42;
case 3: case 4: case 5:
return x - 123;
default:
return 123;
}

Given that x is known for each case, "x - 123" becomes a constant for
cases 3, 4, and 5.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167115 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
04d7d13d301df66f6c232e41611145c062183bf3 30-Oct-2012 Hans Wennborg <hans@hanshq.net> Use TargetTransformInfo to control switch-to-lookup table transformation

When the switch-to-lookup tables transform landed in SimplifyCFG, it
was pointed out that this could be inappropriate for some targets.
Since there was no way at the time for the pass to know anything about
the target, an awkward reverse-transform was added in CodeGenPrepare
that turned lookup tables back into switches for some targets.

This patch uses the new TargetTransformInfo to determine if a
switch should be transformed, and removes
CodeGenPrepare::ConvertLoadToSwitch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7ed4f94c1337b931524af99eb1aac72563888239 29-Oct-2012 Duncan Sands <baldrick@free.fr> Remove a wrapper around getIntPtrType added to GVN by Hal in commit 166624 (the
wrapper returns a vector of integers when passed a vector of pointers) by having
getIntPtrType itself return a vector of integers in this case. Outside of this
wrapper, I didn't find anywhere in the codebase that was relying on the old
behaviour for vectors of pointers, so give this a whirl through the buildbots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166939 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e5a7a68dfabcf10cf5a6409fd1e4020f69564c2e 25-Oct-2012 Jakob Stoklund Olesen <stoklund@2pi.dk> Also optimize large switch statements.

The isValueEqualityComparison() guard at the top of SimplifySwitch()
only applies to some of the possible transformations.

The newer transformations work just fine on large switches, and the
check on predecessor count is nonsensical.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166710 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
aa76e9e2cf50af190de90bc778b7f7e42ef9ceff 24-Oct-2012 Micah Villmow <villmow@gmail.com> Add in support for getIntPtrType to get the pointer type based on the address space.
This checkin also adds in some tests that utilize these paths and updates some of the
clients.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8e13dedd418b06212369cf03a4131ae694a21f3f 14-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> Simplify code. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165904 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d61d1eb165244f62bfd21cdf79e06bc6579950b4 12-Oct-2012 Manman Ren <mren@apple.com> PGO: create metadata for switch only if it has more than one targets.

When all cases of a switch statement are dead, the weights vector only has one
element, and we will get an ssertion failure when calling createBranchWeights.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165759 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3574eca1b02600bac4e625297f4ecf745f4c4f32 08-Oct-2012 Micah Villmow <villmow@gmail.com> Move TargetData to DataLayout.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1e21db6e831923bb35d2c5e22b50ad198de49a61 04-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Enhance the "remove CFG edge that leads to null pointer dereference" optimization to also handle instructions with multiple uses.

We conservatively only check the first use to avoid walking long use chains.
This catches the common case of having both a load and a store to a pointer
supplied by a PHI node.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165232 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
64f27e78c4af3b69930b1d05b13b80cb025f4079 01-Oct-2012 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Don't crash when forming a switch bitmap with an undef default value.

Fixes PR13985.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164934 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
fdb96062b238aa0d751602c916c87f1e13bc59e6 30-Sep-2012 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Enumerating all predecessors of a BB can be expensive (switches), avoid it if possible.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164923 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
465251a7ce52161adbcb6e80cb84f135dd440de9 27-Sep-2012 Benjamin Kramer <benny.kra@googlemail.com> Fix a integer overflow in SimplifyCFG's look up table formation logic.

If the width is very large it gets truncated from uint64_t to uint32_t when
passed to TD->fitsInLegalInteger. The truncated value can fit in a register.
This manifested in massive memory usage or crashes (PR13946).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164784 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
50b7d70707960155ad28ff23d7622009b7b97eb3 26-Sep-2012 Hans Wennborg <hans@hanshq.net> Address Duncan's comments on r164684:

- Put statistics in alphabetical order
- Don't use getZextValue when building TableInt, just use APInts
- Introduce Create{Z,S}ExtOrTrunc in IRBuilder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164696 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
565df79b74126e1f2a2be8e2c55c5bb506270f26 26-Sep-2012 Hans Wennborg <hans@hanshq.net> Address Duncan's comments on r164682:

- Finish assert messages with exclamation mark
- Move overflow checking into ShouldBuildLookupTable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164692 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d72271cd84ab2a0d3855a95719341b036980d5ac 26-Sep-2012 Hans Wennborg <hans@hanshq.net> SimplifyCFG: Make the switch-to-lookup table transformation store the
tables in bitmaps when they fit in a target-legal register.

This saves some space, and it also allows for building tables that would
otherwise be deemed too sparse.

One interesting case that this hits is example 7 from
http://blog.regehr.org/archives/320. We currently generate good code
for this when lowering the switch to the selection DAG: we build a
bitmask to decide whether to jump to one block or the other. My patch
will result in the same bitmask, but it removes the need for the jump,
as the return value can just be retrieved from the mask.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164684 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
db5dbf013cc16aeb2d05ac9223e84a9412c3e278 26-Sep-2012 Hans Wennborg <hans@hanshq.net> SimplifyCFG: Refactor the switch-to-lookup table transformation by
breaking out the building of lookup tables into a separate class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164682 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
554da1a222eaeea71636700ca2b7dd931e81ade6 21-Sep-2012 Manman Ren <mren@apple.com> SimplifyCFG: sink common codes from IF, ELSE blocks down to END block.

We already have HoistThenElseCodeToIf, this patch implements
SinkThenElseCodeToEnd. When END block has only two predecessors and each
predecessor terminates with unconditional branches, we compare instructions in
IF and ELSE blocks backwards and check whether we can sink the common
instructions down.

rdar://12191395


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164325 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
57933e3481cd5bb042415452d39d0d7f4e62d644 19-Sep-2012 Hans Wennborg <hans@hanshq.net> SimplifyCFG: Don't generate invalid code for switch used to initialize
two variables where the first variable is returned and the second
ignored.

I don't think this occurs in practice (other passes should have cleaned
up the unused phi node), but it should still be handled correctly.

Also make the logic for determining if we should return early less
sketchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164225 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
222d6192adeba434d64893de920bd72c36f7e8c8 18-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when simplifying Switch to a sub, an icmp
and a conditional branch; also when removing dead cases from a switch.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164084 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b010277b599a6298b079d5ba2750df25c20c0b9d 18-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when simplifying Switch

Hanlde the case when we split the default edge if the default target has "icmp"
and unconditinal branch.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164076 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b11cbe6b2360cd46e12d676064e8f58a0586c9ba 18-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when simplifying SwitchOnSelect.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164068 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
566540332f6fe59e6424dd0d9a06a29e6f19f790 17-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when simplifying two branches with a common
destination in SimplifyCondBranchToCondBranch.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164054 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3780ad8b998d93d7db406919c06137cdb786ef05 17-Sep-2012 Axel Naumann <Axel.Naumann@cern.ch> Fix a few vars that can end up being used without initialization.
The cases where no initialization happens should still be checked for logic flaws.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164032 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
062986c2f0a020c0652010e3c8549653397048f4 15-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when simplifying two branches with a common
destination.

Updated previous implementation to fix a case not covered:
// PBI: br i1 %x, TrueDest, BB
// BI: br i1 %y, TrueDest, FalseDest
The other case was handled correctly.
// PBI: br i1 %x, BB, FalseDest
// BI: br i1 %y, TrueDest, FalseDest

Also tried to use 64-bit arithmetic instead of APInt with scale to simplify the
computation. Let me know if you have other opinions about this.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163954 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ad2890760f9661fb6a3dfa3ca863a87f6aea4139 14-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when simplifying a switch with a single
case to a conditional branch and when removing dead cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163942 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
796d945d54f9fe9dd55da2bfa23cbcaabcbc6dc1 14-Sep-2012 Manman Ren <mren@apple.com> Try to fix the bots by detecting inconsistant branch-weight metadata.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163926 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a8a2b99aec8fb2e9cb5c5433a59d836e290e4b84 14-Sep-2012 Manman Ren <mren@apple.com> PGO: preserve branch-weight metadata when merging two switches where
the default target of the first switch is not the basic block the second switch
is in (PredDefault != BB).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163916 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
020aba0c3b6092e353e133446cb6453f95f0d61b 11-Sep-2012 Manman Ren <mren@apple.com> SimplifyCFG: preserve branch-weight metadata when creating a new switch from
a pair of switch/branch where both depend on the value of the same variable and
the default case of the first switch/branch goes to the second switch/branch.

Code clean up and fixed a few issues:
1> handling the case where some cases of the 2nd switch are invalidated
2> correctly calculate the weight for the 2nd switch when it is a conditional eq

Testing case is modified from Alastair's original patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163635 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2f9fc761d22fb62d63d5f74a826890d2ec7c72f2 10-Sep-2012 Hans Wennborg <hans@hanshq.net> Fix style issues from r163302 pointed out by Evan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163491 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a34434184915cf869e2daf26a9d15483b7981aaa 08-Sep-2012 Andrew Trick <atrick@apple.com> Remove an incorrect assert during branch weight propagation.

Patch and test case by Alastair Murray!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163437 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bf01582165a9cf8e95a21a284930a82c3fc3bda5 07-Sep-2012 Hans Wennborg <hans@hanshq.net> SimplifyCFG: ValidLookupTableConstant should be static

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163378 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3bd51b8df3212f765e6ffee06e32b9a670f9b16c 06-Sep-2012 Hans Wennborg <hans@hanshq.net> Fix switch_to_lookup_table.ll test from r163302.

The lookup tables did not get built in a deterministic order.
This makes them get built in the order that the corresponding phi nodes
were found.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163305 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
486270aee6ffd2a0c3c2333a8a0091c29f037aae 06-Sep-2012 Hans Wennborg <hans@hanshq.net> Build lookup tables for switches (PR884)

This adds a transformation to SimplifyCFG that attemps to turn switch
instructions into loads from lookup tables. It works on switches that
are only used to initialize one or more phi nodes in a common successor
basic block, for example:

int f(int x) {
switch (x) {
case 0: return 5;
case 1: return 4;
case 2: return -2;
case 5: return 7;
case 6: return 9;
default: return 42;
}

This speeds up the code by removing the hard-to-predict jump, and
reduces code size by removing the code for the jump targets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163302 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
59324297650c12a8dccf1a7ad650a9e895fdc17e 06-Sep-2012 Roman Divacky <rdivacky@freebsd.org> Stop casting away const qualifier needlessly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163258 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
749807852bd927dd225a360e9a388e0cc2792036 30-Aug-2012 Michael Ilseman <milseman@apple.com> test

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162914 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b1b97833aeaf8a7ef6dd3b314a502a1521b02657 29-Aug-2012 Andrew Trick <atrick@apple.com> Preserve branch profile metadata during switch formation.

Patch by Michael Ilseman!
This fixes SimplifyCFGOpt::FoldValueComparisonIntoPredecessors to preserve metata when folding conditional branches into switches.

void foo(int x) {
if (x == 0)
bar(1);
else if (__builtin_expect(x == 10, 1))
bar(2);
else if (x == 20)
bar(3);
}

CFG:

B0
| \
| X0
B10
| \
| X10
B20
| \
E X20

Merge B0-B10:
w(B0-X0) = w(B0-X0)*sum-weights(B10) = w(B0-X0) * (w(B10-X10) + w(B10-B20))
w(B0-X10) = w(B0-B10) * w(B10-X10)
w(B0-B20) = w(B0-B10) * w(B10-B20)

B0 __
| \ \
| X10 X0
B20
| \
E X20

Merge B0-B20:
w(B0-X0) = w(B0-X0) * sum-weights(B20) = w(B0-X0) * (w(B20-E) + w(B20-X20))
w(B0-X10) = w(B0-X10) * sum-weights(B20) = ...
w(B0-X20) = w(B0-B20) * w(B20-X20)
w(B0-E) = w(B0-B20) * w(B20-E)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162868 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6b01438decfc1e2efa642bb80a546c534675c894 29-Aug-2012 Andrew Trick <atrick@apple.com> whitespace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162867 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c8e41c591741b3da1077f7000274ad040bef8002 23-Jul-2012 Sylvestre Ledru <sylvestre@debian.org> Fix a typo (the the => the)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160621 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0baa4809a8de135a6a7abe9cd78a86f208c99164 16-Jul-2012 Chandler Carruth <chandlerc@gmail.com> Move llvm/Support/MDBuilder.h to llvm/MDBuilder.h, to live with
IRBuilder, DIBuilder, etc.

This is the proper layering as MDBuilder can't be used (or implemented)
without the Core Metadata representation.

Patches to Clang and Dragonegg coming up.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160237 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
23d3622e7647a2836e05bffeb24d3d9235a25f24 13-Jul-2012 Benjamin Kramer <benny.kra@googlemail.com> Make helper functions static.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160173 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c723eb1aef817d47feec620933ee1ec6005cdd14 03-Jul-2012 Eric Christopher <echristo@apple.com> Revert "IntRange:" as it appears to be breaking self hosting.

This reverts commit b2833d9dcba88c6f0520cad760619200adc0442c.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159618 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b2833d9dcba88c6f0520cad760619200adc0442c 02-Jul-2012 Stepan Dyatkovskiy <stpworld@narod.ru> IntRange:
- Changed isSingleNumber method behaviour. Now this flag is calculated on demand.
IntegersSubsetMapping
- Optimized diff operation.
- Replaced type of Items field from std::list with std::map.
- Added new methods:
bool isOverlapped(self &RHS)
void add(self& RHS, SuccessorClass *S)
void detachCase(self& NewMapping, SuccessorClass *Succ)
void removeCase(SuccessorClass *Succ)
SuccessorClass *findSuccessor(const IntTy& Val)
const IntTy* getCaseSingleNumber(SuccessorClass *Succ)
IntegersSubsetTest
- DiffTest: Added checks for successors.
SimplifyCFG
Updated SwitchInst usage (now it is case-ragnes compatible) for
- SimplifyEqualityComparisonWithOnlyPredecessor
- FoldValueComparisonIntoPredecessors



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159527 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
06cb8ed00696eb14d1b831921452e50ec0568ea2 29-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Move llvm/Support/IRBuilder.h -> llvm/IRBuilder.h

This was always part of the VMCore library out of necessity -- it deals
entirely in the IR. The .cpp file in fact was already part of the VMCore
library. This is just a mechanical move.

I've tried to go through and re-apply the coding standard's preferred
header sort, but at 40-ish files, I may have gotten some wrong. Please
let me know if so.

I'll be committing the corresponding updates to Clang and Polly, and
Duncan has DragonEgg.

Thanks to Bill and Eric for giving the green light for this bit of cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159421 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
edb5842b7cf53ba4a4b5d3e1bad49a9fad47c02b 24-Jun-2012 Nick Lewycky <nicholas@mxc.ca> Remove dyn_cast + dereference pattern by replacing it with a cast and changing
the safety check to look for the same type we're going to actually cast to.
Fixes PR13180!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159110 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ee28e0fdd1955d9fe7acc05b3250ceee759ac3c6 13-Jun-2012 Manman Ren <mren@apple.com> SimplifyCFG: fold unconditional branch to its predecessor if profitable.

This patch extends FoldBranchToCommonDest to fold unconditional branches.
For unconditional branches, we fold them if it is easy to update the phi nodes
in the common successors.

rdar://10554090


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158392 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3e933ecb74d4d622ae574ad1cb60a5b8ec126774 26-May-2012 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Turn the ad-hoc std::pair that represents switch cases into an explicit struct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157516 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
937338cf64350a7d05d0c956dc8e8564e959cb7b 26-May-2012 Benjamin Kramer <benny.kra@googlemail.com> Add support for branch weight metadata to MDBuilder and use it in various places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157515 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
26c8dcc692fb2addd475446cfff24d6a4e958bca 04-Apr-2012 Rafael Espindola <rafael.espindola@gmail.com> Always compute all the bits in ComputeMaskedBits.
This allows us to keep passing reduced masks to SimplifyDemandedBits, but
know about all the bits if SimplifyDemandedBits fails. This allows instcombine
to simplify cases like the one in the included testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3d3abe0852d5f499bed7ab014519dd582a0a795d 11-Mar-2012 Stepan Dyatkovskiy <stpworld@narod.ru> llvm::SwitchInst
Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default.
Added some notes relative to case iterators.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152532 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c10fa6c801e48771b5eade50afc2fe6abaf08227 08-Mar-2012 Stepan Dyatkovskiy <stpworld@narod.ru> Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html

Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*".

ConstCaseIt is just a read-only iterator.
CaseIt is read-write iterator; it allows to change case successor and case value.

Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters.

Main way of iterator usage looks like this:
SwitchInst *SI = ... // intialize it somehow

for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) {
BasicBlock *BB = i.getCaseSuccessor();
ConstantInt *V = i.getCaseValue();
// Do something.
}

If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method.
If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method.

There are also related changes in llvm-clients: klee and clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152297 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
aa5abe88d6aa445afa593476a665e3ab14b3524c 06-Feb-2012 Bill Wendling <isanbard@gmail.com> [unwind removal] We no longer have 'unwind' instructions being generated, so
remove the code that handles them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149901 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
24473120a253a05f3601cd3373403b47e6d03d41 01-Feb-2012 Stepan Dyatkovskiy <stpworld@narod.ru> SwitchInst refactoring.
The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want.

What was done:

1. Changed semantics of index inside the getCaseValue method:
getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous.
2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned.
3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment.
4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst.
4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor.
4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor.

Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149481 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6c00c6a181934afc8bc23db3033e46a3ff93602b 25-Jan-2012 Nick Lewycky <nicholas@mxc.ca> Gracefully degrade precision in branch probability numbers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148946 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f460bf8cd8e8a711e9de33085884e31d1c989010 19-Jan-2012 Nick Lewycky <nicholas@mxc.ca> Actually, this code handles wrapped sets just fine. Noticed by inspection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148487 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3b205175ea417349ab96f3525d730e005e12c0f9 06-Jan-2012 Dan Gohman <gohman@apple.com> Fix SpeculativelyExecuteBB to either speculate all or none of the phis
present in the bottom of the CFG triangle, as the transformation isn't
ever valuable if the branch can't be eliminated.

Also, unify some heuristics between SimplifyCFG's multiple
if-converters, for consistency.

This fixes rdar://10627242.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147630 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dd35df15a296ca7a6722dc6eb04702e687652c45 05-Jan-2012 Dan Gohman <gohman@apple.com> Revert r56315. When the instruction to speculate is a load, this
code can incorrectly move the load across a store. This never
happens in practice today, but only because the current
heuristics accidentally preclude it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147623 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8da7ddf2d28d27e8b7fd8b7f159e2d9584bdc819 28-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Demystify this comment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
91968489d718b313d4c0b912062e75a82db650e7 27-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Use false not zero, as a bool.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147292 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
06cc66f65a5012471835068029f3f4943790f584 27-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Teach simplifycfg to recompute branch weights when merging some branches, and
to discard weights when appropriate. Still more to do (and a new TODO), but
it's a start!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c9a1aed7fefe627820bb92154361ede0568229fc 26-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Update the branch weight metadata when reversing the order of a branch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147280 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9d5231022283ff20b0291eb5711a449de262d3fe 26-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Sort includes, canonicalize whitespace, fix typos. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147279 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8369687576b062be74c941a4a90dbabb0828e028 21-Dec-2011 Nick Lewycky <nicholas@mxc.ca> Make some intrinsics safe to speculatively execute.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147036 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
67005b311c357abb5dd9d8e66d6521c0c63afbb4 17-Dec-2011 Kevin Enderby <enderby@apple.com> Revert r146822 at Pete Cooper's request as it broke clang self hosting.
Hope I did this correctly :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146834 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
93ca12299f3210e300c9ac4f0fd8d6ce5b7d7d60 17-Dec-2011 Pete Cooper <peter_cooper@apple.com> SimplifyCFG now predicts some conditional branches to true or false depending on previous branch on same comparison operands.

For example,

if (a == b) {
if (a > b) // this is false

Fixes some of the issues on <rdar://problem/10554090>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146822 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f0426601977c3e386d2d26c72a2cca691dc42072 15-Dec-2011 Dan Gohman <gohman@apple.com> Move Instruction::isSafeToSpeculativelyExecute out of VMCore and
into Analysis as a standalone function, since there's no need for
it to be in VMCore. Also, update it to use isKnownNonZero and
other goodies available in Analysis, making it more precise,
enabling more aggressive optimization.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146610 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ad99ef8bf59adf151ac217e3b2ae6abec41f76e6 05-Sep-2011 Duncan Sands <baldrick@free.fr> Delete trivial landing pads that just continue unwinding the caught
exception.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139117 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9bb5488dbd152de41ffcaedccf94bfc43b069bec 26-Aug-2011 Benjamin Kramer <benny.kra@googlemail.com> Address review comments.

- Reword comments.
- Allow undefined behavior interfering with undefined behavior.
- Add address space checks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138619 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
98d6d2372feb2f8bb4c3941b278027499cbfc00b 26-Aug-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: If we have a PHI node that can evaluate to NULL and do a load or store to the address returned by the PHI node then we can consider this incoming value as dead and remove the edge pointing there, unless there are instructions that can affect control flow executed in between.

In theory this could be extended to other instructions, eg. division by zero, but it's likely that it will "miscompile" some code because people depend on div by zero not trapping. NULL pointer dereference usually leads to a crash so we should be on the safe side.

This shrinks the size of a Release clang by 16k on x86_64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138618 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
23b49ba6d55972fdffdfd4ed37edcf067bb60f3c 16-Aug-2011 Bill Wendling <isanbard@gmail.com> I think there was some confusion about what I meant. :-) Replacing the comment.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137743 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6437f2c2e282a7b2a046f0ed282cc7c536ccc48a 16-Aug-2011 Eli Friedman <eli.friedman@gmail.com> After talking with Bill, it seems like the LandingPad handling here is likely
to be wrong (or at least somewhat suspect). Leave a FIXME for Bill.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137694 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
33cb445fb68589d59172e02253367cfae700d4b1 16-Aug-2011 Eli Friedman <eli.friedman@gmail.com> Minor comment fixes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137693 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8176388d65083339efdfa5bee63e620c6bd05aa1 16-Aug-2011 Eli Friedman <eli.friedman@gmail.com> Update SimplifyCFG for atomic operations.

This commit includes a mention of the landingpad instruction, but it's not
changing the behavior around it. I think the current behavior is correct,
though. Bill, can you double-check that?



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137691 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
db125cfaf57cc83e7dd7453de2d509bc8efd0e5e 18-Jul-2011 Chris Lattner <sabre@nondot.org> land David Blaikie's patch to de-constify Type, with a few tweaks.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a3efbb15ddd5aa9006564cd79086723640084878 15-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert CallInst and InvokeInst APIs to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135265 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
77a2c372face15a302f4c9e5cb9acc035b8b3bd3 30-Jun-2011 Rafael Espindola <rafael.espindola@gmail.com> Add r134057 back, but splice the predecessor after the successors phi
nodes.

Original message:
Let simplify cfg simplify bb with only debug and lifetime intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134182 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ce77aa3edc0d07c8a2b9a613d9b57457dee43425 29-Jun-2011 Chad Rosier <mcrosier@apple.com> Temporarily revert r134057: "Let simplify cfg simplify bb with only debug and
lifetime intrinsics" due to buildbot failures.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134071 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0fb7dcd48fd6580e3ebf35eafa952a9fe1cac8b2 29-Jun-2011 Rafael Espindola <rafael.espindola@gmail.com> Let simplify cfg simplify bb with only debug and lifetime intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134057 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
448da519cca87cbcba620188e1e595dc1f120512 18-Jun-2011 Hans Wennborg <hans@hanshq.net> Fix PR10103: Less code for enum type translation.

In cases such as the attached test, where the case value for a switch
destination is used in a phi node that follows the destination, it
might be better to replace that value with the condition value of the
switch, so that more blocks can be folded away with
TryToSimplifyUncondBranchFromEmptyBlock because there are less
conflicts in the phi node.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6a648b8538bb4d4b3e96669ef8cd3a4ce3aedeb8 04-Jun-2011 Bill Wendling <isanbard@gmail.com> If the block that we're threading through is jumped to by an indirect branch,
then we don't want to set the destination in the indirect branch to the
destination. This is because the indirect branch needs its destinations to have
had their block addresses taken. This isn't so of the new critical edge that's
split during this process. If it turns out that the destination block has only
one predecessor, and that being a BB with an indirect branch, then it won't be
marked as 'used' and may be removed.
PR10072


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132638 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5649ba70fb39f2fda4791d255ae8bb373071874f 22-May-2011 Frits van Bommel <fvbommel@gmail.com> Add a parameter to ConstantFoldTerminator() that callers can use to ask it to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior.

I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131855 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d3a1788da15311781f661c1cbfe48cd5f98ae778 19-May-2011 Devang Patel <dpatel@apple.com> Reapply r131605. This time with a fix, which is to use NoFolder.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131673 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
216dde91d1def3e08002d6251e11f3dfa5cb3656 19-May-2011 Rafael Espindola <rafael.espindola@gmail.com> revert 131605 to fix PR9946.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131620 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1f5812bd995afc97d32061c532aaa0aedbead9ff 19-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131609 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1aa89a2f91948993a5d535e3d59513af7f3e7dc9 19-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying unreachable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131607 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0b4ccdc98cd9cc068173e138fd2008e087150c8b 19-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying conditional branch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131605 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
02dd5418d29c2a43f225df887923e144e12e7ec6 19-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying branch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131598 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
176ec40cb18c51c14fccbb38ee0db5deafb6baa9 18-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying return instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131580 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b55d924b1e33341d08b1bead78e86fce56617784 18-May-2011 Devang Patel <dpatel@apple.com> Spread use of IRBuilder even more.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131571 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
007349dafda47296177fd7481aff9764d4179f42 18-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying switch instruction.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131566 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d46ba26a6b513086ad575e5db0069b03d41fca13 18-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying unwind.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131561 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d3372b85e6008d85e30d13172ef0b1646b482b7e 18-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying terminator.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131552 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a23812cfbd23604d2fc103cf232cde8fa270a491 18-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while simplifying unconditional branch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131551 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f60364de44add5c92841425851cda1a6943bfcd7 18-May-2011 Devang Patel <dpatel@apple.com> Use IRBuilder while folding two entry PHINode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131548 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3e410c6607192bbf28ba3708245cb70a0f983556 18-May-2011 Devang Patel <dpatel@apple.com> Set up IRBuilder for use during simplification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131545 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d80e8ed2fa20c7ad51af49c3b2650525edbdcd08 18-May-2011 Devang Patel <dpatel@apple.com> Preseve line numbers while simplifying CFG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131508 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
10fcfb53fdc77061841e815e8b4cd62b48d5767d 14-May-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Use ComputeMaskedBits to prune dead cases from switch instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131345 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
57808b3da00d7abd01382d3ed5e70bfb0b2beb4b 29-Apr-2011 Peter Collingbourne <peter@pcc.me.uk> SimplifyCFG: Expose phi node folding cost threshold as command line parameter

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130528 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f15907feadb979daf30b2569954852778e501b2e 29-Apr-2011 Peter Collingbourne <peter@pcc.me.uk> SimplifyCFG: Add CostRemaining parameter to DominatesMergePoint

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130527 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8a70192b510e2a0f05493b9212e998017f3d178d 29-Apr-2011 Peter Collingbourne <peter@pcc.me.uk> SimplifyCFG: Add Trunc, ZExt and SExt to the list of cheap instructions for phi node folding

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130526 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3c6e746b5f05ffe3870e2aeadd2f9a3c0a96187b 14-Apr-2011 Chris Lattner <sabre@nondot.org> rework FoldBranchToCommonDest to exit earlier when there is a bonus
instruction around, reducing work.

Greatly simplify handling of debug instructions. There is no need to
build up a vector of them and then move them into the one predecessor
if we're processing a block. Instead just rescan the block and *copy*
them into the pred. If a block gets merged into multiple preds, this
will retain more debug info.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129502 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c8fbc34869fc1737adea00f775de5b8dd829f7a1 12-Apr-2011 Chris Lattner <sabre@nondot.org> comment cleanup, use moveBefore instead of removeFromParent+insertBefore.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129319 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
60d490cdc7b11e678f35f5b7eb2c9ef354462211 08-Apr-2011 Devang Patel <dpatel@apple.com> Do not let debug info interfer with branch folding.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129114 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
949666ea16214e1b7e79fc8e653b06ad8b93dd5a 07-Apr-2011 Devang Patel <dpatel@apple.com> While hoisting common code from if/else, hoist debug info intrinsics if they match.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129078 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ae6c95b58e78403707fb75e78f0959a86d57b0c5 07-Apr-2011 Devang Patel <dpatel@apple.com> Simplify. isIdenticalToWhenDefined() checks opcode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129041 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d418194036e9e05f47154535ddb9f1f1c8bc592b 07-Apr-2011 Devang Patel <dpatel@apple.com> While folding branch to a common destination into a predecessor, copy dbg values also.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129035 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3ecfc861b4365f341c5c969b40e1afccde676e6f 30-Mar-2011 Jay Foad <jay.foad@gmail.com> Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
PHINode::Create() giving the (known or expected) number of operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128537 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d8b4fb4aab4d6fedb2b14bed1b846451b17bde7c 30-Mar-2011 Jay Foad <jay.foad@gmail.com> (Almost) always call reserveOperandSpace() on newly created PHINodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128535 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b1a6eab655adce4f84a15afa9092e814b9aaabda 15-Mar-2011 Eli Friedman <eli.friedman@gmail.com> PR9450: Make switch optimization in SimplifyCFG not dependent on the ordering
of pointers in an std::map.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127650 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2adc5b6a17268834b08fda444b1a84550e8c5ae8 09-Mar-2011 Eli Friedman <eli.friedman@gmail.com> PR9420; an instruction before an unreachable is guaranteed not to have any
reachable uses, but there still might be uses in dead blocks. Use the
standard solution of replacing all the uses with undef. This is
a rare case because it's very sensitive to phase ordering in SimplifyCFG.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127299 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f7b2a9d7df0020d5120fbeb3232f9dce57dec6e7 28-Feb-2011 Frits van Bommel <fvbommel@gmail.com> Teach SimplifyCFG that (switch (select cond, X, Y)) is better expressed as a branch.
Based on a patch by Alistair Lynn.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126647 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
278be783b5068e6f87f16bc9b69a77e0bc958f9f 25-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> Revert "SimplifyCFG: GEPs with just one non-constant index are also cheap."

Yes, there are other types than i8* and GEPs on them can produce an add+multiply.
We don't consider that cheap enough to be speculatively executed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126481 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9ae59e3444630419cebea753d65d88f897e586b9 25-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: GEPs with just one non-constant index are also cheap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126452 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9b61c550c2f1fa889163a338f5d6c02b50fe961c 24-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: GEPs with constant indices are cheap enough to be executed unconditionally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126445 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
33828bcb24176aae72afac0e4953e4b7f9560ef1 07-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Track the number of used icmps when turning a icmp chain into a switch. If we used only one icmp, don't turn it into a switch.

Also prevent the switch-to-icmp transform from creating identity adds, noticed by Marius Wachtler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125056 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
042b27f40e4b1dcae70c0e98c3b4f5760dd8fa9b 03-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Also transform switches that represent a range comparison but are not sorted into sub+icmp.

This transforms another 1000 switches in gcc.c.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124826 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
56442dfdcf7b07c04b585de5205b9427b1739895 02-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Turn switches into sub+icmp+branch if possible.

This makes the job of the later optzn passes easier, allowing the vast amount of
icmp transforms to chew on it.

We transform 840 switches in gcc.c, leading to a 16k byte shrink of the resulting
binary on i386-linux.

The testcase from README.txt now compiles into
decl %edi
cmpl $3, %edi
sbbl %eax, %eax
andl $1, %eax
ret

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124724 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c3f507f98a0747bd256e1c13536060b6fc5c4b62 29-Jan-2011 Evan Cheng <evan.cheng@apple.com> Re-apply r124518 with fix. Watch out for invalidated iterator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124526 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b0a42fdb36b575a8ad939ca9624105908aeedf51 29-Jan-2011 Evan Cheng <evan.cheng@apple.com> Revert r124518. It broke Linux self-host.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124522 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5e6940788fb2f8cf3ce4219d3ac0f78317f54696 29-Jan-2011 Evan Cheng <evan.cheng@apple.com> Re-commit r124462 with fixes. Tail recursion elim will now dup ret into unconditional predecessor to enable TCE on demand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124518 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1b5c0cb71dd9d529a14cedb4bd89d544bf7e61c3 28-Jan-2011 Evan Cheng <evan.cheng@apple.com> Revert r124462. There are a few big regressions that I need to fix first.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124478 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
40f64cb0de40802ddd2f928b62e9564e1e721ff3 28-Jan-2011 Evan Cheng <evan.cheng@apple.com> - Stop simplifycfg from duplicating "ret" instructions into unconditional
branches. PR8575, rdar://5134905, rdar://8911460.
- Allow codegen tail duplication to dup small return blocks after register
allocation is done.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124462 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
65fdded3197461232d8428af7ddd0107e4a9f946 11-Jan-2011 Frits van Bommel <fvbommel@gmail.com> Factor the actual simplification out of SimplifyIndirectBrOnSelect and into a new helper function so it can be reused in e.g. an upcoming SimplifySwitchOnSelect.
No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123234 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a37029cd24105f645a694abbafbc9bf1212708b0 18-Dec-2010 Chris Lattner <sabre@nondot.org> simplify this a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122156 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
14c0987bd9ab50ebb8728e62a0b29d8f7f951984 17-Dec-2010 Benjamin Kramer <benny.kra@googlemail.com> SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122054 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e27db74a60c44d2b5d2700ecde11b1adce0d0d59 17-Dec-2010 Chris Lattner <sabre@nondot.org> improve switch formation to handle small range
comparisons formed by comparisons. For example,
this:

void foo(unsigned x) {
if (x == 0 || x == 1 || x == 3 || x == 4 || x == 6)
bar();
}

compiles into:

_foo: ## @foo
## BB#0: ## %entry
cmpl $6, %edi
ja LBB0_2
## BB#1: ## %entry
movl %edi, %eax
movl $91, %ecx
btq %rax, %rcx
jb LBB0_3

instead of:

_foo: ## @foo
## BB#0: ## %entry
cmpl $2, %edi
jb LBB0_4
## BB#1: ## %switch.early.test
cmpl $6, %edi
ja LBB0_3
## BB#2: ## %switch.early.test
movl %edi, %eax
movl $88, %ecx
btq %rax, %rcx
jb LBB0_4

This catches a bunch of cases in GCC, which look like this:

%804 = load i32* @which_alternative, align 4, !tbaa !0
%805 = icmp ult i32 %804, 2
%806 = icmp eq i32 %804, 3
%or.cond121 = or i1 %805, %806
%807 = icmp eq i32 %804, 4
%or.cond124 = or i1 %or.cond121, %807
br i1 %or.cond124, label %.thread, label %808

turning this into a range comparison.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122045 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ba3c8155704e5e2ac24b5069c32bca359b0738ed 15-Dec-2010 Chris Lattner <sabre@nondot.org> make qsort predicate more conformant by returning 0 for equal values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121838 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3aff13b82a579e910420b6c040f3e85c99110e15 14-Dec-2010 Chris Lattner <sabre@nondot.org> - Insert new instructions before DomBlock's terminator,
which is simpler than finding a place to insert in BB.
- Don't perform the 'if condition hoisting' xform on certain
i1 PHIs, as it interferes with switch formation.

This re-fixes "example 7", without breaking the world hopefully.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121764 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
60d410d7bb2eb11f36a004237e5948ffc5aff5a6 14-Dec-2010 Chris Lattner <sabre@nondot.org> fix two significant issues with FoldTwoEntryPHINode:

first, it can kick in on blocks whose conditions have been
folded to a constant, even though one of the edges will be
trivially folded.

second, it doesn't clean up the "if diamond" that it just
eliminated away. This is a problem because other simplifycfg
xforms kick in depending on the order of block visitation,
causing pointless work.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121762 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
071edc81f2a34ff689a2008e327ce7bce3a8edbf 14-Dec-2010 Chris Lattner <sabre@nondot.org> remove the instsimplify logic I added in r121754. It is apparently
breaking the selfhost builds, though I can't fathom how.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121761 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
44da7ca4213333bcade57a407a890970351db494 14-Dec-2010 Chris Lattner <sabre@nondot.org> clean up logic, convert std::set to SmallPtrSet, handle the case
when all 2-entry phis are simplified away.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121760 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e0b18e59120abc29bd25d69d20c4b0f310ec3382 14-Dec-2010 Chris Lattner <sabre@nondot.org> tidy up a bit, move DEBUG down to when we commit to doing the transform so we
don't print it unless the xform happens.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121758 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
07ff3539f5342bdac019c68bb362cb222b3f71d9 14-Dec-2010 Chris Lattner <sabre@nondot.org> use SimplifyInstruction instead of reimplementing part of it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121757 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
995ba1bd49e57dee8e301d5f33a7c01d73b7385d 14-Dec-2010 Chris Lattner <sabre@nondot.org> simplify GetIfCondition by using getSinglePredecessor.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121756 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6de0a28dfb84095ebd7775f371dd4085cf955076 14-Dec-2010 Chris Lattner <sabre@nondot.org> use AddPredecessorToBlock in 3 places instead of a manual loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121755 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
73c50a68a7e26b59db54df86e9cc87eed5034bf4 14-Dec-2010 Chris Lattner <sabre@nondot.org> make FoldTwoEntryPHINode use instsimplify a bit, make
GetIfCondition faster by avoiding pred_iterator. No
really interesting change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121754 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
302ba6fc1cb26248b0d6524fc42c740370926d6d 14-Dec-2010 Chris Lattner <sabre@nondot.org> improve DEBUG's a bit, switch to eraseFromParent() to simplify
code a bit, switch from constant folding to instsimplify.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121751 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
117f8cffc5499217ff8824eb0d6a0f6b1b78d96e 14-Dec-2010 Chris Lattner <sabre@nondot.org> reapply my recent change that disables a piece of the switch formation
work, but fixes 400.perlbmk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121749 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2d9220e8f5b45390d64e943fa4eef1562b87f04b 14-Dec-2010 Owen Anderson <resistor@mac.com> Fix recent buildbot breakage by pulling SimplifyCFG back to its state as of r121694, the most recent state
where I'm confident there were no crashes or miscompilations. XFAIL the test added since then for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121733 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f9a1b2a4cfd4b6b5fc92a09c326f6daef4808059 14-Dec-2010 Chris Lattner <sabre@nondot.org> temporarily disable part of my previous patch, which causes an iterator invalidation issue, causing a crash on some versions of perlbmk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121728 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
94c58a0906522bca664ecf7adfd0d88d37bad84d 13-Dec-2010 Chris Lattner <sabre@nondot.org> add some DEBUG's.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121711 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
cf8b3257c051f2c2908ed289396f41d47fd7a4ed 13-Dec-2010 Benjamin Kramer <benny.kra@googlemail.com> Fix sort predicate. qsort(3)'s predicate semantics differ from std::sort's. Fixes PR 8780.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121705 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a9f6bbea62f42ab052eca423588e309ab67c3fa3 13-Dec-2010 Chris Lattner <sabre@nondot.org> reinstate my patch: the miscompile was caused by an inverted branch in the
'and' case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121695 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
92407e589524d98080f4db943a0e2a3bf18ec8a2 13-Dec-2010 Chris Lattner <sabre@nondot.org> Completely disable the optimization I added in r121680 until
I can track down a miscompile. This should bring the buildbots
back to life


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121693 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
daa02ab70c7619cc22131c75c62390cf3f5f8891 13-Dec-2010 Chris Lattner <sabre@nondot.org> Make simplifycfg reprocess newly formed "br (cond1 | cond2)" conditions
when simplifying, allowing them to be eagerly turned into switches. This
is the last step required to get "Example 7" from this blog post:
http://blog.regehr.org/archives/320

On X86, we now generate this machine code, which (to my eye) seems better
than the ICC generated code:

_crud: ## @crud
## BB#0: ## %entry
cmpb $33, %dil
jb LBB0_4
## BB#1: ## %switch.early.test
addb $-34, %dil
cmpb $58, %dil
ja LBB0_3
## BB#2: ## %switch.early.test
movzbl %dil, %eax
movabsq $288230376537592865, %rcx ## imm = 0x400000017001421
btq %rax, %rcx
jb LBB0_4
LBB0_3: ## %lor.rhs
xorl %eax, %eax
ret
LBB0_4: ## %lor.end
movl $1, %eax
ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121690 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
021c9d3bd41bc446ef0860c05a073e32afa5e20f 13-Dec-2010 Chris Lattner <sabre@nondot.org> make this logic a bit simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121689 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3d5121314ab4af435e1abf5bc09b45c305f2f4b0 13-Dec-2010 Chris Lattner <sabre@nondot.org> split all the guts of SimplifyCFGOpt::run out into one function
per terminator kind.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121688 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
97bd89ece3fff29ab7e0eaa38f85183abd962f42 13-Dec-2010 Chris Lattner <sabre@nondot.org> fix a bug in r121680 that upset the various buildbots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121687 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
979b8f1d8c1887edce1d2381747ee42ff2f6fb17 13-Dec-2010 Chris Lattner <sabre@nondot.org> refactor the speculative execution logic to be factored into the cond branch code instead of
doing a cfg search for every block simplified.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121686 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
eff7edf12628fd83426ce18cf315b12ca6c76923 13-Dec-2010 Chris Lattner <sabre@nondot.org> simplify a bunch of code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121685 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ef5002ba85121178766edd096818a781fdc2dece 13-Dec-2010 Chris Lattner <sabre@nondot.org> move HoistThenElseCodeToIf up to a more logical and efficient-to-handle place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121684 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ddb97a2bf1f06d7d1b0a1af8e74c67917b43b606 13-Dec-2010 Chris Lattner <sabre@nondot.org> move 'MergeBlocksIntoPredecessor' call earlier. Use
getSinglePredecessor to simplify code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121683 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
97fdb898f5350e51bb40afd58e3f4e1d18e348db 13-Dec-2010 Chris Lattner <sabre@nondot.org> factor new code out to a SimplifyBranchOnICmpChain helper function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121681 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7312a22ed63607e4ae7b0d9326e42358fd41e245 13-Dec-2010 Chris Lattner <sabre@nondot.org> enhance the "change or icmp's into switch" xform to handle one value in an
'or sequence' that it doesn't understand. This allows us to optimize
something insane like this:

int crud (unsigned char c, unsigned x)
{
if(((((((((( (int) c <= 32 ||
(int) c == 46) || (int) c == 44)
|| (int) c == 58) || (int) c == 59) || (int) c == 60)
|| (int) c == 62) || (int) c == 34) || (int) c == 92)
|| (int) c == 39) != 0)
foo();
}

into:

define i32 @crud(i8 zeroext %c, i32 %x) nounwind ssp noredzone {
entry:
%cmp = icmp ult i8 %c, 33
br i1 %cmp, label %if.then, label %switch.early.test

switch.early.test: ; preds = %entry
switch i8 %c, label %if.end [
i8 39, label %if.then
i8 44, label %if.then
i8 58, label %if.then
i8 59, label %if.then
i8 60, label %if.then
i8 62, label %if.then
i8 46, label %if.then
i8 92, label %if.then
i8 34, label %if.then
]

by pulling the < comparison out ahead of the newly formed switch.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0aa749bde7c696e0522df5581ea9cc70f25e62cb 13-Dec-2010 Chris Lattner <sabre@nondot.org> merge two very similar functions into one that has a bool argument.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121678 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
662269d2abb2f220c3a9b727c2a948246128cd05 13-Dec-2010 Chris Lattner <sabre@nondot.org> don't bother handling non-canonical icmp's


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121676 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
803a29d19f8e2564fe93e6c43eff2cb7f5934c6f 13-Dec-2010 Chris Lattner <sabre@nondot.org> inline a function, making the result much simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121675 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
abf706703fcbcde8fdc69b1bbdfb34e874813107 13-Dec-2010 Chris Lattner <sabre@nondot.org> Fix my previous patch to handle a degenerate case that the llvm-gcc
bootstrap buildbot tripped over.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121674 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
28acc135481691771205dea7cb4edbd3927aa764 13-Dec-2010 Chris Lattner <sabre@nondot.org> convert some methods to be static functions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121673 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
fca20f507ccfd3407511cd1ccb94ab4421388107 13-Dec-2010 Chris Lattner <sabre@nondot.org> zap two more std::sorts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121672 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
61c77449c772427a0d2559fca500debd93c7f97c 13-Dec-2010 Chris Lattner <sabre@nondot.org> fix a fairly serious oversight with switch formation from
or'd conditions. Previously we'd compile something like this:

int crud (unsigned char c) {
return c == 62 || c == 34 || c == 92;
}

into:

switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
]

lor.rhs: ; preds = %entry
%cmp8 = icmp eq i8 %c, 92
br label %lor.end

lor.end: ; preds = %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext

which failed to merge the compare-with-92 into the switch. With this patch
we simplify this all the way to:

switch i8 %c, label %lor.rhs [
i8 62, label %lor.end
i8 34, label %lor.end
i8 92, label %lor.end
]

lor.rhs: ; preds = %entry
br label %lor.end

lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
%0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ]
%lor.ext = zext i1 %0 to i32
ret i32 %lor.ext

which is much better for codegen's switch lowering stuff. This kicks in 33 times
on 176.gcc (for example) cutting 103 instructions off the generated code.





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121671 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6d4d21e29d4840236ab6f15c5247379820021d0c 13-Dec-2010 Chris Lattner <sabre@nondot.org> convert an std::sort to array_pod_sort.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121669 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
cd4b709d73f8705571d5680d5d7c1962a1239fda 13-Dec-2010 Chris Lattner <sabre@nondot.org> move the "br (X == 0 | X == 1), T, F" -> switch optimization to a new
location in simplifycfg. In the old days, SimplifyCFG was never run on
the entry block, so we had to scan over all preds of the BB passed into
simplifycfg to do this xform, now we can just check blocks ending with
a condbranch. This avoids a scan over all preds of every simplified
block, which should be a significant compile-time perf win on functions
with lots of edges. No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121668 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9a2b72acc9651be04c12ba713702ddc5d449ce72 13-Dec-2010 Chris Lattner <sabre@nondot.org> reduce indentation and generally simplify code, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121667 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dcb54ce3da15ba41adeee020288e6c62cfae8c42 13-Dec-2010 Chris Lattner <sabre@nondot.org> use getFirstNonPHIOrDbg to simplify this code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121664 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7ac40c3ffabcdac9510e7efc4dc75a8ed2b32edb 05-Dec-2010 Frits van Bommel <fvbommel@gmail.com> Teach SimplifyCFG to turn
(indirectbr (select cond, blockaddress(@fn, BlockA),
blockaddress(@fn, BlockB)))
into
(br cond, BlockA, BlockB).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120943 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5f28475b30cf09e946bf6cb7c8de6d597a41610e 24-Oct-2010 Duncan Sands <baldrick@free.fr> Fix PR8445: a block with no predecessors may be the entry block, in which case
it isn't unreachable and should not be zapped. The check for the entry block
was missing in one case: a block containing a unwind instruction. While there,
do some small cleanups: "M" is not a great name for a Function* (it would be
more appropriate for a Module*), change it to "Fn"; use Fn in more places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117224 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7a4994356b0e9726384edda57f7db65e5bc10673 16-Aug-2010 Dan Gohman <gohman@apple.com> Instead, teach SimplifyCFG to trim non-address-taken blocks from
indirectbr destination lists.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111122 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e2c6d131d12c779a410740e0a90545def75e0f48 14-Aug-2010 Dan Gohman <gohman@apple.com> Teach SimplifyCFG how to simplify indirectbr instructions.
- Eliminate redundant successors.
- Convert an indirectbr with one successor into a direct branch.

Also, generalize SimplifyCFG to be able to be run on a function entry block.
It knows quite a few simplifications which are applicable to the entry
block, and it only needs a few checks to avoid trouble with the entry block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111060 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
20361b9d4d9988d7bfa2112650971642cf81d13e 22-Jul-2010 Gabor Greif <ggreif@gmail.com> pass dereferenced iterator to dyn_cast

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109098 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2722dfa75dbf4436197f6fcf9d8cb2391975f1a1 15-Jul-2010 Owen Anderson <resistor@mac.com> Remove unneeded check, and correct style.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108427 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e84178a0bd3a218238b15ef646f2e740f3a48037 14-Jul-2010 Owen Anderson <resistor@mac.com> Extend SimplifyCFG's common-destination folding heuristic to allow a single
"bonus" instruction to be speculatively executed. Add a heuristic to
ensure we're not tripping up out-of-order execution by checking that this bonus
instruction only uses values that were already guaranteed to be available.

This allows us to eliminate the short circuit in (x&1)&&(x&2).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108351 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
625398343e2673a0c4bb5228fc88f71fe4e1c629 12-Jul-2010 Gabor Greif <ggreif@gmail.com> cache dereferenced iterators

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108133 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
58969354238655a87677c7fd439d3e3d134fc89f 09-Jul-2010 Gabor Greif <ggreif@gmail.com> cache result of operator*

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107974 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4bb31bfaa3ed2495dd99304316344dbe54f1d756 30-Mar-2010 Dan Gohman <gohman@apple.com> Fix a grammaro.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99917 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bd44314c676a05e52f3841c5961ea0a2bc1116fb 30-Mar-2010 Gabor Greif <ggreif@gmail.com> fix two cases where the arguments were extracted from the wrong range out of the InvokeInst
spotted by baldrick -- thanks\!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99914 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c69b4a5b8ba83863f9d24f7ca2aa02395addb868 14-Mar-2010 Bill Wendling <isanbard@gmail.com> Make returns more consistent with others.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98490 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1df9859c40492511b8aa4321eb76496005d3b75b 16-Feb-2010 Duncan Sands <baldrick@free.fr> There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy(). Convert most instances of the first form to the second form.
Requested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b0bc6c361da9009e8414efde317d9bbff755f6c0 15-Feb-2010 Duncan Sands <baldrick@free.fr> Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96223 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
58e9ee85fda5083e2eea987917e8eab6ba31fe5e 05-Feb-2010 Jakob Stoklund Olesen <stoklund@2pi.dk> Teach SimplifyCFG about magic pointer constants.

Weird code sometimes uses pointer constants other than null. This patch
teaches SimplifyCFG to build switch instructions in those cases.

Code like this:

void f(const char *x) {
if (!x)
puts("null");
else if ((uintptr_t)x == 1)
puts("one");
else if (x == (char*)2 || x == (char*)3)
puts("two");
else if ((intptr_t)x == 4)
puts("four");
else
puts(x);
}

Now becomes a switch:

define void @f(i8* %x) nounwind ssp {
entry:
%magicptr23 = ptrtoint i8* %x to i64 ; <i64> [#uses=1]
switch i64 %magicptr23, label %if.else16 [
i64 0, label %if.then
i64 1, label %if.then2
i64 2, label %if.then9
i64 3, label %if.then9
i64 4, label %if.then14
]

Note that LLVM's own DenseMap uses magic pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95439 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
11acaa374cdcebb161bf0de5f244265d78a749c1 05-Jan-2010 Benjamin Kramer <benny.kra@googlemail.com> Convert a ton of simple integer type equality tests to the new predicate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92760 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f012705c7e4ca8cf90b6b734ce1d5355daca5ba5 05-Jan-2010 Benjamin Kramer <benny.kra@googlemail.com> Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92726 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
89d6fd36a26fdf068ceea90422dc2897e89700b5 05-Jan-2010 David Greene <greened@obbligato.org> Change errs() to dbgs().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92604 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
44a29e066a24e88bdf127e88be4380a5f259c4b4 05-Jan-2010 Devang Patel <dpatel@apple.com> Remove dead debug info intrinsics.
Intrinsic::dbg_stoppoint
Intrinsic::dbg_region_start
Intrinsic::dbg_region_end
Intrinsic::dbg_func_start
AutoUpgrade simply ignores these intrinsics now.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92557 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
43a8241b65b70ded3a87fb26852719633908a1e4 02-Dec-2009 Jim Grosbach <grosbach@apple.com> Move EliminateDuplicatePHINodes() from SimplifyCFG.cpp to Local.cpp

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90324 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
20f4d34fe3609cda8b70956a36080e9cbcd327d4 19-Nov-2009 Jim Grosbach <grosbach@apple.com> Make EliminateDuplicatePHINodes() available as a utility function

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89297 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dce94d92df77da125a1c1256a9294db891a9db9c 10-Nov-2009 Chris Lattner <sabre@nondot.org> refactor TryToSimplifyUncondBranchFromEmptyBlock out of SimplifyCFG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86666 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7b550ccfc5a3346c17e0390a59e2d6d19bc52705 06-Nov-2009 Chris Lattner <sabre@nondot.org> remove a bunch of extraneous LLVMContext arguments
from various APIs, addressing PR5325.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86231 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0e747beb3cfc48ebcb0a2f8b962f0d0de525d979 31-Oct-2009 Dan Gohman <gohman@apple.com> Add a comment about a missed opportunity.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85635 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2c63566e406974caa70ee27f35af28112e80f951 30-Oct-2009 Dan Gohman <gohman@apple.com> Teach SimplifyCFG how to eliminate duplicate PHI nodes within a block.
This reduces codesize on a variety of codes by 1-2% on x86-64. It also
helps clean up after SSAUpdater.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85626 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
11f15dbb287b5d9aa63913f84ce931569a5ebdf3 13-Oct-2009 Chris Lattner <sabre@nondot.org> change simplifycfg to not duplicate 'unwind' instructions. Hopefully
this will increase the likelihood of common code getting sunk towards
the unwind.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6776064d190701c5bae4d5403939eed2e480d1cd 27-Sep-2009 Nick Lewycky <nicholas@mxc.ca> Instruction::clone does not need to take an LLVMContext&. Remove that and
update all the callers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82889 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
58cfa3b13752579c86cf85270d49f9ced0942f2f 26-Aug-2009 Dan Gohman <gohman@apple.com> Rename Instruction::isIdenticalTo to Instruction::isIdenticalToWhenDefined,
and introduce a new Instruction::isIdenticalTo which tests for full
identity, including the SubclassOptionalData flags. Also, fix the
Instruction::clone implementations to preserve the SubclassOptionalData
flags. Finally, teach several optimizations how to handle
SubclassOptionalData correctly, given these changes.

This fixes the counterintuitive behavior of isIdenticalTo not comparing
the full value, and clone not returning an identical clone, as well as
some subtle bugs that could be caused by these.

Thanks to Nick Lewycky for reporting this, and for an initial patch!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80038 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e317bcc74c1f317f913e9b05db385901cfc54d0b 23-Aug-2009 Daniel Dunbar <daniel@zuster.org> Fix -Asserts warnings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79849 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bdff548e4dd577a72094d57b282de4e765643b96 23-Aug-2009 Chris Lattner <sabre@nondot.org> eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79819 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
12bb766ae9458b631e9acd97443345966788b5de 16-Aug-2009 Eli Friedman <eli.friedman@gmail.com> Fix for PR3016: detect the tricky case, where there are
unfoldable references to a PHI node in the block being folded, and disable
the transformation in that case. The correct transformation of such PHI
nodes depends on whether BB dominates Succ, and dominance is expensive
to compute here. (Alternatively, it's possible to check whether any
uses are live, but that's also essentially a dominance calculation.
Another alternative is to use reg2mem, but it probably isn't a good idea to
use that in simplifycfg.)

Also, remove some incorrect code from CanPropagatePredecessorsForPHIs
which is made unnecessary with this patch: it didn't consider the case
where a PHI node in BB has multiple uses.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79174 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1d0be15f89cb5056e20e2d24faa8d6afb1573bca 13-Aug-2009 Owen Anderson <resistor@mac.com> Push LLVMContexts through the IntegerType APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4ae5126d041768ab9665cf2f11c024becd76c41f 12-Aug-2009 Dan Gohman <gohman@apple.com> Remove a bunch more now-unnecessary Context arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78809 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9e9a0d5fc26878e51a58a8b57900fcbf952c2691 31-Jul-2009 Owen Anderson <resistor@mac.com> Move more code back to 2.5 APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77635 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
460f656475738d1a95a6be95346908ce1597df25 26-Jul-2009 Daniel Dunbar <daniel@zuster.org> Remove Value::getName{Start,End}, the last of the old Name APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ce63ffb52f249b62cdf2d250c128007b13f27e71 25-Jul-2009 Daniel Dunbar <daniel@zuster.org> More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
"magic" DOUT behavior which avoided calling printing functions when the
statement was disabled. In addition to being unnecessary magic, it had the
downside of leaving code in -Asserts builds, and of hiding potentially
unnecessary computations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77019 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
eed707b1e6097aac2bb6b3d47271f6300ace7f2e 25-Jul-2009 Owen Anderson <resistor@mac.com> Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77011 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e922c0201916e0b980ab3cfe91e1413e68d55647 22-Jul-2009 Owen Anderson <resistor@mac.com> Get rid of the Pass+Context magic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76702 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0b79a7727d68a507837e827803859424cf3d997b 17-Jul-2009 Eli Friedman <eli.friedman@gmail.com> Replace isTrapping with a new, similar method called
isSafeToSpeculativelyExecute. The new method is a bit closer to what
the callers actually care about in that it rejects more things callers
don't want. It also adds more precise handling for integer
division, and unifies code for analyzing the legality of a speculative
load.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76150 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
73c6b7127aff4499e4d6a2edb219685aee178ee1 13-Jul-2009 Owen Anderson <resistor@mac.com> Move more functionality over to LLVMContext.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75497 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
333c40096561218bc3597cf153c0a3895274414c 10-Jul-2009 Owen Anderson <resistor@mac.com> This started as a small change, I swear. Unfortunately, lots of things call the [I|F]CmpInst constructors. Who knew!?


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75200 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
07cf79ef537caff6d39145f190a28a336e629b6f 07-Jul-2009 Owen Anderson <resistor@mac.com> "LLVMContext* " --> "LLVMContext *"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74878 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
508955156a25a9abc470a29e1760aa176d341cf9 06-Jul-2009 Owen Anderson <resistor@mac.com> Thread LLVMContext through the constant folding APIs, which touches a lot of files.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74844 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0a205a459884ec745df1c529396dd921f029dafd 06-Jul-2009 Owen Anderson <resistor@mac.com> More LLVMContext-ification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74807 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4b35f83b91a1a313f0730c600e5178aaf7df98d6 27-Jun-2009 Dan Gohman <gohman@apple.com> Teach LoopSimplify how to merge multiple loop exits into a single exit,
when one of them can be converted to a trivial icmp and conditional
branch.

This addresses what is essentially a phase ordering problem.
SimplifyCFG knows how to do this transformation, but it doesn't do so
if the primary block has any instructions in it other than an icmp and
a branch. In the given testcase, the block contains other instructions,
however they are loop-invariant and can be hoisted. SimplifyCFG doesn't
have LoopInfo though, so it can't hoist them. And, it's important that
the blocks be merged before LoopRotation, as it doesn't support
multiple-exit loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74396 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c1f104054dda0b3946abbe3b6859e960b60168f7 15-Jun-2009 Dale Johannesen <dalej@apple.com> Fix the crash in this test. This is basically the same
problem addressed in 31284, but the patch there only
addressed the case where an invoke is the first thing in
a block.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73416 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ae3a0be92e33bc716722aa600983fc1535acb122 05-Jun-2009 Dan Gohman <gohman@apple.com> Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing
FAdd, FSub, and FMul.

For now, the AsmParser, BitcodeReader, and IRBuilder all preserve
backwards compatability, and the Core LLVM APIs preserve backwards
compatibility for IR producers. Most front-ends won't need to change
immediately.

This implements the first step of the plan outlined here:
http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7616a4a1899cf4e0ca43b27c47079411fa84450d 14-May-2009 Dale Johannesen <dalej@apple.com> Reuse existing getUnderlyingObject instead of
adding another copy.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71783 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
556d0a0d15689531f2b203575a3fe55e00713777 13-May-2009 Dale Johannesen <dalej@apple.com> Handle some additonal cases of external weak globals.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71717 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f8bc3008214c8327ff987573a111fc0dcefb7d25 13-May-2009 Dale Johannesen <dalej@apple.com> Don't generate a select whose operand is load of a weak
external. These may have address 0 and are not safe
to execute unconditionally.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71688 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e9d87f49063cb1bd213d8e9c339b9b63393cc2d9 06-May-2009 Dan Gohman <gohman@apple.com> Simplify code by using SmallVector's pop_back_val() instead of
separate back() and pop_back() calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71089 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f33b1103a1d24d5d03294fe7332a295e9f6b1f1d 19-Mar-2009 Dale Johannesen <dalej@apple.com> Fix comment typo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
990afedb3a4b7d32832d74ad5b5863c19f909e1f 13-Mar-2009 Dale Johannesen <dalej@apple.com> Fix one more place where debug info affected
codegen (speculative execution).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66859 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8483e54837ede5dd40c5561f15c6a663e2bee87c 13-Mar-2009 Dale Johannesen <dalej@apple.com> Previous debug info fix to this code wasn't quite
right; did the wrong thing when there are exactly 11
non-debug instructions, followed by debug info.
Remove a FIXME since it's apparently been fixed along the way.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66840 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c81f5445a7cbe3ba0252aec030082a40e5019ece 12-Mar-2009 Dale Johannesen <dalej@apple.com> There already was a class to force deterministic
sorting of ConstantInt's; unreinvent wheel.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66824 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
80b8a62fda56179b00fe463ae55d712aa8abefec 12-Mar-2009 Dale Johannesen <dalej@apple.com> Another missing check for debug intrinsics.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66800 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1379cadf8d34cd4305e1b916d4cd242df4dd474f 12-Mar-2009 Dale Johannesen <dalej@apple.com> Allow for switch values bigger than 64 bits.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66751 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a9537cf3fcf9fdaac94749db9fbd34912b1f0f08 12-Mar-2009 Dale Johannesen <dalej@apple.com> Fix some nondeterministic behavior when forwarding
from a switch table. Multiple table entries that
branch to the same place were being sorted by the
pointer value of the ConstantInt*; changed to sort
by the actual value of the ConstantInt.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66749 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9200c89968e52a590ee0b96092a0a589aa138a6f 10-Mar-2009 Devang Patel <dpatel@apple.com> Ignore dbg info, while estimating size of jump through block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66554 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3a56d146413ee344b10bbcb2b7d8dffaadc9fade 06-Mar-2009 Dale Johannesen <dalej@apple.com> Fix another case where debug info interferes with
an optimization.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66288 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
06b1e67d44a6c13f9e75fbc1ac3c7de2df4776c9 06-Mar-2009 Devang Patel <dpatel@apple.com> While hoisting instruction to speculatively execute simple bb, ignore dbg intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66255 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1c85503e381423f20769582b6ab169bce9cfe2a2 03-Mar-2009 Bill Wendling <isanbard@gmail.com> Remove accidental check-ins in r65960. :-(

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65961 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3aaf5d993365c803dad9a8815b6c9864505af5b6 03-Mar-2009 Bill Wendling <isanbard@gmail.com> Use > instead of >=. We want to promote aggregates of 128-bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65960 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a8d57fe96bb870e4f69c6b522a78936d1495d0d2 26-Feb-2009 Zhou Sheng <zhousheng00@gmail.com> Ignore dbg info intrinsics when folding conditional branch to
conditional branch predecessors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65509 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9a7c743fc0d45e4f2331c4092d3f29bf18351e6f 25-Feb-2009 Zhou Sheng <zhousheng00@gmail.com> Don't block basic block with only SwitchInst to fold into predecessors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65456 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5622f07a21b799964dc172925b9ebc38191859f6 24-Feb-2009 Devang Patel <dpatel@apple.com> While folding unconditional return move DbgRegionEndInst into the predecessor, instead of removing it. This fixes following tests from llvmgcc42 testsuite.

gcc.c-torture/execute/20000605-3.c
gcc.c-torture/execute/20020619-1.c
gcc.c-torture/execute/20030920-1.c
gcc.c-torture/execute/loop-ivopts-1.c



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65353 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bd75b8345f9c2a6efd8fb799ba861129fed36ef8 11-Feb-2009 Devang Patel <dpatel@apple.com> If llvm.dbg.region.end is disappearing then remove corresponding llvm.dbg.func.start also.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64278 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0464a1431b79ed2be54413de239347c56ad84bfa 10-Feb-2009 Devang Patel <dpatel@apple.com> Ignore dbg intrinsic while folding unconditional branch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64242 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
998cbb0444ecb597e4b46f1950561d92b5395769 05-Feb-2009 Devang Patel <dpatel@apple.com> Revert rev. 63876. It is causing llvm-gcc bootstrap failure.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63888 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1851db6b0f9ef1b85d14b24eb9f838748396352f 05-Feb-2009 Devang Patel <dpatel@apple.com> Ignore dbg intrinsics while propagating conditional expression info.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63876 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2cc86a1de1cf598be384836f19d1ef1892fb50fc 05-Feb-2009 Devang Patel <dpatel@apple.com> Ignore dbg intrinsics while folding switch instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63802 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d0a203d76f4ef77ae1c392e8e73e2f05b676a5f2 04-Feb-2009 Devang Patel <dpatel@apple.com> Ignore dbg intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63781 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
556b20ab46520ac53bb689d3c70160bc9d496a3f 04-Feb-2009 Devang Patel <dpatel@apple.com> While folding vallue comparison terminators ignore dbg intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63700 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
65085cf7b3470b7b087f5fd7b0497879b90b32ba 04-Feb-2009 Devang Patel <dpatel@apple.com> Ignore dbg intrinsics while hoisting common code in the two blocks up into the branch block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63687 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
383d7ed9158576aef5cde872548225a17e3c0155 03-Feb-2009 Devang Patel <dpatel@apple.com> Do not let dbg intrinsic block folding of two entry phi node.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63671 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
63bf29b5b1c741038d6d502d62721cac0d2760b4 20-Jan-2009 Chris Lattner <sabre@nondot.org> another fix for PR3354


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62561 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5049fa6bbc66534fe0cc361808dff80fd2d5cde2 20-Jan-2009 Bill Wendling <isanbard@gmail.com> Doxygen-ify comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62546 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6ff645bf0fcfc0c62e9d9126e1243ec8bf10abbc 20-Jan-2009 Chris Lattner <sabre@nondot.org> Fix a problem exposed by PR3354: simplifycfg was making a potentially
trapping instruction be executed unconditionally.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62541 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
13524bfd00482d505dae3f5f99c33e4d19b080ad 19-Jan-2009 Bill Wendling <isanbard@gmail.com> Temporarily revert r62487. It's causing this error during a release bootstrap of
llvm-gcc. Most likely, it's miscompiling one of the "gen*" programs:

/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.obj/./prev-gcc/xgcc -B/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.obj/./prev-gcc/ -B/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.install/i386-apple-darwin9.6.0/bin/ -c -g -O2 -mdynamic-no-pic -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -mdynamic-no-pic -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/build -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include -DENABLE_LLVM -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/../llvm.src/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -o build/gencondmd.o build/gencondmd.c
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected '}' before ')' token
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: warning: excess elements in struct initializer
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: warning: (near initialization for 'insn_conditions[4]')
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected '}' before ')' token
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected ',' or ';' before ')' token
../../llvm-gcc.src/gcc/config/i386/mmx.md:927: error: expected identifier or '(' before ',' token
../../llvm-gcc.src/gcc/config/i386/sse.md:3458: error: expected identifier or '(' before ',' token
...



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62506 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c4f85dd708b2b131222f16071e7b8ce9bc8a4fd6 19-Jan-2009 Chris Lattner <sabre@nondot.org> Fix PR3016, a bug which can occur do to an invalid assumption:
we assumed a CFG structure that would be valid when all code in
the function is reachable, but not all code is necessarily
reachable. Do a simple, but horrible, CFG walk to check for this
case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62487 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9e0dad4f4168d82ae7604caac5c57e79889a57fc 19-Jan-2009 Chris Lattner <sabre@nondot.org> reduce indentation by using 'continue', no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62477 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6fe73bbcf3b6c1ddfd5e70e8b5188f8df439ace6 19-Jan-2009 Chris Lattner <sabre@nondot.org> Fix some problems in SpeculativelyExecuteBB. Basically,
because of dead code, a phi could use the speculated instruction
that was not in "BB2". Make this check explicit and tighten up
some other corners. This fixes PR3292. No testcase becauase this
depends entirely on visitation order of blocks and requires a
sequence of 8 passes to repro.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62476 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9dd3b610dcb17f88ed52ae03022179bf21e0e132 19-Jan-2009 Chris Lattner <sabre@nondot.org> Make this a bit more explicit about which cases need the
check. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62474 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
080efb8cea6255b4f1f373d9cb583d6a6302106b 16-Dec-2008 Eli Friedman <eli.friedman@gmail.com> Add a helper to remove a branch and DCE the condition, and use it
consistently for deleting branches. In addition to being slightly
more readable, this makes SimplifyCFG a bit better
about cleaning up after itself when it makes conditions unused.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61100 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a16ead8b10ab63e08c91afb852f29b32188b9afb 07-Dec-2008 Chris Lattner <sabre@nondot.org> fix a bug I introduced in simplifycfg handling single entry phi
nodes. FoldSingleEntryPHINodes deletes the PHI, so there is no
need to delete it afterward.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60653 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
29874e0dc6c4e55bc384611273343bb358982cc3 03-Dec-2008 Chris Lattner <sabre@nondot.org> Factor some code into a new FoldSingleEntryPHINodes method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60501 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
71af9b07a58a264064813545889cf6473ce23de6 03-Dec-2008 Chris Lattner <sabre@nondot.org> Rename DeleteBlockIfDead to DeleteDeadBlock and make it
unconditionally delete the block. All likely clients will
do the checking anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60464 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2b1ba24fb75e633560846e551acadade92783bb3 03-Dec-2008 Chris Lattner <sabre@nondot.org> Factor some code out of SimplifyCFG, forming a new
DeleteBlockIfDead method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60463 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9fd4955c6ab9a191dec2d5afd4b2027d4b906f2e 28-Nov-2008 Chris Lattner <sabre@nondot.org> delete ErasePossiblyDeadInstructionTree, replacing uses of it with
RecursivelyDeleteTriviallyDeadInstructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60196 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5a5c9a5acd5f90ec3815f4871c66e224902588ce 27-Nov-2008 Chris Lattner <sabre@nondot.org> simplify this code a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60164 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f8131c99de2ac66be4307ae24f2db44d12bc9b3f 29-Oct-2008 Chris Lattner <sabre@nondot.org> Fix PR2967 by not deleting volatile load/stores that occur before unreachable.
I don't really see this as being needed, but there is little harm from doing
it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58385 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
20da1f07dac4d771e55ee5c7f105ccedfa4caaaa 03-Oct-2008 Devang Patel <dpatel@apple.com> Nick Lewycky's patch.
While hosting instruction check PHI node.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57025 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0598866c052147c31b808391f58434ce3dbfb838 25-Sep-2008 Devang Patel <dpatel@apple.com> Large mechanical patch.

s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage
- to implement function notes as function attributes and
- to distinguish between function attributes and return value attributes.

This requires corresponding changes in llvm-gcc and clang.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56622 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3d0a9a371c0ce3a46e845a7bf1f1acb7a1cf523e 19-Sep-2008 Devang Patel <dpatel@apple.com> Try to place hoisted instructions befoe icmp instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56315 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
48fbc2d39b6efbd8d2d02e830cc91ab6e49b8dde 17-Sep-2008 Devang Patel <dpatel@apple.com> Do not hoist instruction above branch condition. The instruction may use branch condition.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a8c763b3071ae1a58ee8baeb282331245527e004 14-Aug-2008 Dan Gohman <gohman@apple.com> Use empty() instead of begin() == end().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54780 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
fc74abfba5128544a750fce22fdf13eb0403e3ce 23-Jul-2008 Dan Gohman <gohman@apple.com> Enable first-class aggregates support.

Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.

The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53941 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
cfa94198d5a75776a600df8113ac565b25552399 18-Jul-2008 Owen Anderson <resistor@mac.com> Reapply r53735. My last patch fixed the failures Dan observed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53761 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
79c23effe22b252060c9bf0ce311f412bc734b7c 18-Jul-2008 Dan Gohman <gohman@apple.com> Revert r53735. It broke SPEC 464.h264ref.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53757 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f7d3ecf0912b8ce083536f4df5677b540ee9592b 17-Jul-2008 Owen Anderson <resistor@mac.com> Use MergeBlockIntoPredecessor to simplify some code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
093a4385027235459ab6972b2e2fdc79061773cf 14-Jul-2008 Chris Lattner <sabre@nondot.org> Fix mishandling of the infinite loop case when merging two blocks. This
fixes PR2540.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53533 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b824512b8d733ccdfb1b1a2e8a6950605acf1c52 14-Jul-2008 Chris Lattner <sabre@nondot.org> more refactoring. Use early exits instead of really complex logic.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53532 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
eb388af89f15ee3de6f53359473e1a54418a667f 13-Jul-2008 Chris Lattner <sabre@nondot.org> improve comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53531 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
867661ac8bd8e202bd4becf9b8e046bf69e150b1 13-Jul-2008 Chris Lattner <sabre@nondot.org> factor another large hunk of code out into its own function.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53530 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3698909623f994826b6a11fc4ea37e4b425a9589 13-Jul-2008 Chris Lattner <sabre@nondot.org> Final bit of simplification for FoldBranchToCommonDest.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53528 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
70087f31f154156bcb494dd0cf3b7d74c0c8b528 13-Jul-2008 Chris Lattner <sabre@nondot.org> simplify logic a bit


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53527 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1347e87c7baa78bd442d7017a8d67bd4fe674e01 13-Jul-2008 Chris Lattner <sabre@nondot.org> Refactor some code out into its own helper function, getting rid of crazy multiline
conditionals and commenting the code better.

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53526 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e5334ea518e3dffec4037ede97433eb700fa1d26 25-Jun-2008 Evan Cheng <evan.cheng@apple.com> - Use O(1) check of basic block size limit.
- Avoid speculatively execute vector ops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52703 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
502a4f5162498ec420e3cb22f667808d726dd7da 12-Jun-2008 Evan Cheng <evan.cheng@apple.com> Do not speculatively execute an instruction by hoisting it to its predecessor BB if any of its operands are defined but not used in BB. The transformation will prevent the operand from being sunk into the use block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52244 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
797d95188d00963a835db9ad66dd3c4a54aa2faf 11-Jun-2008 Evan Cheng <evan.cheng@apple.com> For now, avoid generating FP select instructions in order to speculatively execute integer arithmetic instructions. FP selects are more likely to be expensive (even compared to branch on fcmp). This is not a wonderful solution but I rather err on the side of conservative.

This fixes the heapsort performance regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52224 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f7ea3638e0f85a9793e7c9f081ed6ddb1ebb832e 11-Jun-2008 Gabor Greif <ggreif@gmail.com> op_iterator-ify loops

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52191 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4d09efd7b8fdf9e8a8c89bdb821f4992091a764b 07-Jun-2008 Evan Cheng <evan.cheng@apple.com> Speculatively execute a block when the the block is the then part of a triangle shape and it contains a single, side effect free, cheap instruction. The branch is eliminated by adding a select instruction. i.e.

Turn
BB:
%t1 = icmp
br i1 %t1, label %BB1, label %BB2
BB1:
%t3 = add %t2, c
br label BB2
BB2:
=>
BB:
%t1 = icmp
%t4 = add %t2, c
%t3 = select i1 %t1, %t2, %t3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52073 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
02dea8b39f3acad5de1df36273444d149145e7fc 23-May-2008 Dan Gohman <gohman@apple.com> Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to
use it instead of duplicating its functionality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51499 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
5e179a23e311f8ea74844d7160f6ff9a5a1bd20a 23-May-2008 Matthijs Kooijman <matthijs@stdin.nl> Restucture a part of the SimplifyCFG pass and include a testcase.

The SimplifyCFG pass looks at basic blocks that contain only phi nodes,
followed by an unconditional branch. In a lot of cases, such a block (BB) can
be merged into their successor (Succ).

This merging is performed by TryToSimplifyUncondBranchFromEmptyBlock. It does
this by taking all phi nodes in the succesor block Succ and expanding them to
include the predecessors of BB. Furthermore, any phi nodes in BB are moved to
Succ and expanded to include the predecessors of Succ as well.

Before attempting this merge, CanPropagatePredecessorsForPHIs checks to see if
all phi nodes can be properly merged. All functional changes are made to
this function, only comments were updated in
TryToSimplifyUncondBranchFromEmptyBlock.

In the original code, CanPropagatePredecessorsForPHIs looks quite convoluted
and more like stack of checks added to handle different kinds of situations
than a comprehensive check. In particular the first check in the function did
some value checking for the case that BB and Succ have a common predecessor,
while the last check in the function simply rejected all cases where BB and
Succ have a common predecessor. The first check was still useful in the case
that BB did not contain any phi nodes at all, though, so it was not completely
useless.

Now, CanPropagatePredecessorsForPHIs is restructured to to look a lot more
similar to the code that actually performs the merge. Both functions now look
at the same phi nodes in about the same order. Any conflicts (phi nodes with
different values for the same source) that could arise from merging or moving
phi nodes are detected. If no conflicts are found, the merge can happen.

Apart from only restructuring the checks, two main changes in functionality
happened.

Firstly, the old code rejected blocks with common predecessors in most cases.
The new code performs some extra checks so common predecessors can be handled
in a lot of cases. Wherever common predecessors still pose problems, the
blocks are left untouched.

Secondly, the old code rejected the merge when values (phi nodes) from BB were
used in any other place than Succ. However, it does not seem that there is any
situation that would require this check. Even more, this can be proven.

Consider that BB is a block containing of a single phi node "%a" and a branch
to Succ. Now, since the definition of %a will dominate all of its uses, BB
will dominate all blocks that use %a. Furthermore, since the branch from BB to
Succ is unconditional, Succ will also dominate all uses of %a.

Now, assume that one predecessor of Succ is not dominated by BB (and thus not
dominated by Succ). Since at least one use of %a (but in reality all of them)
is reachable from Succ, you could end up at a use of %a without passing
through it's definition in BB (by coming from X through Succ). This is a
contradiction, meaning that our original assumption is wrong. Thus, all
predecessors of Succ must also be dominated by BB (and thus also by Succ).

This means that moving the phi node %a from BB to Succ does not pose any
problems when the two blocks are merged, and any use checks are not needed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51478 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7cbd8a3e92221437048b484d5ef9c0a22d0f8c58 16-May-2008 Gabor Greif <ggreif@gmail.com> API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51200 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b1dbcd886a4b5597a839f299054b78b33fb2d6df 15-May-2008 Gabor Greif <ggreif@gmail.com> Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51143 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ffba5821eee7b7a6139f9dfb06b8d306bf344a9d 28-Apr-2008 Chris Lattner <sabre@nondot.org> Fix PR2256, yet another miscompilation in simplifycfg of i
multiple return values.

Bill, please pull this into Tak.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50332 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
280a6e607d8eb7401749a92db624a82de47da777 25-Apr-2008 Nick Lewycky <nicholas@mxc.ca> Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50265 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c9e495c534b95a72502d1840293e66fa2e2d6882 24-Apr-2008 Chris Lattner <sabre@nondot.org> Split some code out of the main SimplifyCFG loop into its own function.
Fix said code to handle merging return instructions together correctly
when handling multiple return values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50199 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
051a950000e21935165db56695e35bade668193b 06-Apr-2008 Gabor Greif <ggreif@gmail.com> API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49277 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
882d87d168374ce790621e9ad4d7304b9dff0d78 11-Mar-2008 Dan Gohman <gohman@apple.com> Check to see if a two-entry PHI block can be simplified
before trying to merge the block into its predecessors.
This allows two-entry-phi-return.ll to be simplified
into a single basic block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48252 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9be3c97183f832d084bcf0fab82f7cd8aae08385 10-Mar-2008 Nick Lewycky <nicholas@mxc.ca> Turn unwind_to into "unwinds to".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48123 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3f4cc3101e4c6cccd2ecc2604205ff819fcfa40f 09-Mar-2008 Nick Lewycky <nicholas@mxc.ca> Firstly, having a BranchInst isn't exclusive with having an unwind_to.
Secondly, we have to check whether the branch is actually pointing to the block
with the unwind in it. We could have gotten here because of the unwind_to alone.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48099 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
db96ae9607ddca2e0627c8b87a160d61689663ca 09-Mar-2008 Nick Lewycky <nicholas@mxc.ca> A BB that unwind_to an "unwind" inst is that same as one that doesn't unwind_to
at all.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48096 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6af31aab63583e61b7c7b51bc285541750bd834f 09-Mar-2008 Nick Lewycky <nicholas@mxc.ca> Update the inliner and simplifycfg to handle unwind_to.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48086 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
07e6e56f57e8781a8d7bc601cc9034a3741d84c2 20-Feb-2008 Anton Korobeynikov <asl@math.spbu.ru> Make Transforms to be 4.3 warnings-clean


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47371 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8244243a31d636ce8838a81d4c402274fd391d2b 18-Feb-2008 Chris Lattner <sabre@nondot.org> switch simplifycfg from using vectors for most things to smallvectors,
this speeds it up 2.3% on eon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47261 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3d73bce2d01c7537042bb214edb5fc597f07bf74 03-Jan-2008 Chris Lattner <sabre@nondot.org> don't hoist FP additions into unconditional adds + selects. This
could theoretically introduce a trap, but is also a performance issue.
This speeds up ptrdist/ks by 8%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45533 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4ee451de366474b9c228b4e5fa573795a715216d 29-Dec-2007 Chris Lattner <sabre@nondot.org> Remove attribution from file headers, per discussion on llvmdev.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
01666bf74bd72d43426e62ac9d921a8db0a9179e 22-Dec-2007 Devang Patel <dpatel@apple.com> If succ has succ itself as one of the predecessors then do
not merge current bb and succ even if bb's terminator is
unconditional branch to succ.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45305 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dc024674ff96820d6020757b48d47f46d4c07db2 27-Nov-2007 Duncan Sands <baldrick@free.fr> Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls. This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully
a bitcode guru (who might that be? :) ) will fix it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44359 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
52eec548206d0b135b55ba52dd0e82e978f15ae5 01-Aug-2007 David Greene <greened@obbligato.org> New CallInst interface to address GLIBCXX_DEBUG errors caused by
indexing an empty std::vector.

Updates to all clients.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40660 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
fa73ea2d9fd785a214256ca44488407b26c5a3db 24-May-2007 Dan Gohman <gohman@apple.com> Minor comment cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37321 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
decb0ca18b0fc7ea071b67b005f639fd4c4404d9 17-Apr-2007 Chris Lattner <sabre@nondot.org> remove use of Instruction::getNext


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36199 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c9951231822215d6aea7a9b50947c18d8d745609 02-Apr-2007 Chris Lattner <sabre@nondot.org> reduce use of std::set


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35576 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ecb7a77885b174cf4d001a9b48533b3979e7810d 22-Mar-2007 Dan Gohman <gohman@apple.com> Change uses of Function::front to Function::getEntryBlock for readability.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35265 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e1c99d4c69d20731579ae462db39c3c1393f50fd 03-Mar-2007 Reid Spencer <rspencer@reidspencer.com> Make sorting of ConstantInt be APInt clean through use of ult function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34853 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
93e985f1b17aef62d58e3198a4604f9f6cfe8d19 13-Feb-2007 Chris Lattner <sabre@nondot.org> Eliminate use of ctors that take vectors.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34219 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
86cc42355593dd1689f7d58d56695c451215b02b 11-Feb-2007 Chris Lattner <sabre@nondot.org> simplify code by using Value::takeName


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34177 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
79066fa6acce02c97c714a5a6e151ed8a249721c 31-Jan-2007 Chris Lattner <sabre@nondot.org> Adjust #includes to match movement of constant folding code from transformutils to libanalysis.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
c10305743c313558405079452138f03124e87581 19-Jan-2007 Reid Spencer <rspencer@reidspencer.com> For PR1043:
This is the final patch for this PR. It implements some minor cleanup
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*

This also fixes PR1120.

Patch by Sheng Zhou.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33370 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
42a75517250017a52afb03a0ade03cbd49559fe5 15-Jan-2007 Chris Lattner <sabre@nondot.org> rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent. For example, there are now no longer any
instances of IntegerType that are not considered isInteger! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33225 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4d5f508318b2f666ed50a2ed5e49e4aa343a92d6 15-Jan-2007 Chris Lattner <sabre@nondot.org> Eliminate calls to isInteger, generalizing code and tightening checks as needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33218 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
579dca12c2cfd60bc18aaadbd5331897d48fec29 12-Jan-2007 Reid Spencer <rspencer@reidspencer.com> Implement review feedback for the ConstantBool->ConstantInt merge. Chris
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33110 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4fe16d607d11e29d742208894909733f5ad01f8f 11-Jan-2007 Reid Spencer <rspencer@reidspencer.com> Rename BoolTy as Int1Ty. Patch by Sheng Zhou.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33076 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6b6b6ef1677fa71b1072c2911b4c1f9524a558c9 11-Jan-2007 Zhou Sheng <zhousheng00@gmail.com> For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e4d87aa2de6e52952dca73716386db09aad5a8fd 23-Dec-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and
been replaced with ICmpInst and FCmpInst.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32751 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3da59db637a887474c1b1346c1f3ccf53b6c4663 27-Nov-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0d45a096cff7de5b487f7f7aac17684945dd0b93 26-Nov-2006 Bill Wendling <isanbard@gmail.com> Remove #include <iostream> and use llvm_* streams instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31925 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
822a87998387a4c52be5162523f09cc8e5e5afb7 18-Nov-2006 Chris Lattner <sabre@nondot.org> Do not convert massive blocks on phi nodes into select statements. Instead
only do these transformations if there are a small number of phi's.
This speeds up Ptrdist/ks from 2.35s to 2.19s on my mac pro.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31853 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3822ff5c71478c7c90a50ca57045fb676fcb5005 08-Nov-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
This patch converts the old SHR instruction into two instructions,
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31542 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3ed469ccd7b028a030b550d84b7336d146f5d8fa 02-Nov-2006 Reid Spencer <rspencer@reidspencer.com> For PR786:
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31380 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
120bc21576c33188992fdb5f22459d276f2fb0fc 29-Oct-2006 Chris Lattner <sabre@nondot.org> Fix SimplifyCFG/2006-10-29-InvokeCrash.ll, a crash compiling QT.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31284 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b83eb6447ba155342598f0fabe1f08f5baa9164a 20-Oct-2006 Reid Spencer <rspencer@reidspencer.com> For PR950:
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31063 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b74b1816305affe25da32c2f29532df41a23cd55 20-Oct-2006 Chris Lattner <sabre@nondot.org> Fix SimplifyCFG/2006-10-19-UncondDiv.ll by disabling a bad xform.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31061 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8cfe6335e40a1190e96e470b35a760a2bad7f650 03-Aug-2006 Chris Lattner <sabre@nondot.org> Fix PR867 (and maybe 868) and testcsae:
Transforms/SimplifyCFG/2006-08-03-Crash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29515 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7f2e1dd5d42a4411e5d4c89297952325239b4c2a 12-Jun-2006 Chris Lattner <sabre@nondot.org> Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28758 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a0fcc3ee3fb48553bcf12f471bdf24888a93a123 14-May-2006 Chris Lattner <sabre@nondot.org> remove some dead code identified by coverity


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28289 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
36a169e1a37898f1ff53b1ffa299d023814db43d 14-May-2006 Chris Lattner <sabre@nondot.org> remove dead variables


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
299520de7c5358a30dd7786cf9fe9f9a6ce37d94 18-Feb-2006 Chris Lattner <sabre@nondot.org> Fix Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26275 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
86a5484079abc8a20f24066aaf3f5efcccebb673 22-Jan-2006 Chris Lattner <sabre@nondot.org> Add explicit #includes of <iostream>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25509 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8e75ee212f95861138f813d095d581828ca111cb 03-Dec-2005 Chris Lattner <sabre@nondot.org> Fix SimplifyCFG/2005-12-03-IncorrectPHIFold.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24581 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7a66e686fe1406ea704e71e18cf99d4745d0b43d 04-Oct-2005 Chris Lattner <sabre@nondot.org> Clean up the code a bit. Use isInstructionTriviallyDead to be more aggressive
and more correct than use_empty(). This fixes PR635 and
SimplifyCFG/2005-10-02-InvokeSimplify.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23616 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b60e0815dfe7169255a92957ca8fc96ed866b85e 23-Sep-2005 Chris Lattner <sabre@nondot.org> remove some debugging code


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23411 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
263d1e469d849fb9e2087ea9fbd42b4bfcc98c24 23-Sep-2005 Chris Lattner <sabre@nondot.org> Fold two consequtive branches that share a common destination between them.
This implements SimplifyCFG/branch-fold.ll, and is useful on ?:/min/max heavy
code


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23410 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
055dc102e97316d423bd068f8b228d27fb93c90a 23-Sep-2005 Chris Lattner <sabre@nondot.org> simplify some logic further


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23408 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f58c1a578e63265abf46c395953fe8aa3f73e37c 23-Sep-2005 Chris Lattner <sabre@nondot.org> pull a bunch of logic out of SimplifyCFG into a helper fn


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23407 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e9487f0dc8c6d15cb257d5b49fa96ed436d32f5f 20-Sep-2005 Chris Lattner <sabre@nondot.org> Start threading across blocks with code in them, so long as the code does
not define a value that is used outside of it's block. This catches many
more simplifications, e.g. 854 in 176.gcc, 137 in vpr, etc.

This implements branch-phi-thread.ll:test3.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23397 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2e42e36698d5a34f1952ca3389f1973a6a1166f2 20-Sep-2005 Chris Lattner <sabre@nondot.org> Implement merging of blocks with the same condition if the block has multiple
predecessors. This implements branch-phi-thread.ll::test1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23395 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9c88d9816246d260b37cdc689f313c56aec6941e 20-Sep-2005 Chris Lattner <sabre@nondot.org> Reject a case we don't handle yet


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23393 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7e1ff8d2d923ad62a2776aac35fb88a26a7e83d3 20-Sep-2005 Chris Lattner <sabre@nondot.org> remove debugging code :-/


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23392 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
eaba3a194c23ecbfc5f3da439d1ef7a08eedf02c 20-Sep-2005 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/branch-phi-thread.ll, the most trivial case of threading
control across branches with determined outcomes. More generality to follow.
This triggers a couple thousand times in specint.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23391 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6306d07aa8cf71e3c7fed7f295665f53595473eb 03-Aug-2005 Chris Lattner <sabre@nondot.org> Fix Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll, a problem that
occurred while bugpointing another testcase


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22621 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1aad921c18edbc17fdc7167b6081ba49c4ea39f9 03-Aug-2005 Chris Lattner <sabre@nondot.org> Finally, add the required constraint checks to fix Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll
the right way


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22615 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dc88dbeafade56d8866f93ceb7438ea220ae2a9c 03-Aug-2005 Chris Lattner <sabre@nondot.org> Simplify some code, add the correct pred checks


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22613 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3b3efc77972e654c472cee8a3075e74a7d5f0cc8 03-Aug-2005 Chris Lattner <sabre@nondot.org> Refactor code out of PropagatePredecessorsForPHIs, turning it into a pure function with no side-effects


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22612 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d423b8b6ca3d2d21a8aa07a877d63e5dc45abc70 03-Aug-2005 Chris Lattner <sabre@nondot.org> use splice instead of remove/insert to avoid some symtab operations


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22611 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2bdcb56146279009f233933a101cb3dd54a951cd 03-Aug-2005 Chris Lattner <sabre@nondot.org> move two functions up in the file, use SafeToMergeTerminators to eliminate
some duplicated code


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22610 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7e66348cba4384d07b37ad1c186e67ba6d26babd 03-Aug-2005 Chris Lattner <sabre@nondot.org> Rip some code out of the main SimplifyCFG function into a subfunction and
call it from the only place it is live. No functionality changes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22609 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
17de4149655687f4ca5578e5ef96844019611c3b 03-Aug-2005 Chris Lattner <sabre@nondot.org> Disable this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050801/027345.html

This breaks real programs and only fixes an obscure regression testcase. A
real fix is in development.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22606 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f5e982daa8a83b4fcadccdf67b18889cfdcdf77d 03-Aug-2005 Chris Lattner <sabre@nondot.org> Change a place to use an arbitrary value instead of null, when possible


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22605 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1593ac259db20a5ed71b241c5e9c2796f5d34044 02-Aug-2005 Chris Lattner <sabre@nondot.org> This code was very close, but not quite right. It did not take into
consideration the case where a reference in an unreachable block could
occur. This fixes Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll,
something I ran into while bugpoint'ing another pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22584 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0289929c6212229980c9057853860ccfd3f81678 17-Jun-2005 Chris Lattner <sabre@nondot.org> Don't crash on: X = phi (X, X).

This fixes PR584 and Transforms/SimplifyCFG/2005-06-16-PHICrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22232 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
42eb7524ef3a994f184924e583871406cf5d1ed6 21-May-2005 Chris Lattner <sabre@nondot.org> Fix Transforms/SimplifyCFG/switch-simplify-crash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22158 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
16d0db2da8c274f98db4a89ca7a92f970d464b9a 14-May-2005 Chris Lattner <sabre@nondot.org> Make sure to preserve the calling convention when changing an invoke into
a call. This fixes Prolangs-C++/deriv2, kimwitu++, and Misc-C++/bigfib
on X86 with -enable-x86-fastcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22023 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
fd93908ae8b9684fe71c239e3c6cfe13ff6a2663 22-Apr-2005 Misha Brukman <brukman+llvm@gmail.com> Remove trailing whitespace


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bf5d4fb7d8ee4537955610ef9c48f7009418efc3 21-Apr-2005 Chris Lattner <sabre@nondot.org> Teach simplifycfg that setcc is cheap and non-trapping, so that it can
convert this:

%tmp.1 = seteq int %i, 0 ; <bool> [#uses=1]
br bool %tmp.1, label %shortcirc_done, label %shortcirc_next

shortcirc_next: ; preds = %entry
%tmp.4 = seteq int %j, 0 ; <bool> [#uses=1]
br label %shortcirc_done

shortcirc_done: ; preds = %shortcirc_next, %entry
%shortcirc_val = phi bool [ %tmp.4, %shortcirc_next ], [ true, %entry ] ; <bool> [#uses=1]

to this:
%tmp.1 = seteq int %i, 0 ; <bool> [#uses=1]
%tmp.4 = seteq int %j, 0 ; <bool> [#uses=1]
%shortcirc_val = select bool %tmp.1, bool true, bool %tmp.4 ; <bool> [#uses=1]

... which is later simplified by instcombine into an or.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21388 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
151c80be8180a7a0aa1594848699aa6b678b3998 12-Apr-2005 Chris Lattner <sabre@nondot.org> Get rid of this for_each loop


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21253 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
da895d63377b421dc50117befb2bec80d2973526 27-Feb-2005 Chris Lattner <sabre@nondot.org> Fix spelling, patch contributed by Gabor Greif!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20343 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
be54dcc8a9d14592e324d6e6ae1322782e17f09f 26-Feb-2005 Chris Lattner <sabre@nondot.org> remove extraneous cast


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20334 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
623369ac5669a3667a94a3cbba342dea78845615 24-Feb-2005 Chris Lattner <sabre@nondot.org> Implement Transforms/SimplifyCFG/switch_thread.ll

This does a simple form of "jump threading", which eliminates CFG edges that
are provably dead. This triggers 90 times in the external tests, and
eliminating CFG edges is always always a good thing! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20300 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
378805969ea928b91aa321746031a8f51667a783 29-Jan-2005 Chris Lattner <sabre@nondot.org> switchinst ctor now takes a hint for the number of cases that it will have.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19898 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
13b2f764c041e15af3d6033826deb9c7e669ca97 01-Jan-2005 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/DeadSetCC.ll

SimplifyCFG is one of those passes that we use for final cleanup: it should
not rely on other passes to clean up its garbage. This fixes the "why are
trivially dead setcc's in the output of gccas" problem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19212 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7613437db954abafd1230c961e87872df5721957 10-Dec-2004 Chris Lattner <sabre@nondot.org> Fix Regression/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll,
and the failure on make_dparser last night.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18766 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0f535c6fa8b03491dc110feb65d78922ee29d1fc 30-Nov-2004 Chris Lattner <sabre@nondot.org> Squelch warning


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18381 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6f9e5715298055c63178557f891d28f266f08814 30-Nov-2004 Chris Lattner <sabre@nondot.org> Alkis noticed that this variable is dead. Thanks!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18369 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
37dc938bbe556a9414d063196d367c2f75d07d95 30-Nov-2004 Chris Lattner <sabre@nondot.org> If we have something like this:

if (x) {
code
...
} else {
code
...
}

Turn it into:

code
if (x) {
...
} else {
...
}

This reduces code size and in some common cases allows us to completely
eliminate the conditional. This turns several if/then/else blocks in loops
into straightline code in 179.art, turning the loops into single basic blocks
(good for modsched even!).

Maybe now brg will leave me alone ;-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18366 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bfd3e527015f55d144adf44af94028db61dd6269 01-Nov-2004 Chris Lattner <sabre@nondot.org> Do not compute the predecessor list for a block unless we need it.
This speeds up simplifycfg on this program, from 44.87s to 0.29s (with
a profiled build):

#define CL0(a) case a: goto c;
#define CL1(a) CL0(a##0) CL0(a##1) CL0(a##2) CL0(a##3) CL0(a##4) CL0(a##5) \
CL0(a##6) CL0(a##7) CL0(a##8) CL0(a##9)
#define CL2(a) CL1(a##0) CL1(a##1) CL1(a##2) CL1(a##3) CL1(a##4) CL1(a##5) \
CL1(a##6) CL1(a##7) CL1(a##8) CL1(a##9)
#define CL3(a) CL2(a##0) CL2(a##1) CL2(a##2) CL2(a##3) CL2(a##4) CL2(a##5) \
CL2(a##6) CL2(a##7) CL2(a##8) CL2(a##9)
#define CL4(a) CL3(a##0) CL3(a##1) CL3(a##2) CL3(a##3) CL3(a##4) CL3(a##5) \
CL3(a##6) CL3(a##7) CL3(a##8) CL3(a##9)

void f();

void a() {
int b;
c: switch (b) {
CL4(1)
}
}

This testcase is contrived to expose N^2 behavior, but this patch should speedup
simplifycfg on any programs that use large switch statements. This testcase
comes from GCC PR17895.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17389 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4e073a871b208a2c9dfa004b3a93fb26f96daa17 22-Oct-2004 Reid Spencer <rspencer@reidspencer.com> Eliminate compilation warning on uninitialized variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17163 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
698f96f7c81e45292ae4f5d76b8e06c88a88a71f 18-Oct-2004 Chris Lattner <sabre@nondot.org> Simplify code by deleting instructions that preceed unreachable instructions.
Simplify code by simplifying terminators that branch to blocks that start
with an unreachable instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17116 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
9c07866ef861e072395306e9811c329c7fe5bbe8 14-Oct-2004 Chris Lattner <sabre@nondot.org> When converting phi nodes into select instructions, we shouldn't promote PHI
nodes unless we KNOW that we are able to promote all of them.

This fixes: test/Regression/Transforms/SimplifyCFG/PhiNoEliminate.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16973 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0ed7f42c1b6e6dab8b531d7f2fa45ed2fe310849 29-Sep-2004 Chris Lattner <sabre@nondot.org> Do not insert trivially dead select instructions, which allows us to
potentially fold more in one pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16583 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2da5c3dda6f5b9c4ec6d55008d33327764364bd4 15-Sep-2004 Reid Spencer <rspencer@reidspencer.com> Convert code to compile with vc7.1.

Patch contributed by Paolo Invernizzi. Thanks Paolo!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16368 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
20aa474f8fbebde588edc101b90e834df28ce4ce 03-Sep-2004 Alkis Evlogimenos <alkis@evlogimenos.com> Fixes to make LLVM compile with vc7.1.

Patch contributed by Paolo Invernizzi!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
551ccae044b0ff658fe629dd67edd5ffe75d10e8 02-Sep-2004 Reid Spencer <rspencer@reidspencer.com> Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7848e68c1635ccba5a08d55314d4e5aed5ab54b9 21-Jul-2004 Brian Gaeke <gaeke@uiuc.edu> These files don't need to include <iostream> since they include "Support/Debug.h".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15089 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
af17b1df84c31cb4f9a09213db9aa3c1e8b910ea 20-Jul-2004 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/BrUnwind.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15022 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
460f16c6253928519689e882a4dbb7f236f33294 18-Jul-2004 Reid Spencer <rspencer@reidspencer.com> bug 122:
- Minimize redundant isa<GlobalValue> usage


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14948 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
30b434476796cd4a85c02914687d22f2e5ec95ca 15-Jul-2004 Chris Lattner <sabre@nondot.org> Progress on PR341


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14840 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
954da37bb492b519f5c31dc360f2a142567e08b4 04-Jul-2004 Reid Spencer <rspencer@reidspencer.com> Add #include <iostream> since Value.h does not #include it any more.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14622 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2636c1be17c384993c25e9fe1e61a76cee157aa1 21-Jun-2004 Chris Lattner <sabre@nondot.org> *FINALLY* Fix a really nasty nondeterministic bug that has been haunting us
since May 1st. In this code, the pred iterator was being invalidated sometimes
causing the wrong entries to be added to PHI nodes.

The fix for this is to defererence and safe the *PI value before we hack on
branch instructions, which changes use/def chains, which SOMETIMES invalidates
the iterator.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14278 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
218a8223e62c41ae6318e28e8f4c672fcfbb5082 20-Jun-2004 Chris Lattner <sabre@nondot.org> Add some DEBUG output to the simplifycfg routines
Fix another non-deterministic behavior, this one should actually speed up the
code though as it was doing silly things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14258 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1654cff8e80acdddf5e5f2261595007878924aac 19-Jun-2004 Chris Lattner <sabre@nondot.org> Do not sort by the address of LLVM ConstantInt* objects. This produces
nondeterministic results that depend on where these objects land in memory.
Instead, sort by the value of the constant, which is stable.

Before this patch, the -simplifycfg pass run from two different compilers
could cause different code to be generated, though it was semantically the
same:

@@ -12258,8 +12258,8 @@
%s_addr.1 = phi sbyte* [ %s, %entry ], [ %inc.0, %no_exit ] ; <sbyte*> [#uses=5]
%tmp.1 = load sbyte* %s_addr.1 ; <sbyte> [#uses=1]
switch sbyte %tmp.1, label %no_exit [
- sbyte 0, label %loopexit
sbyte 46, label %loopexit
+ sbyte 0, label %loopexit
]

We need to stomp all of this stuff out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14243 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bdcc0b8c55041ff89b59f0ea2cdbc2ac02f26a3d 02-May-2004 Chris Lattner <sabre@nondot.org> Do not clone arbitrary condition instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13316 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
12fe2b1b82fe825d023f40a98931381e84fbc9d3 02-May-2004 Chris Lattner <sabre@nondot.org> Do not infinitely "unroll" single BB loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13315 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a1f79fb08b92801d4ab3cb32fe0bd9d12dfb3954 02-May-2004 Chris Lattner <sabre@nondot.org> Dont' merge terminators that are needed to select PHI node values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13312 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e67fa05036f634a4ec1e0893033c89250eb58954 02-May-2004 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/branch-cond-merge.ll
Turning "if (A < B && B < C)" into "if (A < B & B < C)"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13311 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
951fdb9764ea7abd1f409712636cf80a86140d90 02-May-2004 Chris Lattner <sabre@nondot.org> Fix my missing parens


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
92da2c2053feda379726f34b227ca6ac3bcdaab4 02-May-2004 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/branch-cond-prop.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13306 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
570751c2a7d8851bc61e408746a903b0253d2d21 10-Apr-2004 Chris Lattner <sabre@nondot.org> Fold code like:
if (C)
V1 |= V2;

into:
Vx = V1 | V2;
V1 = select C, V1, Vx

when the expression can be evaluated unconditionally and is *cheap* to
execute. This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:

int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;

void mux(void) {
output =
(in0 ? 0x00000001 : 0) | (in1 ? 0x00000002 : 0) |
(in2 ? 0x00000004 : 0) | (in3 ? 0x00000008 : 0) |
(in4 ? 0x00000010 : 0) | (in5 ? 0x00000020 : 0) |
(in6 ? 0x00000040 : 0) | (in7 ? 0x00000080 : 0) |
(in8 ? 0x00000100 : 0) | (in9 ? 0x00000200 : 0) |
(in10 ? 0x00000400 : 0) | (in11 ? 0x00000800 : 0) |
(in12 ? 0x00001000 : 0) | (in13 ? 0x00002000 : 0) |
(in14 ? 0x00004000 : 0) | (in15 ? 0x00008000 : 0) ;
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12798 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7aa773bc07fd6125c0e4a965760fa06c5679cc8d 02-Apr-2004 Chris Lattner <sabre@nondot.org> Fix the obvious bug in my previous checkin


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12618 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
147af6b75f2e9a71baf46a12cf1312f627f1590b 02-Apr-2004 Chris Lattner <sabre@nondot.org> Implement Transforms/SimplifyCFG/return-merge.ll

This actually causes us to turn code like:

return C ? A : B;

into a select instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12617 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
552112f2f8702f2cba8cb5775bc24c3e02ba265c 30-Mar-2004 Chris Lattner <sabre@nondot.org> Now that all the code generators support the select instruction, and the instcombine
pass can eliminate many nasty cases of them, start generating them in the optimizers


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12545 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
7acd1ccb8a61217f8c06b5fbdcc9785437bd0989 17-Mar-2004 Chris Lattner <sabre@nondot.org> Fix compilation of mesa, which I broke earlier today


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12465 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
4bebf08d152d84970d250feec72fb734cb8a5316 16-Mar-2004 Chris Lattner <sabre@nondot.org> Do not copy gigantic switch instructions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12441 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
542f149f00afaf1125b8f2040cad4fe05ed24c3a 28-Feb-2004 Chris Lattner <sabre@nondot.org> Implement switch->br and br->switch folding by ripping out the switch->switch
and br->br code and generalizing it. This allows us to compile code like this:

int test(Instruction *I) {
if (isa<CastInst>(I))
return foo(7);
else if (isa<BranchInst>(I))
return foo(123);
else if (isa<UnwindInst>(I))
return foo(1241);
else if (isa<SetCondInst>(I))
return foo(1);
else if (isa<VAArgInst>(I))
return foo(42);
return foo(-1);
}

into:

int %_Z4testPN4llvm11InstructionE("struct.llvm::Instruction"* %I) {
entry:
%tmp.1.i.i.i.i.i.i.i = getelementptr "struct.llvm::Instruction"* %I, long 0, ubyte 4 ; <uint*> [#uses=1]
%tmp.2.i.i.i.i.i.i.i = load uint* %tmp.1.i.i.i.i.i.i.i ; <uint> [#uses=2]
%tmp.2.i.i.i.i.i.i = seteq uint %tmp.2.i.i.i.i.i.i.i, 27 ; <bool> [#uses=0]
switch uint %tmp.2.i.i.i.i.i.i.i, label %endif.0 [
uint 27, label %then.0
uint 2, label %then.1
uint 5, label %then.2
uint 14, label %then.3
uint 15, label %then.3
uint 16, label %then.3
uint 17, label %then.3
uint 18, label %then.3
uint 19, label %then.3
uint 32, label %then.4
]
...

As well as handling the cases in 176.gcc and many other programs more effectively.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11964 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f2dbf50efa2690396e5e46c2a1a2ca80f4c701e9 26-Feb-2004 Chris Lattner <sabre@nondot.org> turn things like:
if (X == 0 || X == 2)

...where the comparisons and branches are in different blocks... into a switch
instruction. This comes up a lot in various programs, and works well with
the switch/switch merging code I checked earlier. For example, this testcase:

int switchtest(int C) {
return C == 0 ? f(123) :
C == 1 ? f(3123) :
C == 4 ? f(312) :
C == 5 ? f(1234): f(444);
}

is converted into this:
switch int %C, label %cond_false.3 [
int 0, label %cond_true.0
int 1, label %cond_true.1
int 4, label %cond_true.2
int 5, label %cond_true.3
]

instead of a whole bunch of conditional branches.

Admittedly the code is ugly, and incomplete. To be complete, we need to add
br -> switch merging and switch -> br merging. For example, this testcase:

struct foo { int Q, R, Z; };
#define A (X->Q+X->R * 123)
int test(struct foo *X) {
return A == 123 ? X1() :
A == 12321 ? X2():
(A == 111 || A == 222) ? X3() :
A == 875 ? X4() : X5();
}

Gets compiled to this:
switch int %tmp.7, label %cond_false.2 [
int 123, label %cond_true.0
int 12321, label %cond_true.1
int 111, label %cond_true.2
int 222, label %cond_true.2
]
...
cond_false.2: ; preds = %entry
%tmp.52 = seteq int %tmp.7, 875 ; <bool> [#uses=1]
br bool %tmp.52, label %cond_true.3, label %cond_false.3

where the branch could be folded into the switch.

This kind of thing occurs *ALL OF THE TIME*, especially in programs like
176.gcc, which is a horrible mess of code. It contains stuff like *shudder*:

#define SWITCH_TAKES_ARG(CHAR) \
( (CHAR) == 'D' \
|| (CHAR) == 'U' \
|| (CHAR) == 'o' \
|| (CHAR) == 'e' \
|| (CHAR) == 'u' \
|| (CHAR) == 'I' \
|| (CHAR) == 'm' \
|| (CHAR) == 'L' \
|| (CHAR) == 'A' \
|| (CHAR) == 'h' \
|| (CHAR) == 'z')

and

#define CONST_OK_FOR_LETTER_P(VALUE, C) \
((C) == 'I' ? SMALL_INTVAL (VALUE) \
: (C) == 'J' ? SMALL_INTVAL (-(VALUE)) \
: (C) == 'K' ? (unsigned)(VALUE) < 32 \
: (C) == 'L' ? ((VALUE) & 0xffff) == 0 \
: (C) == 'M' ? integer_ok_for_set (VALUE) \
: (C) == 'N' ? (VALUE) < 0 \
: (C) == 'O' ? (VALUE) == 0 \
: (C) == 'P' ? (VALUE) >= 0 \
: 0)

and

#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
{ \
if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
copy_to_mode_reg (SImode, XEXP (X, 1))); \
if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
copy_to_mode_reg (SImode, XEXP (X, 0))); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
force_operand (XEXP (X, 0), 0)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
force_operand (XEXP (X, 1), 0)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
(X) = gen_rtx (PLUS, Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
XEXP (X, 1)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
(X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
force_operand (XEXP (X, 1), NULL_RTX)); \
if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
|| GET_CODE (X) == LABEL_REF) \
(X) = legitimize_address (flag_pic, X, 0, 0); \
if (memory_address_p (MODE, X)) \
goto WIN; }

and others. These macros get used multiple times of course. These are such
lovely candidates for macros, aren't they? :)

This code also nicely handles LLVM constructs that look like this:

if (isa<CastInst>(I))
...
else if (isa<BranchInst>(I))
...
else if (isa<SetCondInst>(I))
...
else if (isa<UnwindInst>(I))
...
else if (isa<VAArgInst>(I))
...

where the isa can obviously be a dyn_cast as well. Switch instructions are a
good thing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11870 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
8e509dd5e81e92a466580ab4022994079952cca9 24-Feb-2004 Chris Lattner <sabre@nondot.org> If a block is made dead, make sure to promptly remove it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11799 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d52c261cf801331bebda9711acd54c7c5377a6bd 24-Feb-2004 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/switch_switch_fold.ll
This case occurs many times in various benchmarks, especially when combined
with the previous patch. This allows it to get stuff like:
if (X == 4 || X == 3)
if (X == 5 || X == 8)

and

switch (X) {
case 4: case 5: case 6:
if (X == 4 || X == 5)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11797 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e14ea0804afba2ac5824507571a220d05b0aa21d 24-Feb-2004 Chris Lattner <sabre@nondot.org> Rearrange code a bit


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11793 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
0d56008f53587531718ec36af82cc24576580b36 24-Feb-2004 Chris Lattner <sabre@nondot.org> Implement: test/Regression/Transforms/SimplifyCFG/switch_create.ll

This turns code like this:
if (X == 4 | X == 7)
and
if (X != 4 & X != 7)
into switch instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11792 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
19831ec8531b0710629c1b0a8c0323e70ae0ef07 16-Feb-2004 Chris Lattner <sabre@nondot.org> Implement test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll,
see the testcase for the reasoning.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11496 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
723c66d4c0aa081ea8fa221617c5097e31333e6c 11-Feb-2004 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/PhiEliminate.ll

Having a proper 'select' instruction would allow the elimination of a lot
of the special case cruft in this patch, but we don't have one yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2355f948c59a2b4a78667d6898333524f9b78f27 11-Feb-2004 Chris Lattner <sabre@nondot.org> The hasConstantReferences predicate always returns false.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11301 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
aeb2a1d70807aa626f335fb23d47bc604ffeaa15 08-Feb-2004 Chris Lattner <sabre@nondot.org> rename the "exceptional" destination of an invoke instruction to the 'unwind' dest


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11202 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
f7703df4968084c18c248c1feea9961c19a32e6a 09-Jan-2004 Chris Lattner <sabre@nondot.org> Finegrainify namespacification


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10727 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
d0fde30ce850b78371fd1386338350591f9ff494 11-Nov-2003 Brian Gaeke <gaeke@uiuc.edu> Put all LLVM code into the llvm namespace, as per bug 109.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9903 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
b576c94c15af9a440f69d9d03c2afead7971118c 20-Oct-2003 John Criswell <criswell@uiuc.edu> Added LLVM project notice to the top of every C++ source file.
Header files will be on the way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9298 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
cf00c4ab3ba308d45d98c5ccab87362cf802facb 10-Oct-2003 Misha Brukman <brukman+llvm@gmail.com> Fix spelling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9027 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
ee5457cbe88b7f691f774de8515d9a94226d1b00 08-Sep-2003 Chris Lattner <sabre@nondot.org> Eliminate support for the llvm.unwind intrinisic, using the Unwind instruction instead


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8411 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
dc3602bf0d27aac80e08ef8823967850acd05a14 24-Aug-2003 Chris Lattner <sabre@nondot.org> Implement SimplifyCFG/InvokeEliminate.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8126 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
694e37f08a7c09ccc24642532106295cf7b3a1e3 17-Aug-2003 Chris Lattner <sabre@nondot.org> Fix bug: SimplifyCFG/2003-08-17-BranchFoldOrdering.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7921 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
122558b05bb753894adc7d925f69dc9ddfa586fa 05-Aug-2003 Chris Lattner <sabre@nondot.org> Fix bug: SimplifyCFG/2003-08-05-InvokeCrash.ll
Fix bug: SimplifyCFG/2003-08-05-MishandleInvoke.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7599 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e408e25132b8de8c757db1e3ddcd70432dfeb24d 23-Apr-2003 Chris Lattner <sabre@nondot.org> Remove unnecesary &*'s


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5872 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3a43837d859bddfdc24bc0c2d87669a6300c7bfe 07-Mar-2003 Chris Lattner <sabre@nondot.org> Fix bug: SimplifyCFG/2003-03-07-DominateProblem.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5722 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
46a5f1f6e4a3be3d53b4e0016b78d108a2353f4c 05-Mar-2003 Chris Lattner <sabre@nondot.org> Implement CFGSimplify/PhiBlockMerge*.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5702 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
e2ca540e7c29703c3b943a96fed7e383c7bd35c0 05-Mar-2003 Chris Lattner <sabre@nondot.org> Implement testcase CFGSimplify/EqualPHIEdgeBlockMerge.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5699 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
a3bbcb5b664c1c851b87392119608901b2e1837c 30-Oct-2002 Misha Brukman <brukman+llvm@gmail.com> Fix spelling of `propagate'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4423 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
bb190ac8dafdcc5e604da3695987d69ee8632195 08-Oct-2002 Chris Lattner <sabre@nondot.org> Changes to support PHINode::removeIncoming changes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4079 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
929b2c6900e20859f338d808a1a89ffc5b3563bb 24-Sep-2002 Chris Lattner <sabre@nondot.org> Fix bug: SimplifyCFG/2002-09-24-PHIAssertion.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3913 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
3abb95df01ff2ea5a6a35a1b47351072d4cb4c73 24-Sep-2002 Chris Lattner <sabre@nondot.org> Minor cleanups


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3904 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
91b65c0b42b3d5dece246bdb366441d6f5593396 29-Jul-2002 Chris Lattner <sabre@nondot.org> Allow folding of basic blocks that have PHI nodes in them, fixing "bug":
test/Regression/Transforms/SimplifyCFG/2002-06-24-PHINode.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3128 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
18961504fc2b299578dba817900a0696cf3ccc4d 25-Jun-2002 Chris Lattner <sabre@nondot.org> *** empty log message ***


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2777 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
01d1ee3a4c4153c80c3c415e4612db6c27e37acb 21-May-2002 Chris Lattner <sabre@nondot.org> Add implementation of SimplifyCFG


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2701 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/Utils/SimplifyCFG.cpp