Benjamin Kramer
ae67cc13a9
InstCombine: Turn _chk functions into the "unsafe" variant if length and max langth are equal.
...
This happens when we take the (non-constant) length from a malloc.
llvm-svn: 122961
2011-01-06 14:22:52 +00:00
Benjamin Kramer
799b011276
InstCombine: If we call llvm.objectsize on a malloc call we can replace it with the size passed to malloc.
...
llvm-svn: 122959
2011-01-06 13:11:05 +00:00
Benjamin Kramer
a76cc117e0
InstCombine: Teach llvm.objectsize folding to look through GEPs.
...
llvm-svn: 122958
2011-01-06 13:07:49 +00:00
Cameron Zwarich
9ec19ea06a
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
d28c78eb4f
Move the GEP handling in CodeGenPrepare to OptimizeInst().
...
llvm-svn: 122944
2011-01-06 02:44:52 +00:00
Cameron Zwarich
14ac865ca9
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
70be93a200
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
ce3b930a98
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
b62ccb241b
Add some more statistics to CodeGenPrepare.
...
llvm-svn: 122891
2011-01-05 17:47:38 +00:00
Cameron Zwarich
ced753fadf
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
6a78995369
Use pop_back_val instead of back followed by pop_back.
...
llvm-svn: 122876
2011-01-05 16:08:47 +00:00
Cameron Zwarich
5a2bb998ac
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
4c51d122d5
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
7b25ff04bd
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
e39cb57b09
Complete the NumberTable --> LeaderTable rename.
...
llvm-svn: 122828
2011-01-04 19:29:46 +00:00
Owen Anderson
d7d06d3aaf
Fix typo in a comment.
...
llvm-svn: 122827
2011-01-04 19:25:18 +00:00
Owen Anderson
51489b3b28
Prune #include's.
...
llvm-svn: 122826
2011-01-04 19:24:57 +00:00
Owen Anderson
c7c3bc63f7
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
83546f2fe0
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
a71d2cc88d
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
41a1550ef5
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
22c53e277a
Remove commented out code.
...
llvm-svn: 122817
2011-01-04 18:22:08 +00:00
Cameron Zwarich
b2a41e9388
Switch to the new style of asterisk placement.
...
llvm-svn: 122815
2011-01-04 18:19:19 +00:00
Chris Lattner
8643810ede
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
a62b01dc37
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
f4e13699e7
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
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
Duncan Sands
697de77339
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
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