Commit Graph

4562 Commits

Author SHA1 Message Date
Cameron Zwarich
8c3527e7a4 Stop reallocating SunkAddrs for each basic block. When we move to an instruction
worklist, the key will need to become std::pair<BasicBlock*, Value*>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122932 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 00:42:50 +00:00
Cameron Zwarich
073057f0d0 Add some more statistics to CodeGenPrepare.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122891 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 17:47:38 +00:00
Cameron Zwarich
31ff1333e0 Add some stats to CodeGenPrepare to make it easier to speed it up without
regressing code quality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122887 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 17:27:27 +00:00
Cameron Zwarich
1901925b78 Use pop_back_val instead of back followed by pop_back.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122876 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 16:08:47 +00:00
Cameron Zwarich
08602ab1b4 Use a worklist for later iterations just like ordinary instsimplify. The next
step is to only process instructions in subloops if they have been modified by
an earlier simplification.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122869 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 05:47:47 +00:00
Cameron Zwarich
e389ab16f3 Change LoopInstSimplify back to a LoopPass. It revisits subloops rather than
skipping them, but it should probably use a worklist and only revisit those
instructions in subloops that have actually changed. It should probably also
use a worklist after the first iteration like instsimplify now does. Regardless,
it's only 0.3% of opt -O2 time on 403.gcc if it replaces the instcombine placed
in the middle of the loop passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122868 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 05:15:53 +00:00
Owen Anderson
2cf7537dc6 Don't bother value numbering instructions with void types in GVN. In theory this should allow us to insert
fewer things into the value numbering maps, but any speedup is beneath the noise threshold on my machine
on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122844 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 22:15:21 +00:00
Owen Anderson
b1602abe63 Complete the NumberTable --> LeaderTable rename.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122828 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 19:29:46 +00:00
Owen Anderson
a0709acd6f Fix typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122827 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 19:25:18 +00:00
Owen Anderson
465942d008 Prune #include's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122826 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 19:24:57 +00:00
Owen Anderson
7a75d6108e Clarify terminology, settling on referring to what was the "number table" as the "leader table", and
rename methods to make it much more clear what they're doing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122823 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 19:13:25 +00:00
Owen Anderson
680ac4ff4e When removing a value from GVN's leaders list, don't drop the Next pointer in a corner case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122822 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 19:10:54 +00:00
Owen Anderson
c2146a6abc Branch instructions don't produce values, so there's no need to generate a value number for them. This
avoids adding them to the various value numbering tables, resulting in a minor (~3%) speedup for GVN
on 40.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122819 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 18:54:18 +00:00
Owen Anderson
2802c7536f Remove commented out code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122817 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 18:22:08 +00:00
Cameron Zwarich
64573aecb6 Switch to the new style of asterisk placement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 18:19:19 +00:00
Chris Lattner
e41d3c015c Teach loop-idiom to turn a loop containing a memset into a larger memset
when safe.

The testcase is basically this nested loop:
void foo(char *X) {
  for (int i = 0; i != 100; ++i) 
    for (int j = 0; j != 100; ++j)
      X[j+i*100] = 0;
}

which gets turned into a single memset now.  clang -O3 doesn't optimize
this yet though due to a phase ordering issue I haven't analyzed yet.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122806 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 07:46:33 +00:00
Chris Lattner
b7e9ef0ed1 restructure this a bit. Initialize the WeakVH with "I", the
instruction *after* the store.  The store will always be deleted
if the transformation kicks in, so we'd do an N^2 scan of every
loop block.  Whoops.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122805 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 07:27:30 +00:00
Cameron Zwarich
95bb00414e Avoid finding loop back edges when we are not splitting critical edges in
CodeGenPrepare (which is the default behavior).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122801 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 04:43:31 +00:00
Cameron Zwarich
a1cb585384 Address most of Duncan's review comments. Also, make LoopInstSimplify a simple
FunctionPass. It probably doesn't have a reason to be a LoopPass, as it will
probably drop the simple fixed point and either use RPO iteration or Duncan's
approach in instsimplify of only revisiting instructions that have changed.

The next step is to preserve LoopSimplify. This looks like it won't be too hard,
although the pass manager doesn't actually seem to respect when non-loop passes
claim to preserve LCSSA or LoopSimplify. This will have to be fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122791 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 00:12:46 +00:00
Chris Lattner
7c90b90f4e use the very-handy getTruncateOrZeroExtend helper function, and
stop setting NSW: signed overflow is possible.  Thanks to Dan
for pointing these out.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122790 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 00:06:55 +00:00
Owen Anderson
6f96b275b6 Fix comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122788 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 23:51:56 +00:00
Owen Anderson
392249fcf3 Use the new addEscapingValue callback to update GlobalsModRef when GVN adds PHIs of GEPs. For the moment,
have GlobalsModRef handle this conservatively by simply removing the value from its maps.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122787 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 23:51:43 +00:00
Chris Lattner
e508dd4c75 Duncan deftly points out that readnone functions aren't
invalidated by stores, so they can be handled as 'simple'
operations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122785 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 23:38:13 +00:00
Owen Anderson
30f4a559d7 Simplify GVN's value expression structure, allowing the elimination of a lot of
almost-but-not-quite-identical code.  No intended functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122760 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 19:00:11 +00:00
Chris Lattner
10b883b13f stength reduce my previous patch a bit. The only instructions
that are allowed to have metadata operands are intrinsic calls,
and the only ones that take metadata currently return void.
Just reject all void instructions, which should not be value
numbered anyway.  To future proof things, add an assert to the
getHashValue impl for calls to check that metadata operands 
aren't present.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122759 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 18:43:03 +00:00
Chris Lattner
a12ba39a1d fix PR8895: metadata operands don't have a strong use of their
nested values, so they can change and drop to null, which can
change the hash and cause havok.

It turns out that it isn't a good idea to value number stuff
with metadata operands anyway, so... don't.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122758 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 18:28:15 +00:00
Cameron Zwarich
7cb4fa20b5 Switch a worklist in CodeGenPrepare to SmallVector and increase the inline
capacity on the Visited SmallPtrSet. On 403.gcc, this is about a 4.5% speedup of
CodeGenPrepare time (which itself is 10% of time spent in the backend).

This is progress towards PR8889.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122741 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 06:33:01 +00:00
Chris Lattner
75637154c3 earlycse can do trivial with-a-block dead store
elimination as well.  This deletes 60 stores in 176.gcc
that largely come from bitfield code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122736 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 04:17:24 +00:00
Chris Lattner
71230acbbe switch the load table to use a recycling bump pointer allocator,
speeding earlycse up by 6%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 03:53:50 +00:00
Chris Lattner
ef87fc2e0a now that loads are in their own table, we can implement
store->load forwarding.  This allows EarlyCSE to zap 600 more
loads from 176.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122732 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 03:46:34 +00:00
Chris Lattner
85db61066a split loads and calls into separate tables. Loads are now just indexed
by their pointer instead of using MemoryValue to wrap it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122731 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 03:41:27 +00:00
Chris Lattner
a60a8b0eb7 various cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122729 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 03:28:23 +00:00
Chris Lattner
8e7f0d70c7 Teach EarlyCSE to do trivial CSE of loads and read-only calls.
On 176.gcc, this catches 13090 loads and calls, and increases the
number of simple instructions CSE'd from 29658 to 36208.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122727 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 03:18:43 +00:00
Chris Lattner
f19745947d rename InstValue to SimpleValue, add some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122725 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 02:20:48 +00:00
Michael J. Spencer
f0da7299fa CMake: Add missing source file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122724 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 02:13:05 +00:00
Chris Lattner
82dcd5edd2 Allocate nodes for the scoped hash table from a recyling bump pointer
allocator.  This speeds up early cse by about 20%


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122723 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 01:42:46 +00:00
Chris Lattner
d957c71791 reduce redundancy in the hashing code and other misc cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122720 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 01:10:08 +00:00
Cameron Zwarich
832f61117d Add a new loop-instsimplify pass, with the intention of replacing the instance
of instcombine that is currently in the middle of the loop pass pipeline. This
commit only checks in the pass; it will hopefully be enabled by default later.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122719 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 00:25:16 +00:00
Chris Lattner
67678c8307 fix some pastos
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122718 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 23:29:58 +00:00
Chris Lattner
91139ccd99 add DEBUG and -stats output to earlycse.
Teach it to CSE the rest of the non-side-effecting instructions.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122716 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 23:19:45 +00:00
Chris Lattner
cc9eab26b3 Enhance earlycse to do CSE of casts, instsimplify and die.
Add a testcase.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122715 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 23:04:14 +00:00
Chris Lattner
9fc5cdf77c split dom frontier handling stuff out to its own DominanceFrontier header,
so that Dominators.h is *just* domtree.  Also prune #includes a bit.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122714 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 22:09:33 +00:00
Chris Lattner
12be936cc9 sketch out a new early cse pass. No functionality yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122713 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 21:47:05 +00:00
Chris Lattner
63f9c3c49a fix a miscompilation of tramp3d-v4: when forming a memcpy, we have to make
sure that the loop we're promoting into a memcpy doesn't mutate the input
of the memcpy.  Before we were just checking that the dest of the memcpy
wasn't mod/ref'd by the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122712 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 21:14:18 +00:00
Chris Lattner
8e08e73f0e If a loop iterates exactly once (has backedge count = 0) then don't
mess with it.  We'd rather peel/unroll it than convert all of its 
stores into memsets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122711 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 20:24:21 +00:00
Chris Lattner
62c50fdf69 enhance loop idiom recognition to scan *all* unconditionally executed
blocks in a loop, instead of just the header block.  This makes it more
aggressive, able to handle Duncan's Ada examples.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122704 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 19:01:03 +00:00
Chris Lattner
81a866d615 make inSubLoop much more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122703 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 18:53:08 +00:00
Chris Lattner
83fc584ea8 rip out isExitBlockDominatedByBlockInLoop, calling DomTree::dominates instead.
isExitBlockDominatedByBlockInLoop is a relic of the days when domtree was 
*just* a tree and didn't have DFS numbers.  Checking DFS numbers is faster
and easier than "limiting the search of the tree".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122702 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 18:45:39 +00:00
Chris Lattner
bdce5720ad add a list of opportunities for future improvement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122701 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 18:32:09 +00:00
Chris Lattner
cf078f2b20 Allow loop-idiom to run on multiple BB loops, but still only scan the loop
header for now for memset/memcpy opportunities.  It turns out that loop-rotate
is successfully rotating loops, but *DOESN'T MERGE THE BLOCKS*, turning "for 
loops" into 2 basic block loops that loop-idiom was ignoring.

With this fix, we form many *many* more memcpy and memsets than before, including
on the "history" loops in the viterbi benchmark, which look like this:

        for (j=0; j<MAX_history; ++j) {
          history_new[i][j+1] = history[2*i][j];
        }

Transforming these loops into memcpy's speeds up the viterbi benchmark from
11.98s to 3.55s on my machine.  Woo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122685 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 07:58:36 +00:00
Chris Lattner
6b04160dd8 remove debugging code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122683 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 07:37:13 +00:00
Chris Lattner
4ce31fb574 add some -stats output.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122682 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 07:36:44 +00:00
Chris Lattner
d9e079706e improve loop rotation to use CodeMetrics to analyze the
size of a loop header instead of its own code size estimator.
This allows it to handle bitcasts etc more precisely.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122681 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 07:35:53 +00:00
Chris Lattner
e2c4392091 teach loop idiom recognition to form memcpy's from simple loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122678 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 03:37:56 +00:00
Chris Lattner
bafa117e8f add a validity check that was missed, fixing a crash on the
new testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122662 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-01 20:12:04 +00:00
Chris Lattner
a64cbf067d improve validity check to handle constant-trip-count loops more
aggressively.  In practice, this doesn't help anything though,
see the todo.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122660 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-01 19:54:22 +00:00
Chris Lattner
30980b6815 implement the "no aliasing accesses in loop" safety check. This pass
should be correct now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122659 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-01 19:39:01 +00:00
Chris Lattner
95ae676bc8 simplify this, isBytewiseValue handles the extra check. We still
check for "multiple of a byte" in size to make it clear that the
>> 3 below is safe.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122604 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-28 18:53:48 +00:00
Duncan Sands
7922d34b60 Silence gcc warning about an unused variable when doing a release build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122593 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-28 09:41:15 +00:00
Chris Lattner
2e12f1ac6e fix some issues Frits noticed, add AliasAnalysis as a dependency
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122585 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-27 18:39:08 +00:00
Benjamin Kramer
a1bf4ca773 SimplifyLibCalls: Use IRBuilder to simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122575 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-27 00:16:46 +00:00
Chris Lattner
9f39188def have loop-idiom nuke instructions that feed stores that get removed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122574 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-27 00:03:23 +00:00
Chris Lattner
a92ff91a96 implement enough of the memset inference algorithm to recognize and insert
memsets.  This is still missing one important validity check, but this is enough
to compile stuff like this:

void test0(std::vector<char> &X) {
  for (std::vector<char>::iterator I = X.begin(), E = X.end(); I != E; ++I)
    *I = 0;
}

void test1(std::vector<int> &X) {
  for (long i = 0, e = X.size(); i != e; ++i)
    X[i] = 0x01010101;
}

With:
 $ clang t.cpp -S -o - -O2 -emit-llvm | opt -loop-idiom | opt -O3 | llc 

to:

__Z5test0RSt6vectorIcSaIcEE:            ## @_Z5test0RSt6vectorIcSaIcEE
## BB#0:                                ## %entry
	subq	$8, %rsp
	movq	(%rdi), %rax
	movq	8(%rdi), %rsi
	cmpq	%rsi, %rax
	je	LBB0_2
## BB#1:                                ## %bb.nph
	subq	%rax, %rsi
	movq	%rax, %rdi
	callq	___bzero
LBB0_2:                                 ## %for.end
	addq	$8, %rsp
	ret
...
__Z5test1RSt6vectorIiSaIiEE:            ## @_Z5test1RSt6vectorIiSaIiEE
## BB#0:                                ## %entry
	subq	$8, %rsp
	movq	(%rdi), %rax
	movq	8(%rdi), %rdx
	subq	%rax, %rdx
	cmpq	$4, %rdx
	jb	LBB1_2
## BB#1:                                ## %for.body.preheader
	andq	$-4, %rdx
	movl	$1, %esi
	movq	%rax, %rdi
	callq	_memset
LBB1_2:                                 ## %for.end
	addq	$8, %rsp
	ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122573 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 23:42:51 +00:00
Chris Lattner
61db1f56d0 start using irbuilder to make mem intrinsics in a few passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122572 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 22:57:41 +00:00
Chris Lattner
22920b5986 sketch more of this out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122567 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 20:45:45 +00:00
Chris Lattner
bb89710ddd move isBytewiseValue out to ValueTracking.h/cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122565 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 20:15:01 +00:00
Chris Lattner
e6bb649ec6 actually add the file...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122563 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 19:39:38 +00:00
Chris Lattner
b0db161f5b Start of a pass for recognizing memset and memcpy idioms.
No functionality yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122562 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 19:32:44 +00:00
Benjamin Kramer
3fed0d917d Simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-26 15:23:45 +00:00
Benjamin Kramer
49c7e3e290 Fix a thinko pointed out by Frits van Bommel: looking through global variables in isBytewiseValue is not safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122550 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 22:23:59 +00:00
Benjamin Kramer
a112087e42 MemCpyOpt: Turn memcpys from a constant into a memset if possible.
This allows us to compile "int cst[] = {-1, -1, -1};" into
  movl  $-1, 16(%rsp)
  movq  $-1, 8(%rsp)
instead of
  movl  _cst+8(%rip), %eax
  movl  %eax, 16(%rsp)
  movq  _cst(%rip), %rax
  movq  %rax, 8(%rsp)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122548 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 21:17:12 +00:00
Owen Anderson
d5f8684b16 It is possible for SimplifyCFG to cause PHI nodes to become redundant too late in the optimization
pipeline to be caught by instcombine, and it's not feasible to catch them in SimplifyCFG because the
use-lists are in an inconsistent state at the point where it could know that it need to simplify them.
Instead, have CodeGenPrepare look for trivially redundant PHIs as part of its general cleanup effort.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 20:57:35 +00:00
Mon P Wang
e90a6333c3 Preserve the address space when generating bitcasts for MemTransferInst in ConvertToScalarInfo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122462 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 01:41:32 +00:00
Jeffrey Yasskin
8e68c38735 Change all self assignments X=X to (void)X, so that we can turn on a
new gcc warning that complains on self-assignments and
self-initializations.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 00:58:24 +00:00
Owen Anderson
f056838956 Give GVN back the ability to perform simple conditional propagation on conditional branch values.
I still think that LVI should be handling this, but that capability is some ways off in the future,
and this matters for some significant benchmarks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 23:54:34 +00:00
Owen Anderson
491e0307a8 Remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122371 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 22:31:24 +00:00
Benjamin Kramer
aad94aa437 GVN's Expression is not POD-like (it contains a SmallVector). Simplify code while at it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122362 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 21:30:19 +00:00
Chris Lattner
459f4f8c25 tidy up
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122190 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 20:24:28 +00:00
Chris Lattner
1dec0d2704 Enhance LICM to promote alias sets whose pointers themselves are stored,
which doesn't affect the memory address being promoted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122172 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 05:57:25 +00:00
Chris Lattner
1c0af0ed25 fix PR8602, a bug in an assertion: a volatile store *of* a pointer
does not make the alias set for that pointer volatile, just stores
*to* the pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122171 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 05:51:54 +00:00
Chris Lattner
a0d172f7fe revert r122164, I'm going to go with a different approach.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122168 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 04:23:03 +00:00
Chris Lattner
140f4a315b first step to fixing PR8642: don't fold away empty basic blocks
which have trapping constant exprs in them due to PHI nodes.
Eliminating them can cause the constant expr to be evalutated
on new paths if the input edges are critical.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 03:02:34 +00:00
Dan Gohman
c32046e6ea Revert r64460. strtol and friends cannot be marked readonly, even with
a null endptr argument, because they may write to errno.

This fixes a seflhost miscompile observed on Linux targets when TBAA
was enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122014 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 01:09:43 +00:00
Frits van Bommel
01abcf339f Fix a bug in the loop in JumpThreading::ProcessThreadableEdges() where it could falsely produce a MultipleDestSentinel value if the first predecessor ended with an 'indirectbr'. If that happened, it caused an unnecessary FindMostPopularDest() call.
This wasn't a correctness problem, but it broke the fast path for single-predecessor blocks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-16 12:16:00 +00:00
Dan Gohman
387f28aff4 Make memcpyopt TBAA-aware.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121944 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-16 02:51:19 +00:00
Dan Gohman
f4177aa019 Preserve TBAA tags when doing load PRE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121921 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 23:53:55 +00:00
Dan Gohman
5034dd318a Move Value::getUnderlyingObject to be a standalone
function so that it can live in Analysis instead of
VMCore.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121885 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 20:02:24 +00:00
Frits van Bommel
26e097ca4b Teach jump threading to "look through" a select when the branch direction of a terminator depends on it.
When it sees a promising select it now tries to figure out whether the condition of the select is known in any of the predecessors and if so it maps the operands appropriately.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121859 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 09:51:20 +00:00
Owen Anderson
86e8a700f5 Fix PR8790, another instance where unreachable code can cause instruction simplification to fail,
this case involve a select that simplifies to itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121817 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 00:55:35 +00:00
Owen Anderson
93f83deba1 Cleanup trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-15 00:52:44 +00:00
Chris Lattner
e991b5fdd5 simplify code and reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121670 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-13 02:38:13 +00:00
Chris Lattner
8fdca6a873 enhance memcpyopt to zap memcpy's that have the same src/dst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121362 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 07:45:45 +00:00
Chris Lattner
f7f35467a9 fix PR8753, eliminating a case where we'd infinitely make a
substitution because it doesn't actually change the IR.  Patch by
Jakub Staszak!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-09 07:39:50 +00:00
Frits van Bommel
8e8cdc8fe0 Remove some dead code from the jump threading pass.
The last uses of these functions were removed in r113852 when LazyValueInfo was permanently enabled and removed the need for them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 13:08:07 +00:00
Jay Foad
40f8f6264d PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 08:25:19 +00:00
Frits van Bommel
6033b346e2 Implement jump threading of 'indirectbr' by keeping track of whether we're looking for ConstantInt*s or BlockAddress*s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121066 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 23:36:56 +00:00
Chris Lattner
29d8d6b039 Use a stronger predicate here, pointed out by Duncan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121040 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 21:48:10 +00:00
Chris Lattner
a9d4da85d6 add some DEBUG statements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121038 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 21:13:51 +00:00
Chris Lattner
cc10244d77 Fix PR8728, a miscompilation I recently introduced. When optimizing
memcpy's like:
  memcpy(A, B)
  memcpy(A, C)

we cannot delete the first memcpy as dead if A and C might be aliases.
If so, we actually get:

  memcpy(A, B)
  memcpy(A, A)

which is not correct to transform into:

  memcpy(A, A)

This patch was heavily influenced by Jakub Staszak's patch in PR8728, thanks
Jakub!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120974 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 01:48:06 +00:00
Frits van Bommel
ea388f217b Refactor jump threading.
Should have no functional change other than the order of two transformations that are mutually-exclusive and the exact formatting of debug output.
Internally, it now stores the ConstantInt*s as Constant*s, and actual undef values instead of nulls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120946 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-05 19:06:41 +00:00