aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* PR5207: Rename overloaded APInt methods set(), clear(), flip() toJay Foad2010-12-013-21/+21
| | | | | | setAllBits(), setBit(unsigned), etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120564 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bozo bug I introduced in r119930, causing a miscompile ofChris Lattner2010-12-011-1/+2
| | | | | | | | 20040709-1.c from the gcc testsuite. I was using the size of a pointer instead of the pointee. This fixes rdar://8713376 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120519 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance DSE to handle the variable index case in PR8657.Chris Lattner2010-11-301-2/+31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120498 91177308-0d34-0410-b5e6-96231b3b80d8
* teach DSE to use GetPointerBaseWithConstantOffset to analyzeChris Lattner2010-11-301-16/+49
| | | | | | | | | may-aliasing stores that partially overlap with different base pointers. This implements PR6043 and the non-variable part of PR8657 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120485 91177308-0d34-0410-b5e6-96231b3b80d8
* move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.hChris Lattner2010-11-301-58/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120476 91177308-0d34-0410-b5e6-96231b3b80d8
* remove a fixed fixmeChris Lattner2010-11-301-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120474 91177308-0d34-0410-b5e6-96231b3b80d8
* Make DeleteDeadInstruction be a static function, move some code around.Chris Lattner2010-11-301-59/+64
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120471 91177308-0d34-0410-b5e6-96231b3b80d8
* switch RemoveAccessedObjects to use AliasAnalysis::Location to simplifyChris Lattner2010-11-301-17/+13
| | | | | | | | the code. We now get accurate sizes on Loads, though it surely doesn't matter in practice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120469 91177308-0d34-0410-b5e6-96231b3b80d8
* two improvements to RemoveAccessedObjects:Chris Lattner2010-11-301-28/+7
| | | | | | | | | | | | | | | 1. if the underlying pointer passed in can be resolved to any argument or alloca, then we don't need to scan. Previously we would only avoid the scan if the alloca or byval was actually considered dead. 2. The dead store processing code is itself completely dead and didn't handle volatile stores right anyway, so delete it. This allows simplifying the interface to RemoveAccessedObjects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120467 91177308-0d34-0410-b5e6-96231b3b80d8
* remove the "undead" terminology, which is nonstandard and never Chris Lattner2010-11-301-40/+47
| | | | | | | | | made sense to me. We now have a set of dead stack objects, and they become live when loaded. Fix a theoretical problem where we'd pass in the wrong pointer to the alias query. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120465 91177308-0d34-0410-b5e6-96231b3b80d8
* move call handling in handleEndBlock up a bit, and simplify it.Chris Lattner2010-11-301-37/+40
| | | | | | | | | If the call might read all the allocas, stop scanning early. Convert a vector to smallvector, shrink SmallPtrSet to 16 instead of 64 to avoid crazy linear scans. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120463 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid exponential growth of a table. It feels likeDale Johannesen2010-11-301-5/+22
| | | | | | | | there should be a better way to do this. PR 8679. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120457 91177308-0d34-0410-b5e6-96231b3b80d8
* various cleanups and code simplificationChris Lattner2010-11-301-87/+63
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120454 91177308-0d34-0410-b5e6-96231b3b80d8
* make getPointerSize a static function. Add ivars to DSE forChris Lattner2010-11-301-46/+42
| | | | | | | AA and MD pass info instead of using getAnalysis<> all over. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120453 91177308-0d34-0410-b5e6-96231b3b80d8
* reduce indentation, clean up TD use a bit.Chris Lattner2010-11-301-28/+31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120452 91177308-0d34-0410-b5e6-96231b3b80d8
* enhance isRemovable to refuse to delete volatile mem transfersChris Lattner2010-11-301-4/+19
| | | | | | | | now that DSE hacks on them. This fixes a regression I introduced, by generalizing DSE to hack on transfers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120445 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite the main DSE loop to be written in terms of reasoningChris Lattner2010-11-301-77/+106
| | | | | | | | | | | | | | | | about pairs of AA::Location's instead of looking for MemDep's "Def" predicate. This is more powerful and general, handling memset/memcpy/store all uniformly, and implementing PR8701 and probably obsoleting parts of memcpyoptimizer. This also fixes an obscure bug with init.trampoline and i8 stores, but I'm not surprised it hasn't been hit yet. Enhancing init.trampoline to carry the size that it stores would allow DSE to be much more aggressive about optimizing them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120406 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a puts optimization that converts puts() to putchar('\n').Anders Carlsson2010-11-301-3/+30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120398 91177308-0d34-0410-b5e6-96231b3b80d8
* rename a function and reduce some indentation, no functionality change.Chris Lattner2010-11-301-19/+21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120391 91177308-0d34-0410-b5e6-96231b3b80d8
* remove the pointless check of MemoryUseIntrinsic fromChris Lattner2010-11-301-3/+0
| | | | | | | | is trivially dead, since these have side effects. This makes the (misnamed) MemoryUseIntrinsic class dead, so remove it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120382 91177308-0d34-0410-b5e6-96231b3b80d8
* rename doesClobberMemory -> hasMemoryWrite to be more specific, andChris Lattner2010-11-301-11/+11
| | | | | | | remove an actively-wrong comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120378 91177308-0d34-0410-b5e6-96231b3b80d8
* clean up handling of 'free', detangling it from everything else.Chris Lattner2010-11-301-22/+22
| | | | | | | | It can be seriously improved, but at least now it isn't intertwined with the other logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120377 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach basicaa that memset's modref set is at worst "mod" and neverChris Lattner2010-11-301-7/+12
| | | | | | | | | | | contains "ref". Enhance DSE to use a modref query instead of a store-specific hack to generalize the "ignore may-alias stores" optimization to handle memset and memcpy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120368 91177308-0d34-0410-b5e6-96231b3b80d8
* my previous patch would cause us to start deleting some volatileChris Lattner2010-11-301-1/+1
| | | | | | | stores, fix and add a testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120363 91177308-0d34-0410-b5e6-96231b3b80d8
* two changes to DSE that shouldn't affect anything:Chris Lattner2010-11-301-58/+28
| | | | | | | | | | | | | | | | 1. Don't bother trying to optimize: lifetime.end(ptr) store(ptr) as it is undefined, and therefore shouldn't exist. 2. Move the 'storing a loaded pointer' xform up, simplifying the may-aliased store code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120359 91177308-0d34-0410-b5e6-96231b3b80d8
* prune an llvmcontext include and simplify some code.Chris Lattner2010-11-291-6/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120347 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR8677, patch by Jakub Staszak!Chris Lattner2010-11-291-2/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120325 91177308-0d34-0410-b5e6-96231b3b80d8
* Transform (extractvalue (load P), ...) to (load (gep P, 0, ...)) if the load ↵Frits van Bommel2010-11-291-3/+30
| | | | | | has no other uses, shrinking the load. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120323 91177308-0d34-0410-b5e6-96231b3b80d8
* Second attempt at fixing the performance regressions introducedOwen Anderson2010-11-271-24/+55
| | | | | | | | | by my recent GVN improvement. Looking through a single layer of PHI nodes when attempting to sink GEPs, we need to iteratively look through arbitrary PHI nests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120202 91177308-0d34-0410-b5e6-96231b3b80d8
* Treat a call of function pointer like a load of the pointer when consideringNick Lewycky2010-11-241-1/+6
| | | | | | | | whether the pointer can be replaced with the global variable it is a copy of. Fixes PR8680. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120126 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename SimplifyDistributed to the more meaningfull name SimplifyByFactorizing.Duncan Sands2010-11-234-15/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120051 91177308-0d34-0410-b5e6-96231b3b80d8
* The srem -> urem transform is not safe for any divisor that's not a power of ↵Benjamin Kramer2010-11-231-11/+9
| | | | | | | | | | | two. E.g. -5 % 5 is 0 with srem and 1 with urem. Also addresses Frits van Bommel's comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120049 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace calls to ConstantFoldInstruction with calls to SimplifyInstructionDuncan Sands2010-11-232-11/+12
| | | | | | | | in two places that are really interested in simplified instructions, not constants. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120044 91177308-0d34-0410-b5e6-96231b3b80d8
* Constant folding here is pointless, because InstructionSimplifyDuncan Sands2010-11-231-8/+1
| | | | | | | | (which does constant folding and more) is called a few lines later. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120042 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Reduce "X shift (A srem B)" to "X shift (A urem B)" iff B is ↵Benjamin Kramer2010-11-231-0/+15
| | | | | | | | | positive. This allows to transform the rem in "1 << ((int)x % 8);" to an and. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120028 91177308-0d34-0410-b5e6-96231b3b80d8
* Propagate LeftDistributes and RightDistributes into their only uses.Duncan Sands2010-11-231-6/+4
| | | | | | | Stylistic improvement suggested by Frits van Bommel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120026 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo pointed out by Frits van Bommel and Marius Wachtler.Duncan Sands2010-11-231-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120025 91177308-0d34-0410-b5e6-96231b3b80d8
* Exploit distributive laws (eg: And distributes over Or, Mul over Add, etc) in aDuncan Sands2010-11-234-42/+133
| | | | | | | | | | | | | fairly systematic way in instcombine. Some of these cases were already dealt with, in which case I removed the existing code. The case of Add has a bunch of funky logic which covers some of this plus a few variants (considers shifts to be a form of multiplication), which I didn't touch. The simplification performed is: A*B+A*C -> A*(B+C). The improvement is to do this in cases that were not already handled [such as A*B-A*C -> A*(B-C), which was reported on the mailing list], and also to do it more often by not checking for "only one use" if "B+C" simplifies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120024 91177308-0d34-0410-b5e6-96231b3b80d8
* duncan's spider sense was right, I completely reversed the conditionChris Lattner2010-11-231-8/+8
| | | | | | | on this instcombine xform. This fixes a miscompilation of 403.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119988 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Implement X - A*-B -> X + A*B.Benjamin Kramer2010-11-221-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119984 91177308-0d34-0410-b5e6-96231b3b80d8
* If a GEP index simply advances by multiples of a type of zero size,Duncan Sands2010-11-221-14/+24
| | | | | | | then replace the index with zero. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119974 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the "gep undef" -> "undef" transform from instcombine toDuncan Sands2010-11-221-3/+0
| | | | | | | InstructionSimplify. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119970 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't keep track of inserted phis in PromoteMemoryToRegister: the informationDuncan Sands2010-11-221-8/+3
| | | | | | | is never used. Patch by Cameron Zwarich. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119963 91177308-0d34-0410-b5e6-96231b3b80d8
* fix commentChris Lattner2010-11-211-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119948 91177308-0d34-0410-b5e6-96231b3b80d8
* rework some DSE paths to use the newly-public "getPointerDependencyFrom"Chris Lattner2010-11-211-46/+37
| | | | | | | | method in MemDep instead of inserting an instruction, doing a query, then removing it. Neither operation is effectively cached. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119930 91177308-0d34-0410-b5e6-96231b3b80d8
* implement PR8576, deleting dead stores with intervening may-alias stores.Chris Lattner2010-11-211-3/+22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119927 91177308-0d34-0410-b5e6-96231b3b80d8
* optimize:Chris Lattner2010-11-211-2/+72
| | | | | | | | | | | void a(int x) { if (((1<<x)&8)==0) b(); } into "x != 3", which occurs over 100 times in 403.gcc but in no other program in llvm-test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119922 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement PR8644: forwarding a memcpy value to a byval,Chris Lattner2010-11-211-44/+127
| | | | | | | | | | | | | allowing the memcpy to be eliminated. Unfortunately, the requirements on byval's without explicit alignment are really weak and impossible to predict in the mid-level optimizer, so this doesn't kick in much with current frontends. The fix is to change clang to set alignment on all byval arguments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119916 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify code. No change in functionality.Benjamin Kramer2010-11-203-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119908 91177308-0d34-0410-b5e6-96231b3b80d8
* Document the new GVN number table structure.Owen Anderson2010-11-191-0/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119865 91177308-0d34-0410-b5e6-96231b3b80d8