summaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
Commit message (Collapse)AuthorAge
...
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164767 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix integer undefined behavior due to signed left shift overflow in LLVM.Richard Smith2012-08-24
| | | | | | | Reviewed offline by chandlerc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162623 91177308-0d34-0410-b5e6-96231b3b80d8
* PHINode::hasConstantValue(): return undef if the PHI is fully recursive.Nuno Lopes2012-07-03
| | | | | | Thanks Duncan for the idea git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159687 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach DeadStoreElimination to eliminate exit-block stores with phi addresses.Dan Gohman2012-05-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156558 91177308-0d34-0410-b5e6-96231b3b80d8
* Just mark the sign bit as known zero, rather than any other irrelevant bitsDuncan Sands2012-04-30
| | | | | | | known zero in the LHS. Fixes PR12541. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155818 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix ValueTracking to conclude that debug intrinsics are safe toChandler Carruth2012-04-07
| | | | | | | | | | | | | | | | | | speculate. Without this, loop rotate (among many other places) would suddenly stop working in the presence of debug info. I found this looking at loop rotate, and have augmented its tests with a reduction out of a very hot loop in yacr2 where failing to do this rotation costs sometimes more than 10% in runtime performance, perturbing numerous downstream optimizations. This should have no impact on performance without debug info, but the change in performance when debug info is enabled can be extreme. As a consequence (and this how I got to this yak) any profiling of performance problems should be treated with deep suspicion -- they may have been wildly innacurate of debug info was enabled for profiling. =/ Just a heads up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154263 91177308-0d34-0410-b5e6-96231b3b80d8
* Always compute all the bits in ComputeMaskedBits.Rafael Espindola2012-04-04
| | | | | | | | This allows us to keep passing reduced masks to SimplifyDemandedBits, but know about all the bits if SimplifyDemandedBits fails. This allows instcombine to simplify cases like the one in the included testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154011 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach CodeGen's version of computeMaskedBits to understand the range metadata.Rafael Espindola2012-03-31
| | | | | | | | This is the CodeGen equivalent of r153747. I tested that there is not noticeable performance difference with any combination of -O0/-O2 /-g when compiling gcc as a single compilation unit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153817 91177308-0d34-0410-b5e6-96231b3b80d8
* Add computeMaskedBitsLoad back, as it was the change to instsimplify thatRafael Espindola2012-03-30
| | | | | | caused the slowdown last time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153747 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r153521 as it's causing large regressions on the nightly testers.Chad Rosier2012-03-28
| | | | | | | | | Original commit message for r153521 (aka r153423): Use the new range metadata in computeMaskedBits and add a new optimization to instruction simplify that lets us remove an and when loding a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153587 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r153423; the original commit was fine. The failing test, distray, had Chad Rosier2012-03-27
| | | | | | | | | | | undefined behavior, which Rafael was kind enough to fix. Original commit message for r153423: Use the new range metadata in computeMaskedBits and add a new optimization to instruction simplify that lets us remove an and when loding a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153521 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r153423 as this is causing failures on our internal nightly testers.Chad Rosier2012-03-26
| | | | | | | | Original commit message: Use the new range metadata in computeMaskedBits and add a new optimization to instruction simplify that lets us remove an and when loading a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153452 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new range metadata in computeMaskedBits and add a new optimization toRafael Espindola2012-03-26
| | | | | | instruction simplify that lets us remove an and when loding a boolean value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153423 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out the multiply analysis code in ComputeMaskedBits and apply it to theNick Lewycky2012-03-18
| | | | | | | | | overflow checking multiply intrinsic as well. Add a test for this, updating the test from grep to FileCheck. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153028 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out the analysis of addition and subtraction in ComputeMaskedBits. ReuseNick Lewycky2012-03-09
| | | | | | | it to analyze extractvalue(llvm.[us](add|sub).with.overflow.*) intrinsics! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152398 91177308-0d34-0410-b5e6-96231b3b80d8
* No functionality change. Type::isSized() can be expensive, so avoid calling itNick Lewycky2012-03-07
| | | | | | | until after other inexpensive tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152195 91177308-0d34-0410-b5e6-96231b3b80d8
* A few more cases of missing masking in ComputeMaskedBits; found by inspection.Eli Friedman2012-03-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152070 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure we don't return bits outside the mask in ComputeMaskedBits. PR12189.Eli Friedman2012-03-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152066 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove some dead code and tidy things up now that vectors use ConstantDataVectorChris Lattner2012-02-06
| | | | | | | | instead of always using ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149912 91177308-0d34-0410-b5e6-96231b3b80d8
* [unwind removal] Remove all of the code for the dead 'unwind' instruction. ThereBill Wendling2012-02-06
| | | | | | | | were no 'unwind' instructions being generated before this, so this is in effect a no-op. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149906 91177308-0d34-0410-b5e6-96231b3b80d8
* reapply the patches reverted in r149470 that reenable ConstantDataArray,Chris Lattner2012-02-05
| | | | | | | | | | | but with a critical fix to the SelectionDAG code that optimizes copies from strings into immediate stores: the previous code was stopping reading string data at the first nul. Address this by adding a new argument to llvm::getConstantStringInfo, preserving the behavior before the patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149800 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert Chris' commits up to r149348 that started causing VMCoreTests unit ↵Argyrios Kyrtzidis2012-02-01
| | | | | | | | | | | | | | | | | | | test to fail. These are: r149348 r149351 r149352 r149354 r149356 r149357 r149361 r149362 r149364 r149365 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149470 91177308-0d34-0410-b5e6-96231b3b80d8
* remove the last vestiges of llvm::GetConstantStringInfo, in CodeGen.Chris Lattner2012-01-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149356 91177308-0d34-0410-b5e6-96231b3b80d8
* Change ConstantArray::get to form a ConstantDataArray when possible,Chris Lattner2012-01-31
| | | | | | | | | | | | | | | | | kicking in the big win of ConstantDataArray. As part of this, change the implementation of GetConstantStringInfo in ValueTracking to work with ConstantDataArray (and not ConstantArray) making it dramatically, amazingly, more efficient in the process and renaming it to getConstantStringInfo. This keeps around a GetConstantStringInfo entrypoint that (grossly) forwards to getConstantStringInfo and constructs the std::string required, but existing clients should move over to getConstantStringInfo instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149351 91177308-0d34-0410-b5e6-96231b3b80d8
* progress making the world safe to ConstantDataVector. WhileChris Lattner2012-01-26
| | | | | | | | | we're at it, allow PatternMatch's "neg" pattern to match integer vector negations, and enhance ComputeNumSigned bits to handle shl of vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149082 91177308-0d34-0410-b5e6-96231b3b80d8
* use Constant::getAggregateElement to simplify a bunch of code.Chris Lattner2012-01-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148934 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the right method to get the # elements in a CDS.Chris Lattner2012-01-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148897 91177308-0d34-0410-b5e6-96231b3b80d8
* teach valuetracking about ConstantDataSequentialChris Lattner2012-01-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148790 91177308-0d34-0410-b5e6-96231b3b80d8
* Generalize isSafeToSpeculativelyExecute to work on arbitraryDan Gohman2012-01-04
| | | | | | | | Values, rather than just Instructions, since it's interesting for ConstantExprs too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147560 91177308-0d34-0410-b5e6-96231b3b80d8
* PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use ↵Benjamin Kramer2012-01-01
| | | | | | it to simplify a few matchers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147403 91177308-0d34-0410-b5e6-96231b3b80d8
* ComputeMaskedBits: Make knownzero computation more aggressive for ctlz with ↵Benjamin Kramer2011-12-24
| | | | | | | | | undef zero. unsigned foo(unsigned x) { return 31 - __builtin_clz(x); } now compiles into a single "bsrl" instruction on x86. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147255 91177308-0d34-0410-b5e6-96231b3b80d8
* Make some intrinsics safe to speculatively execute.Nick Lewycky2011-12-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147036 91177308-0d34-0410-b5e6-96231b3b80d8
* Move Instruction::isSafeToSpeculativelyExecute out of VMCore andDan Gohman2011-12-14
| | | | | | | | | | into Analysis as a standalone function, since there's no need for it to be in VMCore. Also, update it to use isKnownNonZero and other goodies available in Analysis, making it more precise, enabling more aggressive optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146610 91177308-0d34-0410-b5e6-96231b3b80d8
* 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