Chris Lattner
dbad0b5e40
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
e396e846b4
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
688675a0be
sketch out a new early cse pass. No functionality yet.
...
llvm-svn: 122713
2011-01-02 21:47:05 +00:00
Chris Lattner
0c2cfcf430
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
c655681b32
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
Nick Lewycky
06b94a5e5b
Also remove functions that use complex constant expressions in terms of
...
another function.
llvm-svn: 122705
2011-01-02 19:16:44 +00:00
Chris Lattner
c78e4bc366
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
3bb2e83433
make inSubLoop much more efficient.
...
llvm-svn: 122703
2011-01-02 18:53:08 +00:00
Chris Lattner
2bcd2564d6
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
bbae3ddf12
add a list of opportunities for future improvement.
...
llvm-svn: 122701
2011-01-02 18:32:09 +00:00
Duncan Sands
2d1c116071
Fix PR8702 by not having LoopSimplify claim to preserve LCSSA form. As described
...
in the PR, the pass could break LCSSA form when inserting preheaders. It probably
would be easy enough to fix this, but since currently we always go into LCSSA form
after running this pass, doing so is not urgent.
llvm-svn: 122695
2011-01-02 13:38:21 +00:00
Chris Lattner
f669d6a901
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
8a72a8f315
remove debugging code.
...
llvm-svn: 122683
2011-01-02 07:37:13 +00:00
Chris Lattner
bbd22e0c3c
add some -stats output.
...
llvm-svn: 122682
2011-01-02 07:36:44 +00:00
Chris Lattner
2afc3c0dc4
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
34a61ab676
teach loop idiom recognition to form memcpy's from simple loops.
...
llvm-svn: 122678
2011-01-02 03:37:56 +00:00
Nick Lewycky
68d915ae1a
Remove functions from the FnSet when one of their callee's is being merged. This
...
maintains the guarantee that the DenseSet expects two elements it contains to
not go from inequal to equal under its nose.
As a side-effect, this also lets us switch from iterating to a fixed-point to
actually maintaining a work queue of functions to look at again, and we don't
add thunks to our work queue so we don't need to detect and ignore them.
llvm-svn: 122677
2011-01-02 02:46:33 +00:00
Chris Lattner
fda382af51
fix a globalopt crash on two Adobe-C++ testcases that the recent
...
loop idiom pass exposed.
llvm-svn: 122674
2011-01-01 22:31:46 +00:00
Chris Lattner
b9c1684fce
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
9a9f43c4a2
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
4651f8b037
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
Duncan Sands
74270e8100
Simplify this pass by using a depth-first iterator to ensure that all
...
operands are visited before the instructions themselves.
llvm-svn: 122647
2010-12-31 17:49:05 +00:00
Duncan Sands
ca280dbcd5
Zap dead instructions harder.
...
llvm-svn: 122645
2010-12-31 16:17:54 +00:00
Benjamin Kramer
c84434924f
Make a bunch of symbols internal.
...
llvm-svn: 122642
2010-12-30 22:34:44 +00:00
Chris Lattner
51a906ce92
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
1395f115d8
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
2658d522b1
fix some issues Frits noticed, add AliasAnalysis as a dependency
...
llvm-svn: 122585
2010-12-27 18:39:08 +00:00
Benjamin Kramer
30e1ba0fcc
BuildLibCalls: Nuke EmitMemCpy, EmitMemMove and EmitMemSet. They are dead and superseded by IRBuilder.
...
llvm-svn: 122576
2010-12-27 00:25:32 +00:00
Benjamin Kramer
c66455a774
SimplifyLibCalls: Use IRBuilder to simplify code.
...
llvm-svn: 122575
2010-12-27 00:16:46 +00:00
Chris Lattner
a4249272b5
have loop-idiom nuke instructions that feed stores that get removed.
...
llvm-svn: 122574
2010-12-27 00:03:23 +00:00
Chris Lattner
d4daf9f002
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
9007b56712
start using irbuilder to make mem intrinsics in a few passes.
...
llvm-svn: 122572
2010-12-26 22:57:41 +00:00
Chris Lattner
27961b5180
sketch more of this out.
...
llvm-svn: 122567
2010-12-26 20:45:45 +00:00
Chris Lattner
c56d20aa48
move isBytewiseValue out to ValueTracking.h/cpp
...
llvm-svn: 122565
2010-12-26 20:15:01 +00:00
Chris Lattner
73f562af94
actually add the file...
...
llvm-svn: 122563
2010-12-26 19:39:38 +00:00
Chris Lattner
e210c31646
Start of a pass for recognizing memset and memcpy idioms.
...
No functionality yet.
llvm-svn: 122562
2010-12-26 19:32:44 +00:00
Benjamin Kramer
626fccab8b
Simplify code.
...
llvm-svn: 122561
2010-12-26 15:23:45 +00:00
Chris Lattner
a73a53e67f
don't lose TD info
...
llvm-svn: 122556
2010-12-25 20:52:04 +00:00
Chris Lattner
38d6d6d367
switch the inliner alignment enforcement stuff to use the
...
getOrEnforceKnownAlignment function, which simplifies the code
and makes it stronger.
llvm-svn: 122555
2010-12-25 20:42:38 +00:00
Chris Lattner
c4cb20b9bf
Move getOrEnforceKnownAlignment out of instcombine into Transforms/Utils.
...
llvm-svn: 122554
2010-12-25 20:37:57 +00:00
Benjamin Kramer
720b32b319
Fix a thinko pointed out by Frits van Bommel: looking through global variables in isBytewiseValue is not safe.
...
llvm-svn: 122550
2010-12-24 22:23:59 +00:00
Benjamin Kramer
49e40d4c4b
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)
llvm-svn: 122548
2010-12-24 21:17:12 +00:00
Owen Anderson
6afd90810e
When determining if we can fold (x >> C1) << C2, the bits that we need to verify are zero
...
are not the low bits of x, but the bits that WILL be the low bits after the operation completes.
llvm-svn: 122529
2010-12-23 23:56:24 +00:00
Owen Anderson
be8084acdd
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.
llvm-svn: 122516
2010-12-23 20:57:35 +00:00
Mon P Wang
eb2ae28352
Preserve the address space when generating bitcasts for MemTransferInst in ConvertToScalarInfo
...
llvm-svn: 122462
2010-12-23 01:41:32 +00:00
Jeffrey Yasskin
a199652a3e
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.
llvm-svn: 122458
2010-12-23 00:58:24 +00:00
Benjamin Kramer
27d13684f5
InstCombine: creating selects from -1 and 0 is fine, they combine into a sext from i1.
...
llvm-svn: 122453
2010-12-22 23:12:15 +00:00
Duncan Sands
922251757b
Add a generic expansion transform: A op (B op' C) -> (A op B) op' (A op C)
...
if both A op B and A op C simplify. This fires fairly often but doesn't
make that much difference. On gcc-as-one-file it removes two "and"s and
turns one branch into a select.
llvm-svn: 122399
2010-12-22 13:36:08 +00:00
Duncan Sands
9b28a173fe
Add some statistics, good for understanding how much more powerful
...
instcombine is compared to instsimplify.
llvm-svn: 122397
2010-12-22 09:40:51 +00:00
Owen Anderson
b4f1511864
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.
llvm-svn: 122378
2010-12-21 23:54:34 +00:00