1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 12:33:33 +02:00
Commit Graph

267 Commits

Author SHA1 Message Date
Dan Gohman
e1f9be27bc Tidy up several unbeseeming casts from pointer to intptr_t.
llvm-svn: 55779
2008-09-04 17:05:41 +00:00
Owen Anderson
94bd638e81 Fix a bug that prevented PRE from applying in some cases.
llvm-svn: 55744
2008-09-03 23:06:07 +00:00
Owen Anderson
14510f8fee Put a heuristic in place to prevent GVN from falling into bad cases with massively complicated CFGs.
This speeds up a particular testcase from 12+ hours to 5 seconds with little perceptible loss of quality.

llvm-svn: 55391
2008-08-26 22:07:42 +00:00
Chris Lattner
fd64cbf22d consolidate DenseMapInfo implementations, and add one for std::pair.
Patch contributed by m-s.

llvm-svn: 55167
2008-08-22 05:08:25 +00:00
Duncan Sands
b4646d7dbe Supress a gcc-4.3 warning.
llvm-svn: 53771
2008-07-18 21:06:02 +00:00
Owen Anderson
8500aba55a Make PRE actually handle critical edges (by splitting them). Confirmed that bootstrap passes with this change.
llvm-svn: 53762
2008-07-18 18:03:38 +00:00
Owen Anderson
5524271234 Enable PRE. My last batch of changes fixed the miscompile.
llvm-svn: 53730
2008-07-17 19:41:00 +00:00
Owen Anderson
7fb36c8bba Factor MergeBlockIntoPredecessor out into BasicBlockUtils.
llvm-svn: 53705
2008-07-17 00:01:40 +00:00
Owen Anderson
f91aa3b22f There's no need to iterate block merging and PRE. In fact, iterating the latter
could cause problems for memdep when it breaks critical edges.

llvm-svn: 53691
2008-07-16 17:52:31 +00:00
Owen Anderson
e12f7904ff Revert this, as it seems to still be broken.
llvm-svn: 53627
2008-07-15 17:59:02 +00:00
Owen Anderson
73bdb28e89 Enable local PRE by default.
llvm-svn: 53616
2008-07-15 16:28:23 +00:00
Owen Anderson
f1b3898e7f Have GVN do a pre-pass over the CFG that folds away unconditional branches where possible. This allows local PRE to be more aggressive.
llvm-svn: 53615
2008-07-15 16:28:06 +00:00
Owen Anderson
cc861329ee Don't call lookupNumber more than we have to.
llvm-svn: 53470
2008-07-11 20:05:13 +00:00
Owen Anderson
035bf4d2ca Use information already present in the ValueTable to fast-fail when we know there won't be a value number match. This speeds up GVN on a case where there are very few redundancies by ~25%.
llvm-svn: 53108
2008-07-03 17:44:33 +00:00
Owen Anderson
0b0017e514 Avoid a redundant call.
llvm-svn: 53040
2008-07-02 18:15:31 +00:00
Owen Anderson
5747d627e0 A better fix for PR2503 that doesn't pessimize GVN in the presence of unreachable blocks.
llvm-svn: 53032
2008-07-02 17:20:16 +00:00
Evan Cheng
174f11c202 Disable PRE. It's breaking bootstrapping.
llvm-svn: 52643
2008-06-23 21:22:35 +00:00
Owen Anderson
0dcae02ad4 Tighten the conditions under which we do PRE, remove some unneeded code, and correct our preserved analyses list, since we
do now change the CFG by splitting critical edges during PRE.

llvm-svn: 52631
2008-06-23 17:49:45 +00:00
Evan Cheng
2ff47edc37 Enable PRE.
llvm-svn: 52574
2008-06-21 07:26:53 +00:00
Owen Anderson
5213d215e0 Really disable PRE.
llvm-svn: 52531
2008-06-20 08:59:13 +00:00
Owen Anderson
3231e506cb Change around the data structures used to store availability sets, resulting in a GVN+PRE that is faster that GVN alone was before.
llvm-svn: 52521
2008-06-20 01:15:47 +00:00
Evan Cheng
d4c055e1f8 Disable PRE for now. It seems to be breaking llvm-gcc bootstrapping.
llvm-svn: 52518
2008-06-20 01:01:07 +00:00
Owen Anderson
c979fcf8ff Add a hidden -disable-pre flag for testing purposes. This should be removed
once benchmarking is completed.

llvm-svn: 52506
2008-06-19 19:57:25 +00:00
Owen Anderson
35fb8dbfef PRE requires that critical edges be split.
llvm-svn: 52505
2008-06-19 19:54:19 +00:00
Owen Anderson
87d761460e Be sure to remove values from the value numbering table after we delete them.
This fixes a failure on povray.

llvm-svn: 52499
2008-06-19 17:53:26 +00:00
Owen Anderson
aa850d32db Revert support for insertvalue and extractvalue instructions for the moment.
GVN expects that all inputs which to an instruction fall somewhere in the value
hierarchy, which isn't true for these.

llvm-svn: 52496
2008-06-19 17:25:39 +00:00
Owen Anderson
5b8d39569b Add support for extractvalue and insertvalue instructions in GVN.
llvm-svn: 52472
2008-06-18 21:59:00 +00:00
Owen Anderson
3f78e260c1 Add local PRE to GVN. This only operates in cases where it would not increase code size, namely when the instantiated expression
would only need to be created in one predecessor.

llvm-svn: 52471
2008-06-18 21:41:49 +00:00
Owen Anderson
c1ac0c1c41 We don't want to find dependencies within the same block in this case. It leads to incorrect results because
we're detecting something at or after the call we're querying on.

llvm-svn: 52433
2008-06-17 22:27:06 +00:00
Owen Anderson
22a982f9eb Switch GVN to use ScopedHashTable.
llvm-svn: 52242
2008-06-12 19:25:32 +00:00
Matthijs Kooijman
1fd76cd396 Update comments and documentation to reflect that GCSE and ValueNumbering are
deprecated by the GVN and GVNPRE passes.

llvm-svn: 51983
2008-06-05 07:55:49 +00:00
Owen Anderson
264b60b69d Remove unneeded #include.
llvm-svn: 51955
2008-06-04 18:28:10 +00:00
Nate Begeman
fdedac42c7 Teach GVN to not assert on vector comparisons
llvm-svn: 51230
2008-05-18 19:49:05 +00:00
Owen Anderson
6a2ee9af7a Fix Analysis/BasicAA/pure-const-dce.ll. This turned out to be a correctness
bug as well as a missed optimization.  We weren't properly checking for local
dependencies before moving on to non-local ones when doing non-local read-only 
call CSE.

llvm-svn: 51082
2008-05-13 23:18:30 +00:00
Owen Anderson
7f6db08b5f Make the non-local CSE safety checks slightly more thorough.
llvm-svn: 51035
2008-05-13 13:41:23 +00:00
Owen Anderson
c54c61634c Add support for non-local CSE of read-only calls.
llvm-svn: 51024
2008-05-13 08:17:22 +00:00
Owen Anderson
0256b368f8 Go back to passing the analyses around as parameters.
llvm-svn: 50995
2008-05-12 20:15:55 +00:00
Owen Anderson
3f2d12126f Move the various analyses used by GVN into static variables so we don't have to keep passing them around or refetching them.
llvm-svn: 50963
2008-05-12 08:15:27 +00:00
Owen Anderson
b171c54227 Remove unneeded #include's.
llvm-svn: 50035
2008-04-21 07:47:38 +00:00
Owen Anderson
cd1b9c4b43 Make GVN able to remove unnecessary calls to read-only functions again.
llvm-svn: 49842
2008-04-17 05:36:50 +00:00
Owen Anderson
f55bae07b7 Fix PR2213 by simultaneously making GVN more aggressive with the return values
of calls and less aggressive with non-readnone calls.

llvm-svn: 49516
2008-04-11 05:11:49 +00:00
Owen Anderson
ca7e0e21f3 Factor a bunch of functionality related to memcpy and memset transforms out of
GVN and into its own pass.

llvm-svn: 49419
2008-04-09 08:23:16 +00:00
Owen Anderson
0d844f6205 Remove accidentally duplicated code.
llvm-svn: 49418
2008-04-09 07:55:01 +00:00
Owen Anderson
4ad5a5201c Add operator= implementations to SparseBitVector, allowing it to be used in GVN. This results
in both time and memory savings for GVN.  For example, one testcase went from 10.5s to 6s with
this patch.

llvm-svn: 49345
2008-04-07 17:38:23 +00:00
Owen Anderson
93ab00f1d9 Make GVN more memory efficient, particularly on code that contains a large number of
allocations, which GVN can't optimize anyways.

llvm-svn: 49329
2008-04-07 09:59:07 +00:00
Gabor Greif
6c6b8a57f3 API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.

llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Chris Lattner
10e3ff7e5f change iterator invalidation avoidance to just move the iterator backward
when something changes, instead of moving forward.  This allows us to 
simplify memset lowering, inserting the memset at the end of the range of 
stuff we're touching instead of at the start.

This, in turn, allows us to make use of the addressing instructions already
used in the function instead of inserting our own.  For example, we now
codegen:

	%tmp41 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 0		; <i8*> [#uses=2]
	call void @llvm.memset.i64( i8* %tmp41, i8 -1, i64 8, i32 1 )

instead of:

	%tmp20 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 7		; <i8*> [#uses=1]
	%ptroffset = getelementptr i8* %tmp20, i64 -7		; <i8*> [#uses=1]
	call void @llvm.memset.i64( i8* %ptroffset, i8 -1, i64 8, i32 1 )

llvm-svn: 48940
2008-03-29 05:15:47 +00:00
Chris Lattner
48b3859ee9 make the common case of a single store (which clearly shouldn't be turned
into a memset!) faster by avoiding an allocation of an std::list node.

llvm-svn: 48939
2008-03-29 04:52:12 +00:00
Chris Lattner
722c9a539f give form-memset a significantly more sane heuristic, enable it by default.
llvm-svn: 48937
2008-03-29 04:36:18 +00:00
Chris Lattner
0a18724a00 make memset inference significantly more powerful: it can now handle
memsets that initialize "structs of arrays" and other store sequences
that are not sequential.  This is still only enabled if you pass 
-form-memset-from-stores.  The flag is not heavily tested and I haven't
analyzed the perf regressions when -form-memset-from-stores is passed
either, but this causes no make check regressions.

llvm-svn: 48909
2008-03-28 06:45:13 +00:00
Evan Cheng
95cc5fca5c Temporarily disabling memset forming optimization. Add an option.
llvm-svn: 48720
2008-03-24 05:28:38 +00:00
Chris Lattner
16f62d36e8 implement an initial hack at a straight-line store -> memset optimization.
This fires dozens of times across spec and multisource, but I don't know
if it actually speeds stuff up.  Hopefully the testers will show something
nice :)

llvm-svn: 48680
2008-03-22 05:37:16 +00:00
Chris Lattner
9a567d824d implement the logic for memset insertion and store deletion.
llvm-svn: 48679
2008-03-22 04:13:49 +00:00
Chris Lattner
9d8b1ee347 This is a partially implemented and currently disabled start of a store
merging optimization.  Nothing to see here, hopefully more later :)

llvm-svn: 48670
2008-03-22 00:31:52 +00:00
Chris Lattner
18f7655a45 the size of a smallvector shouldn't be part of the interface to these methods.
llvm-svn: 48662
2008-03-21 22:01:16 +00:00
Chris Lattner
15d06c679b make gvn marginally faster by reallocating the lastSeenLoad map for
each basic block.

llvm-svn: 48660
2008-03-21 21:33:23 +00:00
Chris Lattner
b8102d9de3 Minor cleanups and shrinkification.
llvm-svn: 48658
2008-03-21 21:14:38 +00:00
Owen Anderson
6c2454d9d1 Fix a bug in GVN that Duncan noticed, where we potentially need to insert a
pointer bitcast when performing return slot optimization.

llvm-svn: 48343
2008-03-13 22:07:10 +00:00
Owen Anderson
5887233a3f Improve the return slot optimization to be both more aggressive (not limited to sret parameters), and
safer (when the passed pointer might be invalid).  Thanks to Duncan and Chris for the idea behind this, 
and extra thanks to Duncan for helping me work out the trap-safety.

llvm-svn: 48280
2008-03-12 07:37:44 +00:00
Owen Anderson
eadd074b22 Fix an issue where GVN had the sizes of the two memcpy's reverse, resulting
in an invalid transformation.

llvm-svn: 47639
2008-02-26 23:06:17 +00:00
Owen Anderson
6eafd532ab Fix an issue where GVN was performing the return slot optimization when it was
not safe.  This is fixed by more aggressively checking that the return slot is
not used elsewhere in the function.

llvm-svn: 47544
2008-02-25 04:08:09 +00:00
Owen Anderson
432abc0479 Fix an issue where GVN would try to use an instruction before its definition when performing return slot optimization.
llvm-svn: 47541
2008-02-25 00:40:41 +00:00
Anton Korobeynikov
fd6b669c80 Make Transforms to be 4.3 warnings-clean
llvm-svn: 47371
2008-02-20 11:26:25 +00:00
Owen Anderson
52ed56338d When performing return slot optimization, remember to inform memdep when we're removing the memcpy.
llvm-svn: 47364
2008-02-20 08:23:02 +00:00
Owen Anderson
6196cdcb48 Refactor this method a bit, and correct a test that was completely wrong but happened to work out anyways. :-)
llvm-svn: 47321
2008-02-19 07:07:51 +00:00
Chris Lattner
99e0b1c063 isa+cast -> dyncast.
llvm-svn: 47320
2008-02-19 06:53:20 +00:00
Chris Lattner
0ee0f38084 simplify this code again, try 2 :)
llvm-svn: 47319
2008-02-19 06:52:38 +00:00
Owen Anderson
d60bb0a64b Fix a comment.
llvm-svn: 47318
2008-02-19 06:51:23 +00:00
Owen Anderson
dbc264003e Major improvements to yesterday's return slot optimization. Remove some unneccessary constraints,
and add some others that should have been in from the first place.  Document the whole thing better.

llvm-svn: 47315
2008-02-19 06:35:43 +00:00
Owen Anderson
4e6f18d5bf Factor the profitability check for return slot optimization out into a static function.
At some point in the future, this check will become smarter.

llvm-svn: 47310
2008-02-19 03:27:34 +00:00
Owen Anderson
3782cd74d1 An sret parameter is required to be the first parameter, so there's no need to loop
over all the parameters of the callee looking for it.

llvm-svn: 47309
2008-02-19 03:15:29 +00:00
Owen Anderson
ea5cdf1a83 Cleanup some of my patches from yesterday. Refactor the check for which xform
to apply to a memcpy into processInstruction.  Also, fix a bug in the check due to
missing braces.

llvm-svn: 47307
2008-02-19 03:09:45 +00:00
Owen Anderson
5c258ed93d Fix Transforms/GVN/memcpy.ll, which Chris broke in r47275 by reordering the branches. memcpy's are a kind of CallInst.
llvm-svn: 47305
2008-02-19 02:53:23 +00:00
Chris Lattner
a3318d17d4 minor code simplification, no functionality change.
llvm-svn: 47275
2008-02-18 17:47:29 +00:00
Owen Anderson
7b092ea631 Add support to GVN for performing sret return slot optimization. This means that, if an sret function tail calls
another sret function, it should pass its own sret parameter to the tail callee, allowing it to fill in the correct
return value.  llvm-gcc does not emit this by default.  Instead, it allocates space in the caller for the sret of
the tail call and then uses memcpy to copy the result into the caller's sret parameter.  This optimization detects
and optimizes that case.

llvm-svn: 47265
2008-02-18 09:24:53 +00:00
Nick Lewycky
0dd6ce5d3a Fix PR2032. Inform the alias analysis of changes to the underlying program.
llvm-svn: 47111
2008-02-14 07:11:24 +00:00
Owen Anderson
274aa2846e Re-apply the patch to improve the optimizations of memcpy's, with several
bugs fixed.  This now passes PPC bootstrap.

llvm-svn: 47026
2008-02-12 21:15:18 +00:00
Eli Friedman
69268a529e Fix for bug 1996: optimize out loads of undef. This code basically just
checks for a malloc/alloca immediately followed by a load.

llvm-svn: 47006
2008-02-12 12:08:14 +00:00
Bill Wendling
8a28ab4b1f Temporarily reverting:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080128/057882.html

This is causing a miscompilation on PPC G5 and just now seeing it on iMac x86-64.

llvm-svn: 46822
2008-02-06 20:03:07 +00:00
Owen Anderson
aaba6f96da Allow GVN to hack on memcpy's, making them open to further optimization.
llvm-svn: 46693
2008-02-04 02:59:58 +00:00
Chris Lattner
ad9a6ccb83 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Owen Anderson
e3de18ac1d Fix several cache coherence bugs in MemDep/GVN that were found. Also add some (disabled) debugging code
to make such problems easier to diagnose in the future, written by Duncan Sands.

llvm-svn: 44695
2007-12-08 01:37:09 +00:00
Duncan Sands
14f11d6836 Integrate the readonly/readnone logic more deeply
into alias analysis.  This meant updating the API
which now has versions of the getModRefBehavior,
doesNotAccessMemory and onlyReadsMemory methods
which take a callsite parameter.  These should be
used unless the callsite is not known, since in
general they can do a better job than the versions
that take a function.  Also, users should no longer
call the version of getModRefBehavior that takes
both a function and a callsite.  To reduce the
chance of misuse it is now protected.

llvm-svn: 44487
2007-12-01 07:51:45 +00:00
Owen Anderson
3b893e1f84 Fix a miscompilation in spiff on PPC.
llvm-svn: 44437
2007-11-29 18:02:22 +00:00
Owen Anderson
2aa0218a6c Fix another bug that was causing siod to fail.
llvm-svn: 44325
2007-11-26 07:17:19 +00:00
Owen Anderson
05275b7b14 Allow GVN to eliminate read-only function calls when it can detect that they are redundant.
llvm-svn: 44323
2007-11-26 02:26:36 +00:00
Owen Anderson
f0e040a0c7 Allow GVN to eliminate redundant calls to functions without side effects.
llvm-svn: 43147
2007-10-18 19:39:33 +00:00
Owen Anderson
9070cf6dea Add partial caching of non-local memory dependence queries. This provides a modest
speedup for GVN.

llvm-svn: 42185
2007-09-21 03:53:52 +00:00
Chris Lattner
cc315726f7 Merge DenseMapKeyInfo & DenseMapValueInfo into DenseMapInfo
Add a new DenseMapInfo::isEqual method to allow clients to redefine
the equality predicate used when probing the hash table.

llvm-svn: 42042
2007-09-17 18:34:04 +00:00
Owen Anderson
fd6ec5cf82 Be more careful when constant-folding PHI nodes.
llvm-svn: 41998
2007-09-16 08:04:16 +00:00
Owen Anderson
5173494693 Factor out some code into a helper function.
llvm-svn: 41131
2007-08-16 22:51:56 +00:00
Owen Anderson
70ac81f489 Add some more comments to GVN.
llvm-svn: 41129
2007-08-16 22:02:55 +00:00
Owen Anderson
b970937b06 Eliminate PHI nodes with constant values during normal GVN processing, even when
they're not related to eliminating a load.

llvm-svn: 41081
2007-08-14 18:33:27 +00:00
Owen Anderson
d9a7b61a64 Be more aggressive in pruning unnecessary PHI nodes when doing PHI construction.
llvm-svn: 41080
2007-08-14 18:16:29 +00:00
Owen Anderson
c855195b2f Make GVN iterative.
llvm-svn: 41078
2007-08-14 18:04:11 +00:00
Owen Anderson
8d15350c4e Fix a case where GVN was failing to return true when it had, in fact, modified
the function.

llvm-svn: 41077
2007-08-14 17:59:48 +00:00
Owen Anderson
3eba1e8f5c Make NonLocal and None const in the right way. :-)
llvm-svn: 40961
2007-08-09 04:42:44 +00:00
Owen Anderson
f988c3ee5c Change the None and NonLocal markers in memdep to be const.
llvm-svn: 40946
2007-08-08 21:39:39 +00:00
Owen Anderson
2c98f8ee3c Don't insert nearly as many redundant phi nodes.
llvm-svn: 40909
2007-08-07 23:12:31 +00:00
Owen Anderson
891f5b4d28 Fix a subtle miscompilation. This allows 197.parser to be compiled correctly.
llvm-svn: 40791
2007-08-03 19:59:35 +00:00
Owen Anderson
d1063b7a3c Fix a subtle iterator invalidation bug in a recursive algorithm.
llvm-svn: 40776
2007-08-03 11:03:26 +00:00
Owen Anderson
ad74eeed3d Fix 80 col. violations.
llvm-svn: 40750
2007-08-02 18:16:06 +00:00
Owen Anderson
d617e4c963 Fix a bug that was causing several miscompilations on SPEC.
llvm-svn: 40746
2007-08-02 17:56:05 +00:00
Owen Anderson
7028dfaf9d Make non-local memdep not be recursive, and fix a bug on 403.gcc that this exposed.
llvm-svn: 40692
2007-08-01 22:01:54 +00:00
Owen Anderson
89022c1367 Don't let the memory allocator outsmart GVN. ;-)
llvm-svn: 40655
2007-07-31 23:27:13 +00:00
Owen Anderson
9c996b3212 Fix a failure I accidentally caused in my last commit by mishandling the
removal of redundant phis.

llvm-svn: 40650
2007-07-31 20:18:28 +00:00
Owen Anderson
d178c05c62 Fix a misoptimization in aha.
llvm-svn: 40642
2007-07-31 17:43:14 +00:00
Owen Anderson
c7545280a2 Avoid potential iterator invalidation problems.
llvm-svn: 40607
2007-07-30 21:26:39 +00:00
Owen Anderson
fff534d147 Use more caching when computing non-local dependence. This makes bzip2 not
use up the entire 32-bit address space.

llvm-svn: 40596
2007-07-30 17:29:24 +00:00
Owen Anderson
a8d0a6ee40 Fix a bug caused by indiscriminantly asking for the dominators of a predecessor.
llvm-svn: 40595
2007-07-30 16:57:08 +00:00
Owen Anderson
f2b10d3de3 Fix a couple more bugs in the phi construction by pulling in code that does
almost the same things from LCSSA.

llvm-svn: 40540
2007-07-26 18:26:51 +00:00
Owen Anderson
ed75133924 Fix what is _hopefully_ the last corner case for loops.
llvm-svn: 40503
2007-07-25 23:54:42 +00:00
Owen Anderson
1e53615073 My last commit was not correct for nested loops. Fix it, and add a testcase for it.
llvm-svn: 40498
2007-07-25 22:19:40 +00:00
Owen Anderson
ce9d73dbe7 Fix an infinite loop on 300.twolf.
llvm-svn: 40497
2007-07-25 22:03:06 +00:00
Owen Anderson
522f7a7608 Fix a bug that was causing GVN to crash on 252.eon.
llvm-svn: 40494
2007-07-25 21:13:41 +00:00
Owen Anderson
6a1a8d05b8 Add basic support for performing whole-function RLE.
Note: This has not yet been thoroughly tested.  Use at your own risk.

llvm-svn: 40489
2007-07-25 19:57:03 +00:00
Owen Anderson
eb9f1b612c Add a GVN pass, using the value numbering code I developed for GVNPRE and the
load elimination code from RedundantLoadElimination.

llvm-svn: 40469
2007-07-24 17:55:58 +00:00