Cameron Zwarich
246056cbb7
Add the CallInst optimizations that don't involve expanding inline assembly to
...
OptimizeInst() so that they can be used on a worklist instruction.
llvm-svn: 122945
2011-01-06 02:56:42 +00:00
Cameron Zwarich
314d16039a
Move the GEP handling in CodeGenPrepare to OptimizeInst().
...
llvm-svn: 122944
2011-01-06 02:44:52 +00:00
Cameron Zwarich
40cfb75bd7
Split the optimizations in CodeGenPrepare that don't manipulate the iterators
...
into a separate function, so that it can be called from a loop using a worklist
rather than a loop traversing a whole basic block.
llvm-svn: 122943
2011-01-06 02:37:26 +00:00
Jakob Stoklund Olesen
b3e7b27c1f
Zap the last two -Wself-assign warnings in llvm.
...
Simplify RALinScan::DowngradeRegister with TRI::getOverlaps while we are there.
llvm-svn: 122940
2011-01-06 01:33:22 +00:00
Cameron Zwarich
eeea9f7113
Stop reallocating SunkAddrs for each basic block. When we move to an instruction
...
worklist, the key will need to become std::pair<BasicBlock*, Value*>.
llvm-svn: 122932
2011-01-06 00:42:50 +00:00
Cameron Zwarich
2543ec1d29
Add some more statistics to CodeGenPrepare.
...
llvm-svn: 122891
2011-01-05 17:47:38 +00:00
Cameron Zwarich
eca6d2c70a
Add some stats to CodeGenPrepare to make it easier to speed it up without
...
regressing code quality.
llvm-svn: 122887
2011-01-05 17:27:27 +00:00
Cameron Zwarich
a7b9603f24
Use pop_back_val instead of back followed by pop_back.
...
llvm-svn: 122876
2011-01-05 16:08:47 +00:00
Cameron Zwarich
1dc3325c51
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.
llvm-svn: 122869
2011-01-05 05:47:47 +00:00
Cameron Zwarich
498b19fe4f
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.
llvm-svn: 122868
2011-01-05 05:15:53 +00:00
Owen Anderson
cc0a091a5b
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.
llvm-svn: 122844
2011-01-04 22:15:21 +00:00
Owen Anderson
21c2cbcdbc
Complete the NumberTable --> LeaderTable rename.
...
llvm-svn: 122828
2011-01-04 19:29:46 +00:00
Owen Anderson
52b41efbe8
Fix typo in a comment.
...
llvm-svn: 122827
2011-01-04 19:25:18 +00:00
Owen Anderson
eab44ddb0d
Prune #include's.
...
llvm-svn: 122826
2011-01-04 19:24:57 +00:00
Owen Anderson
e8b5675dfa
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.
llvm-svn: 122823
2011-01-04 19:13:25 +00:00
Owen Anderson
192bc8fe10
When removing a value from GVN's leaders list, don't drop the Next pointer in a corner case.
...
llvm-svn: 122822
2011-01-04 19:10:54 +00:00
Dale Johannesen
de70d69dff
Improve the accuracy of the inlining heuristic looking for the
...
case where a static caller is itself inlined everywhere else, and
thus may go away if it doesn't get too big due to inlining other
things into it. If there are references to the caller other than
calls, it will not be removed; account for this.
This results in same-day completion of the case in PR8853.
llvm-svn: 122821
2011-01-04 19:01:54 +00:00
Owen Anderson
0ebc81b8d6
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.
llvm-svn: 122819
2011-01-04 18:54:18 +00:00
Owen Anderson
035828ecc6
Remove commented out code.
...
llvm-svn: 122817
2011-01-04 18:22:08 +00:00
Cameron Zwarich
8df51d24bd
Switch to the new style of asterisk placement.
...
llvm-svn: 122815
2011-01-04 18:19:19 +00:00
Chris Lattner
1f58120bfe
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.
llvm-svn: 122806
2011-01-04 07:46:33 +00:00
Chris Lattner
0c29b20b46
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.
llvm-svn: 122805
2011-01-04 07:27:30 +00:00
Cameron Zwarich
150ef32f67
Avoid finding loop back edges when we are not splitting critical edges in
...
CodeGenPrepare (which is the default behavior).
llvm-svn: 122801
2011-01-04 04:43:31 +00:00
Cameron Zwarich
61a903b51b
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
0caf5cbbe7
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
c724c5969d
Fix comment.
...
llvm-svn: 122788
2011-01-03 23:51:56 +00:00
Owen Anderson
ce48a5e838
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
cd13979300
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
e7a89f4646
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
5b5347fde6
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
9f81cc5372
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
Duncan Sands
667024a2eb
Speed up instsimplify by about 10-15% by not bothering to retry
...
InstructionSimplify on instructions that didn't change since the
last time round the loop.
llvm-svn: 122745
2011-01-03 10:50:04 +00:00
Cameron Zwarich
3914a9751c
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
c1ebe702b1
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
e44a99ac89
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
d19ae32f2f
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
b242caa491
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
3d56e5f6d5
various cleanups, no functionality change.
...
llvm-svn: 122729
2011-01-03 03:28:23 +00:00
Chris Lattner
4cfdaa3f02
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
4ad0cdebbb
rename InstValue to SimpleValue, add some comments.
...
llvm-svn: 122725
2011-01-03 02:20:48 +00:00
Michael J. Spencer
1c649efb52
CMake: Add missing source file.
...
llvm-svn: 122724
2011-01-03 02:13:05 +00:00
Chris Lattner
e89f2f9078
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
f6a71c6cd5
reduce redundancy in the hashing code and other misc cleanups.
...
llvm-svn: 122720
2011-01-03 01:10:08 +00:00
Cameron Zwarich
a4f2efdd41
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
506c2deff3
fix some pastos
...
llvm-svn: 122718
2011-01-02 23:29:58 +00:00
Chris Lattner
39d1fb3320
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
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