summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/GVN.cpp
Commit message (Collapse)AuthorAge
* Convert some of the dynamic opcode lookups into static ones.Owen Anderson2010-01-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93693 91177308-0d34-0410-b5e6-96231b3b80d8
* Use do+while instead of while for loops which obviously have aDan Gohman2010-01-05
| | | | | | | non-zero trip count. Use SmallVector's pop_back_val(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92734 91177308-0d34-0410-b5e6-96231b3b80d8
* Change errs() to dbgs().David Greene2010-01-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92613 91177308-0d34-0410-b5e6-96231b3b80d8
* split code that doesn't need to be templated out of IRBuilder into a newChris Lattner2009-12-28
| | | | | | | | non-templated IRBuilderBase class. Move that large CreateGlobalString out of line, eliminating the need to #include GlobalVariable.h in IRBuilder.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92227 91177308-0d34-0410-b5e6-96231b3b80d8
* The phi translated pointer can be computed when returning a partially cached ↵Chris Lattner2009-12-22
| | | | | | | | | | | result instead of stored. This reduces memdep memory usage, and also eliminates a bunch of weakvh's. This speeds up gvn on gcc.c-torture/20001226-1.c from 23.9s to 8.45s (2.8x) on a different machine than earlier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91885 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a fastpath to Load GVN to special case when we have exactly one dominatingChris Lattner2009-12-21
| | | | | | | | | | | | load to avoid even messing around with SSAUpdate at all. In this case (which is very common, we can just use the input value directly). This speeds up GVN time on gcc.c-torture/20001226-1.c from 36.4s to 16.3s, which still isn't great, but substantially better and this is a simple speedup that applies to lots of different cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91851 91177308-0d34-0410-b5e6-96231b3b80d8
* refactor some code out to a new helper method.Chris Lattner2009-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91849 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminte unnecessary uses of <cstdio>.Dan Gohman2009-12-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91666 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove isPod() from DenseMapInfo, splitting it out to its ownChris Lattner2009-12-15
| | | | | | | | | | isPodLike type trait. This is a generally useful type trait for more than just DenseMap, and we really care about whether something acts like a pod, not whether it really is a pod. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91421 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR5744, a case where we were getting the pointer size instead of theChris Lattner2009-12-10
| | | | | | | | | value size. This only manifested when memdep inprecisely returns clobber, which is do to a caching issue in the PR5744 testcase. We can 'efficiently emulate' this by using '-no-aa' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91004 91177308-0d34-0410-b5e6-96231b3b80d8
* allow this to build when the #if 0's are enabled. No functionality change.Chris Lattner2009-12-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90999 91177308-0d34-0410-b5e6-96231b3b80d8
* fix hte last remaining known (by me) phi translation bug. When we reanalyzeChris Lattner2009-12-09
| | | | | | | | clobbers to forward pieces of large stores to small loads, we need to consider the properly phi translated pointer in the store block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90978 91177308-0d34-0410-b5e6-96231b3b80d8
* change GetStoreValueForLoad to use IRBuilder, which is cleaner andChris Lattner2009-12-09
| | | | | | | implicitly constant folds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90977 91177308-0d34-0410-b5e6-96231b3b80d8
* change AnalyzeLoadFromClobberingMemInst/AnalyzeLoadFromClobberingStoreChris Lattner2009-12-09
| | | | | | | to require the load ty/ptr to be passed in, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90960 91177308-0d34-0410-b5e6-96231b3b80d8
* change AnalyzeLoadFromClobberingWrite and clients to pass in type Chris Lattner2009-12-09
| | | | | | | and pointer instead of the load. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90959 91177308-0d34-0410-b5e6-96231b3b80d8
* change NonLocalDepEntry from being a typedef for an std::pair to be itsChris Lattner2009-12-09
| | | | | | | own small class. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90956 91177308-0d34-0410-b5e6-96231b3b80d8
* add some aborts to #if 0's.Chris Lattner2009-12-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90929 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch GVN and memdep to use PHITransAddr, which correctly handlesChris Lattner2009-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | phi translation of complex expressions like &A[i+1]. This has the following benefits: 1. The phi translation logic is all contained in its own class with a strong interface and verification that it is self consistent. 2. The logic is more correct than before. Previously, if intermediate expressions got PHI translated, we'd miss the update and scan for the wrong pointers in predecessor blocks. @phi_trans2 is a testcase for this. 3. We have a lot less code in memdep. We can handle phi translation across blocks of things like @phi_trans3, which is pretty insane :). This patch should fix the miscompiles of 255.vortex, and I tested it with a bootstrap of llvm-gcc, llvm-test and dejagnu of course. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90926 91177308-0d34-0410-b5e6-96231b3b80d8
* constant fold loads from memcpy's from global constants. This is importantChris Lattner2009-12-06
| | | | | | | | because clang lowers nontrivial automatic struct/array inits to memcpy from a global array. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90698 91177308-0d34-0410-b5e6-96231b3b80d8
* add support for forwarding mem intrinsic values to non-local loads.Chris Lattner2009-12-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90697 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle forwarding local memsets to loads. For example, we optimize this:Chris Lattner2009-12-06
| | | | | | | | | | | | | short x(short *A) { memset(A, 1, sizeof(*A)*100); return A[42]; } to 'return 257' instead of doing the load. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90695 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix this crasher, and add a FIXME for a missed optimization.Owen Anderson2009-12-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90408 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup/remove some parts of the lifetime region handling code in memdep and ↵Owen Anderson2009-12-02
| | | | | | | | | GVN, per Chris' comments. Adjust testcases to match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90304 91177308-0d34-0410-b5e6-96231b3b80d8
* factor some code better.Chris Lattner2009-12-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90299 91177308-0d34-0410-b5e6-96231b3b80d8
* reenable load address insertion in load pre. This allows us toChris Lattner2009-11-28
| | | | | | | | | | | | | | | handle cases like this: void test(int N, double* G) { long j; for (j = 1; j < N - 1; j++) G[j+1] = G[j] + G[j+1]; } where G[1] isn't live into the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90041 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance InsertPHITranslatedPointer to be able to return a list of newlyChris Lattner2009-11-28
| | | | | | | inserted instructions. No functionality change until someone starts using it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90039 91177308-0d34-0410-b5e6-96231b3b80d8
* disable value insertion for now, I need to figure out howChris Lattner2009-11-27
| | | | | | | | to inform GVN about the newly inserted values. This fixes PR5631. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90022 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework InsertPHITranslatedPointer to handle the recursive case, this Chris Lattner2009-11-27
| | | | | | | | fixes PR5630 and sets the stage for the next phase of goodness (testcase pending). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90019 91177308-0d34-0410-b5e6-96231b3b80d8
* teach GVN's load PRE to insert computations of the address in predecessorsChris Lattner2009-11-27
| | | | | | | | where it is not available. It's unclear how to get this inserted computation into GVN's scalar availability sets, Owen, help? :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89997 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix phi translation in load PRE to agree with the phi Chris Lattner2009-11-27
| | | | | | | | translation done by memdep, and reenable gep translation again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89992 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an option for running GVN with redundant load processing disabled.Dan Gohman2009-11-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88742 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix DenseMap iterator constness.Jeffrey Yasskin2009-11-10
| | | | | | | | | | | | | | | | | | | | This patch forbids implicit conversion of DenseMap::const_iterator to DenseMap::iterator which was possible because DenseMapIterator inherited (publicly) from DenseMapConstIterator. Conversion the other way around is now allowed as one may expect. The template DenseMapConstIterator is removed and the template parameter IsConst which specifies whether the iterator is constant is added to DenseMapIterator. Actually IsConst parameter is not necessary since the constness can be determined from KeyT but this is not relevant to the fix and can be addressed later. Patch by Victor Zverovich! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86636 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure PRE doesn't split crit edges from indirectbr.Chris Lattner2009-10-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85692 91177308-0d34-0410-b5e6-96231b3b80d8
* Add option to createGVNPass to disable PRE.Evan Cheng2009-10-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85609 91177308-0d34-0410-b5e6-96231b3b80d8
* Treat lifetime begin/end markers as allocations/frees respectively for theOwen Anderson2009-10-28
| | | | | | | purposes for GVN/DSE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85383 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename MallocFreeHelper as MemoryBuiltinsVictor Hernandez2009-10-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85286 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename MallocHelper as MallocFreeHelper, since it now also identifies calls ↵Victor Hernandez2009-10-26
| | | | | | to free() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85181 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove AllocationInst. Since MallocInst went away, AllocaInst is the only ↵Victor Hernandez2009-10-23
| | | | | | subclass of AllocationInst, so it no longer is necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84969 91177308-0d34-0410-b5e6-96231b3b80d8
* make GVN work better when TD is not around:Chris Lattner2009-10-21
| | | | | | | | | | | | | | | | | | | "In the existing code, if the load and the value to replace it with are of different types *and* target data is available, it tries to use the target data to coerce the replacement value to the type of the load. Otherwise, it skips all effort to handle the type mismatch and just feeds the wrongly-typed replacement value to replaceAllUsesWith, which triggers an assertion. The patch replaces it with an outer if checking for type mismatch, and an inner if-else that checks whether target data is available and, if not, returns false rather than trying to replace the load." Patch by Kenneth Uildriks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84739 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor lookup_or_add to contain _MUCH_ less duplicated code. Add support forOwen Anderson2009-10-19
| | | | | | | numbering first class aggregate instructions while we're at it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84547 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify some code.Owen Anderson2009-10-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84533 91177308-0d34-0410-b5e6-96231b3b80d8
* Use isVoidTy()Devang Patel2009-10-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84118 91177308-0d34-0410-b5e6-96231b3b80d8
* switch GVN to use SSAUpdater. Besides removing a lot of complexityChris Lattner2009-10-10
| | | | | | | | | from GVN, this also speeds it up, inserts fewer PHI nodes (see the testcase) and allows it to remove more loads (due to fewer PHI nodes standing in the way). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83746 91177308-0d34-0410-b5e6-96231b3b80d8
* remove dead codeChris Lattner2009-10-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83742 91177308-0d34-0410-b5e6-96231b3b80d8
* random tidyingChris Lattner2009-10-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83701 91177308-0d34-0410-b5e6-96231b3b80d8
* simplify some code.Chris Lattner2009-09-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82936 91177308-0d34-0410-b5e6-96231b3b80d8
* Instruction::clone does not need to take an LLVMContext&. Remove that andNick Lewycky2009-09-27
| | | | | | | update all the callers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82889 91177308-0d34-0410-b5e6-96231b3b80d8
* big endian systems shift by bits too, hopefully this will fix the ppc Chris Lattner2009-09-21
| | | | | | | bootstrap problems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82464 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR5016, a crash I introduced in GVN handing first classChris Lattner2009-09-21
| | | | | | | arrays and structs, which cannot be bitcast to integers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82460 91177308-0d34-0410-b5e6-96231b3b80d8
* enable non-local analysis and PRE of large store -> little load.Chris Lattner2009-09-21
| | | | | | | | This doesn't kick in too much because of phi translation issues, but this can be resolved in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82447 91177308-0d34-0410-b5e6-96231b3b80d8