aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* give instcombine some helper functions for matching MIN and MAX, andChris Lattner2009-12-211-10/+118
| | | | | | | | | | implement some optimizations for MIN(MIN()) and MAX(MAX()) and MIN(MAX()) etc. This substantially improves the code in PR5822 but doesn't kick in much elsewhere. 2 max's were optimized in pairlocalalign and one in smg2000. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91814 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance x-(-A) -> x+A to preserve NUW/NSW.Chris Lattner2009-12-211-11/+47
| | | | | | | | | | | | | Use the presence of NSW/NUW to fold "icmp (x+cst), x" to a constant in cases where it would otherwise be undefined behavior. Surprisingly (to me at least), this triggers hundreds of the times in a few benchmarks: lencode, ldecode, and 466.h264ref seem to *really* like this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91812 91177308-0d34-0410-b5e6-96231b3b80d8
* Optimize all cases of "icmp (X+Cst), X" to something simpler. This triggersChris Lattner2009-12-211-3/+74
| | | | | | | | a bunch in lencode, ldecod, spass, 176.gcc, 252.eon, among others. It is also the first part of PR5822 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91811 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bunch of little errors that Clang complains about when its being pedanticDouglas Gregor2009-12-191-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91764 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR5827 by disabling the phi slicing transformation in a caseChris Lattner2009-12-191-1/+20
| | | | | | | | | | where instcombine would have to split a critical edge due to a phi node of an invoke. Since instcombine can't change the CFG, it has to bail out from doing the transformation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91763 91177308-0d34-0410-b5e6-96231b3b80d8
* Update my SROA changes in response to review.Bob Wilson2009-12-191-33/+38
| | | | | | | | | | | * change FindElementAndOffset to return a uint64_t instead of unsigned, and to identify the type to be used for that result in a GEP instruction. * move "isa<ConstantInt>" to be first in conditional. * replace some dyn_casts with casts. * add a comment about handling mem intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91762 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 91459 with a simple fix for the problem that broke the x86_64-darwinBob Wilson2009-12-181-405/+425
| | | | | | | | bootstrap. This also replaces the WeakVH references that Chris objected to with normal Value references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91711 91177308-0d34-0410-b5e6-96231b3b80d8
* Optimize icmp of null and select of two constants even if the select hasEli Friedman2009-12-181-15/+17
| | | | | | | | multiple uses. (The construct in question was found in gcc.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91675 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminte unnecessary uses of <cstdio>.Dan Gohman2009-12-182-5/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91666 91177308-0d34-0410-b5e6-96231b3b80d8
* Add Loop contains utility methods for testing whether a loopDan Gohman2009-12-187-26/+26
| | | | | | | | | contains another loop, or an instruction. The loop form is substantially more efficient on large loops than the typical code it replaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91654 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code simplification.Dan Gohman2009-12-181-4/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91653 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't pass const pointers by reference.Dan Gohman2009-12-181-13/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91647 91177308-0d34-0410-b5e6-96231b3b80d8
* Update a comment.Dan Gohman2009-12-181-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91645 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply LoopStrengthReduce and IVUsers cleanups, excluding the partDan Gohman2009-12-181-70/+30
| | | | | | | | | of 91296 that caused trouble -- the Processed list needs to be preserved for the livetime of the pass, as AddUsersIfInteresting is called from other passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91641 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow instcombine to combine "sext(a) >u const" to "a >u trunc(const)".Eli Friedman2009-12-171-12/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91631 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the ptrtoint comparison simplification work if one side is a global.Eli Friedman2009-12-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91624 91177308-0d34-0410-b5e6-96231b3b80d8
* Slightly generalize transformation of memmove(a,a,n) so that it also appliesEli Friedman2009-12-171-1/+3
| | | | | | | | | to memcpy. (Such a memcpy is technically illegal, but in practice is safe and is generated by struct self-assignment in C code.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91621 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-revert 91459. It's breaking the x86_64 darwin bootstrap.Bob Wilson2009-12-171-424/+404
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91607 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert 91280-91283, 91286-91289, 91291, 91293, 91295-91296. It apparently ↵Evan Cheng2009-12-172-38/+78
| | | | | | introduced a non-deterministic behavior in the optimizer somewhere. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91598 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r91459, it was only unmasking the bug, and since TOT is still broken ↵Daniel Dunbar2009-12-161-404/+424
| | | | | | having it reverted does no good. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91559 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Reapply 91184 with fixes and an addition to the testcase to cover theDaniel Dunbar2009-12-161-424/+404
| | | | | | | | | problem", this broke llvm-gcc bootstrap for release builds on x86_64-apple-darwin10. This reverts commit db22309800b224a9f5f51baf76071d7a93ce59c9. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91534 91177308-0d34-0410-b5e6-96231b3b80d8
* reapply my strstr optimization. I have reproduced the x86-64 bootstrapChris Lattner2009-12-161-9/+75
| | | | | | | | miscompile (i386.o miscompares) but it happens both with and without this patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91532 91177308-0d34-0410-b5e6-96231b3b80d8
* revert my strstr optimization, I'm told it breaks x86-64 bootstrap.Chris Lattner2009-12-161-75/+9
| | | | | | | Will reapply with a fix when I get a chance. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91486 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply 91184 with fixes and an addition to the testcase to cover the problemBob Wilson2009-12-151-404/+424
| | | | | | | | | | | found last time. Instead of trying to modify the IR while iterating over it, I've change it to keep a list of WeakVH references to dead instructions, and then delete those instructions later. I also added some special case code to detect and handle the situation when both operands of a memcpy intrinsic are referencing the same alloca. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91459 91177308-0d34-0410-b5e6-96231b3b80d8
* optimize strstr, PR5783Chris Lattner2009-12-151-9/+75
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91438 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete an unused function.Dan Gohman2009-12-151-38/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91432 91177308-0d34-0410-b5e6-96231b3b80d8
* add some other xforms that should be done as part of PR5783Chris Lattner2009-12-151-3/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91428 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove isPod() from DenseMapInfo, splitting it out to its ownChris Lattner2009-12-154-4/+9
| | | | | | | | | | 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 a thinko; isNotAlreadyContainedIn had a built-in negative, so theDan Gohman2009-12-141-1/+1
| | | | | | | condition was inverted when the code was converted to contains(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91295 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unnecessary #includes.Dan Gohman2009-12-141-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91293 91177308-0d34-0410-b5e6-96231b3b80d8
* Instead of having a ScalarEvolution pointer member in BasedUser, just passDan Gohman2009-12-141-12/+13
| | | | | | | the ScalarEvolution pointer into the functions which need it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91289 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't bother cleaning up if there's nothing to clean up.Dan Gohman2009-12-141-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91288 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete an unused variable.Dan Gohman2009-12-141-10/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91287 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR itself doesn't need LoopInfo.Dan Gohman2009-12-141-6/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91283 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR itself doesn't need DominatorTree.Dan Gohman2009-12-141-6/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91282 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the code in LSR that manually hoists expansions out of loops;Dan Gohman2009-12-141-29/+9
| | | | | | | SCEVExpander does this automatically. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91281 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code cleanups.Dan Gohman2009-12-141-4/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91280 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r91184, because it causes a crash on a .bc file I justChris Lattner2009-12-141-366/+390
| | | | | | | sent to Bob. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91268 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't leave pointers uninitialized in the default constructor. GCC complainsChandler Carruth2009-12-131-1/+1
| | | | | | | about the potential use of these uninitialized members under certain conditions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91239 91177308-0d34-0410-b5e6-96231b3b80d8
* Revise scalar replacement to be more flexible about handle bitcasts and GEPs.Bob Wilson2009-12-111-390/+366
| | | | | | | | | | | | | | | | While scanning through the uses of an alloca, keep track of the current offset relative to the start of the alloca, and check memory references to see if the offset & size correspond to a component within the alloca. This has the nice benefit of unifying much of the code from isSafeUseOfAllocation, isSafeElementUse, and isSafeUseOfBitCastedAllocation. The code to rewrite the uses of a promoted alloca, after it is determined to be safe, is reorganized in the same way. Also, when rewriting GEP instructions, mark them as "in-bounds" since all the indices are known to be safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91184 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure the immediate dominator isn't NULL through iterationsEric Christopher2009-12-101-5/+6
| | | | | | | | of the loop. We could get to this condition via indirect branches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91009 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR5744, a case where we were getting the pointer size instead of theChris Lattner2009-12-101-1/+1
| | | | | | | | | 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-101-6/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90999 91177308-0d34-0410-b5e6-96231b3b80d8
* Dereference loopHeader after checking for null rather than before.Dan Gohman2009-12-091-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90990 91177308-0d34-0410-b5e6-96231b3b80d8
* fix hte last remaining known (by me) phi translation bug. When we reanalyzeChris Lattner2009-12-091-6/+9
| | | | | | | | 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-091-7/+7
| | | | | | | implicitly constant folds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90977 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a comment.Bob Wilson2009-12-091-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90975 91177308-0d34-0410-b5e6-96231b3b80d8
* change AnalyzeLoadFromClobberingMemInst/AnalyzeLoadFromClobberingStoreChris Lattner2009-12-091-13/+22
| | | | | | | 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-091-10/+12
| | | | | | | 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-091-10/+10
| | | | | | | own small class. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90956 91177308-0d34-0410-b5e6-96231b3b80d8