summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* 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. llvm-svn: 120406
* Add a puts optimization that converts puts() to putchar('\n').Anders Carlsson2010-11-301-3/+30
| | | | llvm-svn: 120398
* rename a function and reduce some indentation, no functionality change.Chris Lattner2010-11-301-19/+21
| | | | llvm-svn: 120391
* 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. llvm-svn: 120382
* rename doesClobberMemory -> hasMemoryWrite to be more specific, andChris Lattner2010-11-301-11/+11
| | | | | | remove an actively-wrong comment. llvm-svn: 120378
* 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. llvm-svn: 120377
* 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. llvm-svn: 120368
* my previous patch would cause us to start deleting some volatileChris Lattner2010-11-301-1/+1
| | | | | | stores, fix and add a testcase. llvm-svn: 120363
* 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. llvm-svn: 120359
* prune an llvmcontext include and simplify some code.Chris Lattner2010-11-291-6/+3
| | | | llvm-svn: 120347
* fix PR8677, patch by Jakub Staszak!Chris Lattner2010-11-291-2/+4
| | | | llvm-svn: 120325
* 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. llvm-svn: 120323
* 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. llvm-svn: 120202
* 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. llvm-svn: 120126
* Rename SimplifyDistributed to the more meaningfull name SimplifyByFactorizing.Duncan Sands2010-11-234-15/+15
| | | | llvm-svn: 120051
* 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. llvm-svn: 120049
* 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. llvm-svn: 120044
* Constant folding here is pointless, because InstructionSimplifyDuncan Sands2010-11-231-8/+1
| | | | | | | (which does constant folding and more) is called a few lines later. llvm-svn: 120042
* 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. llvm-svn: 120028
* Propagate LeftDistributes and RightDistributes into their only uses.Duncan Sands2010-11-231-6/+4
| | | | | | Stylistic improvement suggested by Frits van Bommel. llvm-svn: 120026
* Fix typo pointed out by Frits van Bommel and Marius Wachtler.Duncan Sands2010-11-231-1/+1
| | | | llvm-svn: 120025
* 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. llvm-svn: 120024
* 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. llvm-svn: 119988
* InstCombine: Implement X - A*-B -> X + A*B.Benjamin Kramer2010-11-221-0/+9
| | | | llvm-svn: 119984
* 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. llvm-svn: 119974
* Move the "gep undef" -> "undef" transform from instcombine toDuncan Sands2010-11-221-3/+0
| | | | | | InstructionSimplify. llvm-svn: 119970
* Don't keep track of inserted phis in PromoteMemoryToRegister: the informationDuncan Sands2010-11-221-8/+3
| | | | | | is never used. Patch by Cameron Zwarich. llvm-svn: 119963
* fix commentChris Lattner2010-11-211-1/+0
| | | | llvm-svn: 119948
* 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. llvm-svn: 119930
* implement PR8576, deleting dead stores with intervening may-alias stores.Chris Lattner2010-11-211-3/+22
| | | | llvm-svn: 119927
* 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. llvm-svn: 119922
* 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. llvm-svn: 119916
* Simplify code. No change in functionality.Benjamin Kramer2010-11-203-3/+3
| | | | llvm-svn: 119908
* Document the new GVN number table structure.Owen Anderson2010-11-191-0/+12
| | | | llvm-svn: 119865
* When folding addressing modes in CodeGenPrepare, attempt to look through PHI ↵Owen Anderson2010-11-191-3/+29
| | | | | | | | | nodes if all the operands of the PHI are equivalent. This allows CodeGenPrepare to undo unprofitable PRE transforms. llvm-svn: 119853
* Factor code for testing whether replacing one value with anotherDuncan Sands2010-11-182-20/+23
| | | | | | | | preserves LCSSA form out of ScalarEvolution and into the LoopInfo class. Use it to check that SimplifyInstruction simplifications are not breaking LCSSA form. Fixes PR8622. llvm-svn: 119727
* Completely rework the datastructure GVN uses to represent the value number ↵Owen Anderson2010-11-181-72/+86
| | | | | | | | | | | | | | | | | | | | | | | to leader mapping. Previously, this was a tree of hashtables, and a query recursed into the table for the immediate dominator ad infinitum if the initial lookup failed. This led to really bad performance on tall, narrow CFGs. We can instead replace it with what is conceptually a multimap of value numbers to leaders (actually represented by a hashtable with a list of Value*'s as the value type), and then determine which leader from that set to use very cheaply thanks to the DFS numberings maintained by DominatorTree. Because there are typically few duplicates of a given value, this scan tends to be quite fast. Additionally, we use a custom linked list and BumpPtr allocation to avoid any unnecessary allocation in representing the value-side of the multimap. This change brings with it a 15% (!) improvement in the total running time of GVN on 403.gcc, which I think is pretty good considering that includes all the "real work" being done by MemDep as well. The one downside to this approach is that we can no longer use GVN to perform simple conditional progation, but that seems like an acceptable loss since we now have LVI and CorrelatedValuePropagation to pick up the slack. If you see conditional propagation that's not happening, please file bugs against LVI or CVP. llvm-svn: 119714
* slightly simplify code and substantially improve comment. Instead of Chris Lattner2010-11-181-20/+23
| | | | | | saying "it would be bad", give an example of what is going on. llvm-svn: 119695
* remove a pointless restriction from memcpyopt. It wasChris Lattner2010-11-181-4/+7
| | | | | | | | | | | | refusing to optimize two memcpy's like this: copy A <- B copy C <- A if it couldn't prove that noalias(B,C). We can eliminate the copy by producing a memmove instead of memcpy. llvm-svn: 119694
* remove another pointless noalias check: M is a memcpy, so theChris Lattner2010-11-181-2/+1
| | | | | | source and dest are known to not overlap. llvm-svn: 119692
* use AA::isNoAlias instead of open coding it. Remove an extraneous noalias ↵Chris Lattner2010-11-181-11/+7
| | | | | | | | | check: there is no need to check to see if the source and dest of a memcpy are noalias, behavior is undefined if not. llvm-svn: 119691
* finish a thought.Chris Lattner2010-11-181-1/+1
| | | | llvm-svn: 119690
* rearrange some code, splitting memcpy/memcpy optimizationChris Lattner2010-11-181-45/+56
| | | | | | out of processMemCpy into its own function. llvm-svn: 119687
* allow eliminating an alloca that is just copied from an constant globalChris Lattner2010-11-181-3/+10
| | | | | | | | if it is passed as a byval argument. The byval argument will just be a read, so it is safe to read from the original global instead. This allows us to promote away the %agg.tmp alloca in PR8582 llvm-svn: 119686
* enhance the "alloca is just a memcpy from constant global"Chris Lattner2010-11-181-0/+7
| | | | | | | to ignore calls that obviously can't modify the alloca because they are readonly/readnone. llvm-svn: 119683
* fix a small oversight in the "eliminate memcpy from constant global"Chris Lattner2010-11-181-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optimization. If the alloca that is "memcpy'd from constant" also has a memcpy from *it*, ignore it: it is a load. We now optimize the testcase to: define void @test2() { %B = alloca %T %a = bitcast %T* @G to i8* %b = bitcast %T* %B to i8* call void @llvm.memcpy.p0i8.p0i8.i64(i8* %b, i8* %a, i64 124, i32 4, i1 false) call void @bar(i8* %b) ret void } previously we would generate: define void @test() { %B = alloca %T %b = bitcast %T* %B to i8* %G.0 = getelementptr inbounds %T* @G, i32 0, i32 0 %tmp3 = load i8* %G.0, align 4 %G.1 = getelementptr inbounds %T* @G, i32 0, i32 1 %G.15 = bitcast [123 x i8]* %G.1 to i8* %1 = bitcast [123 x i8]* %G.1 to i984* %srcval = load i984* %1, align 1 %B.0 = getelementptr inbounds %T* %B, i32 0, i32 0 store i8 %tmp3, i8* %B.0, align 4 %B.1 = getelementptr inbounds %T* %B, i32 0, i32 1 %B.12 = bitcast [123 x i8]* %B.1 to i8* %2 = bitcast [123 x i8]* %B.1 to i984* store i984 %srcval, i984* %2, align 1 call void @bar(i8* %b) ret void } llvm-svn: 119682
* Move SCEV::dominates and properlyDominates to ScalarEvolution.Dan Gohman2010-11-171-13/+11
| | | | llvm-svn: 119570
* Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be memberDan Gohman2010-11-172-15/+15
| | | | | | | functions of ScalarEvolution, in preparation for memoization and other optimizations. llvm-svn: 119562
* Reference ScalarEvolution by name rather than directly in LICM,Dan Gohman2010-11-171-2/+1
| | | | | | to avoid an unneeded dependence. llvm-svn: 119557
* InstCombine: Add a missing irem identity (X % X -> 0).Benjamin Kramer2010-11-171-0/+4
| | | | llvm-svn: 119538
OpenPOWER on IntegriCloud