summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/GVN.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Switch GVN and memdep to use PHITransAddr, which correctly handlesChris Lattner2009-12-091-17/+22
| | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 90926
* constant fold loads from memcpy's from global constants. This is importantChris Lattner2009-12-061-6/+46
| | | | | | | because clang lowers nontrivial automatic struct/array inits to memcpy from a global array. llvm-svn: 90698
* add support for forwarding mem intrinsic values to non-local loads.Chris Lattner2009-12-061-33/+71
| | | | llvm-svn: 90697
* Handle forwarding local memsets to loads. For example, we optimize this:Chris Lattner2009-12-061-43/+136
| | | | | | | | | | | short x(short *A) { memset(A, 1, sizeof(*A)*100); return A[42]; } to 'return 257' instead of doing the load. llvm-svn: 90695
* Fix this crasher, and add a FIXME for a missed optimization.Owen Anderson2009-12-031-0/+10
| | | | llvm-svn: 90408
* Cleanup/remove some parts of the lifetime region handling code in memdep and ↵Owen Anderson2009-12-021-8/+6
| | | | | | | | GVN, per Chris' comments. Adjust testcases to match. llvm-svn: 90304
* factor some code better.Chris Lattner2009-12-021-10/+10
| | | | llvm-svn: 90299
* reenable load address insertion in load pre. This allows us toChris Lattner2009-11-281-11/+19
| | | | | | | | | | | | | 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. llvm-svn: 90041
* Enhance InsertPHITranslatedPointer to be able to return a list of newlyChris Lattner2009-11-281-1/+3
| | | | | | inserted instructions. No functionality change until someone starts using it. llvm-svn: 90039
* disable value insertion for now, I need to figure out howChris Lattner2009-11-271-1/+7
| | | | | | | to inform GVN about the newly inserted values. This fixes PR5631. llvm-svn: 90022
* Rework InsertPHITranslatedPointer to handle the recursive case, this Chris Lattner2009-11-271-24/+14
| | | | | | | fixes PR5630 and sets the stage for the next phase of goodness (testcase pending). llvm-svn: 90019
* teach GVN's load PRE to insert computations of the address in predecessorsChris Lattner2009-11-271-18/+26
| | | | | | | where it is not available. It's unclear how to get this inserted computation into GVN's scalar availability sets, Owen, help? :) llvm-svn: 89997
* Fix phi translation in load PRE to agree with the phi Chris Lattner2009-11-271-2/+8
| | | | | | | translation done by memdep, and reenable gep translation again. llvm-svn: 89992
* Add an option for running GVN with redundant load processing disabled.Dan Gohman2009-11-141-9/+23
| | | | llvm-svn: 88742
* Fix DenseMap iterator constness.Jeffrey Yasskin2009-11-101-4/+4
| | | | | | | | | | | | | | | | | | | 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! llvm-svn: 86636
* Make sure PRE doesn't split crit edges from indirectbr.Chris Lattner2009-10-311-1/+5
| | | | llvm-svn: 85692
* Add option to createGVNPass to disable PRE.Evan Cheng2009-10-301-2/+3
| | | | llvm-svn: 85609
* Treat lifetime begin/end markers as allocations/frees respectively for theOwen Anderson2009-10-281-0/+21
| | | | | | purposes for GVN/DSE. llvm-svn: 85383
* Rename MallocFreeHelper as MemoryBuiltinsVictor Hernandez2009-10-271-1/+1
| | | | llvm-svn: 85286
* Rename MallocHelper as MallocFreeHelper, since it now also identifies calls ↵Victor Hernandez2009-10-261-1/+1
| | | | | | to free() llvm-svn: 85181
* Remove AllocationInst. Since MallocInst went away, AllocaInst is the only ↵Victor Hernandez2009-10-231-4/+4
| | | | | | subclass of AllocationInst, so it no longer is necessary. llvm-svn: 84969
* make GVN work better when TD is not around:Chris Lattner2009-10-211-15/+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! llvm-svn: 84739
* Refactor lookup_or_add to contain _MUCH_ less duplicated code. Add support forOwen Anderson2009-10-191-181/+217
| | | | | | numbering first class aggregate instructions while we're at it. llvm-svn: 84547
* Simplify some code.Owen Anderson2009-10-191-124/+61
| | | | llvm-svn: 84533
* Use isVoidTy()Devang Patel2009-10-141-1/+1
| | | | llvm-svn: 84118
* switch GVN to use SSAUpdater. Besides removing a lot of complexityChris Lattner2009-10-101-151/+38
| | | | | | | | 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). llvm-svn: 83746
* remove dead codeChris Lattner2009-10-101-65/+0
| | | | llvm-svn: 83742
* random tidyingChris Lattner2009-10-101-5/+7
| | | | llvm-svn: 83701
* simplify some code.Chris Lattner2009-09-271-2/+2
| | | | llvm-svn: 82936
* Instruction::clone does not need to take an LLVMContext&. Remove that andNick Lewycky2009-09-271-1/+1
| | | | | | update all the callers. llvm-svn: 82889
* big endian systems shift by bits too, hopefully this will fix the ppc Chris Lattner2009-09-211-1/+1
| | | | | | bootstrap problems. llvm-svn: 82464
* fix PR5016, a crash I introduced in GVN handing first classChris Lattner2009-09-211-10/+38
| | | | | | arrays and structs, which cannot be bitcast to integers. llvm-svn: 82460
* enable non-local analysis and PRE of large store -> little load.Chris Lattner2009-09-211-30/+66
| | | | | | | This doesn't kick in too much because of phi translation issues, but this can be resolved in the future. llvm-svn: 82447
* convert an std::pair to an explicit struct.Chris Lattner2009-09-211-17/+32
| | | | llvm-svn: 82446
* move some functions, add a comment.Chris Lattner2009-09-211-164/+165
| | | | llvm-svn: 82444
* split HandleLoadFromClobberingStore in two pieces: one that does theChris Lattner2009-09-211-21/+41
| | | | | | analysis, one that does the xform. llvm-svn: 82443
* Improve GVN to be able to forward substitute a small load Chris Lattner2009-09-211-7/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from a piece of a large store when both are in the same block. This allows clang to compile the testcase in PR4216 to this code: _test_bitfield: movl 4(%esp), %eax movl %eax, %ecx andl $-65536, %ecx orl $32962, %eax andl $40186, %eax orl %ecx, %eax ret This is not ideal, but is a whole lot better than the code produced by llvm-gcc: _test_bitfield: movw $-32574, %ax orw 4(%esp), %ax andw $-25350, %ax movw %ax, 4(%esp) movw 7(%esp), %cx shlw $8, %cx movzbl 6(%esp), %edx orw %cx, %dx movzwl %dx, %ecx shll $16, %ecx movzwl %ax, %eax orl %ecx, %eax ret and dramatically better than that produced by gcc 4.2: _test_bitfield: pushl %ebx call L3 "L00000000001$pb": L3: popl %ebx movl 8(%esp), %eax leal 0(,%eax,4), %edx sarb $7, %dl movl %eax, %ecx andl $7168, %ecx andl $-7201, %ebx movzbl %dl, %edx andl $1, %edx sall $5, %edx orl %ecx, %ebx orl %edx, %ebx andl $24, %eax andl $-58336, %ebx orl %eax, %ebx orl $32962, %ebx movl %ebx, %eax popl %ebx ret llvm-svn: 82439
* formatting cleanups, no functionality change.Chris Lattner2009-09-211-118/+116
| | | | llvm-svn: 82426
* Move CoerceAvailableValueToLoadType earlier in GVN.cpp. Hook it upChris Lattner2009-09-201-105/+152
| | | | | | | | so that nonlocal and partially redundant loads can use it as well. The testcase shows examples of craziness this can handle. This triggers *many* times in 176.gcc. llvm-svn: 82403
* change the interface to CoerceAvailableValueToLoadType to be Chris Lattner2009-09-201-15/+21
| | | | | | more generic. llvm-svn: 82402
* enhance GVN to forward substitute a stored value to a loadChris Lattner2009-09-201-15/+129
| | | | | | | | (and load -> load) when the base pointers must alias but when they are different types. This occurs very very frequently in 176.gcc and other code that uses bitfields a lot. llvm-svn: 82399
* Tabs -> spaces, and remove trailing whitespace.Daniel Dunbar2009-09-201-211/+211
| | | | llvm-svn: 82355
* Enhance transform passes so that they apply the same tranforms to malloc ↵Victor Hernandez2009-09-181-5/+6
| | | | | | | | calls as to MallocInst. Reviewed by Dan Gohman. llvm-svn: 82300
* Change PHINode::hasConstantValue to have a DominatorTree argumentDan Gohman2009-09-031-1/+1
| | | | | | | | instead of a bool argument, and to do the dominator check itself. This makes it eaiser to use when DominatorTree information is available. llvm-svn: 80920
* eliminate VISIBILITY_HIDDEN from Transforms/Scalar. PR4861Chris Lattner2009-09-021-5/+4
| | | | llvm-svn: 80766
* Make this into a static method.Owen Anderson2009-08-261-15/+13
| | | | llvm-svn: 80170
* Push LLVMContexts through the IntegerType APIs.Owen Anderson2009-08-131-1/+2
| | | | llvm-svn: 78948
* Fix GVN's debug output, now that operator<< on Value* doesn't printDan Gohman2009-07-311-11/+12
| | | | | | a trailing newline. llvm-svn: 77719
* Move getTrue() and getFalse() to 2.5-like APIs.Owen Anderson2009-07-311-2/+4
| | | | llvm-svn: 77685
* Move more code back to 2.5 APIs.Owen Anderson2009-07-301-4/+4
| | | | llvm-svn: 77635
OpenPOWER on IntegriCloud