Cameron Zwarich
e924969380
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.
llvm-svn: 122791
2011-01-04 00:12:46 +00:00
Chris Lattner
0ba473c218
use the very-handy getTruncateOrZeroExtend helper function, and
...
stop setting NSW: signed overflow is possible. Thanks to Dan
for pointing these out.
llvm-svn: 122790
2011-01-04 00:06:55 +00:00
Owen Anderson
0839d3930a
Fix comment.
...
llvm-svn: 122788
2011-01-03 23:51:56 +00:00
Owen Anderson
d62d37225a
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.
llvm-svn: 122787
2011-01-03 23:51:43 +00:00
Chris Lattner
bde6ec1db6
Duncan deftly points out that readnone functions aren't
...
invalidated by stores, so they can be handled as 'simple'
operations.
llvm-svn: 122785
2011-01-03 23:38:13 +00:00
Owen Anderson
3a33d0cc4a
Simplify GVN's value expression structure, allowing the elimination of a lot of
...
almost-but-not-quite-identical code. No intended functionality change.
llvm-svn: 122760
2011-01-03 19:00:11 +00:00
Chris Lattner
16ca19ffc5
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.
llvm-svn: 122759
2011-01-03 18:43:03 +00:00
Chris Lattner
142f1cd251
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.
llvm-svn: 122758
2011-01-03 18:28:15 +00:00
Cameron Zwarich
43cecb1200
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.
llvm-svn: 122741
2011-01-03 06:33:01 +00:00
Chris Lattner
9e5e9ed79a
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.
llvm-svn: 122736
2011-01-03 04:17:24 +00:00
Chris Lattner
4b9a525742
switch the load table to use a recycling bump pointer allocator,
...
speeding earlycse up by 6%.
llvm-svn: 122733
2011-01-03 03:53:50 +00:00
Chris Lattner
e0e32a9ef0
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.
llvm-svn: 122732
2011-01-03 03:46:34 +00:00
Chris Lattner
92bb0f9f9d
split loads and calls into separate tables. Loads are now just indexed
...
by their pointer instead of using MemoryValue to wrap it.
llvm-svn: 122731
2011-01-03 03:41:27 +00:00
Chris Lattner
4cb365414f
various cleanups, no functionality change.
...
llvm-svn: 122729
2011-01-03 03:28:23 +00:00
Chris Lattner
b9a8efc960
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.
llvm-svn: 122727
2011-01-03 03:18:43 +00:00
Chris Lattner
79d83067ee
rename InstValue to SimpleValue, add some comments.
...
llvm-svn: 122725
2011-01-03 02:20:48 +00:00
Michael J. Spencer
edb5bcdde5
CMake: Add missing source file.
...
llvm-svn: 122724
2011-01-03 02:13:05 +00:00
Chris Lattner
d815f69b30
Allocate nodes for the scoped hash table from a recyling bump pointer
...
allocator. This speeds up early cse by about 20%
llvm-svn: 122723
2011-01-03 01:42:46 +00:00
Chris Lattner
02a9776b64
reduce redundancy in the hashing code and other misc cleanups.
...
llvm-svn: 122720
2011-01-03 01:10:08 +00:00
Cameron Zwarich
cab9a0abab
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.
llvm-svn: 122719
2011-01-03 00:25:16 +00:00
Chris Lattner
0844c76f9a
fix some pastos
...
llvm-svn: 122718
2011-01-02 23:29:58 +00:00
Chris Lattner
8fac5db251
add DEBUG and -stats output to earlycse.
...
Teach it to CSE the rest of the non-side-effecting instructions.
llvm-svn: 122716
2011-01-02 23:19:45 +00:00
Chris Lattner
18ae5436b1
Enhance earlycse to do CSE of casts, instsimplify and die.
...
Add a testcase.
llvm-svn: 122715
2011-01-02 23:04:14 +00:00
Chris Lattner
bf0aa927cc
split dom frontier handling stuff out to its own DominanceFrontier header,
...
so that Dominators.h is *just* domtree. Also prune #includes a bit.
llvm-svn: 122714
2011-01-02 22:09:33 +00:00
Chris Lattner
704541bb23
sketch out a new early cse pass. No functionality yet.
...
llvm-svn: 122713
2011-01-02 21:47:05 +00:00
Chris Lattner
9c69406f2b
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.
llvm-svn: 122712
2011-01-02 21:14:18 +00:00
Chris Lattner
5702a43c09
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.
llvm-svn: 122711
2011-01-02 20:24:21 +00:00
Chris Lattner
8455b6e45e
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.
llvm-svn: 122704
2011-01-02 19:01:03 +00:00
Chris Lattner
0cdc6f62a5
make inSubLoop much more efficient.
...
llvm-svn: 122703
2011-01-02 18:53:08 +00:00
Chris Lattner
27497ece96
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".
llvm-svn: 122702
2011-01-02 18:45:39 +00:00
Chris Lattner
0469e01c02
add a list of opportunities for future improvement.
...
llvm-svn: 122701
2011-01-02 18:32:09 +00:00
Chris Lattner
ddf58010bd
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.
llvm-svn: 122685
2011-01-02 07:58:36 +00:00
Chris Lattner
5b5a043d82
remove debugging code.
...
llvm-svn: 122683
2011-01-02 07:37:13 +00:00
Chris Lattner
12f91befce
add some -stats output.
...
llvm-svn: 122682
2011-01-02 07:36:44 +00:00
Chris Lattner
679572e584
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.
llvm-svn: 122681
2011-01-02 07:35:53 +00:00
Chris Lattner
85b6d81d41
teach loop idiom recognition to form memcpy's from simple loops.
...
llvm-svn: 122678
2011-01-02 03:37:56 +00:00
Chris Lattner
a3514441e0
add a validity check that was missed, fixing a crash on the
...
new testcase.
llvm-svn: 122662
2011-01-01 20:12:04 +00:00
Chris Lattner
91a4435875
improve validity check to handle constant-trip-count loops more
...
aggressively. In practice, this doesn't help anything though,
see the todo.
llvm-svn: 122660
2011-01-01 19:54:22 +00:00
Chris Lattner
8b3baf6d75
implement the "no aliasing accesses in loop" safety check. This pass
...
should be correct now.
llvm-svn: 122659
2011-01-01 19:39:01 +00:00
Chris Lattner
65a699d4d0
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.
llvm-svn: 122604
2010-12-28 18:53:48 +00:00
Duncan Sands
5cf10e691b
Silence gcc warning about an unused variable when doing a release build.
...
llvm-svn: 122593
2010-12-28 09:41:15 +00:00
Chris Lattner
cb18bfa3d2
fix some issues Frits noticed, add AliasAnalysis as a dependency
...
llvm-svn: 122585
2010-12-27 18:39:08 +00:00
Benjamin Kramer
7cba269dfb
SimplifyLibCalls: Use IRBuilder to simplify code.
...
llvm-svn: 122575
2010-12-27 00:16:46 +00:00
Chris Lattner
b9fe685b9a
have loop-idiom nuke instructions that feed stores that get removed.
...
llvm-svn: 122574
2010-12-27 00:03:23 +00:00
Chris Lattner
29e14edc8d
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
llvm-svn: 122573
2010-12-26 23:42:51 +00:00
Chris Lattner
6cf8d6cc6e
start using irbuilder to make mem intrinsics in a few passes.
...
llvm-svn: 122572
2010-12-26 22:57:41 +00:00
Chris Lattner
7c5f9c35d1
sketch more of this out.
...
llvm-svn: 122567
2010-12-26 20:45:45 +00:00
Chris Lattner
9cb1035f94
move isBytewiseValue out to ValueTracking.h/cpp
...
llvm-svn: 122565
2010-12-26 20:15:01 +00:00
Chris Lattner
81ae3f299a
actually add the file...
...
llvm-svn: 122563
2010-12-26 19:39:38 +00:00
Chris Lattner
2ef535a4e4
Start of a pass for recognizing memset and memcpy idioms.
...
No functionality yet.
llvm-svn: 122562
2010-12-26 19:32:44 +00:00