summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* My auto-simplifier noticed that ((X/Y)*Y)/Y occurs several times in SPECDuncan Sands2011-01-281-0/+107
| | | | | | | | | | | | | | | | | benchmarks, and that it can be simplified to X/Y. (In general you can only simplify (Z*Y)/Y to Z if the multiplication did not overflow; if Z has the form "X/Y" then this is the case). This patch implements that transform and moves some Div logic out of instcombine and into InstructionSimplify. Unfortunately instcombine gets in the way somewhat, since it likes to change (X/Y)*Y into X-(X rem Y), so I had to teach instcombine about this too. Finally, thanks to the NSW/NUW flags, sometimes we know directly that "Z*Y" does not overflow, because the flag says so, so I added that logic too. This eliminates a bunch of divisions and subtractions in 447.dealII, and has good effects on some other benchmarks too. It seems to have quite an effect on tramp3d-v4 but it's hard to say if it's good or bad because inlining decisions changed, resulting in massive changes all over. llvm-svn: 124487
* Temporarily revert 124275 to see if it brings the dragonegg buildbot back.Eric Christopher2011-01-261-85/+82
| | | | llvm-svn: 124312
* APInt has a method for determining whether a number is a power of 2Duncan Sands2011-01-261-1/+1
| | | | | | which is more efficient than countPopulation - use it. llvm-svn: 124283
* Fix memory corruption. If one of the SCEV creation functions calls another butNick Lewycky2011-01-261-0/+2
| | | | | | | doesn't return immediately after then the insert position in UniqueSCEVs will be out of date. No test because this is a memory corruption issue. Fixes PR9051! llvm-svn: 124282
* Separate out the constant bonus from the size reduction metrics. ReworkEric Christopher2011-01-261-82/+85
| | | | | | | | | a few loops accordingly. Should be no functional change. This is a step for more accurate cost/benefit analysis of devirt/inlining bonuses. llvm-svn: 124275
* Coding style formatting changes.Eric Christopher2011-01-261-7/+2
| | | | llvm-svn: 124260
* In which I discover that zero+zero is zero, d'oh!Duncan Sands2011-01-251-3/+3
| | | | llvm-svn: 124188
* See if this fixes llvm-gcc bootstrap.Duncan Sands2011-01-251-1/+2
| | | | llvm-svn: 124184
* According to my auto-simplifier the most common missed simplifications inDuncan Sands2011-01-252-13/+228
| | | | | | | | | | | optimized code are: (non-negative number)+(power-of-two) != 0 -> true and (x | 1) != 0 -> true Instcombine knows about the second one of course, but only does it if X|1 has only one use. These fire thousands of times in the testsuite. llvm-svn: 124183
* Reorganize this so that the early exit and special cases come earlyEric Christopher2011-01-251-26/+26
| | | | | | rather than interspersed. No functional change. llvm-svn: 124168
* Give GetUnderlyingObject a TargetData, to keep it in syncDan Gohman2011-01-245-11/+13
| | | | | | | | | | | with BasicAA's DecomposeGEPExpression, which recently began using a TargetData. This fixes PR8968, though the testcase is awkward to reduce. Also, update several off GetUnderlyingObject's users which happen to have a TargetData handy to pass it in. llvm-svn: 124134
* fix PR8928 by clearing a stale map, patch by Jakub Staszak!Chris Lattner2011-01-241-0/+1
| | | | llvm-svn: 124132
* Add a comment.Dan Gohman2011-01-241-0/+1
| | | | llvm-svn: 124126
* Simplify some code with no functionality change. Make the test a lot moreNick Lewycky2011-01-231-12/+4
| | | | | | robust against smarter optimizations, using the power of FileCheck. llvm-svn: 124081
* Null initialize a few variables flagged byTed Kremenek2011-01-231-1/+1
| | | | | | | | | | clang's -Wuninitialized-experimental warning. While these don't look like real bugs, clang's -Wuninitialized-experimental analysis is stricter than GCC's, and these fixes have the benefit of being general nice cleanups. llvm-svn: 124073
* 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
OpenPOWER on IntegriCloud