summaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
Commit message (Collapse)AuthorAge
* Probably not a good idea to convert a single vector load into a memcpy. WeChad Rosier2011-12-06
| | | | | | | | don't do this now, but add a test case to prevent this from happening in the future. Additional test for rdar://9892684 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145879 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for vectors of pointers.Nadav Rotem2011-12-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145801 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a theoretical problem (not seen in the wild): if different instances of aDuncan Sands2011-11-29
| | | | | | | | | | | | | | | | weak variable are compiled by different compilers, such as GCC and LLVM, while LLVM may increase the alignment to the preferred alignment there is no reason to think that GCC will use anything more than the ABI alignment. Since it is the GCC version that might end up in the final program (as the linkage is weak), it is wrong to increase the alignment of loads from the global up to the preferred alignment as the alignment might only be the ABI alignment. Increasing alignment up to the ABI alignment might be OK, but I'm not totally convinced that it is. It seems better to just leave the alignment of weak globals alone. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145413 91177308-0d34-0410-b5e6-96231b3b80d8
* Make SelectionDAG::InferPtrAlignment use llvm::ComputeMaskedBits instead of ↵Eli Friedman2011-11-28
| | | | | | duplicating the logic for globals. Make llvm::ComputeMaskedBits handle GlobalVariables slightly more aggressively, to match what InferPtrAlignment knew how to do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145304 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crash in which a multiplication was being reported as being both negativeDuncan Sands2011-11-23
| | | | | | | | | and positive: positive, because it could be directly computed to be positive; negative, because the nsw flags means it is either negative or undefined (the multiplication always overflowed). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145104 91177308-0d34-0410-b5e6-96231b3b80d8
* A shift of a power of two is a power of two or zero.Duncan Sands2011-10-28
| | | | | | | For completeness - not spotted in the wild. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143211 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply commit 143028 with a fix: the problem was casting a ConstantExpr MulDuncan Sands2011-10-27
| | | | | | | | | | | | using BinaryOperator (which only works for instructions) when it should have been a cast to OverflowingBinaryOperator (which also works for constants). While there, correct a few other dubious looking uses of BinaryOperator. Thanks to Chad Rosier for the testcase. Original commit message: My super-optimizer noticed that we weren't folding this expression to true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143125 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert Duncan's r143028 expression folding which appears to be the culpritBob Wilson2011-10-27
| | | | | | behind a compile failure on 483.xalancbmk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143102 91177308-0d34-0410-b5e6-96231b3b80d8
* The maximum power of 2 dividing a power of 2 is itself. This occursDuncan Sands2011-10-26
| | | | | | | in 403.gcc and was spotted by my super-optimizer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143054 91177308-0d34-0410-b5e6-96231b3b80d8
* My super-optimizer noticed that we weren't folding this expression toDuncan Sands2011-10-26
| | | | | | | true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143028 91177308-0d34-0410-b5e6-96231b3b80d8
* "@string = constant i8 0" is a value i8* string of length zero. Analyze thatNick Lewycky2011-10-20
| | | | | | | correctly in GetStringLength, fixing PR11181! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142558 91177308-0d34-0410-b5e6-96231b3b80d8
* Migrate LLVM and Clang to use the new makeArrayRef(...) functions where ↵Frits van Bommel2011-07-18
| | | | | | | | | previously explicit non-default constructors were used. Mostly mechanical with some manual reformatting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135390 91177308-0d34-0410-b5e6-96231b3b80d8
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.Jay Foad2011-07-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135040 91177308-0d34-0410-b5e6-96231b3b80d8
* Move onlyUsedByLifetimeMarkers to ValueTracking so that it can be used by otherNick Lewycky2011-06-27
| | | | | | | passes as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133904 91177308-0d34-0410-b5e6-96231b3b80d8
* Renamed llvm.x86.sse42.crc32 intrinsics; crc64 doesn't exist. Chad Rosier2011-05-26
| | | | | | | | | | crc32.[8|16|32] have been renamed to .crc32.32.[8|16|32] and crc64.[8|16|32] have been renamed to .crc32.64.[8|64]. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132163 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach valuetracking that byval arguments with a specified alignment areChris Lattner2011-05-23
| | | | | | | | | | | | | | | | | | | | | | | | aligned. Teach memcpyopt to not give up all hope when confonted with an underaligned memcpy feeding an overaligned byval. If the *source* of the memcpy can be determined to be adequeately aligned, or if it can be forced to be, we can eliminate the memcpy. This addresses PR9794. We now compile the example into: define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp { entry: %call = call i32 @g(%struct.p* byval align 8 %q) nounwind ret i32 %call } in both x86-64 and x86-32 mode. We still don't get a tailcall though, because tailcalls apparently can't handle byval. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131884 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ValueTracking about x86 crc32 intrinsics.Evan Cheng2011-05-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131861 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-15
| | | | | | | | Luis Felipe Strano Moraes! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't assume something which might be a constant expression is an instruction.Eli Friedman2011-04-02
| | | | | | | | | Based on PR9429, but no testcase because I can't figure out how to trigger it anymore given other changes to the relevant code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128781 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix INT_MIN gotcha pointed out by Eli Friedman.Nick Lewycky2011-03-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128028 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ComputeMaskedBits about sub nsw.Benjamin Kramer2011-03-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127548 91177308-0d34-0410-b5e6-96231b3b80d8
* ComputeMaskedBits: sub falls through to add, and sub doesn't have the same ↵Benjamin Kramer2011-03-11
| | | | | | | | overflow semantics as add. Should fix the selfhost failures that started with r127463. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127465 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ComputeMaskedBits about nsw on add. I don't think there's anything we canNick Lewycky2011-03-11
| | | | | | | | do with nuw here, but sub and mul should be given similar treatment. Fixes PR9343 #15! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127463 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR9331. Simplified version of a patch by Jakub Staszak.Duncan Sands2011-03-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127243 91177308-0d34-0410-b5e6-96231b3b80d8
* Add more analysis of the sign bit of an srem instruction. If the LHS is negativeNick Lewycky2011-03-07
| | | | | | | | then the result could go either way. If it's provably positive then so is the srem. Fixes PR9343 #7! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127146 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix comment.Nick Lewycky2011-02-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126645 91177308-0d34-0410-b5e6-96231b3b80d8
* srem doesn't actually have the same resulting sign as its numerator, you couldNick Lewycky2011-02-28
| | | | | | | | also have a zero when numerator = denominator. Reverts parts of r126635 and r126637. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126644 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach value tracking to make use of flags in more situations.Nick Lewycky2011-02-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126642 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ValueTracking to look at the dividend when determining the sign bit of anNick Lewycky2011-02-28
| | | | | | | srem instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126637 91177308-0d34-0410-b5e6-96231b3b80d8
* Stores of null pointers should turn into memset, we weren't recognizingChris Lattner2011-02-19
| | | | | | | them as splat values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126041 91177308-0d34-0410-b5e6-96231b3b80d8
* Tolerate degenerate phi nodes that can occur in the middle of optimizationNick Lewycky2011-02-10
| | | | | | | passes. Fixes PR9112. Patch by Jakub Staszak! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125319 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a m_SignBit pattern for convenience.Duncan Sands2011-02-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124656 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo: should have been testing that X was odd, not V.Duncan Sands2011-01-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124533 91177308-0d34-0410-b5e6-96231b3b80d8
* APInt has a method for determining whether a number is a power of 2Duncan Sands2011-01-26
| | | | | | | which is more efficient than countPopulation - use it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124283 91177308-0d34-0410-b5e6-96231b3b80d8
* In which I discover that zero+zero is zero, d'oh!Duncan Sands2011-01-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124188 91177308-0d34-0410-b5e6-96231b3b80d8
* See if this fixes llvm-gcc bootstrap.Duncan Sands2011-01-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124184 91177308-0d34-0410-b5e6-96231b3b80d8
* According to my auto-simplifier the most common missed simplifications inDuncan Sands2011-01-25
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124183 91177308-0d34-0410-b5e6-96231b3b80d8
* Give GetUnderlyingObject a TargetData, to keep it in syncDan Gohman2011-01-24
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124134 91177308-0d34-0410-b5e6-96231b3b80d8
* fix an off-by-one bug that caused a crash analyzingChris Lattner2011-01-04
| | | | | | | ashr's with huge shift amounts, PR8896 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122814 91177308-0d34-0410-b5e6-96231b3b80d8
* move isBytewiseValue out to ValueTracking.h/cppChris Lattner2010-12-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122565 91177308-0d34-0410-b5e6-96231b3b80d8
* Add vector versions of some existing scalar transforms to aid codegen in ↵Nate Begeman2010-12-17
| | | | | | matching psign & pblend operations to the IR produced by clang/gcc for their C idioms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122105 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r121886, and also update DecomposeGEPExpression to keepDan Gohman2010-12-15
| | | | | | | it in sync. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121895 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r121886. DecomposeGEPExpression needs to be keptDan Gohman2010-12-15
| | | | | | | in sync. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121892 91177308-0d34-0410-b5e6-96231b3b80d8
* Strengthen GetUnderlyingObject using InstructionSimplify.Dan Gohman2010-12-15
| | | | | | | | | | | While LLVM's main design is that analysis code shouldn't go out of its way to understand code which hasn't been InstCombined, analysis utility routines like this can find themselves being called in the middle of transform passes when instcombine hasn't had a chance to run. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121886 91177308-0d34-0410-b5e6-96231b3b80d8
* Move Value::getUnderlyingObject to be a standaloneDan Gohman2010-12-15
| | | | | | | | function so that it can live in Analysis instead of VMCore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121885 91177308-0d34-0410-b5e6-96231b3b80d8
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-07
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
* PR5207: Rename overloaded APInt methods set(), clear(), flip() toJay Foad2010-12-01
| | | | | | setAllBits(), setBit(unsigned), etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120564 91177308-0d34-0410-b5e6-96231b3b80d8
* move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.hChris Lattner2010-11-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120476 91177308-0d34-0410-b5e6-96231b3b80d8
* PR5207: Make APInt::set(), APInt::clear() and APInt::flip() return void.Jay Foad2010-11-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120413 91177308-0d34-0410-b5e6-96231b3b80d8