summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove a repeated comment line. NFC.Easwaran Raman2017-04-211-1/+0
| | | | llvm-svn: 301059
* [ValueTracking] Use APInt::setAllBits and APInt::intersects to simplify some ↵Craig Topper2017-04-211-3/+4
| | | | | | code. NFC llvm-svn: 300997
* [MSSA] Clean up the updater a bit. NFCGeorge Burgess IV2017-04-211-5/+4
| | | | | | | | - Mark an internal function static - Remove the llvm namespace (just holding on to the `using namespace llvm;` Works on My Machine(TM)) llvm-svn: 300947
* Revert r300746 (SCEV analysis for or instructions).Eli Friedman2017-04-201-6/+22
| | | | | | | | There have been multiple reports of this causing problems: a compile-time explosion on the LLVM testsuite, and a stack overflow for an opencl kernel. llvm-svn: 300928
* [APInt] Rename getSignBit to getSignMaskCraig Topper2017-04-203-11/+11
| | | | | | | | getSignBit is a static function that creates an APInt with only the sign bit set. getSignMask seems like a better name to convey its functionality. In fact several places use it and then store in an APInt named SignMask. Differential Revision: https://reviews.llvm.org/D32108 llvm-svn: 300856
* [APInt] Cast calls to add/sub/mul overflow methods to void if only their ↵Craig Topper2017-04-192-3/+3
| | | | | | | | | | overflow bool out param is used. This is preparation for a clang change to improve the [[nodiscard]] warning to not be ignored on methods that return a class marked [[nodiscard]] that are defined in the class itself. See D32207. We should consider adding wrapper methods to APInt that return the overflow flag directly and discard the APInt result. This would eliminate the void casts and the need to create a bool before the call to pass to the out param. llvm-svn: 300758
* [SCEV] Make SCEV or modeling more aggressive.Eli Friedman2017-04-191-22/+6
| | | | | | | | | | Use haveNoCommonBitsSet to figure out whether an "or" instruction is equivalent to addition. This handles more cases than just checking for a constant on the RHS. Differential Revision: https://reviews.llvm.org/D32239 llvm-svn: 300746
* [InstSimplify] fold identity shuffles (recursing if needed)Sanjay Patel2017-04-191-1/+76
| | | | | | | | | | | | | | | | | This patch simplifies the examples from D31509 and D31927 (PR30630) and catches the basic identity shuffle tests that Zvi recently added. I'm not sure if we have something like this in DAGCombiner, but we should? It's worth noting that "MaxRecurse / RecursionLimit" is only 3 on entry at the moment. We might want to bump that up if there are longer shuffle chains like this in the wild. For now, we're ignoring shuffles that have undef mask elements because it's not clear how those should be handled. Differential Revision: https://reviews.llvm.org/D31960 llvm-svn: 300714
* [InstSimplify] Deduce correct type for vector GEP.Davide Italiano2017-04-191-0/+2
| | | | | | | | | | InstSimplify returned the wrong type when simplifying a vector GEP and we ended up crashing when trying to replace all uses with the new value. Fixes PR32697. Differential Revision: https://reviews.llvm.org/D32180 llvm-svn: 300693
* Add a getPointerOperandType() helper to LoadInst and StoreInst; NFCSanjoy Das2017-04-181-6/+4
| | | | | | I will use this in a later change. llvm-svn: 300613
* [MemoryBuiltins] Add isMallocOrCallocLikeFn so BasicAA can check for both at ↵Craig Topper2017-04-183-3/+11
| | | | | | | | | | | | | | the same time BasicAA wants to know if a function is either a malloc or calloc like function. Currently we have to check both separately. This means both calls check if its an intrinsic, query TLI, check the nobuiltin attribute, scan the AllocationFnData, etc. This patch adds a isMallocOrCallocLikeFn so we can go through all of the checks once per call. This also changes the one other location I saw that called both together. Differential Revision: https://reviews.llvm.org/D32188 llvm-svn: 300608
* [MemoryBuiltins] Use ImmutableCallSite instead of CallSite to remove a ↵Craig Topper2017-04-181-4/+4
| | | | | | const_cast and const correct. NFCI llvm-svn: 300585
* [APInt] Use lshrInPlace to replace lshr where possibleCraig Topper2017-04-182-9/+14
| | | | | | | | | | This patch uses lshrInPlace to replace code where the object that lshr is called on is being overwritten with the result. This adds an lshrInPlace(const APInt &) version as well. Differential Revision: https://reviews.llvm.org/D32155 llvm-svn: 300566
* [SCEV] Fix another unused variable warning in release builds.Benjamin Kramer2017-04-171-0/+1
| | | | llvm-svn: 300500
* Fix an unused variable error in rL300494.Wei Mi2017-04-171-0/+1
| | | | llvm-svn: 300499
* [SCEV] Add a local cache for getZeroExtendExpr and getSignExtendExpr to preventWei Mi2017-04-171-61/+115
| | | | | | | | | | | | | | | | | | the exponential behavior. The patch is to fix PR32043. Functions getZeroExtendExpr and getSignExtendExpr may call themselves recursively more than once. This is potentially a 2^N complexity behavior. The exponential behavior was not commonly exposed before because of existing global cache mechnism like UniqueSCEVs or some early return mechanism when flags FlagNSW or FlagNUW are seen. However, we still have case which can expose the exponential behavior, like the case in PR32043, so we add a local cache in getZeroExtendExpr and getSignExtendExpr. If the input of the functions -- SCEV and type pair have been seen before, we can find the extended expression directly in the local cache. Differential Revision: https://reviews.llvm.org/D30350 llvm-svn: 300494
* Introduce APInt::isSignBitSet/isSignBitClear. Use in place isSignBitSet in ↵Craig Topper2017-04-171-34/+34
| | | | | | | | place of isNegative in known bits tracking. This makes statements like KnownZero.isNegative() (which means the value we're tracking is positive) less confusing. llvm-svn: 300457
* [BPI] NFC: reorder ifs to bail out earlierSerguei Katkov2017-04-171-19/+18
| | | | | | | | | | | | | | | This is non-functional change to re-order if statements to bail out earlier from unreachable and ColdCall heuristics. Reviewers: sanjoy, reames, junbuml, vsk, chandlerc Reviewed By: chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31704 llvm-svn: 300442
* [BPI] Use metadata info before any other heuristicsSerguei Katkov2017-04-171-19/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Metadata potentially is more precise than any heuristics we use, so it makes sense to use first metadata info if it is available. However it makes sense to examine it against other strong heuristics like unreachable one. If edge coming to unreachable block has higher probability then it is expected by unreachable heuristic then we use heuristic and remaining probability is distributed among other reachable blocks equally. An example where metadata might be more strong then unreachable heuristic is as follows: it is possible that there are two branches and for the branch A metadata says that its probability is (0, 2^25). For the branch B the probability is (1, 2^25). So the expectation is that first edge of B is hotter than first edge of A because first edge of A did not executed at least once. If first edge of A points to the unreachable block then using the unreachable heuristics we'll set the probability for A to (1, 2^20) and now edge of A becomes hotter than edge of B. This is unexpected behavior. This fixed the biggest part of https://bugs.llvm.org/show_bug.cgi?id=32214 Reviewers: sanjoy, junbuml, vsk, chandlerc Reviewed By: chandlerc Subscribers: llvm-commits, reames, davidxl Differential Revision: https://reviews.llvm.org/D30631 llvm-svn: 300440
* [InstCombine][ValueTracking] When computing known bits for Srem make sure we ↵Craig Topper2017-04-161-8/+5
| | | | | | | | don't compute known bits for the LHS twice. If we already called computeKnownBits for the RHS being a constant power of 2, we've already computed everything we can and should just stop. I think previously we would still recurse if we had determined the result was negative or had not determined the sign bit at all. llvm-svn: 300432
* MemorySSA: Stop tracking def-or-use blocks.Bryant Wong2017-04-161-3/+0
| | | | | | | | The tracking is unused, since MemoryPhis are not pruned as of r282419. Differential Revision: https://reviews.llvm.org/D32121 llvm-svn: 300428
* [InstSimplify] improve getTrue/getFalse; NFCISanjay Patel2017-04-161-10/+6
| | | | | | | | The ConstantInt version has the same assert, and using null/allOnes is likely less efficient. The only advantage of these local variants (and there's probably a better way to achieve this?) is to save typing "ConstantInt::" over and over. llvm-svn: 300426
* Tidy checking for the soft float attribute.Eric Christopher2017-04-151-10/+1
| | | | llvm-svn: 300394
* Cache the DataLayout rather than looking it up frequently.Eric Christopher2017-04-151-20/+14
| | | | llvm-svn: 300393
* [IR] Make paramHasAttr to use arg indices instead of attr indicesReid Kleckner2017-04-144-7/+6
| | | | | | | | | This avoids the confusing 'CS.paramHasAttr(ArgNo + 1, Foo)' pattern. Previously we were testing return value attributes with index 0, so I introduced hasReturnAttr() for that use case. llvm-svn: 300367
* Rewrite SCEV Normalization using SCEVRewriteVisitor; NFCSanjoy Das2017-04-141-121/+57
| | | | | | | Removes all of the boilerplate, cache management etc. from ScalarEvolutionNormalization, and keeps only the interesting bits. llvm-svn: 300349
* Remove "#if 0"ed out assertSanjoy Das2017-04-141-5/+0
| | | | | | | | | | | It won't compile after the recent changes I've made, and I think keeping it in provides very little value. Instead I've added (in an earlier commit) a C++ unit test to check the Denormalize(Normalized(X)) == X property for specific instances of X, which is what the assert was trying to do anyway. llvm-svn: 300339
* Delete some unnecessary boilerplateSanjoy Das2017-04-141-47/+29
| | | | | | | | | | | | The PostIncTransform class was not pulling its weight, so delete it and use free functions instead. This also makes the use of `function_ref` more idiomatic. We were storing an instance of function_ref in the PostIncTransform class before, which was fine in that specific case, but the usage after this change is more obviously okay. llvm-svn: 300338
* Use range forSanjoy Das2017-04-141-3/+1
| | | | llvm-svn: 300334
* Simplify PostIncTransform further; NFCSanjoy Das2017-04-141-16/+19
| | | | | | | Instead of having two ways to check if an add recurrence needs to be normalized, just pass in one predicate to decide that. llvm-svn: 300333
* Tighten the API for ScalarEvolutionNormalizationSanjoy Das2017-04-143-16/+40
| | | | llvm-svn: 300331
* Remove NormalizeAutodetect; NFCSanjoy Das2017-04-143-122/+96
| | | | | | | | | It is cleaner to have a callback based system where the logic of whether an add recurrence is normalized or not lives on IVUsers. This is one step in a multi-step cleanup. llvm-svn: 300330
* [ValueTracking] Calculate the KnownZeros for Intrinsic::ctpop without using ↵Craig Topper2017-04-141-5/+2
| | | | | | | | a temporary APInt to count leading zeros on. The APInt was created from an 'unsigned' and we just wanted to know how many bits the value needed to represent it. We can just use Log2_32 from MathExtras.h to get the info. llvm-svn: 300309
* [ValueTracking] Use APInt::isNegative(). NFCCraig Topper2017-04-141-1/+1
| | | | llvm-svn: 300308
* [ValueTracking] Use APInt::sext instead of zext and setBitsFrom. NFCCraig Topper2017-04-141-7/+2
| | | | llvm-svn: 300307
* Use range-for; NFCSanjoy Das2017-04-141-6/+4
| | | | llvm-svn: 300292
* Use transform instead of manual loop; NFCSanjoy Das2017-04-141-5/+5
| | | | llvm-svn: 300291
* [ValueTracking] Remove duplicate call to computeKnownBits for the operands ↵Craig Topper2017-04-131-5/+1
| | | | | | | | of Select. We call it unconditionally on the operands of the select. Then decide if its a min/max and call it on the min/max operands or on the select operands again. Either of those second calls will overwrite the results of the initial call so we can just delete the first call. llvm-svn: 300256
* [ValueTracking] Prevent a call to computeKnownBits if we already know the ↵Craig Topper2017-04-131-7/+8
| | | | | | state of the bit we would calculate. Also reuse a temporary APInt instead of creating a new one. llvm-svn: 300239
* [ValueTracking] Move a temporary APInt instead of copying it.Craig Topper2017-04-131-1/+1
| | | | llvm-svn: 300233
* [Analysis] Support bitreverse in -demanded-bits passBrian Gesiak2017-04-131-0/+3
| | | | | | | | | | | | | | | | | | | | Summary: * Add a bitreverse case in the demanded bits analysis pass. * Add tests for the bitreverse (and bswap) intrinsic in the demanded bits pass. * Add a test case to the BDCE tests: that manipulations to high-order bits are eliminated once the bits are reversed and then right-shifted. Reviewers: mkuper, jmolloy, hfinkel, trentxintong Reviewed By: jmolloy Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31857 llvm-svn: 300215
* [InstSimplify] Don't try to constant fold AllocaInsts since it won't do ↵Craig Topper2017-04-121-0/+4
| | | | | | | | anything. Should give a small compile time improvement. llvm-svn: 300125
* [ValueTracking] Teach GetUnderlyingObject to stop when it reachs an alloca ↵Craig Topper2017-04-121-0/+3
| | | | | | | | instruction. Previously it tried to call SimplifyInstruction which doesn't know anything about alloca so defers to constant folding which also doesn't do anything with alloca. This results in wasted cycles making calls that won't do anything. Given the frequency with which this function is called this time adds up. llvm-svn: 300118
* [LoopVectorizer, TTI] New method supportsEfficientVectorElementLoadStore()Jonas Paulsson2017-04-121-0/+4
| | | | | | | | | | | | | | | | | | | Since SystemZ supports vector element load/store instructions, there is no need for extracts/inserts if a vector load/store gets scalarized. This patch lets Target specify that it supports such instructions by means of a new TTI hook that defaults to false. The use for this is in the LoopVectorizer getScalarizationOverhead() method, which will with this patch produce a smaller sum for a vector load/store on SystemZ. New test: test/Transforms/LoopVectorize/SystemZ/load-store-scalarization-cost.ll Review: Adam Nemet https://reviews.llvm.org/D30680 llvm-svn: 300056
* [SystemZ] TargetTransformInfo cost functions implemented.Jonas Paulsson2017-04-122-13/+20
| | | | | | | | | | | | | | | | getArithmeticInstrCost(), getShuffleCost(), getCastInstrCost(), getCmpSelInstrCost(), getVectorInstrCost(), getMemoryOpCost(), getInterleavedMemoryOpCost() implemented. Interleaved access vectorization enabled. BasicTTIImpl::getCastInstrCost() improved to check for legal extending loads, in which case the cost of the z/sext instruction becomes 0. Review: Ulrich Weigand, Renato Golin. https://reviews.llvm.org/D29631 llvm-svn: 300052
* [IR] Redesign the case iterator in SwitchInst to actually be an iteratorChandler Carruth2017-04-123-8/+8
| | | | | | | | | | | | | | | | and to expose a handle to represent the actual case rather than having the iterator return a reference to itself. All of this allows the iterator to be used with common STL facilities, standard algorithms, etc. Doing this exposed some missing facilities in the iterator facade that I've fixed and required some work to the actual iterator to fully support the necessary API. Differential Revision: https://reviews.llvm.org/D31548 llvm-svn: 300032
* [BPI] Refactor post domination calculation and simple fix for ColdCallSerguei Katkov2017-04-121-46/+73
| | | | | | | | | | | | | | | | | | | | Collection of PostDominatedByUnreachable and PostDominatedByColdCall have been split out of heuristics itself. Update of the data happens now for each basic block (before update for PostDominatedByColdCall might be skipped if unreachable or matadata heuristic handled this basic block). This separation allows re-ordering of heuristics without loosing the post-domination information. Reviewers: sanjoy, junbuml, vsk, chandlerc, reames Reviewed By: chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31701 llvm-svn: 300029
* InstSimplify: A shuffle of a splat is always the splat itselfZvi Rackover2017-04-111-4/+16
| | | | | | | | | | | | | | | | Summary: Fold: shuffle (splat-shuffle), undef, M --> splat-shuffle Reviewers: spatel, RKSimon, craig.topper Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31527 llvm-svn: 299990
* MemorySSA: Move to Analysis, from Transforms/Utils. It's used asDaniel Berlin2017-04-114-0/+2557
| | | | | | | | Analysis, it has Analysis passes, and once NewGVN is made an Analysis, this removes the cross dependency from Analysis to Transform/Utils. NFC. llvm-svn: 299980
* Remove unused functions. Remove static qualifier from functions in header ↵Vassil Vassilev2017-04-111-7/+0
| | | | | | files. NFC. llvm-svn: 299947
OpenPOWER on IntegriCloud