summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* Use value ranges to fold ext(trunc) in SCEV when possible.Nick Lewycky2011-01-231-0/+34
| | | | llvm-svn: 124062
* Have SCEV turn sext(x) into zext(x) when x is s>= 0. This applies many times inNick Lewycky2011-01-221-0/+4
| | | | | | "make check" alone. llvm-svn: 124046
* Add a FIXME explaining the move to a single indirect call bonus per functionEric Christopher2011-01-221-0/+5
| | | | | | that we can change from indirect to direct. llvm-svn: 124045
* Only apply the devirtualization bonus once instead of per-call site in theEric Christopher2011-01-221-2/+6
| | | | | | | | target function. Fixes part of rdar://8546196 llvm-svn: 124044
* At -O123 the early-cse pass is run before instcombine has run. According to myDuncan Sands2011-01-201-0/+162
| | | | | | | | | | | | | | | | auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0. This patch adds this transform and some related logic to InstructionSimplify and removes some of the logic from instcombine (unfortunately not all because there are several situations in which instcombine can improve things by making new instructions, whereas instsimplify is not allowed to do this). At -O2 this often results in more than 15% more simplifications by early-cse, and results in hundreds of lines of bitcode being eliminated from the testsuite. I did see some small negative effects in the testsuite, for example a few additional instructions in three programs. One program, 483.xalancbmk, got an additional 35 instructions, which seems to be due to a function getting an additional instruction and then being inlined all over the place. llvm-svn: 123911
* Similarly, analyze truncate through multiply.Nick Lewycky2011-01-191-0/+14
| | | | llvm-svn: 123842
* Add a missed SCEV fold that is required to continue analyzing the IR producedNick Lewycky2011-01-191-0/+14
| | | | | | | | | | | by indvars through the scev expander. trunc(add x, y) --> add(trunc x, y). Currently SCEV largely folds the other way which is probably wrong, but preserved to minimize churn. Instcombine doesn't do this fold either, demonstrating a missed optz'n opportunity on code doing add+trunc+add. llvm-svn: 123838
* Add a missing SCEV simplification sext(zext x) --> zext x.Nick Lewycky2011-01-191-0/+4
| | | | llvm-svn: 123832
* Teach BasicAA to return PartialAlias in cases where both pointersDan Gohman2011-01-181-12/+35
| | | | | | | | are pointing to the same object, one pointer is accessing the entire object, and the other is access has a non-zero size. This prevents TBAA from kicking in and saying NoAlias in such cases. llvm-svn: 123775
* For completeness, generalize the (X + Y) - Y -> X transform and add X - (X + ↵Duncan Sands2011-01-181-15/+57
| | | | | | | | | | 1) -> -1. These were not recommended by my auto-simplifier since they don't fire often enough. However they do fire from time to time, for example they remove one subtraction from the final bitcode for 483.xalancbmk. llvm-svn: 123755
* Simplify (X<<1)-X into X. According to my auto-simplier this is the most ↵Duncan Sands2011-01-181-0/+6
| | | | | | | | | | | | | common missed simplification in fully optimized code. It occurs sporadically in the testsuite, and many times in 403.gcc: the final bitcode has 131 fewer subtractions after this change. The reason that the multiplies are not eliminated is the same reason that instcombine did not catch this: they are used by other instructions (instcombine catches this with a more general transform which in general is only profitable if the operands have only one use). llvm-svn: 123754
* Move DominanceFrontier from VMCore to Analysis.Cameron Zwarich2011-01-183-0/+139
| | | | llvm-svn: 123747
* fix PR8983, a broken assertion.Chris Lattner2011-01-161-1/+1
| | | | llvm-svn: 123562
* Teach LazyValueInfo that allocas aren't NULL. Over all of llvm-test, this savesNick Lewycky2011-01-151-5/+27
| | | | | | | | | | | half a million non-local queries, each of which would otherwise have triggered a linear scan over a basic block. Also fix a fixme for memory intrinsics which dereference pointers. With this, we prove that a pointer is non-null because it was dereferenced by an intrinsic 112 times in llvm-test. llvm-svn: 123533
* Turn X-(X-Y) into Y. According to my auto-simplifier this is the most commonDuncan Sands2011-01-141-1/+15
| | | | | | | | | simplification present in fully optimized code (I think instcombine fails to transform some of these when "X-Y" has more than one use). Fires here and there all over the test-suite, for example it eliminates 8 subtractions in the final IR for 445.gobmk, 2 subs in 447.dealII, 2 in paq8p etc. llvm-svn: 123442
* Factorize common code out of the InstructionSimplify shift logic. Add inDuncan Sands2011-01-141-62/+38
| | | | | | | | | | | threading of shifts over selects and phis while there. This fires here and there in the testsuite, to not much effect. For example when compiling spirit it fires 5 times, during early-cse, resulting in 6 more cse simplifications, and 3 more terminators being folded by jump threading, but the final bitcode doesn't change in any interesting way: other optimizations would have caught the opportunity anyway, only later. llvm-svn: 123441
* Move some shift transforms out of instcombine and into InstructionSimplify.Duncan Sands2011-01-141-0/+142
| | | | | | | | | | | | While there, I noticed that the transform "undef >>a X -> undef" was wrong. For example if X is 2 then the top two bits must be equal, so the result can not be anything. I fixed this in the constant folder as well. Also, I made the transform for "X << undef" stronger: it now folds to undef always, even though X might be zero. This is in accordance with the LangRef, but I must admit that it is fairly aggressive. Also, I added "i32 X << 32 -> undef" following the LangRef and the constant folder, likewise fairly aggressive. llvm-svn: 123417
* Add single entry / single exit accessors.Tobias Grosser2011-01-131-23/+32
| | | | | | | | | | | Add methods for accessing the (single) entry / exit edge of a region. If no such edge exists, null is returned. Both accessors return the start block of the corresponding edge. The edge can finally be formed by utilizing Region::getEntry() or Region::getExit(); Contributed by: Andreas Simbuerger <simbuerg@fim.uni-passau.de> llvm-svn: 123410
* Remove some wrong code which fortunately was never executed (as explained inDuncan Sands2011-01-131-6/+9
| | | | | | the comment I added): an extern weak global may have a null address. llvm-svn: 123373
* The most common simplification missed by instsimplify in unoptimized bitcodeDuncan Sands2011-01-131-19/+70
| | | | | | | | is "X != 0 -> X" when X is a boolean. This occurs a lot because of the way llvm-gcc converts gcc's conditional expressions. Add this, and a few other similar transforms for completeness. llvm-svn: 123372
* some comment improvements.Chris Lattner2011-01-111-3/+4
| | | | llvm-svn: 123243
* Temporarily revert 123133, it's causing some regressions and I'm tryingEric Christopher2011-01-111-8/+4
| | | | | | to get a testcase. llvm-svn: 123225
* the GEP faq says that only inbounds geps are guaranteed to not overflow.Chris Lattner2011-01-111-2/+3
| | | | llvm-svn: 123218
* Revert r123207: "Turn on memdep's verifyRemoved() in an attempt to smoke out ↵Jakob Stoklund Olesen2011-01-111-3/+1
| | | | | | | | the cause of our gcc bootstrap miscompare." It didn't. llvm-svn: 123215
* Turn on memdep's verifyRemoved() in an attempt to smoke out the cause of our ↵Jakob Stoklund Olesen2011-01-111-1/+3
| | | | | | gcc bootstrap miscompare. llvm-svn: 123207
* Teach constant folding to perform conversions from constant floatingChandler Carruth2011-01-111-0/+56
| | | | | | | | point values to their integer representation through the SSE intrinsic calls. This is the last part of a README.txt entry for which I have real world examples. llvm-svn: 123206
* Cleanup some of the constant folding code to consistently test intrinsicChandler Carruth2011-01-101-16/+18
| | | | | | | IDs when available rather than using a mixture of IDs and textual name comparisons. llvm-svn: 123165
* add a fixme: ir isn't expressive enough.Chris Lattner2011-01-091-0/+1
| | | | llvm-svn: 123139
* Step #4 in improving trip count analysis: HowFarToZero can analyzeChris Lattner2011-01-091-2/+11
| | | | | | | NUW AddRec's much more aggressively. We now get a trip count for @test2 in nsw.ll llvm-svn: 123138
* rearrange some code, no functionality change.Chris Lattner2011-01-091-41/+45
| | | | llvm-svn: 123136
* Step #3 to improving trip count analysis: If we foldChris Lattner2011-01-091-4/+8
| | | | | | | | a + {b,+,stride} into {a+b,+,stride} (because a is LIV), then the resultant AddRec is NUW/NSW if the client says it is. llvm-svn: 123133
* Step #2 to improve trip count analysis for loops like this:Chris Lattner2011-01-091-6/+105
| | | | | | | | | | | | | | | | | | | void f(int* begin, int* end) { std::fill(begin, end, 0); } which turns into a != exit expression where one pointer is strided and (thanks to step #1) known to not overflow, and the other is loop invariant. The observation here is that, though the IV is strided by 4 in this case, that the IV *has* to become equal to the end value. It cannot "miss" the end value by stepping over it, because if it did, the strided IV expression would eventually wrap around. Handle this by turning A != B into "A-B != 0" where the A-B part is known to be NUW. llvm-svn: 123131
* teach SCEV analysis of PHI nodes that PHI recurences formedChris Lattner2011-01-091-0/+5
| | | | | | | with GEP instructions are always NUW, because PHIs cannot wrap the end of the address space. llvm-svn: 123105
* reduce indentation. Print <nuw> and <nsw> when dumping SCEV AddRec'sChris Lattner2011-01-091-49/+54
| | | | | | that have the bit set. llvm-svn: 123104
* use isNullValue() to simplify code, add an assert.Chris Lattner2011-01-061-5/+6
| | | | llvm-svn: 122977
* implement constant folding support for an exotic constant expr:Chris Lattner2011-01-061-1/+19
| | | | | | | | | | ret i64 ptrtoint (i8* getelementptr ([1000 x i8]* @X, i64 1, i64 sub (i64 0, i64 ptrtoint ([1000 x i8]* @X to i64))) to i64) to "ret i64 1000". This allows us to correctly compute the trip count on a loop in PR8883, which occurs with std::fill on a char array. This allows us to transform it into a memset with a constant size. llvm-svn: 122950
* Reorder, rename, and document some members to make this easier to follow.Owen Anderson2011-01-051-20/+23
| | | | llvm-svn: 122929
* When computing the value on an edge, in certain cases LVI would fail to ↵Owen Anderson2011-01-051-0/+5
| | | | | | | | compute the value range in the predecessor block, leading to an incorrect conclusion for the edge value. Found by inspection. llvm-svn: 122908
* Re-convert several of LazyValueInfo's internal maps to Dense{Map|Set}, and ↵Owen Anderson2011-01-051-33/+93
| | | | | | | | | fix the issue in hasBlockValue() that was causing iterator invalidations. Many thanks to Dimitry Andric for tracking down those invalidations! llvm-svn: 122906
* fix an off-by-one bug that caused a crash analyzingChris Lattner2011-01-041-1/+1
| | | | | | ashr's with huge shift amounts, PR8896 llvm-svn: 122814
* Use the new addEscapingValue callback to update GlobalsModRef when GVN adds ↵Owen Anderson2011-01-032-0/+12
| | | | | | | | PHIs of GEPs. For the moment, have GlobalsModRef handle this conservatively by simply removing the value from its maps. llvm-svn: 122787
* Stub out a new updating interface to AliasAnalysis, allowing stateful ↵Owen Anderson2011-01-031-0/+6
| | | | | | | | | analyses to be informed when a pointer value has potentially become escaping. Implementations can choose to either fall back to conservative responses for that value, or may recompute their analysis to accomodate the change. llvm-svn: 122777
* fix rdar://8813415 - a miscompilation of 164.gzip that loop-idiomChris Lattner2011-01-031-0/+2
| | | | | | exposed. It turns out to be a latent bug in basicaa, scary. llvm-svn: 122772
* Add spliceFunction to the CallGraph interface. This allows users to efficientlyNick Lewycky2011-01-031-1/+15
| | | | | | | | | | update a callGraph when performing the common operation of splicing the body to a new function and updating all callers (such as via RAUW). No users yet, though this is intended for DeadArgumentElimination as part of PR8887. llvm-svn: 122728
* split dom frontier handling stuff out to its own DominanceFrontier header,Chris Lattner2011-01-027-3/+6
| | | | | | so that Dominators.h is *just* domtree. Also prune #includes a bit. llvm-svn: 122714
* Revert commit 122654 at the request of Chris, who reckons that instsimplifyDuncan Sands2011-01-011-124/+52
| | | | | | is the wrong hammer for this nail, and is probably right. llvm-svn: 122661
* Fix a README item by having InstructionSimplify do a mild form of valueDuncan Sands2011-01-011-52/+124
| | | | | | | | | | | numbering, in which it considers (for example) "%a = add i32 %x, %y" and "%b = add i32 %x, %y" to be equal because the operands are equal and the result of the instructions only depends on the values of the operands. This has almost no effect (it removes 4 instructions from gcc-as-one-file), and perhaps slows down compilation: I measured a 0.4% slowdown on the large gcc-as-one-file testcase, but it wasn't statistically significant. llvm-svn: 122654
* Cast away "comparison between signed and unsigned integer" warnings.Benjamin Kramer2010-12-281-3/+6
| | | | llvm-svn: 122598
* move isBytewiseValue out to ValueTracking.h/cppChris Lattner2010-12-261-0/+69
| | | | llvm-svn: 122565
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-232-3/+2
| | | | | | | new gcc warning that complains on self-assignments and self-initializations. llvm-svn: 122458
OpenPOWER on IntegriCloud