|
LLVM
4.0.0
|
#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/ADT/Optional.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/ScopeExit.h"#include "llvm/ADT/Sequence.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/ScalarEvolutionExpressions.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/ConstantRange.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/InstIterator.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Operator.h"#include "llvm/IR/PatternMatch.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Support/SaveAndRestore.h"#include <algorithm>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "scalar-evolution" |
Typedefs | |
| typedef DenseMap< const Loop *, std::string > | VerifyMap |
Functions | |
| STATISTIC (NumArrayLenItCounts,"Number of trip counts computed with array length") | |
| STATISTIC (NumTripCountsComputed,"Number of loops with predictable loop counts") | |
| STATISTIC (NumTripCountsNotComputed,"Number of loops without predictable loop counts") | |
| STATISTIC (NumBruteForceTripCountsComputed,"Number of loops with trip counts computed by force") | |
| static int | CompareValueComplexity (SmallSet< std::pair< Value *, Value * >, 8 > &EqCache, const LoopInfo *const LI, Value *LV, Value *RV, unsigned Depth) |
Compare the two values LV and RV in terms of their "complexity" where "complexity" is a partial (and somewhat ad-hoc) relation used to order operands in SCEV expressions. More... | |
| static int | CompareSCEVComplexity (SmallSet< std::pair< const SCEV *, const SCEV * >, 8 > &EqCacheSCEV, const LoopInfo *const LI, const SCEV *LHS, const SCEV *RHS, unsigned Depth=0) |
| static void | GroupByComplexity (SmallVectorImpl< const SCEV * > &Ops, LoopInfo *LI) |
| Given a list of SCEV objects, order them by their complexity, and group objects of the same complexity together by value. More... | |
| static int | sizeOfSCEV (const SCEV *S) |
| static const SCEV * | BinomialCoefficient (const SCEV *It, unsigned K, ScalarEvolution &SE, Type *ResultTy) |
| Compute BC(It, K). The result has width W. Assume, K > 0. More... | |
| static const SCEV * | getSignedOverflowLimitForStep (const SCEV *Step, ICmpInst::Predicate *Pred, ScalarEvolution *SE) |
| static const SCEV * | getUnsignedOverflowLimitForStep (const SCEV *Step, ICmpInst::Predicate *Pred, ScalarEvolution *SE) |
| template<typename ExtendOpTy > | |
| static const SCEV * | getPreStartForExtend (const SCEVAddRecExpr *AR, Type *Ty, ScalarEvolution *SE) |
| template<typename ExtendOpTy > | |
| static const SCEV * | getExtendAddRecStart (const SCEVAddRecExpr *AR, Type *Ty, ScalarEvolution *SE) |
| static bool | CollectAddOperandsWithScales (DenseMap< const SCEV *, APInt > &M, SmallVectorImpl< const SCEV * > &NewOps, APInt &AccumulatedConstant, const SCEV *const *Ops, size_t NumOperands, const APInt &Scale, ScalarEvolution &SE) |
| Process the given Ops list, which is a list of operands to be added under the given scale, update the given map. More... | |
| static SCEV::NoWrapFlags | StrengthenNoWrapFlags (ScalarEvolution *SE, SCEVTypes Type, const SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags) |
| static uint64_t | umul_ov (uint64_t i, uint64_t j, bool &Overflow) |
| static uint64_t | Choose (uint64_t n, uint64_t k, bool &Overflow) |
| Compute the result of "n choose k", the binomial coefficient. More... | |
| static bool | containsConstantSomewhere (const SCEV *StartExpr) |
| Determine if any of the operands in this SCEV are a constant or if any of the add or multiply expressions in this SCEV contain a constant. More... | |
| static const APInt | gcd (const SCEVConstant *C1, const SCEVConstant *C2) |
| static std::pair< const SCEV *, ConstantInt * > | splitAddExpr (const SCEV *S) |
| Try to split a SCEVAddExpr into a pair of {SCEV, ConstantInt}. More... | |
| static void | PushDefUseChildren (Instruction *I, SmallVectorImpl< Instruction * > &Worklist) |
| Push users of the given Instruction onto the given Worklist. More... | |
| static Optional< BinaryOp > | MatchBinaryOp (Value *V, DominatorTree &DT) |
Try to map V into a BinaryOp, and return None on failure. More... | |
| static bool | IsAvailableOnEntry (const Loop *L, DominatorTree &DT, const SCEV *S, BasicBlock *BB) |
| static bool | BrPHIToSelect (DominatorTree &DT, BranchInst *BI, PHINode *Merge, Value *&C, Value *&LHS, Value *&RHS) |
| static Optional< ConstantRange > | GetRangeFromMetadata (Value *V) |
| Helper method to assign a range to V from metadata present in the IR. More... | |
| static unsigned | getConstantTripCount (const SCEVConstant *ExitCount) |
| static void | PushLoopPHIs (const Loop *L, SmallVectorImpl< Instruction * > &Worklist) |
| Push PHI nodes in the header of the given loop onto the given Worklist. More... | |
| static ConstantInt * | EvaluateConstantChrecAtConstant (const SCEVAddRecExpr *AddRec, ConstantInt *C, ScalarEvolution &SE) |
| static bool | CanConstantFold (const Instruction *I) |
| Return true if we can constant fold an instruction of the specified type, assuming that all operands were constants. More... | |
| static bool | canConstantEvolve (Instruction *I, const Loop *L) |
| Determine whether this instruction can constant evolve within this loop assuming its operands can all constant evolve. More... | |
| static PHINode * | getConstantEvolvingPHIOperands (Instruction *UseInst, const Loop *L, DenseMap< Instruction *, PHINode * > &PHIMap) |
| getConstantEvolvingPHIOperands - Implement getConstantEvolvingPHI by recursing through each instruction operand until reaching a loop header phi. More... | |
| static PHINode * | getConstantEvolvingPHI (Value *V, const Loop *L) |
| getConstantEvolvingPHI - Given an LLVM value and a loop, return a PHI node in the loop that V is derived from. More... | |
| static Constant * | EvaluateExpression (Value *V, const Loop *L, DenseMap< Instruction *, Constant * > &Vals, const DataLayout &DL, const TargetLibraryInfo *TLI) |
| EvaluateExpression - Given an expression that passes the getConstantEvolvingPHI predicate, evaluate its value assuming the PHI node in the loop has the value PHIVal. More... | |
| static Constant * | getOtherIncomingValue (PHINode *PN, BasicBlock *BB) |
| static Constant * | BuildConstantFromSCEV (const SCEV *V) |
| This builds up a Constant using the ConstantExpr interface. More... | |
| static const SCEV * | SolveLinEquationWithOverflow (const APInt &A, const APInt &B, ScalarEvolution &SE) |
| Finds the minimum unsigned root of the following equation: More... | |
| static Optional< std::pair < const SCEVConstant *, const SCEVConstant * > > | SolveQuadraticEquation (const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) |
| Find the roots of the quadratic equation for the given quadratic chrec {L,+,M,+,N}. More... | |
| static bool | HasSameValue (const SCEV *A, const SCEV *B) |
| SCEV structural equivalence is usually sufficient for testing whether two expressions are equal, however for the purposes of looking for a condition guarding a loop, it can be useful to be a little more general, since a front-end may have replicated the controlling expression. More... | |
| static const SCEV * | MatchNotExpr (const SCEV *Expr) |
| If Expr computes ~A, return A else return nullptr. More... | |
| template<typename MaxExprType > | |
| static bool | IsMaxConsistingOf (const SCEV *MaybeMaxExpr, const SCEV *Candidate) |
| Is MaybeMaxExpr an SMax or UMax of Candidate and some other values? More... | |
| template<typename MaxExprType > | |
| static bool | IsMinConsistingOf (ScalarEvolution &SE, const SCEV *MaybeMinExpr, const SCEV *Candidate) |
| Is MaybeMinExpr an SMin or UMin of Candidate and some other values? More... | |
| static bool | IsKnownPredicateViaAddRecStart (ScalarEvolution &SE, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
| static bool | IsKnownPredicateViaMinOrMax (ScalarEvolution &SE, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
Is LHS Pred RHS true on the virtue of LHS or RHS being a Min or Max expression? More... | |
| static bool | containsUndefs (const SCEV *S) |
| static bool | findArrayDimensionsRec (ScalarEvolution &SE, SmallVectorImpl< const SCEV * > &Terms, SmallVectorImpl< const SCEV * > &Sizes) |
| static bool | containsParameters (SmallVectorImpl< const SCEV * > &Terms) |
| static int | numberOfTerms (const SCEV *S) |
| static const SCEV * | removeConstantFactors (ScalarEvolution &SE, const SCEV *T) |
| static void | PrintLoopInfo (raw_ostream &OS, ScalarEvolution *SE, const Loop *L) |
| static StringRef | loopDispositionToStr (ScalarEvolution::LoopDisposition LD) |
| static void | replaceSubString (std::string &Str, StringRef From, StringRef To) |
| replaceSubString - Replaces all occurrences of From in Str with To. More... | |
| static void | getLoopBackedgeTakenCounts (Loop *L, VerifyMap &Map, ScalarEvolution &SE) |
| getLoopBackedgeTakenCounts - Helper method for verifyAnalysis. More... | |
| INITIALIZE_PASS_BEGIN (ScalarEvolutionWrapperPass,"scalar-evolution","Scalar Evolution Analysis", false, true) INITIALIZE_PASS_END(ScalarEvolutionWrapperPass | |
Variables | |
| static cl::opt< unsigned > | MaxBruteForceIterations ("scalar-evolution-max-iterations", cl::ReallyHidden, cl::desc("Maximum number of iterations SCEV will ""symbolically execute a constant ""derived loop"), cl::init(100)) |
| static cl::opt< bool > | VerifySCEV ("verify-scev", cl::desc("Verify ScalarEvolution's backedge taken counts (slow)")) |
| static cl::opt< bool > | VerifySCEVMap ("verify-scev-maps", cl::desc("Verify no dangling value in ScalarEvolution's ""ExprValueMap (slow)")) |
| static cl::opt< unsigned > | MulOpsInlineThreshold ("scev-mulops-inline-threshold", cl::Hidden, cl::desc("Threshold for inlining multiplication operands into a SCEV"), cl::init(1000)) |
| static cl::opt< unsigned > | MaxSCEVCompareDepth ("scalar-evolution-max-scev-compare-depth", cl::Hidden, cl::desc("Maximum depth of recursive SCEV complexity comparisons"), cl::init(32)) |
| static cl::opt< unsigned > | MaxValueCompareDepth ("scalar-evolution-max-value-compare-depth", cl::Hidden, cl::desc("Maximum depth of recursive value complexity comparisons"), cl::init(2)) |
| scalar | evolution |
| scalar Scalar Evolution | Analysis |
| scalar Scalar Evolution | false |
| #define DEBUG_TYPE "scalar-evolution" |
Definition at line 98 of file ScalarEvolution.cpp.
Definition at line 9949 of file ScalarEvolution.cpp.
|
static |
Compute BC(It, K). The result has width W. Assume, K > 0.
Definition at line 1003 of file ScalarEvolution.cpp.
References llvm::APInt::countTrailingZeros(), llvm::ScalarEvolution::getConstant(), llvm::ScalarEvolution::getContext(), llvm::ScalarEvolution::getCouldNotCompute(), llvm::ScalarEvolution::getMinusSCEV(), llvm::ScalarEvolution::getMulExpr(), llvm::ScalarEvolution::getTruncateOrZeroExtend(), llvm::SCEV::getType(), llvm::ScalarEvolution::getTypeSizeInBits(), llvm::ScalarEvolution::getUDivExpr(), i, llvm::APInt::lshr(), llvm::MipsISD::Mult, llvm::APInt::multiplicativeInverse(), T, llvm::APInt::trunc(), and llvm::APInt::zext().
Referenced by llvm::SCEVAddRecExpr::evaluateAtIteration().
|
static |
Definition at line 4212 of file ScalarEvolution.cpp.
References assert(), llvm::DominatorTree::dominates(), llvm::BranchInst::getCondition(), llvm::User::getOperandUse(), llvm::Instruction::getParent(), and llvm::BranchInst::getSuccessor().
This builds up a Constant using the ConstantExpr interface.
That way, we will return Constants for objects which aren't represented by a SCEVConstant, because SCEVConstant is restricted to ConstantInt. Returns NULL if the SCEV isn't representable as a Constant.
Definition at line 6719 of file ScalarEvolution.cpp.
References C, llvm::dyn_cast(), llvm::ConstantExpr::getAdd(), llvm::ConstantExpr::getBitCast(), llvm::ConstantExpr::getGetElementPtr(), llvm::Type::getInt32Ty(), llvm::Type::getInt8PtrTy(), llvm::ConstantExpr::getIntegerCast(), llvm::SCEVUDivExpr::getLHS(), llvm::ConstantExpr::getMul(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVCastExpr::getOperand(), llvm::SCEVNAryExpr::getOperand(), llvm::Type::getPointerAddressSpace(), llvm::SCEVUDivExpr::getRHS(), llvm::SCEV::getSCEVType(), llvm::ConstantExpr::getSExt(), llvm::ConstantExpr::getTrunc(), llvm::SCEVCastExpr::getType(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantExpr::getUDiv(), llvm::ConstantExpr::getZExt(), i, llvm::Type::isPointerTy(), llvm::scAddExpr, llvm::scAddRecExpr, llvm::scConstant, llvm::scCouldNotCompute, llvm::scMulExpr, llvm::scSignExtend, llvm::scSMaxExpr, llvm::scTruncate, llvm::scUDivExpr, llvm::scUMaxExpr, llvm::scUnknown, llvm::scZeroExtend, llvm::ARM_MB::ST, and std::swap().
|
static |
Determine whether this instruction can constant evolve within this loop assuming its operands can all constant evolve.
Definition at line 6392 of file ScalarEvolution.cpp.
References CanConstantFold(), llvm::LoopBase< N, M >::contains(), llvm::LoopBase< N, M >::getHeader(), and llvm::Instruction::getParent().
Referenced by EvaluateExpression(), getConstantEvolvingPHI(), and getConstantEvolvingPHIOperands().
|
static |
Return true if we can constant fold an instruction of the specified type, assuming that all operands were constants.
Definition at line 6378 of file ScalarEvolution.cpp.
References llvm::canConstantFoldCallTo().
Referenced by canConstantEvolve().
|
static |
Compute the result of "n choose k", the binomial coefficient.
If an intermediate computation overflows, Overflow will be set and the return will be garbage. Overflow is not cleared on absence of overflow.
Definition at line 2466 of file ScalarEvolution.cpp.
Referenced by llvm::ScalarEvolution::getMulExpr().
|
static |
Process the given Ops list, which is a list of operands to be added under the given scale, update the given map.
This is a helper function for getAddRecExpr. As an example of what it does, given a sequence of operands that would form an add expression like this:
m + n + 13 + (A * (o + p + (B * (q + m + 29)))) + r + (-1 * r)
where A and B are constants, update the map with these values:
(m, 1+A*B), (n, 1), (o, A), (p, A), (q, A*B), (r, 0)
and add 13 + A*B*29 to AccumulatedConstant. This will allow getAddRecExpr to produce this:
13+A*B*29 + n + (m * (1+A*B)) + ((o + p) * A) + (q * A*B)
This form often exposes folding opportunities that are hidden in the original operand list.
Return true iff it appears that any interesting folding opportunities may be exposed. This helps getAddRecExpr short-circuit extra work in the common case where no interesting opportunities are present, and is also used as a check to avoid infinite recursion.
Definition at line 1977 of file ScalarEvolution.cpp.
References llvm::MCID::Add, C, llvm::dyn_cast(), llvm::ScalarEvolution::getMulExpr(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVNAryExpr::getOperand(), i, llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::SCEVNAryExpr::op_begin(), llvm::SCEVNAryExpr::op_end(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by llvm::ScalarEvolution::getAddExpr().
|
static |
Definition at line 563 of file ScalarEvolution.cpp.
References llvm::Depth, llvm::SCEV::getSCEVType(), and MaxSCEVCompareDepth.
Referenced by GroupByComplexity().
|
static |
Compare the two values LV and RV in terms of their "complexity" where "complexity" is a partial (and somewhat ad-hoc) relation used to order operands in SCEV expressions.
EqCache is a set of pairs of values that have been previously deemed to be "equally complex" by this routine. It is intended to avoid exponential time complexity in cases like:
a = f(x, y) b = f(a, a) c = f(b, b)
d = f(x, y) e = f(d, d) f = f(e, e)
CompareValueComplexity(f, c)
Since we do not continue running this routine on expression trees once we have seen unequal values, there is no need to track them in the cache.
Definition at line 486 of file ScalarEvolution.cpp.
References MaxValueCompareDepth.
Determine if any of the operands in this SCEV are a constant or if any of the add or multiply expressions in this SCEV contain a constant.
Definition at line 2491 of file ScalarEvolution.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::SmallVectorBase::empty(), llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by llvm::ScalarEvolution::getMulExpr().
|
inlinestatic |
Definition at line 9192 of file ScalarEvolution.cpp.
References llvm::SCEVExprContains().
Referenced by llvm::ScalarEvolution::findArrayDimensions().
Definition at line 8990 of file ScalarEvolution.cpp.
References llvm::PPCISD::SC, and llvm::SCEVExprContains().
|
static |
Definition at line 6144 of file ScalarEvolution.cpp.
References assert(), llvm::SCEVAddRecExpr::evaluateAtIteration(), and llvm::ScalarEvolution::getConstant().
Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange().
|
static |
EvaluateExpression - Given an expression that passes the getConstantEvolvingPHI predicate, evaluate its value assuming the PHI node in the loop has the value PHIVal.
If we can't fold this expression for some reason, return null.
Definition at line 6465 of file ScalarEvolution.cpp.
References C, canConstantEvolve(), llvm::ConstantFoldCompareInstOperands(), llvm::ConstantFoldInstOperands(), llvm::ConstantFoldLoadFromConstPtr(), llvm::dyn_cast(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Value::getType(), i, llvm::LoadInst::isVolatile(), and llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::lookup().
|
static |
Definition at line 9144 of file ScalarEvolution.cpp.
References E, llvm::ScalarEvolution::getMulExpr(), llvm::SCEV::isZero(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::remove_if(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::ScalarEvolution::findArrayDimensions().
|
static |
Definition at line 2867 of file ScalarEvolution.cpp.
References A, llvm::APInt::abs(), B, llvm::SCEVConstant::getAPInt(), llvm::APInt::getBitWidth(), llvm::APIntOps::GreatestCommonDivisor(), and llvm::APInt::zext().
Referenced by llvm::ScalarEvolution::getUDivExactExpr().
getConstantEvolvingPHI - Given an LLVM value and a loop, return a PHI node in the loop that V is derived from.
We allow arbitrary operations along the way, but the operands of an operation must either be constants or a value derived from a constant PHI. If this expression does not fit with these constraints, return null.
Definition at line 6449 of file ScalarEvolution.cpp.
References canConstantEvolve(), llvm::dyn_cast(), and getConstantEvolvingPHIOperands().
|
static |
getConstantEvolvingPHIOperands - Implement getConstantEvolvingPHI by recursing through each instruction operand until reaching a loop header phi.
Definition at line 6410 of file ScalarEvolution.cpp.
References canConstantEvolve(), llvm::dyn_cast(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), llvm::User::operands(), and P.
Referenced by getConstantEvolvingPHI().
|
static |
Definition at line 5337 of file ScalarEvolution.cpp.
References llvm::APInt::getActiveBits(), llvm::SCEVConstant::getValue(), llvm::ConstantInt::getValue(), and llvm::ConstantInt::getZExtValue().
Referenced by llvm::ScalarEvolution::getSmallConstantMaxTripCount(), and llvm::ScalarEvolution::getSmallConstantTripCount().
|
static |
Definition at line 1390 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getAddExpr().
|
static |
getLoopBackedgeTakenCounts - Helper method for verifyAnalysis.
Definition at line 9962 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getBackedgeTakenCount(), L, llvm::SCEV::print(), replaceSubString(), llvm::reverse(), and llvm::raw_string_ostream::str().
Referenced by llvm::ScalarEvolution::verify().
|
static |
Definition at line 6513 of file ScalarEvolution.cpp.
References llvm::dyn_cast(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), and i.
|
static |
Definition at line 1316 of file ScalarEvolution.cpp.
References llvm::dyn_cast(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNUW, llvm::IntegerType::get(), llvm::ScalarEvolution::getAddExpr(), llvm::ScalarEvolution::getAddRecExpr(), llvm::ScalarEvolution::getBackedgeTakenCount(), llvm::ScalarEvolution::getContext(), llvm::SCEVAddRecExpr::getLoop(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVAddRecExpr::getStart(), llvm::SCEVAddRecExpr::getStepRecurrence(), llvm::SCEVNAryExpr::getType(), llvm::ScalarEvolution::getTypeSizeInBits(), llvm::ScalarEvolution::isKnownPositive(), llvm::ScalarEvolution::isLoopEntryGuardedByCond(), L, llvm::ScalarEvolution::maskFlags(), llvm::SCEVNAryExpr::operands(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::SmallVectorTemplateCommon< T >::size().
|
static |
Helper method to assign a range to V from metadata present in the IR.
Definition at line 4490 of file ScalarEvolution.cpp.
References llvm::getConstantRangeFromMetadata(), llvm::Instruction::getMetadata(), llvm::LLVMContext::MD_range, and llvm::None.
|
static |
Definition at line 1226 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getConstant(), llvm::ConstantRange::getSignedMax(), llvm::APInt::getSignedMaxValue(), llvm::ConstantRange::getSignedMin(), llvm::APInt::getSignedMinValue(), llvm::ScalarEvolution::getSignedRange(), llvm::SCEV::getType(), llvm::ScalarEvolution::getTypeSizeInBits(), llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::ScalarEvolution::isKnownNegative(), and llvm::ScalarEvolution::isKnownPositive().
Referenced by llvm::ScalarEvolution::getSignExtendExpr().
|
static |
Definition at line 1246 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getConstant(), llvm::APInt::getMinValue(), llvm::SCEV::getType(), llvm::ScalarEvolution::getTypeSizeInBits(), llvm::ConstantRange::getUnsignedMax(), llvm::ScalarEvolution::getUnsignedRange(), and llvm::CmpInst::ICMP_ULT.
|
static |
Given a list of SCEV objects, order them by their complexity, and group objects of the same complexity together by value.
When this routine is finished, we know that any duplicates in the vector are consecutive and that complexity is monotonically increasing.
Note that we go take special precautions to ensure that we get deterministic results from this routine. In other words, we don't want the results of this to depend on where the addresses of various SCEV objects happened to land in memory.
Definition at line 705 of file ScalarEvolution.cpp.
References llvm::SmallVectorTemplateCommon< T >::begin(), CompareSCEVComplexity(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::SCEV::getSCEVType(), i, llvm::SmallVectorTemplateCommon< T >::size(), and std::swap().
Referenced by llvm::ScalarEvolution::getAddExpr(), llvm::ScalarEvolution::getMulExpr(), llvm::ScalarEvolution::getSMaxExpr(), and llvm::ScalarEvolution::getUMaxExpr().
SCEV structural equivalence is usually sufficient for testing whether two expressions are equal, however for the purposes of looking for a condition guarding a loop, it can be useful to be a little more general, since a front-end may have replicated the controlling expression.
Definition at line 7354 of file ScalarEvolution.cpp.
References A, B, and llvm::Instruction::isIdenticalTo().
Referenced by llvm::ScalarEvolution::SimplifyICmpOperands().
| INITIALIZE_PASS_BEGIN | ( | ScalarEvolutionWrapperPass | , |
| "scalar-evolution" | , | ||
| "Scalar Evolution Analysis" | , | ||
| false | , | ||
| true | |||
| ) |
|
static |
Definition at line 4138 of file ScalarEvolution.cpp.
References llvm::LoopBase< N, M >::contains(), llvm::DominatorTree::dominates(), llvm::SCEV::getSCEVType(), L, llvm_unreachable, llvm::scAddExpr, llvm::scAddRecExpr, llvm::scConstant, llvm::scCouldNotCompute, llvm::scMulExpr, llvm::scSignExtend, llvm::scSMaxExpr, llvm::scTruncate, llvm::scUDivExpr, llvm::scUMaxExpr, llvm::scUnknown, llvm::scZeroExtend, llvm::ARM_MB::ST, and llvm::SCEVTraversal< SV >::visitAll().
|
static |
Definition at line 8425 of file ScalarEvolution.cpp.
References llvm::dyn_cast(), llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::SCEVAddRecExpr::getLoop(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVAddRecExpr::getStart(), llvm::SCEVAddRecExpr::getStepRecurrence(), llvm::SCEVAddRecExpr::isAffine(), llvm::ScalarEvolution::isKnownPredicate(), llvm::ICmpInst::isRelational(), and llvm::CmpInst::isSigned().
|
static |
Is LHS Pred RHS true on the virtue of LHS or RHS being a Min or Max expression?
Definition at line 8460 of file ScalarEvolution.cpp.
References llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULE, LLVM_FALLTHROUGH, llvm_unreachable, and std::swap().
|
static |
Is MaybeMaxExpr an SMax or UMax of Candidate and some other values?
Definition at line 8404 of file ScalarEvolution.cpp.
References llvm::dyn_cast(), and llvm::find().
|
static |
Is MaybeMinExpr an SMin or UMin of Candidate and some other values?
Definition at line 8415 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getNotSCEV(), and MatchNotExpr().
|
static |
Definition at line 9626 of file ScalarEvolution.cpp.
References llvm_unreachable, llvm::ScalarEvolution::LoopComputable, llvm::ScalarEvolution::LoopInvariant, and llvm::ScalarEvolution::LoopVariant.
Referenced by llvm::ScalarEvolution::print().
|
static |
Try to map V into a BinaryOp, and return None on failure.
Definition at line 3890 of file ScalarEvolution.cpp.
References llvm::MCID::Add, llvm::APIntOps::And(), llvm::dyn_cast(), F, llvm::ConstantInt::get(), getBitWidth(), llvm::APInt::getOneBitSet(), llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::isOverflowIntrinsicNoWrap(), llvm::None, llvm::APIntOps::Or(), X, and llvm::APIntOps::Xor().
If Expr computes ~A, return A else return nullptr.
Definition at line 8387 of file ScalarEvolution.cpp.
References llvm::MCID::Add, llvm::dyn_cast(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVNAryExpr::getOperand(), and llvm::SCEV::isAllOnesValue().
Referenced by IsMinConsistingOf().
Definition at line 9200 of file ScalarEvolution.cpp.
Referenced by llvm::ScalarEvolution::findArrayDimensions().
|
static |
Definition at line 9575 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getBackedgeTakenCount(), llvm::ScalarEvolution::getMaxBackedgeTakenCount(), llvm::ScalarEvolution::getPredicatedBackedgeTakenCount(), llvm::ScalarEvolution::hasLoopInvariantBackedgeTakenCount(), llvm::ScalarEvolution::isBackedgeTakenCountMaxOrZero(), llvm::SCEVUnionPredicate::print(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::ScalarEvolution::print().
|
static |
Push users of the given Instruction onto the given Worklist.
Definition at line 3713 of file ScalarEvolution.cpp.
References llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::Value::users().
Referenced by llvm::ScalarEvolution::forgetLoop(), and llvm::ScalarEvolution::forgetValue().
|
static |
Push PHI nodes in the header of the given loop onto the given Worklist.
Definition at line 5457 of file ScalarEvolution.cpp.
References llvm::BasicBlock::begin(), llvm::dyn_cast(), llvm::LoopBase< N, M >::getHeader(), I, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by llvm::ScalarEvolution::forgetLoop().
|
static |
Definition at line 9206 of file ScalarEvolution.cpp.
References llvm::ScalarEvolution::getMulExpr(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and T.
Referenced by llvm::ScalarEvolution::findArrayDimensions().
replaceSubString - Replaces all occurrences of From in Str with To.
Definition at line 9952 of file ScalarEvolution.cpp.
References llvm::StringRef::data(), and llvm::StringRef::size().
Referenced by getLoopBackedgeTakenCounts().
Definition at line 747 of file ScalarEvolution.cpp.
References F, llvm::ARM_MB::ST, and llvm::SCEVTraversal< SV >::visitAll().
|
static |
Finds the minimum unsigned root of the following equation:
A * X = B (mod N)
where N = 2^BW and BW is the common bit width of A and B. The signedness of A and B isn't important.
If the equation does not have a solution, SCEVCouldNotCompute is returned.
Definition at line 7017 of file ScalarEvolution.cpp.
References assert(), B, llvm::APInt::countTrailingZeros(), llvm::APInt::getBitWidth(), llvm::ScalarEvolution::getConstant(), llvm::ScalarEvolution::getCouldNotCompute(), llvm::APInt::lshr(), llvm::APIntOps::lshr(), llvm::APInt::multiplicativeInverse(), llvm::APInt::setBit(), llvm::APInt::trunc(), and llvm::APInt::zext().
|
static |
Find the roots of the quadratic equation for the given quadratic chrec {L,+,M,+,N}.
This returns either the two roots (which might be the same) or two SCEVCouldNotCompute objects.
Definition at line 7062 of file ScalarEvolution.cpp.
References A, assert(), B, C, Context, llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::ScalarEvolution::getConstant(), llvm::ScalarEvolution::getContext(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVNAryExpr::getOperand(), llvm::APInt::isMinValue(), L, N, NC, llvm::None, llvm::APInt::sdiv(), and llvm::APIntOps::sdiv().
Referenced by llvm::SCEVAddRecExpr::getNumIterationsInRange().
|
static |
Try to split a SCEVAddExpr into a pair of {SCEV, ConstantInt}.
If S is a SCEVAddExpr and is composed of a sub SCEV S' and an offset I, then return {S', I}, else return {S, nullptr}.
Definition at line 3414 of file ScalarEvolution.cpp.
References llvm::MCID::Add, and llvm::dyn_cast().
Referenced by llvm::ScalarEvolution::eraseValueFromMap(), and llvm::ScalarEvolution::getSCEV().
| STATISTIC | ( | NumArrayLenItCounts | , |
| "Number of trip counts computed with array length" | |||
| ) |
| STATISTIC | ( | NumTripCountsComputed | , |
| "Number of loops with predictable loop counts" | |||
| ) |
| STATISTIC | ( | NumTripCountsNotComputed | , |
| "Number of loops without predictable loop counts" | |||
| ) |
| STATISTIC | ( | NumBruteForceTripCountsComputed | , |
| "Number of loops with trip counts computed by force" | |||
| ) |
|
static |
Definition at line 2046 of file ScalarEvolution.cpp.
References llvm::MCID::Add, llvm::all_of(), assert(), C, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, fuzzer::Flags, llvm::ScalarEvolution::getSignedRange(), llvm::ScalarEvolution::getUnsignedRange(), llvm::ScalarEvolution::isKnownNonNegative(), llvm::ConstantRange::makeGuaranteedNoWrapRegion(), llvm::ScalarEvolution::maskFlags(), llvm::scAddExpr, llvm::scAddRecExpr, llvm::scMulExpr, llvm::ScalarEvolution::setFlags(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by llvm::ScalarEvolution::getAddExpr(), llvm::ScalarEvolution::getAddRecExpr(), and llvm::ScalarEvolution::getMulExpr().
|
static |
Definition at line 2457 of file ScalarEvolution.cpp.
Referenced by Choose(), and llvm::ScalarEvolution::getMulExpr().
| scalar Scalar Evolution Analysis |
Definition at line 10063 of file ScalarEvolution.cpp.
| scalar evolution |
Definition at line 10063 of file ScalarEvolution.cpp.
| scalar Scalar Evolution false |
Definition at line 10063 of file ScalarEvolution.cpp.
|
static |
|
static |
Referenced by CompareSCEVComplexity().
|
static |
Referenced by CompareValueComplexity().
|
static |
Referenced by llvm::ScalarEvolution::getMulExpr().
|
static |
Referenced by llvm::ScalarEvolutionWrapperPass::verifyAnalysis().
|
static |
Referenced by llvm::ScalarEvolution::getSCEVValues().
1.8.6