LLVM
13.0.0git
|
The main scalar evolution driver. More...
#include "llvm/Analysis/ScalarEvolution.h"
Classes | |
struct | LoopInvariantPredicate |
Public Types | |
enum | LoopDisposition { LoopVariant, LoopInvariant, LoopComputable } |
An enum describing the relationship between a SCEV and a loop. More... | |
enum | BlockDisposition { DoesNotDominateBlock, DominatesBlock, ProperlyDominatesBlock } |
An enum describing the relationship between a SCEV and a basic block. More... | |
enum | ExitCountKind { Exact, ConstantMaximum, SymbolicMaximum } |
The terms "backedge taken count" and "exit count" are used interchangeably to refer to the number of times the backedge of a loop has executed before the loop is exited. More... | |
enum | MonotonicPredicateType { MonotonicallyIncreasing, MonotonicallyDecreasing } |
A predicate is said to be monotonically increasing if may go from being false to being true as the loop iterates, but never the other way around. More... | |
Public Member Functions | |
ScalarEvolution (Function &F, TargetLibraryInfo &TLI, AssumptionCache &AC, DominatorTree &DT, LoopInfo &LI) | |
ScalarEvolution (ScalarEvolution &&Arg) | |
~ScalarEvolution () | |
LLVMContext & | getContext () const |
bool | isSCEVable (Type *Ty) const |
Test if values of the given type are analyzable within the SCEV framework. More... | |
uint64_t | getTypeSizeInBits (Type *Ty) const |
Return the size in bits of the specified type, for which isSCEVable must return true. More... | |
Type * | getEffectiveSCEVType (Type *Ty) const |
Return a type with the same bitwidth as the given type and which represents how SCEV will treat the given type, for which isSCEVable must return true. More... | |
Type * | getWiderType (Type *Ty1, Type *Ty2) const |
bool | containsAddRecurrence (const SCEV *S) |
Return true if the SCEV is a scAddRecExpr or it contains scAddRecExpr. More... | |
void | eraseValueFromMap (Value *V) |
Erase Value from ValueExprMap and ExprValueMap. More... | |
const SCEV * | getSCEV (Value *V) |
Return a SCEV expression for the full generality of the specified expression. More... | |
const SCEV * | getConstant (ConstantInt *V) |
const SCEV * | getConstant (const APInt &Val) |
const SCEV * | getConstant (Type *Ty, uint64_t V, bool isSigned=false) |
const SCEV * | getLosslessPtrToIntExpr (const SCEV *Op, unsigned Depth=0) |
const SCEV * | getPtrToIntExpr (const SCEV *Op, Type *Ty) |
const SCEV * | getTruncateExpr (const SCEV *Op, Type *Ty, unsigned Depth=0) |
const SCEV * | getZeroExtendExpr (const SCEV *Op, Type *Ty, unsigned Depth=0) |
const SCEV * | getSignExtendExpr (const SCEV *Op, Type *Ty, unsigned Depth=0) |
const SCEV * | getAnyExtendExpr (const SCEV *Op, Type *Ty) |
getAnyExtendExpr - Return a SCEV for the given operand extended with unspecified bits out to the given type. More... | |
const SCEV * | getAddExpr (SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
Get a canonical add expression, or something simpler if possible. More... | |
const SCEV * | getAddExpr (const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
const SCEV * | getAddExpr (const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
const SCEV * | getMulExpr (SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
Get a canonical multiply expression, or something simpler if possible. More... | |
const SCEV * | getMulExpr (const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
const SCEV * | getMulExpr (const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
const SCEV * | getUDivExpr (const SCEV *LHS, const SCEV *RHS) |
Get a canonical unsigned division expression, or something simpler if possible. More... | |
const SCEV * | getUDivExactExpr (const SCEV *LHS, const SCEV *RHS) |
Get a canonical unsigned division expression, or something simpler if possible. More... | |
const SCEV * | getURemExpr (const SCEV *LHS, const SCEV *RHS) |
Represents an unsigned remainder expression based on unsigned division. More... | |
const SCEV * | getAddRecExpr (const SCEV *Start, const SCEV *Step, const Loop *L, SCEV::NoWrapFlags Flags) |
Get an add recurrence expression for the specified loop. More... | |
const SCEV * | getAddRecExpr (SmallVectorImpl< const SCEV * > &Operands, const Loop *L, SCEV::NoWrapFlags Flags) |
Get an add recurrence expression for the specified loop. More... | |
const SCEV * | getAddRecExpr (const SmallVectorImpl< const SCEV * > &Operands, const Loop *L, SCEV::NoWrapFlags Flags) |
Optional< std::pair< const SCEV *, SmallVector< const SCEVPredicate *, 3 > > > | createAddRecFromPHIWithCasts (const SCEVUnknown *SymbolicPHI) |
Checks if SymbolicPHI can be rewritten as an AddRecExpr under some Predicates. More... | |
const SCEV * | getGEPExpr (GEPOperator *GEP, const SmallVectorImpl< const SCEV * > &IndexExprs) |
Returns an expression for a GEP. More... | |
const SCEV * | getAbsExpr (const SCEV *Op, bool IsNSW) |
const SCEV * | getMinMaxExpr (SCEVTypes Kind, SmallVectorImpl< const SCEV * > &Operands) |
const SCEV * | getSMaxExpr (const SCEV *LHS, const SCEV *RHS) |
const SCEV * | getSMaxExpr (SmallVectorImpl< const SCEV * > &Operands) |
const SCEV * | getUMaxExpr (const SCEV *LHS, const SCEV *RHS) |
const SCEV * | getUMaxExpr (SmallVectorImpl< const SCEV * > &Operands) |
const SCEV * | getSMinExpr (const SCEV *LHS, const SCEV *RHS) |
const SCEV * | getSMinExpr (SmallVectorImpl< const SCEV * > &Operands) |
const SCEV * | getUMinExpr (const SCEV *LHS, const SCEV *RHS) |
const SCEV * | getUMinExpr (SmallVectorImpl< const SCEV * > &Operands) |
const SCEV * | getUnknown (Value *V) |
const SCEV * | getCouldNotCompute () |
const SCEV * | getZero (Type *Ty) |
Return a SCEV for the constant 0 of a specific type. More... | |
const SCEV * | getOne (Type *Ty) |
Return a SCEV for the constant 1 of a specific type. More... | |
const SCEV * | getMinusOne (Type *Ty) |
Return a SCEV for the constant -1 of a specific type. More... | |
const SCEV * | getSizeOfScalableVectorExpr (Type *IntTy, ScalableVectorType *ScalableTy) |
Return an expression for sizeof ScalableTy that is type IntTy, where ScalableTy is a scalable vector type. More... | |
const SCEV * | getSizeOfExpr (Type *IntTy, Type *AllocTy) |
Return an expression for the alloc size of AllocTy that is type IntTy. More... | |
const SCEV * | getStoreSizeOfExpr (Type *IntTy, Type *StoreTy) |
Return an expression for the store size of StoreTy that is type IntTy. More... | |
const SCEV * | getOffsetOfExpr (Type *IntTy, StructType *STy, unsigned FieldNo) |
Return an expression for offsetof on the given field with type IntTy. More... | |
const SCEV * | getNegativeSCEV (const SCEV *V, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap) |
Return the SCEV object corresponding to -V. More... | |
const SCEV * | getNotSCEV (const SCEV *V) |
Return the SCEV object corresponding to ~V. More... | |
const SCEV * | getMinusSCEV (const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0) |
Return LHS-RHS. Minus is represented in SCEV as A+B*-1. More... | |
const SCEV * | getTruncateOrZeroExtend (const SCEV *V, Type *Ty, unsigned Depth=0) |
Return a SCEV corresponding to a conversion of the input value to the specified type. More... | |
const SCEV * | getTruncateOrSignExtend (const SCEV *V, Type *Ty, unsigned Depth=0) |
Return a SCEV corresponding to a conversion of the input value to the specified type. More... | |
const SCEV * | getNoopOrZeroExtend (const SCEV *V, Type *Ty) |
Return a SCEV corresponding to a conversion of the input value to the specified type. More... | |
const SCEV * | getNoopOrSignExtend (const SCEV *V, Type *Ty) |
Return a SCEV corresponding to a conversion of the input value to the specified type. More... | |
const SCEV * | getNoopOrAnyExtend (const SCEV *V, Type *Ty) |
Return a SCEV corresponding to a conversion of the input value to the specified type. More... | |
const SCEV * | getTruncateOrNoop (const SCEV *V, Type *Ty) |
Return a SCEV corresponding to a conversion of the input value to the specified type. More... | |
const SCEV * | getUMaxFromMismatchedTypes (const SCEV *LHS, const SCEV *RHS) |
Promote the operands to the wider of the types using zero-extension, and then perform a umax operation with them. More... | |
const SCEV * | getUMinFromMismatchedTypes (const SCEV *LHS, const SCEV *RHS) |
Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them. More... | |
const SCEV * | getUMinFromMismatchedTypes (SmallVectorImpl< const SCEV * > &Ops) |
Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them. More... | |
const SCEV * | getPointerBase (const SCEV *V) |
Transitively follow the chain of pointer-type operands until reaching a SCEV that does not have a single pointer operand. More... | |
const SCEV * | getSCEVAtScope (const SCEV *S, const Loop *L) |
Return a SCEV expression for the specified value at the specified scope in the program. More... | |
const SCEV * | getSCEVAtScope (Value *V, const Loop *L) |
This is a convenience function which does getSCEVAtScope(getSCEV(V), L). More... | |
bool | isLoopEntryGuardedByCond (const Loop *L, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
Test whether entry to the loop is protected by a conditional between LHS and RHS. More... | |
bool | isBasicBlockEntryGuardedByCond (const BasicBlock *BB, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
Test whether entry to the basic block is protected by a conditional between LHS and RHS. More... | |
bool | isLoopBackedgeGuardedByCond (const Loop *L, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
Test whether the backedge of the loop is protected by a conditional between LHS and RHS. More... | |
unsigned | getSmallConstantTripCount (const Loop *L) |
Returns the maximum trip count of the loop if it is a single-exit loop and we can compute a small maximum for that loop. More... | |
unsigned | getSmallConstantTripCount (const Loop *L, const BasicBlock *ExitingBlock) |
Returns the maximum trip count of this loop as a normal unsigned value. More... | |
unsigned | getSmallConstantMaxTripCount (const Loop *L) |
Returns the upper bound of the loop trip count as a normal unsigned value. More... | |
unsigned | getSmallConstantTripMultiple (const Loop *L) |
Returns the largest constant divisor of the trip count of the loop if it is a single-exit loop and we can compute a small maximum for that loop. More... | |
unsigned | getSmallConstantTripMultiple (const Loop *L, const BasicBlock *ExitingBlock) |
Returns the largest constant divisor of the trip count of this loop as a normal unsigned value, if possible. More... | |
const SCEV * | getExitCount (const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact) |
Return the number of times the backedge executes before the given exit would be taken; if not exactly computable, return SCEVCouldNotCompute. More... | |
const SCEV * | getBackedgeTakenCount (const Loop *L, ExitCountKind Kind=Exact) |
If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCouldNotCompute object. More... | |
const SCEV * | getPredicatedBackedgeTakenCount (const Loop *L, SCEVUnionPredicate &Predicates) |
Similar to getBackedgeTakenCount, except it will add a set of SCEV predicates to Predicates that are required to be true in order for the answer to be correct. More... | |
const SCEV * | getConstantMaxBackedgeTakenCount (const Loop *L) |
When successful, this returns a SCEVConstant that is greater than or equal to (i.e. More... | |
const SCEV * | getSymbolicMaxBackedgeTakenCount (const Loop *L) |
When successful, this returns a SCEV that is greater than or equal to (i.e. More... | |
bool | isBackedgeTakenCountMaxOrZero (const Loop *L) |
Return true if the backedge taken count is either the value returned by getConstantMaxBackedgeTakenCount or zero. More... | |
bool | hasLoopInvariantBackedgeTakenCount (const Loop *L) |
Return true if the specified loop has an analyzable loop-invariant backedge-taken count. More... | |
void | forgetAllLoops () |
void | forgetLoop (const Loop *L) |
This method should be called by the client when it has changed a loop in a way that may effect ScalarEvolution's ability to compute a trip count, or if the loop is deleted. More... | |
void | forgetTopmostLoop (const Loop *L) |
void | forgetValue (Value *V) |
This method should be called by the client when it has changed a value in a way that may effect its value, or which may disconnect it from a def-use chain linking it to a loop. More... | |
void | forgetLoopDispositions (const Loop *L) |
Called when the client has changed the disposition of values in this loop. More... | |
uint32_t | GetMinTrailingZeros (const SCEV *S) |
Determine the minimum number of zero bits that S is guaranteed to end in (at every loop iteration). More... | |
ConstantRange | getUnsignedRange (const SCEV *S) |
Determine the unsigned range for a particular SCEV. More... | |
APInt | getUnsignedRangeMin (const SCEV *S) |
Determine the min of the unsigned range for a particular SCEV. More... | |
APInt | getUnsignedRangeMax (const SCEV *S) |
Determine the max of the unsigned range for a particular SCEV. More... | |
ConstantRange | getSignedRange (const SCEV *S) |
Determine the signed range for a particular SCEV. More... | |
APInt | getSignedRangeMin (const SCEV *S) |
Determine the min of the signed range for a particular SCEV. More... | |
APInt | getSignedRangeMax (const SCEV *S) |
Determine the max of the signed range for a particular SCEV. More... | |
bool | isKnownNegative (const SCEV *S) |
Test if the given expression is known to be negative. More... | |
bool | isKnownPositive (const SCEV *S) |
Test if the given expression is known to be positive. More... | |
bool | isKnownNonNegative (const SCEV *S) |
Test if the given expression is known to be non-negative. More... | |
bool | isKnownNonPositive (const SCEV *S) |
Test if the given expression is known to be non-positive. More... | |
bool | isKnownNonZero (const SCEV *S) |
Test if the given expression is known to be non-zero. More... | |
std::pair< const SCEV *, const SCEV * > | SplitIntoInitAndPostInc (const Loop *L, const SCEV *S) |
Splits SCEV expression S into two SCEVs. More... | |
bool | isKnownViaInduction (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
We'd like to check the predicate on every iteration of the most dominated loop between loops used in LHS and RHS. More... | |
bool | isKnownPredicate (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS. More... | |
Optional< bool > | evaluatePredicate (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) |
Check whether the condition described by Pred, LHS, and RHS is true or false. More... | |
bool | isKnownPredicateAt (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *Context) |
Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS in the given Context. More... | |
Optional< bool > | evaluatePredicateAt (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *Context) |
Check whether the condition described by Pred, LHS, and RHS is true or false in the given Context . More... | |
bool | isKnownOnEveryIteration (ICmpInst::Predicate Pred, const SCEVAddRecExpr *LHS, const SCEV *RHS) |
Test if the condition described by Pred, LHS, RHS is known to be true on every iteration of the loop of the recurrency LHS. More... | |
Optional< MonotonicPredicateType > | getMonotonicPredicateType (const SCEVAddRecExpr *LHS, ICmpInst::Predicate Pred) |
If, for all loop invariant X, the predicate "LHS `Pred` X" is monotonically increasing or decreasing, returns Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing) respectively. More... | |
Optional< LoopInvariantPredicate > | getLoopInvariantPredicate (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L) |
If the result of the predicate LHS Pred RHS is loop invariant with respect to L, return a LoopInvariantPredicate with LHS and RHS being invariants, available at L's entry. More... | |
Optional< LoopInvariantPredicate > | getLoopInvariantExitCondDuringFirstIterations (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L, const Instruction *Context, const SCEV *MaxIter) |
If the result of the predicate LHS Pred RHS is loop invariant with respect to L at given Context during at least first MaxIter iterations, return a LoopInvariantPredicate with LHS and RHS being invariants, available at L's entry. More... | |
bool | SimplifyICmpOperands (ICmpInst::Predicate &Pred, const SCEV *&LHS, const SCEV *&RHS, unsigned Depth=0) |
Simplify LHS and RHS in a comparison with predicate Pred. More... | |
LoopDisposition | getLoopDisposition (const SCEV *S, const Loop *L) |
Return the "disposition" of the given SCEV with respect to the given loop. More... | |
bool | isLoopInvariant (const SCEV *S, const Loop *L) |
Return true if the value of the given SCEV is unchanging in the specified loop. More... | |
bool | isAvailableAtLoopEntry (const SCEV *S, const Loop *L) |
Determine if the SCEV can be evaluated at loop's entry. More... | |
bool | hasComputableLoopEvolution (const SCEV *S, const Loop *L) |
Return true if the given SCEV changes value in a known way in the specified loop. More... | |
BlockDisposition | getBlockDisposition (const SCEV *S, const BasicBlock *BB) |
Return the "disposition" of the given SCEV with respect to the given block. More... | |
bool | dominates (const SCEV *S, const BasicBlock *BB) |
Return true if elements that makes up the given SCEV dominate the specified basic block. More... | |
bool | properlyDominates (const SCEV *S, const BasicBlock *BB) |
Return true if elements that makes up the given SCEV properly dominate the specified basic block. More... | |
bool | hasOperand (const SCEV *S, const SCEV *Op) const |
Test whether the given SCEV has Op as a direct or indirect operand. More... | |
const SCEV * | getElementSize (Instruction *Inst) |
Return the size of an element read or written by Inst. More... | |
void | findArrayDimensions (SmallVectorImpl< const SCEV * > &Terms, SmallVectorImpl< const SCEV * > &Sizes, const SCEV *ElementSize) |
Compute the array dimensions Sizes from the set of Terms extracted from the memory access function of this SCEVAddRecExpr (second step of delinearization). More... | |
void | print (raw_ostream &OS) const |
void | verify () const |
bool | invalidate (Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv) |
void | collectParametricTerms (const SCEV *Expr, SmallVectorImpl< const SCEV * > &Terms) |
Collect parametric terms occurring in step expressions (first step of delinearization). More... | |
void | computeAccessFunctions (const SCEV *Expr, SmallVectorImpl< const SCEV * > &Subscripts, SmallVectorImpl< const SCEV * > &Sizes) |
Return in Subscripts the access functions for each dimension in Sizes (third step of delinearization). More... | |
bool | getIndexExpressionsFromGEP (const GetElementPtrInst *GEP, SmallVectorImpl< const SCEV * > &Subscripts, SmallVectorImpl< int > &Sizes) |
Gathers the individual index expressions from a GEP instruction. More... | |
void | delinearize (const SCEV *Expr, SmallVectorImpl< const SCEV * > &Subscripts, SmallVectorImpl< const SCEV * > &Sizes, const SCEV *ElementSize) |
Split this SCEVAddRecExpr into two vectors of SCEVs representing the subscripts and sizes of an array access. More... | |
const DataLayout & | getDataLayout () const |
Return the DataLayout associated with the module this SCEV instance is operating on. More... | |
const SCEVPredicate * | getEqualPredicate (const SCEV *LHS, const SCEV *RHS) |
const SCEVPredicate * | getWrapPredicate (const SCEVAddRecExpr *AR, SCEVWrapPredicate::IncrementWrapFlags AddedFlags) |
const SCEV * | rewriteUsingPredicate (const SCEV *S, const Loop *L, SCEVUnionPredicate &A) |
Re-writes the SCEV according to the Predicates in A . More... | |
const SCEVAddRecExpr * | convertSCEVToAddRecWithPredicates (const SCEV *S, const Loop *L, SmallPtrSetImpl< const SCEVPredicate * > &Preds) |
Tries to convert the S expression to an AddRec expression, adding additional predicates to Preds as required. More... | |
Optional< APInt > | computeConstantDifference (const SCEV *LHS, const SCEV *RHS) |
Compute LHS - RHS and returns the result as an APInt if it is a constant, and None if it isn't. More... | |
void | setNoWrapFlags (SCEVAddRecExpr *AddRec, SCEV::NoWrapFlags Flags) |
Update no-wrap flags of an AddRec. More... | |
const SCEV * | applyLoopGuards (const SCEV *Expr, const Loop *L) |
Try to apply information from loop guards for L to Expr . More... | |
Static Public Member Functions | |
static LLVM_NODISCARD SCEV::NoWrapFlags | maskFlags (SCEV::NoWrapFlags Flags, int Mask) |
Convenient NoWrapFlags manipulation that hides enum casts and is visible in the ScalarEvolution name space. More... | |
static LLVM_NODISCARD SCEV::NoWrapFlags | setFlags (SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags) |
static LLVM_NODISCARD SCEV::NoWrapFlags | clearFlags (SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags) |
Friends | |
class | ScalarEvolutionsTest |
class | SCEVCallbackVH |
class | SCEVExpander |
class | SCEVUnknown |
The main scalar evolution driver.
Because client code (intentionally) can't do much with the SCEV objects directly, they must ask this class for services.
Definition at line 443 of file ScalarEvolution.h.
The terms "backedge taken count" and "exit count" are used interchangeably to refer to the number of times the backedge of a loop has executed before the loop is exited.
Definition at line 750 of file ScalarEvolution.h.
A predicate is said to be monotonically increasing if may go from being false to being true as the loop iterates, but never the other way around.
A predicate is said to be monotonically decreasing if may go from being true to being false as the loop iterates, but never the other way around.
Enumerator | |
---|---|
MonotonicallyIncreasing | |
MonotonicallyDecreasing |
Definition at line 969 of file ScalarEvolution.h.
ScalarEvolution::ScalarEvolution | ( | Function & | F, |
TargetLibraryInfo & | TLI, | ||
AssumptionCache & | AC, | ||
DominatorTree & | DT, | ||
LoopInfo & | LI | ||
) |
Definition at line 12139 of file ScalarEvolution.cpp.
References F, and llvm::Intrinsic::getName().
ScalarEvolution::ScalarEvolution | ( | ScalarEvolution && | Arg | ) |
Definition at line 12160 of file ScalarEvolution.cpp.
References Arg.
ScalarEvolution::~ScalarEvolution | ( | ) |
Definition at line 12188 of file ScalarEvolution.cpp.
References assert(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear().
Try to apply information from loop guards for L
to Expr
.
Definition at line 13387 of file ScalarEvolution.cpp.
References llvm::AssumptionCache::assumptions(), containsAddRecurrence(), llvm::DominatorTree::dominates(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::BranchInst::getCondition(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::CmpInst::getInversePredicate(), llvm::LoopBase< BlockT, LoopT >::getLoopPredecessor(), getMinusSCEV(), getMulExpr(), getOne(), getSCEV(), llvm::BranchInst::getSuccessor(), llvm::CmpInst::getSwappedPredicate(), getUDivExpr(), getUMaxExpr(), getUMinExpr(), llvm::SCEVConstant::getValue(), I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::Constant::isNullValue(), llvm::BranchInst::isUnconditional(), Rewriter, and std::swap().
Referenced by llvm::LoopVectorizationCostModel::computeMaxVF(), and getSmallConstantTripMultiple().
|
inlinestatic |
Definition at line 472 of file ScalarEvolution.h.
void ScalarEvolution::collectParametricTerms | ( | const SCEV * | Expr, |
SmallVectorImpl< const SCEV * > & | Terms | ||
) |
Collect parametric terms occurring in step expressions (first step of delinearization).
Find parametric terms in this SCEVAddRecExpr.
We first for parameters in two places: 1) The strides of AddRec expressions. 2) Unknowns that are multiplied with AddRec expressions.
Definition at line 11721 of file ScalarEvolution.cpp.
References llvm::dbgs(), LLVM_DEBUG, S, T, and llvm::visitAll().
Referenced by delinearize().
void ScalarEvolution::computeAccessFunctions | ( | const SCEV * | Expr, |
SmallVectorImpl< const SCEV * > & | Subscripts, | ||
SmallVectorImpl< const SCEV * > & | Sizes | ||
) |
Return in Subscripts the access functions for each dimension in Sizes (third step of delinearization).
Definition at line 11904 of file ScalarEvolution.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::SCEVDivision::divide(), i, llvm::SCEVAddRecExpr::isAffine(), LLVM_DEBUG, llvm::reverse(), and S.
Referenced by delinearize().
Compute LHS
- RHS
and returns the result as an APInt if it is a constant, and None if it isn't.
This is intended to be a cheaper version of getMinusSCEV. We can be frugal here since we just bail out of actually constructing and canonicalizing an expression in the cases where the result isn't going to be a constant.
Definition at line 10489 of file ScalarEvolution.cpp.
References C1, llvm::SCEV::getType(), getTypeSizeInBits(), llvm::CodeGenOpt::Less, M, and llvm::None.
Referenced by DbgGatherEqualValues().
Return true if the SCEV is a scAddRecExpr or it contains scAddRecExpr.
The result will be cached in HasRecMap.
Definition at line 3804 of file ScalarEvolution.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), S, and llvm::SCEVExprContains().
Referenced by applyLoopGuards().
const SCEVAddRecExpr * ScalarEvolution::convertSCEVToAddRecWithPredicates | ( | const SCEV * | S, |
const Loop * | L, | ||
SmallPtrSetImpl< const SCEVPredicate * > & | Preds | ||
) |
Tries to convert the S
expression to an AddRec expression, adding additional predicates to Preds
as required.
Definition at line 12994 of file ScalarEvolution.cpp.
References llvm::SmallPtrSetImpl< PtrType >::insert(), P, rewrite(), and S.
Referenced by llvm::PredicatedScalarEvolution::getAsAddRec().
Optional< std::pair< const SCEV *, SmallVector< const SCEVPredicate *, 3 > > > ScalarEvolution::createAddRecFromPHIWithCasts | ( | const SCEVUnknown * | SymbolicPHI | ) |
Checks if SymbolicPHI
can be rewritten as an AddRecExpr under some Predicates.
If successful return these <AddRecExpr, Predicates>; The function is intended to be called from PSCEV (the caller will decide whether to actually add the predicates and carry out the rewrites).
Definition at line 4995 of file ScalarEvolution.cpp.
References assert(), llvm::SCEVUnknown::getValue(), I, isIntegerLoopHeaderPHI(), and llvm::None.
void ScalarEvolution::delinearize | ( | const SCEV * | Expr, |
SmallVectorImpl< const SCEV * > & | Subscripts, | ||
SmallVectorImpl< const SCEV * > & | Sizes, | ||
const SCEV * | ElementSize | ||
) |
Split this SCEVAddRecExpr into two vectors of SCEVs representing the subscripts and sizes of an array access.
Splits the SCEV into two vectors of SCEVs representing the subscripts and sizes of an array access.
The delinearization is a 3 step process: the first two steps compute the sizes of each subscript and the third step computes the access functions for the delinearized array:
To compute a uniform array size for several memory accesses to the same object, one can collect in step 1 all the step terms for all the memory accesses, and compute in step 2 a unique array shape. This guarantees that the array shape will be the same across all memory accesses.
FIXME: We could derive the result of steps 1 and 2 from a description of the array shape given in metadata.
Example:
A[][n][m]
for i for j for k A[j+k][2i][5i] =
The initial SCEV:
A[{{{0,+,2*m+5}_i, +, n*m}_j, +, n*m}_k]
b. Divide Quotient: {{{0,+,2}_i, +, n}_j, +, n}_k by next outer size n Quotient: {{{0,+,0}_i, +, 1}_j, +, 1}_k Remainder: {{{0,+,2}_i, +, 0}_j, +, 0}_k The Remainder is the subscript of the next array dimension: [2i].
The subscript of the outermost dimension is the Quotient: [j+k].
Overall, we have: A[][n][m], and the access function: A[j+k][2i][5i].
Returns the remainder of the delinearization that is the offset start of the array. The SCEV->delinearize algorithm computes the multiples of SCEV coefficients: that is a pattern matching of sub expressions in the stride and base of a SCEV corresponding to the computation of a GCD (greatest common divisor) of base and stride. When SCEV->delinearize fails, it returns the SCEV unchanged.
For example: when analyzing the memory access A[i][j][k] in this loop nest
void foo(long n, long m, long o, double A[n][m][o]) {
for (long i = 0; i < n; i++) for (long j = 0; j < m; j++) for (long k = 0; k < o; k++) A[i][j][k] = 1.0; }
the delinearization input is the following AddRec SCEV:
AddRec: {{{A,+,(8 * m * o)}<for.i>,+,(8 * o)}<for.j>,+,8}<for.k>
From this SCEV, we are able to say that the base offset of the access is A because it appears as an offset that does not divide any of the strides in the loops:
CHECK: Base offset: A
and then SCEV->delinearize determines the size of some of the dimensions of the array as these are the multiples by which the strides are happening:
CHECK: ArrayDecl[UnknownSize][m][o] with elements of sizeof(double) bytes.
Note that the outermost dimension remains of UnknownSize because there are no strides that would help identifying the size of the last dimension: when the array has been statically allocated, one could compute the size of that dimension by dividing the overall size of the array by the size of the known dimensions: m * o * 8.
Finally delinearize provides the access functions for the array reference that does correspond to A[i][j][k] of the above C testcase:
CHECK: ArrayRef[{0,+,1}<for.i>][{0,+,1}<for.j>][{0,+,1}<for.k>]
The testcases are checking the output of a function pass: DelinearizationPass that walks through all loads and stores of a function asking for the SCEV of the memory access with respect to all enclosing loops, calling SCEV->delinearize on that and printing the results.
Definition at line 12010 of file ScalarEvolution.cpp.
References collectParametricTerms(), computeAccessFunctions(), llvm::dbgs(), findArrayDimensions(), LLVM_DEBUG, and S.
bool ScalarEvolution::dominates | ( | const SCEV * | S, |
const BasicBlock * | BB | ||
) |
Return true if elements that makes up the given SCEV dominate the specified basic block.
Definition at line 12578 of file ScalarEvolution.cpp.
References BB, DominatesBlock, getBlockDisposition(), and S.
Referenced by llvm::isSafeToExpandAt().
void ScalarEvolution::eraseValueFromMap | ( | Value * | V | ) |
Erase Value from ValueExprMap and ExprValueMap.
ValueExprMap.erase(V) cannot be used separately. eraseValueFromMap should be used to remove V from ValueExprMap and ExprValueMap at the same time.
Definition at line 3853 of file ScalarEvolution.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find_as(), I, Offset, S, and splitAddExpr().
Referenced by forgetValue().
Optional< bool > ScalarEvolution::evaluatePredicate | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS | ||
) |
Check whether the condition described by Pred, LHS, and RHS is true or false.
If we know it, return the evaluation of this condition. If neither is proved, return None.
Definition at line 9626 of file ScalarEvolution.cpp.
References llvm::CmpInst::getInversePredicate(), isKnownPredicate(), and llvm::None.
Referenced by countToEliminateCompares(), and evaluatePredicateAt().
Optional< bool > ScalarEvolution::evaluatePredicateAt | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS, | ||
const Instruction * | Context | ||
) |
Check whether the condition described by Pred, LHS, and RHS is true or false in the given Context
.
If we know it, return the evaluation of this condition. If neither is proved, return None.
Definition at line 9645 of file ScalarEvolution.cpp.
References Context, evaluatePredicate(), llvm::CmpInst::getInversePredicate(), isBasicBlockEntryGuardedByCond(), and llvm::None.
void ScalarEvolution::findArrayDimensions | ( | SmallVectorImpl< const SCEV * > & | Terms, |
SmallVectorImpl< const SCEV * > & | Sizes, | ||
const SCEV * | ElementSize | ||
) |
Compute the array dimensions Sizes from the set of Terms extracted from the memory access function of this SCEVAddRecExpr (second step of delinearization).
Definition at line 11841 of file ScalarEvolution.cpp.
References llvm::array_pod_sort(), llvm::SmallVectorImpl< T >::clear(), containsParameters(), llvm::dbgs(), llvm::SCEVDivision::divide(), llvm::SmallVectorImpl< T >::erase(), findArrayDimensionsRec(), llvm::SCEV::isZero(), LLVM_DEBUG, numberOfTerms(), removeConstantFactors(), S, llvm::sort(), T, and llvm::M68kBeads::Term.
Referenced by delinearize().
void ScalarEvolution::forgetAllLoops | ( | ) |
Definition at line 7158 of file ScalarEvolution.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear().
Referenced by llvm::UnrollLoop().
This method should be called by the client when it has changed a loop in a way that may effect ScalarEvolution's ability to compute a trip count, or if the loop is deleted.
This call is potentially expensive for large loop bodies.
Definition at line 7180 of file ScalarEvolution.cpp.
References I, and llvm::SmallVectorImpl< T >::pop_back_val().
Referenced by llvm::breakLoopBackedge(), llvm::deleteDeadLoop(), deleteLoopIfDead(), DoFlattenLoopPair(), llvm::InnerLoopVectorizer::fixVectorizedLoop(), forgetTopmostLoop(), llvm::formLCSSA(), separateNestedLoop(), llvm::UnrollAndJamLoop(), unswitchNontrivialInvariants(), unswitchTrivialBranch(), and unswitchTrivialSwitch().
Called when the client has changed the disposition of values in this loop.
We don't have a way to invalidate per-loop dispositions. Clear and recompute is simpler.
Definition at line 7279 of file ScalarEvolution.cpp.
Referenced by isLoopDead(), simplifyOneLoop(), and sinkLoopInvariantInstructions().
Definition at line 7246 of file ScalarEvolution.cpp.
References forgetLoop(), and llvm::LoopBase< BlockT, LoopT >::getParentLoop().
Referenced by llvm::peelLoop(), simplifyLoopCFG(), llvm::UnrollLoop(), llvm::UnrollRuntimeLoopRemainder(), unswitchNontrivialInvariants(), unswitchTrivialBranch(), and unswitchTrivialSwitch().
void ScalarEvolution::forgetValue | ( | Value * | V | ) |
This method should be called by the client when it has changed a value in a way that may effect its value, or which may disconnect it from a def-use chain linking it to a loop.
Definition at line 7252 of file ScalarEvolution.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), eraseValueFromMap(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find_as(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), and PushDefUseChildren().
Referenced by llvm::formLCSSAForInstructions(), moveInstructionBefore(), llvm::rewriteLoopExitValues(), simplifyOneLoop(), and GeneratedRTChecks::~GeneratedRTChecks().
Definition at line 3514 of file ScalarEvolution.cpp.
References llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, getNegativeSCEV(), and getSMaxExpr().
|
inline |
Definition at line 524 of file ScalarEvolution.h.
References llvm::Depth, and getAddExpr().
|
inline |
Definition at line 530 of file ScalarEvolution.h.
References llvm::Depth, and getAddExpr().
const SCEV * ScalarEvolution::getAddExpr | ( | SmallVectorImpl< const SCEV * > & | Ops, |
SCEV::NoWrapFlags | Flags = SCEV::FlagAnyWrap , |
||
unsigned | Depth = 0 |
||
) |
Get a canonical add expression, or something simpler if possible.
Definition at line 2313 of file ScalarEvolution.cpp.
References AddOpsInlineThreshold, llvm::SmallVectorImpl< T >::append(), assert(), llvm::BitWidth, llvm::SmallVectorImpl< T >::clear(), CollectAddOperandsWithScales(), llvm::Depth, llvm::DominatorTree::dominates(), llvm::numbers::e, llvm::SmallVectorImpl< T >::erase(), f(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::SCEV::FlagNW, getAddRecExpr(), getAnyExtendExpr(), getConstant(), getEffectiveSCEVType(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::SCEVAddRecExpr::getLoop(), getMulExpr(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVNAryExpr::getNumOperands(), getOne(), llvm::SCEVNAryExpr::getOperand(), llvm::SCEVAddRecExpr::getStart(), getTruncateExpr(), llvm::Intrinsic::getType(), getTypeSizeInBits(), getZero(), GroupByComplexity(), hasHugeExpression(), i, isAvailableAtLoopEntry(), j(), M, MaxArithDepth, llvm::Mul, llvm::SCEVNAryExpr::op_begin(), llvm::SCEVNAryExpr::op_end(), llvm::SCEVNAryExpr::operands(), S, llvm::scAddExpr, llvm::scAddRecExpr, llvm::scMulExpr, setFlags(), StrengthenNoWrapFlags(), T, and llvm::APInt::ult().
Referenced by canBeCheaplyTransformed(), llvm::LoopVectorizationCostModel::computeMaxVF(), computeTripCount(), countToEliminateCompares(), llvm::SCEVAddRecExpr::evaluateAtIteration(), expandBounds(), ExposePointerBase(), ExtractImmediate(), ExtractSymbol(), FactorOutConstant(), genLoopLimit(), getAddExpr(), getExtendAddRecStart(), getGEPExpr(), getLosslessPtrToIntExpr(), getMinusSCEV(), getMulExpr(), getNewAlignment(), getNumBytes(), llvm::InnerLoopVectorizer::getOrCreateTripCount(), llvm::SCEVAddRecExpr::getPostIncExpr(), WidenIV::getSCEVByOpCode(), getSignExtendExpr(), getSmallConstantTripMultiple(), getTruncateExpr(), getUDivExpr(), llvm::RuntimePointerChecking::insert(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), IsIncrementNSW(), IsIncrementNUW(), SimplifyAddOperands(), SimplifyICmpOperands(), llvm::UnrollRuntimeLoopRemainder(), llvm::SCEVDivision::visitAddExpr(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitAddExpr(), and willNotOverflow().
const SCEV * ScalarEvolution::getAddRecExpr | ( | const SCEV * | Start, |
const SCEV * | Step, | ||
const Loop * | L, | ||
SCEV::NoWrapFlags | Flags | ||
) |
Get an add recurrence expression for the specified loop.
Simplify the expression as much as possible.
Definition at line 3346 of file ScalarEvolution.cpp.
Referenced by CollectSubexprs(), DoInitialMatch(), ExposePointerBase(), ExtractImmediate(), ExtractSymbol(), getAddExpr(), getAddRecExpr(), getAnyExtendExpr(), getMulExpr(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), llvm::SCEVAddRecExpr::getPostIncExpr(), llvm::SCEVAddRecExpr::getStepRecurrence(), getTruncateExpr(), getUDivExpr(), isLoopBackedgeGuardedByCond(), llvm::SCEVDivision::visitAddRecExpr(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitAddRecExpr(), and llvm::SCEVLoopAddRecRewriter::visitAddRecExpr().
|
inline |
Definition at line 558 of file ScalarEvolution.h.
References getAddRecExpr(), and Operands.
const SCEV * ScalarEvolution::getAddRecExpr | ( | SmallVectorImpl< const SCEV * > & | Operands, |
const Loop * | L, | ||
SCEV::NoWrapFlags | Flags | ||
) |
Get an add recurrence expression for the specified loop.
Simplify the expression as much as possible.
Definition at line 3364 of file ScalarEvolution.cpp.
References llvm::all_of(), assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::DominatorTree::dominates(), llvm::numbers::e, llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNW, getAddRecExpr(), getEffectiveSCEVType(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), llvm::Intrinsic::getType(), i, isLoopInvariant(), maskFlags(), Operands, llvm::scAddRecExpr, and StrengthenNoWrapFlags().
getAnyExtendExpr - Return a SCEV for the given operand extended with unspecified bits out to the given type.
Definition at line 2104 of file ScalarEvolution.cpp.
References assert(), llvm::SCEV::FlagNW, getAddRecExpr(), getEffectiveSCEVType(), getSignExtendExpr(), getTruncateOrNoop(), llvm::SCEV::getType(), getTypeSizeInBits(), getZeroExtendExpr(), isSCEVable(), llvm::PPCISD::SC, and T.
Referenced by getAddExpr(), and getNoopOrAnyExtend().
If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCouldNotCompute object.
The backedge-taken count is the number of times the loop header will be branched to from within the loop, assuming there are no abnormal exists like exception throws. This is one less than the trip count of the loop, since it doesn't count the first iteration, when the header is branched to from outside the loop.
Note that it is not valid to call this method on a loop without a loop-invariant backedge-taken count (see hasLoopInvariantBackedgeTakenCount).
Definition at line 7012 of file ScalarEvolution.cpp.
References ConstantMaximum, Exact, llvm_unreachable, and SymbolicMaximum.
Referenced by breakBackedgeIfNotTaken(), computeTripCount(), getConstantMaxBackedgeTakenCount(), getSymbolicMaxBackedgeTakenCount(), hasLoopInvariantBackedgeTakenCount(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::IVUsers::print(), PrintLoopInfo(), and verify().
ScalarEvolution::BlockDisposition ScalarEvolution::getBlockDisposition | ( | const SCEV * | S, |
const BasicBlock * | BB | ||
) |
Return the "disposition" of the given SCEV with respect to the given block.
Definition at line 12493 of file ScalarEvolution.cpp.
References BB, D, DoesNotDominateBlock, llvm::make_range(), and S.
Referenced by dominates(), and properlyDominates().
Definition at line 455 of file ScalarEvolution.cpp.
References llvm::ConstantInt::get(), getConstant(), and getContext().
const SCEV * ScalarEvolution::getConstant | ( | ConstantInt * | V | ) |
Definition at line 444 of file ScalarEvolution.cpp.
References S, and llvm::scConstant.
Referenced by BinomialCoefficient(), llvm::cannotBeMaxInLoop(), llvm::cannotBeMinInLoop(), CollectSubexprs(), llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::IndexedReference::computeRefCost(), countToEliminateCompares(), DoInitialMatch(), EvaluateConstantChrecAtConstant(), ExposePointerBase(), ExtractImmediate(), ExtractSymbol(), FactorOutConstant(), getAddExpr(), getConstant(), getExactSDiv(), getMinMaxExpr(), getMinusOne(), getMulExpr(), getNegativeSCEV(), getNotSCEV(), getNumBytes(), getOffsetOfExpr(), getOne(), getSignedOverflowLimitForStep(), getSignExtendExpr(), getSizeOfExpr(), getStoreSizeOfExpr(), getTruncateExpr(), getUDivExactExpr(), getUDivExpr(), getUnsignedOverflowLimitForStep(), getZero(), getZeroExtendExpr(), llvm::InductionDescriptor::isInductionPHI(), isSafeDependenceDistance(), SimplifyAddOperands(), SimplifyICmpOperands(), SolveLinEquationWithOverflow(), llvm::UnrolledInstAnalyzer::UnrolledInstAnalyzer(), llvm::UnrollRuntimeLoopRemainder(), verify(), and llvm::SCEVDivision::visitConstant().
Definition at line 460 of file ScalarEvolution.cpp.
References llvm::ConstantInt::get(), getConstant(), and getEffectiveSCEVType().
When successful, this returns a SCEVConstant that is greater than or equal to (i.e.
a "conservative over-approximation") of the value returend by getBackedgeTakenCount. If such a value cannot be computed, it returns the SCEVCouldNotCompute object.
Definition at line 792 of file ScalarEvolution.h.
References ConstantMaximum, and getBackedgeTakenCount().
Referenced by deleteLoopIfDead(), getSmallConstantMaxTripCount(), mustBeFiniteCountedLoop(), and PrintLoopInfo().
|
inline |
Definition at line 481 of file ScalarEvolution.h.
References F.
Referenced by BinomialCoefficient(), FactorOutConstant(), getConstant(), getMinMaxExpr(), getUDivExpr(), getURemExpr(), isAddRecSExtable(), isAddSExtable(), isMulSExtable(), SimplifyICmpOperands(), SolveQuadraticAddRecExact(), and SolveQuadraticAddRecRange().
Definition at line 3791 of file ScalarEvolution.cpp.
Referenced by BinomialCoefficient(), getLosslessPtrToIntExpr(), getMinAnalyzeableBackedgeTakenCount(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getSmallConstantTripMultiple(), isKnownViaInduction(), isLoopBackedgeGuardedByCond(), SolveLinEquationWithOverflow(), and verify().
|
inline |
Return the DataLayout associated with the module this SCEV instance is operating on.
Definition at line 1160 of file ScalarEvolution.h.
References llvm::Module::getDataLayout(), and llvm::GlobalValue::getParent().
Referenced by getEffectiveSCEVType(), getLosslessPtrToIntExpr(), getOffsetOfExpr(), getSizeOfExpr(), getStoreSizeOfExpr(), getTypeSizeInBits(), and llvm::simplifyLoopIVs().
Return a type with the same bitwidth as the given type and which represents how SCEV will treat the given type, for which isSCEVable must return true.
For pointer types, this is the pointer-sized integer type.
For pointer types, this is the pointer index sized integer type.
Definition at line 3776 of file ScalarEvolution.cpp.
References assert(), getDataLayout(), llvm::DataLayout::getIndexType(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), and isSCEVable().
Referenced by llvm::SCEVAAResult::alias(), canBeCheaplyTransformed(), WidenIV::createWideIV(), DoInitialMatch(), genLoopLimit(), getAddExpr(), getAddRecExpr(), getAnyExtendExpr(), getConstant(), getElementSize(), getGEPExpr(), getLosslessPtrToIntExpr(), getMinMaxExpr(), getMulExpr(), getNegativeSCEV(), getNewAlignment(), getNotSCEV(), getSignExtendExpr(), getTruncateExpr(), getUDivExpr(), getURemExpr(), getZeroExtendExpr(), isExistingPhi(), and visitIVCast().
const SCEV * ScalarEvolution::getElementSize | ( | Instruction * | Inst | ) |
Return the size of an element read or written by Inst.
Definition at line 11828 of file ScalarEvolution.cpp.
References getEffectiveSCEVType(), getSizeOfExpr(), llvm::PointerType::getUnqual(), llvm::SPII::Load, and llvm::SPII::Store.
Definition at line 12837 of file ScalarEvolution.cpp.
References assert(), llvm::SCEV::getType(), llvm::SCEVPredicate::P_Equal, and S.
Referenced by llvm::PredicatedScalarEvolution::areAddRecsEqualWithPreds(), and llvm::replaceSymbolicStrideSCEV().
const SCEV * ScalarEvolution::getExitCount | ( | const Loop * | L, |
const BasicBlock * | ExitingBlock, | ||
ExitCountKind | Kind = Exact |
||
) |
Return the number of times the backedge executes before the given exit would be taken; if not exactly computable, return SCEVCouldNotCompute.
For a single exit loop, this value is equivelent to the result of getBackedgeTakenCount. The loop is guaranteed to exit (via some exit) before the backedge is executed (ExitCount + 1) times. Note that there is no guarantee about which exit is taken on the exiting iteration.
Definition at line 6993 of file ScalarEvolution.cpp.
References ConstantMaximum, Exact, llvm_unreachable, and SymbolicMaximum.
Referenced by getMinAnalyzeableBackedgeTakenCount(), getSmallConstantTripCount(), getSmallConstantTripMultiple(), llvm::hasIterationCountInvariantInParent(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), mustBeFiniteCountedLoop(), PrintLoopInfo(), llvm::rewriteLoopExitValues(), and llvm::UnrollRuntimeLoopRemainder().
const SCEV * ScalarEvolution::getGEPExpr | ( | GEPOperator * | GEP, |
const SmallVectorImpl< const SCEV * > & | IndexExprs | ||
) |
Returns an expression for a GEP.
GEP
The GEP. The indices contained in the GEP itself are ignored, instead we use IndexExprs. IndexExprs
The expressions for the indices.
Definition at line 3439 of file ScalarEvolution.cpp.
References assert(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, GEP, getAddExpr(), getEffectiveSCEVType(), getMulExpr(), getOffsetOfExpr(), getSCEV(), getSizeOfExpr(), getTruncateOrSignExtend(), llvm::SCEV::getType(), llvm::GetElementPtrInst::getTypeAtIndex(), Index, isKnownNonNegative(), and Offset.
bool ScalarEvolution::getIndexExpressionsFromGEP | ( | const GetElementPtrInst * | GEP, |
SmallVectorImpl< const SCEV * > & | Subscripts, | ||
SmallVectorImpl< int > & | Sizes | ||
) |
Gathers the individual index expressions from a GEP instruction.
This function optimistically assumes the GEP references into a fixed size array. If this is actually true, this function returns a list of array subscript expressions in Subscripts
and a list of integers describing the size of the individual array dimensions in Sizes
. Both lists have either equal length or the size list is one element shorter in case there is no known size available for the outermost array dimension. Returns true if successful and false otherwise.
Definition at line 12046 of file ScalarEvolution.cpp.
References assert(), llvm::SmallVectorImpl< T >::clear(), GEP, getSCEV(), and i.
ScalarEvolution::LoopDisposition ScalarEvolution::getLoopDisposition | ( | const SCEV * | S, |
const Loop * | L | ||
) |
Return the "disposition" of the given SCEV with respect to the given loop.
Definition at line 12385 of file ScalarEvolution.cpp.
References D, LoopVariant, llvm::make_range(), and S.
Referenced by hasComputableLoopEvolution(), llvm::hasIterationCountInvariantInParent(), isLoopInvariant(), and print().
Optional< ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS, | ||
const Loop * | L, | ||
const Instruction * | Context, | ||
const SCEV * | MaxIter | ||
) |
If the result of the predicate LHS Pred
RHS is loop invariant with respect to L at given Context during at least first MaxIter iterations, return a LoopInvariantPredicate with LHS and RHS being invariants, available at L's entry.
Otherwise, return None. The predicate should be the loop's exit condition.
Definition at line 9782 of file ScalarEvolution.cpp.
References llvm::SCEVAddRecExpr::evaluateAtIteration(), llvm::SCEVAddRecExpr::getLoop(), getNegativeSCEV(), getOne(), llvm::SCEVAddRecExpr::getStepRecurrence(), llvm::CmpInst::getSwappedPredicate(), llvm::SCEV::getType(), llvm::SCEVNAryExpr::getType(), llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_ULE, isLoopBackedgeGuardedByCond(), isLoopInvariant(), llvm::ICmpInst::isRelational(), llvm::CmpInst::isSigned(), llvm::None, and std::swap().
Referenced by optimizeLoopExitWithUnknownExitCount().
Optional< ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantPredicate | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS, | ||
const Loop * | L | ||
) |
If the result of the predicate LHS Pred
RHS is loop invariant with respect to L, return a LoopInvariantPredicate with LHS and RHS being invariants, available at L's entry.
Otherwise, return None.
Definition at line 9735 of file ScalarEvolution.cpp.
References llvm::CmpInst::getInversePredicate(), llvm::SCEVAddRecExpr::getLoop(), getMonotonicPredicateType(), llvm::SCEVAddRecExpr::getStart(), llvm::CmpInst::getSwappedPredicate(), isLoopBackedgeGuardedByCond(), isLoopInvariant(), MonotonicallyIncreasing, llvm::None, P, and std::swap().
The SCEVPtrToIntSinkingRewriter takes a scalar evolution expression, which computes a pointer-typed value, and rewrites the whole expression tree so that all the computations are done on integers, and the only pointer-typed operands in the expression are SCEVUnknown.
Definition at line 1046 of file ScalarEvolution.cpp.
References assert(), llvm::Depth, getAddExpr(), getCouldNotCompute(), getDataLayout(), getEffectiveSCEVType(), llvm::DataLayout::getIntPtrType(), getLosslessPtrToIntExpr(), getMulExpr(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEV::getType(), llvm::SCEVUnknown::getType(), getTypeSizeInBits(), getZero(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), Operands, llvm::SCEVNAryExpr::operands(), rewrite(), Rewriter, S, and llvm::scPtrToInt.
Referenced by getLosslessPtrToIntExpr(), and getPtrToIntExpr().
const SCEV * ScalarEvolution::getMinMaxExpr | ( | SCEVTypes | Kind, |
SmallVectorImpl< const SCEV * > & | Operands | ||
) |
Definition at line 3519 of file ScalarEvolution.cpp.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), llvm::SmallVectorImpl< T >::append(), assert(), llvm::numbers::e, llvm::SmallVectorImpl< T >::erase(), llvm::ConstantInt::get(), getConstant(), getContext(), getEffectiveSCEVType(), llvm::Intrinsic::getType(), GroupByComplexity(), i, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULE, llvm_unreachable, llvm::RISCVFenceField::O, llvm::SCEVNAryExpr::op_begin(), llvm::SCEVNAryExpr::op_end(), S, llvm::scSMaxExpr, llvm::scSMinExpr, llvm::scUMaxExpr, llvm::scUMinExpr, llvm::APIntOps::smax(), llvm::APIntOps::smin(), llvm::APIntOps::umax(), and llvm::APIntOps::umin().
Referenced by getNotSCEV(), getSMaxExpr(), getSMinExpr(), getUMaxExpr(), and getUMinExpr().
Determine the minimum number of zero bits that S is guaranteed to end in (at every loop iteration).
It is, at the same time, the minimum number of times S is divisible by 2. For example, given {4,+,8} it returns 2. If S is guaranteed to be 0, it returns the bitwidth of S.
Definition at line 5623 of file ScalarEvolution.cpp.
References assert(), I, and S.
Referenced by extractConstantWithoutWrapping(), getSmallConstantTripMultiple(), getTruncateExpr(), and SolveLinEquationWithOverflow().
Return a SCEV for the constant -1 of a specific type.
Definition at line 599 of file ScalarEvolution.h.
References getConstant().
Referenced by getNegativeSCEV(), getNotSCEV(), and optimizeLoopExitWithUnknownExitCount().
const SCEV * ScalarEvolution::getMinusSCEV | ( | const SCEV * | LHS, |
const SCEV * | RHS, | ||
SCEV::NoWrapFlags | Flags = SCEV::FlagAnyWrap , |
||
unsigned | Depth = 0 |
||
) |
Return LHS-RHS. Minus is represented in SCEV as A+B*-1.
Definition at line 3994 of file ScalarEvolution.cpp.
References llvm::Depth, llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, getAddExpr(), getNegativeSCEV(), getSignedRangeMin(), llvm::SCEV::getType(), getZero(), isKnownNonNegative(), llvm::APInt::isMinSignedValue(), and maskFlags().
Referenced by llvm::SCEVAAResult::alias(), applyLoopGuards(), BinomialCoefficient(), getMinFromExprs(), getNewAlignment(), getNotSCEV(), llvm::getPointersDiff(), WidenIV::getSCEVByOpCode(), getURemExpr(), llvm::IndexedReference::hasSpacialReuse(), isSafeDependenceDistance(), optimizeLoopExitWithUnknownExitCount(), verify(), llvm::SCEVDivision::visitMulExpr(), and willNotOverflow().
Optional< ScalarEvolution::MonotonicPredicateType > ScalarEvolution::getMonotonicPredicateType | ( | const SCEVAddRecExpr * | LHS, |
ICmpInst::Predicate | Pred | ||
) |
If, for all loop invariant X, the predicate "LHS `Pred` X" is monotonically increasing or decreasing, returns Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing) respectively.
If we could not prove either of these facts, returns None.
Definition at line 9670 of file ScalarEvolution.cpp.
References assert(), and llvm::CmpInst::getSwappedPredicate().
Referenced by countToEliminateCompares(), and getLoopInvariantPredicate().
|
inline |
Definition at line 539 of file ScalarEvolution.h.
References llvm::Depth, and getMulExpr().
|
inline |
Definition at line 545 of file ScalarEvolution.h.
References llvm::Depth, and getMulExpr().
const SCEV * ScalarEvolution::getMulExpr | ( | SmallVectorImpl< const SCEV * > & | Ops, |
SCEV::NoWrapFlags | Flags = SCEV::FlagAnyWrap , |
||
unsigned | Depth = 0 |
||
) |
Get a canonical multiply expression, or something simpler if possible.
Definition at line 2829 of file ScalarEvolution.cpp.
References llvm::SmallVectorImpl< T >::append(), assert(), Choose(), containsConstantInAddMulChain(), llvm::Depth, llvm::numbers::e, llvm::SmallVectorImpl< T >::erase(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::SCEV::FlagNW, getAddExpr(), getAddRecExpr(), getConstant(), getEffectiveSCEVType(), llvm::SCEVAddRecExpr::getLoop(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVNAryExpr::getOperand(), llvm::Intrinsic::getType(), llvm::SCEVNAryExpr::getType(), getTypeSizeInBits(), getZero(), GroupByComplexity(), hasHugeExpression(), i, isAvailableAtLoopEntry(), maskFlags(), llvm::max(), MaxAddRecSize, MaxArithDepth, llvm::min(), llvm::Mul, MulOpsInlineThreshold, Operands, llvm::SmallVectorImpl< T >::reserve(), S, llvm::scAddRecExpr, llvm::scMulExpr, StrengthenNoWrapFlags(), umul_ov(), x, y, and z.
Referenced by applyLoopGuards(), BinomialCoefficient(), CollectAddOperandsWithScales(), CollectSubexprs(), llvm::IndexedReference::computeRefCost(), DoInitialMatch(), llvm::SCEVAddRecExpr::evaluateAtIteration(), FactorOutConstant(), findArrayDimensionsRec(), getAddExpr(), getExactSDiv(), getGEPExpr(), getLosslessPtrToIntExpr(), getMulExpr(), getNegativeSCEV(), getNumBytes(), WidenIV::getSCEVByOpCode(), getTruncateExpr(), getUDivExactExpr(), getUDivExpr(), getURemExpr(), isSafeDependenceDistance(), removeConstantFactors(), SolveLinEquationWithOverflow(), llvm::SCEVDivision::visitMulExpr(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitMulExpr(), and willNotOverflow().
const SCEV * ScalarEvolution::getNegativeSCEV | ( | const SCEV * | V, |
SCEV::NoWrapFlags | Flags = SCEV::FlagAnyWrap |
||
) |
Return the SCEV object corresponding to -V.
Return a SCEV corresponding to -V = -1*V.
Definition at line 3940 of file ScalarEvolution.cpp.
References getConstant(), getEffectiveSCEVType(), getMinusOne(), getMulExpr(), llvm::ConstantExpr::getNeg(), llvm::SCEV::getType(), and llvm::AArch64CC::VC.
Referenced by canBeCheaplyTransformed(), llvm::IndexedReference::computeRefCost(), getAbsExpr(), getLoopInvariantExitCondDuringFirstIterations(), getMinusSCEV(), getNumBytes(), isSafeDependenceDistance(), and WidenIV::widenWithVariantUse().
Return a SCEV corresponding to a conversion of the input value to the specified type.
If the type must be extended, it is extended with unspecified bits. The conversion must not be narrowing.
Definition at line 4082 of file ScalarEvolution.cpp.
References assert(), getAnyExtendExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().
Referenced by llvm::IndexedReference::computeRefCost().
Return a SCEV corresponding to a conversion of the input value to the specified type.
If the type must be extended, it is sign extended. The conversion must not be narrowing.
Definition at line 4070 of file ScalarEvolution.cpp.
References assert(), getSignExtendExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().
Referenced by getNewAlignment(), isSafeDependenceDistance(), and NoopOrExtend().
Return a SCEV corresponding to a conversion of the input value to the specified type.
If the type must be extended, it is zero extended. The conversion must not be narrowing.
Definition at line 4058 of file ScalarEvolution.cpp.
References assert(), llvm::SCEV::getType(), getTypeSizeInBits(), getZeroExtendExpr(), and llvm::Type::isIntOrPtrTy().
Referenced by llvm::InnerLoopVectorizer::getOrCreateTripCount(), getUMaxFromMismatchedTypes(), getUMinFromMismatchedTypes(), and NoopOrExtend().
Return the SCEV object corresponding to ~V.
Return a SCEV corresponding to ~V = -1-V.
Definition at line 3967 of file ScalarEvolution.cpp.
References getConstant(), getEffectiveSCEVType(), getMinMaxExpr(), getMinusOne(), getMinusSCEV(), llvm::ConstantExpr::getNot(), llvm::SCEV::getType(), MatchNotExpr(), llvm::SCEVMinMaxExpr::negate(), and llvm::AArch64CC::VC.
const SCEV * ScalarEvolution::getOffsetOfExpr | ( | Type * | IntTy, |
StructType * | STy, | ||
unsigned | FieldNo | ||
) |
Return an expression for offsetof on the given field with type IntTy.
Definition at line 3719 of file ScalarEvolution.cpp.
References getConstant(), and getDataLayout().
Referenced by getGEPExpr().
Return a SCEV for the constant 1 of a specific type.
Definition at line 596 of file ScalarEvolution.h.
References getConstant().
Referenced by applyLoopGuards(), llvm::LoopVectorizationCostModel::computeMaxVF(), computeTripCount(), expandBounds(), genLoopLimit(), getAddExpr(), getLoopInvariantExitCondDuringFirstIterations(), getNumBytes(), llvm::InnerLoopVectorizer::getOrCreateTripCount(), getSmallConstantTripMultiple(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), isLoopBackedgeGuardedByCond(), optimizeLoopExitWithUnknownExitCount(), and llvm::replaceSymbolicStrideSCEV().
Transitively follow the chain of pointer-type operands until reaching a SCEV that does not have a single pointer operand.
This returns a SCEVUnknown pointer for well-formed pointer-type expressions, but corner cases do exist.
Definition at line 4149 of file ScalarEvolution.cpp.
References llvm::SCEV::getType(), and llvm::Type::isPointerTy().
Referenced by isValidRewrite().
const SCEV * ScalarEvolution::getPredicatedBackedgeTakenCount | ( | const Loop * | L, |
SCEVUnionPredicate & | Predicates | ||
) |
Similar to getBackedgeTakenCount, except it will add a set of SCEV predicates to Predicates that are required to be true in order for the answer to be correct.
Predicates can be checked with run-time checks and can be used to perform loop versioning.
Definition at line 7007 of file ScalarEvolution.cpp.
Referenced by llvm::PredicatedScalarEvolution::getBackedgeTakenCount(), and PrintLoopInfo().
Definition at line 1166 of file ScalarEvolution.cpp.
References assert(), getLosslessPtrToIntExpr(), getTruncateOrZeroExtend(), and llvm::Type::isIntegerTy().
Referenced by llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitPtrToIntExpr().
Return a SCEV expression for the full generality of the specified expression.
Return an existing SCEV if it exists, otherwise analyze the expression and create a new one.
Definition at line 3893 of file ScalarEvolution.cpp.
References assert(), llvm::Value::getType(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), isSCEVable(), Offset, S, SCEVCallbackVH, SCEVLostPoisonFlags(), and splitAddExpr().
Referenced by llvm::IVUsers::AddUsersImpl(), llvm::SCEVAAResult::alias(), applyLoopGuards(), WidenIV::cloneArithmeticIVUser(), countToEliminateCompares(), WidenIV::createWideIV(), DbgGatherEqualValues(), llvm::DependenceInfo::depends(), DoInitialMatch(), expandBounds(), llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(), findIVOperand(), FindLoopCounter(), genLoopLimit(), llvm::PredicatedScalarEvolution::getAsAddRec(), llvm::Loop::LoopBounds::getBounds(), getBoundsCheckCond(), WidenIV::getExtendedOperandRecurrence(), getFalkorUnrollingPreferences(), getGEPExpr(), getIndexExpressionsFromGEP(), getInductionVariable(), getNewAlignment(), llvm::getPointersDiff(), llvm::IVUsers::getReplacementExpr(), llvm::PredicatedScalarEvolution::getSCEV(), getSCEVAtScope(), llvm::DependenceInfo::getSplitIteration(), llvm::getStrideFromPointer(), WidenIV::getWideRecurrence(), llvm::isDereferenceableAndAlignedInLoop(), isExistingPhi(), isHighCostExpansion(), llvm::InductionDescriptor::isInductionPHI(), isLoopCounter(), isProfitableChain(), isSimpleIVUser(), llvm::LoopAccessInfo::isUniform(), isValidRewrite(), print(), llvm::PredicatedScalarEvolution::print(), llvm::AlignmentFromAssumptionsPass::processAssumption(), WidenIV::pushNarrowIVUsers(), llvm::replaceSymbolicStrideSCEV(), llvm::rewriteLoopExitValues(), llvm::stripGetElementPtr(), WidenIV::widenIVUse(), and WidenIV::widenWithVariantUse().
Return a SCEV expression for the specified value at the specified scope in the program.
The L value specifies a loop nest to evaluate the expression at, where null is the top-level or a specified loop is immediately inside of the loop.
This method can be used to compute the exit value for a variable defined in a loop by querying what the value will hold in the parent loop.
In the case that a relevant loop exit value cannot be computed, the original value V is returned.
Definition at line 8437 of file ScalarEvolution.cpp.
References llvm::AArch64CC::LS, and llvm::reverse().
Referenced by computeUnrollAndJamCount(), getSCEVAtScope(), isInteresting(), optimizeLoopExitWithUnknownExitCount(), print(), and llvm::rewriteLoopExitValues().
This is a convenience function which does getSCEVAtScope(getSCEV(V), L).
Definition at line 8806 of file ScalarEvolution.cpp.
References getSCEV(), and getSCEVAtScope().
|
inline |
Determine the signed range for a particular SCEV.
NOTE: This returns a copy of the reference returned by getRangeRef.
Definition at line 867 of file ScalarEvolution.h.
References S.
Referenced by getSignExtendExpr(), print(), and StrengthenNoWrapFlags().
Determine the max of the signed range for a particular SCEV.
Definition at line 877 of file ScalarEvolution.h.
References llvm::ConstantRange::getSignedMax(), and S.
Referenced by getSignedOverflowLimitForStep(), isKnownNegative(), isKnownNonPositive(), and SimplifyICmpOperands().
Determine the min of the signed range for a particular SCEV.
Definition at line 872 of file ScalarEvolution.h.
References llvm::ConstantRange::getSignedMin(), and S.
Referenced by getMinusSCEV(), getSignedOverflowLimitForStep(), isKnownNonNegative(), isKnownPositive(), and SimplifyICmpOperands().
Definition at line 1868 of file ScalarEvolution.cpp.
References assert(), llvm::ConstantRange::contains(), D, llvm::Depth, extractConstantWithoutWrapping(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, getAddExpr(), getConstant(), getEffectiveSCEVType(), llvm::ConstantExpr::getSExt(), getSignedRange(), getTruncateOrSignExtend(), getTypeSizeInBits(), getZeroExtendExpr(), isSCEVable(), MaxCastDepth, S, llvm::PPCISD::SC, llvm::scSignExtend, llvm::ConstantRange::sextOrTrunc(), llvm::ConstantRange::signExtend(), llvm::X86AS::SS, llvm::ARM_MB::ST, llvm::ConstantRange::truncate(), and X.
Referenced by WidenIV::cloneArithmeticIVUser(), WidenIV::createWideIV(), getAnyExtendExpr(), WidenIV::getExtendedOperandRecurrence(), getNoopOrSignExtend(), getTruncateOrSignExtend(), WidenIV::getWideRecurrence(), isAddRecSExtable(), isAddSExtable(), IsIncrementNSW(), isMulSExtable(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitSignExtendExpr(), and willNotOverflow().
Return an expression for the alloc size of AllocTy that is type IntTy.
Definition at line 3701 of file ScalarEvolution.cpp.
References getConstant(), getDataLayout(), and getSizeOfScalableVectorExpr().
Referenced by genLoopLimit(), getElementSize(), and getGEPExpr().
const SCEV * ScalarEvolution::getSizeOfScalableVectorExpr | ( | Type * | IntTy, |
ScalableVectorType * | ScalableTy | ||
) |
Return an expression for sizeof ScalableTy that is type IntTy, where ScalableTy is a scalable vector type.
Definition at line 3690 of file ScalarEvolution.cpp.
References GEP, llvm::ConstantInt::get(), llvm::ConstantExpr::getGetElementPtr(), llvm::Constant::getNullValue(), llvm::Type::getPointerTo(), llvm::ConstantExpr::getPtrToInt(), and getUnknown().
Referenced by getSizeOfExpr(), and getStoreSizeOfExpr().
Returns the upper bound of the loop trip count as a normal unsigned value.
Returns 0 if the trip count is unknown or not constant.
Definition at line 6934 of file ScalarEvolution.cpp.
References getConstantMaxBackedgeTakenCount(), and getConstantTripCount().
Referenced by llvm::HexagonTTIImpl::getPeelingPreferences(), getSmallBestKnownTC(), llvm::isDereferenceableAndAlignedInLoop(), and tryToUnrollLoop().
Returns the maximum trip count of the loop if it is a single-exit loop and we can compute a small maximum for that loop.
Implemented in terms of the getSmallConstantTripCount
overload with the single exiting block passed to it. See that routine for details.
Definition at line 6915 of file ScalarEvolution.cpp.
References llvm::LoopBase< BlockT, LoopT >::getExitingBlock().
Referenced by llvm::CacheCost::CacheCost(), llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::HexagonTTIImpl::getPeelingPreferences(), getSmallBestKnownTC(), llvm::PPCTTIImpl::isHardwareLoopProfitable(), tryToUnrollAndJamLoop(), tryToUnrollLoop(), and llvm::UnrollLoop().
unsigned ScalarEvolution::getSmallConstantTripCount | ( | const Loop * | L, |
const BasicBlock * | ExitingBlock | ||
) |
Returns the maximum trip count of this loop as a normal unsigned value.
Returns 0 if the trip count is unknown or not constant. This "trip count" assumes that control exits via ExitingBlock. More precisely, it is the number of times that control may reach ExitingBlock before taking the branch. For loops with multiple exits, it may not be the number times that the loop header executes if the loop exits prematurely via another branch.
Definition at line 6924 of file ScalarEvolution.cpp.
References assert(), getConstantTripCount(), getExitCount(), and llvm::LoopBase< BlockT, LoopT >::isLoopExiting().
Returns the largest constant divisor of the trip count of the loop if it is a single-exit loop and we can compute a small maximum for that loop.
Implemented in terms of the getSmallConstantTripMultiple
overload with the single exiting block passed to it. See that routine for details.
Definition at line 6940 of file ScalarEvolution.cpp.
References llvm::LoopBase< BlockT, LoopT >::getExitingBlock().
Referenced by PrintLoopInfo(), tryToUnrollAndJamLoop(), tryToUnrollLoop(), and llvm::UnrollLoop().
unsigned ScalarEvolution::getSmallConstantTripMultiple | ( | const Loop * | L, |
const BasicBlock * | ExitingBlock | ||
) |
Returns the largest constant divisor of the trip count of this loop as a normal unsigned value, if possible.
This means that the actual trip count is always a multiple of the returned value (don't forget the trip count could very well be zero as well!). As explained in the comments for getSmallConstantTripCount, this assumes that control exits the loop via ExitingBlock.
This means that the actual trip count is always a multiple of the returned value (don't forget the trip count could very well be zero as well!).
Returns 1 if the trip count is unknown or not guaranteed to be the multiple of a constant (which is also the case if the trip count is simply constant, use getSmallConstantTripCount for that case), Will also return 1 if the trip count is very large (>= 2^32).
As explained in the comments for getSmallConstantTripCount, this assumes that control exits the loop via ExitingBlock.
Definition at line 6961 of file ScalarEvolution.cpp.
References applyLoopGuards(), assert(), getAddExpr(), getCouldNotCompute(), getExitCount(), GetMinTrailingZeros(), getOne(), llvm::SCEV::getType(), llvm::SCEVConstant::getValue(), llvm::LoopBase< BlockT, LoopT >::isLoopExiting(), and llvm::min().
Definition at line 3651 of file ScalarEvolution.cpp.
Referenced by getAbsExpr(), IntersectSignedRange(), and llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitSMaxExpr().
const SCEV * ScalarEvolution::getSMaxExpr | ( | SmallVectorImpl< const SCEV * > & | Operands | ) |
Definition at line 3656 of file ScalarEvolution.cpp.
References getMinMaxExpr(), and llvm::scSMaxExpr.
Definition at line 3669 of file ScalarEvolution.cpp.
Referenced by IntersectSignedRange(), and llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitSMinExpr().
const SCEV * ScalarEvolution::getSMinExpr | ( | SmallVectorImpl< const SCEV * > & | Operands | ) |
Definition at line 3675 of file ScalarEvolution.cpp.
References getMinMaxExpr(), and llvm::scSMinExpr.
Return an expression for the store size of StoreTy that is type IntTy.
Definition at line 3710 of file ScalarEvolution.cpp.
References getConstant(), getDataLayout(), and getSizeOfScalableVectorExpr().
Referenced by llvm::RuntimePointerChecking::insert().
When successful, this returns a SCEV that is greater than or equal to (i.e.
a "conservative over-approximation") of the value returend by getBackedgeTakenCount. If such a value cannot be computed, it returns the SCEVCouldNotCompute object.
Definition at line 800 of file ScalarEvolution.h.
References getBackedgeTakenCount(), and SymbolicMaximum.
Definition at line 1176 of file ScalarEvolution.cpp.
References assert(), llvm::Depth, llvm::numbers::e, llvm::SCEV::FlagAnyWrap, getAddExpr(), getAddRecExpr(), getConstant(), getEffectiveSCEVType(), GetMinTrailingZeros(), getMulExpr(), llvm::ConstantExpr::getTrunc(), getTruncateOrSignExtend(), getTruncateOrZeroExtend(), getTypeSizeInBits(), getZero(), i, isSCEVable(), llvm_unreachable, MaxCastDepth, Operands, S, llvm::PPCISD::SC, llvm::scTruncate, llvm::X86AS::SS, and llvm::ARM_MB::ST.
Referenced by generateLoopLatchCheck(), genLoopLimit(), getAddExpr(), getTruncateOrNoop(), getTruncateOrSignExtend(), getTruncateOrZeroExtend(), getURemExpr(), optimizeLoopExitWithUnknownExitCount(), and llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitTruncateExpr().
Return a SCEV corresponding to a conversion of the input value to the specified type.
The conversion must not be widening.
Definition at line 4094 of file ScalarEvolution.cpp.
References assert(), getTruncateExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().
Referenced by canBeCheaplyTransformed(), getAnyExtendExpr(), and llvm::InnerLoopVectorizer::getOrCreateTripCount().
const SCEV * ScalarEvolution::getTruncateOrSignExtend | ( | const SCEV * | V, |
Type * | Ty, | ||
unsigned | Depth = 0 |
||
) |
Return a SCEV corresponding to a conversion of the input value to the specified type.
If the type must be extended, it is sign extended.
Definition at line 4045 of file ScalarEvolution.cpp.
References assert(), llvm::Depth, getSignExtendExpr(), getTruncateExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().
Referenced by getGEPExpr(), getSignExtendExpr(), and getTruncateExpr().
const SCEV * ScalarEvolution::getTruncateOrZeroExtend | ( | const SCEV * | V, |
Type * | Ty, | ||
unsigned | Depth = 0 |
||
) |
Return a SCEV corresponding to a conversion of the input value to the specified type.
If the type must be extended, it is zero extended.
Definition at line 4033 of file ScalarEvolution.cpp.
References assert(), llvm::Depth, getTruncateExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), getZeroExtendExpr(), and llvm::Type::isIntOrPtrTy().
Referenced by BinomialCoefficient(), llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(), genLoopLimit(), getNewAlignment(), getNumBytes(), getPtrToIntExpr(), getTruncateExpr(), and getZeroExtendExpr().
uint64_t ScalarEvolution::getTypeSizeInBits | ( | Type * | Ty | ) | const |
Return the size in bits of the specified type, for which isSCEVable must return true.
Definition at line 3766 of file ScalarEvolution.cpp.
References assert(), getDataLayout(), llvm::DataLayout::getIndexTypeSizeInBits(), llvm::DataLayout::getTypeSizeInBits(), llvm::Type::isPointerTy(), and isSCEVable().
Referenced by llvm::IVUsers::AddUsersImpl(), llvm::SCEVAAResult::alias(), BinomialCoefficient(), computeConstantDifference(), FindLoopCounter(), genLoopLimit(), getAddExpr(), getAnyExtendExpr(), getLosslessPtrToIntExpr(), getMulExpr(), getNoopOrAnyExtend(), getNoopOrSignExtend(), getNoopOrZeroExtend(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), llvm::InnerLoopVectorizer::getOrCreateTripCount(), getSignedOverflowLimitForStep(), getSignExtendExpr(), getTruncateExpr(), getTruncateOrNoop(), getTruncateOrSignExtend(), getTruncateOrZeroExtend(), getUDivExpr(), getUMaxFromMismatchedTypes(), getUnsignedOverflowLimitForStep(), WidenIV::getWideRecurrence(), getWiderType(), getZeroExtendExpr(), isAddRecSExtable(), isAddSExtable(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), isMulSExtable(), isSimpleCastedPHI(), optimizeLoopExitWithUnknownExitCount(), SolveLinEquationWithOverflow(), SolveQuadraticAddRecRange(), verify(), visitIVCast(), WidenIV::widenIVUse(), and WidenIV::widenLoopCompare().
Get a canonical unsigned division expression, or something simpler if possible.
There is no representation for an exact udiv in SCEV IR, but we can attempt to remove factors from the LHS and RHS. We can't do this when it's not exact because the udiv may be clearing bits.
Definition at line 3292 of file ScalarEvolution.cpp.
References llvm::drop_begin(), llvm::numbers::e, gcd(), getConstant(), getMulExpr(), getUDivExpr(), i, llvm::APInt::isIntN(), llvm::Mul, and Operands.
Referenced by SolveLinEquationWithOverflow().
Get a canonical unsigned division expression, or something simpler if possible.
Get a canonical UDivExpr for a recurrence. {X,+,N}/C => {Y,+,N}/C where Y=X-(XN). Safe when CN=0.
Definition at line 3122 of file ScalarEvolution.cpp.
References assert(), llvm::numbers::e, llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNW, llvm::IntegerType::get(), getAddExpr(), getAddRecExpr(), llvm::SCEVConstant::getAPInt(), getConstant(), getContext(), getEffectiveSCEVType(), getMulExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), llvm::ConstantExpr::getUDiv(), getZeroExtendExpr(), i, M, Operands, S, llvm::scUDivExpr, llvm::APInt::umul_ov(), and llvm::APInt::urem().
Referenced by applyLoopGuards(), BinomialCoefficient(), llvm::IndexedReference::computeRefCost(), WidenIV::getSCEVByOpCode(), getUDivExactExpr(), getURemExpr(), and llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitUDivExpr().
Definition at line 3660 of file ScalarEvolution.cpp.
Referenced by applyLoopGuards(), getUMaxFromMismatchedTypes(), llvm::RuntimePointerChecking::insert(), IntersectUnsignedRange(), and llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitUMaxExpr().
const SCEV * ScalarEvolution::getUMaxExpr | ( | SmallVectorImpl< const SCEV * > & | Operands | ) |
Definition at line 3665 of file ScalarEvolution.cpp.
References getMinMaxExpr(), and llvm::scUMaxExpr.
Promote the operands to the wider of the types using zero-extension, and then perform a umax operation with them.
Definition at line 4105 of file ScalarEvolution.cpp.
References getNoopOrZeroExtend(), llvm::SCEV::getType(), getTypeSizeInBits(), getUMaxExpr(), and getZeroExtendExpr().
Definition at line 3679 of file ScalarEvolution.cpp.
Referenced by applyLoopGuards(), getUMinFromMismatchedTypes(), llvm::RuntimePointerChecking::insert(), IntersectUnsignedRange(), and llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitUMinExpr().
const SCEV * ScalarEvolution::getUMinExpr | ( | SmallVectorImpl< const SCEV * > & | Operands | ) |
Definition at line 3685 of file ScalarEvolution.cpp.
References getMinMaxExpr(), and llvm::scUMinExpr.
Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them.
Definition at line 4118 of file ScalarEvolution.cpp.
Referenced by getMinAnalyzeableBackedgeTakenCount().
const SCEV * ScalarEvolution::getUMinFromMismatchedTypes | ( | SmallVectorImpl< const SCEV * > & | Ops | ) |
Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them.
N-ary function.
Definition at line 4124 of file ScalarEvolution.cpp.
References assert(), getNoopOrZeroExtend(), getUMinExpr(), getWiderType(), and S.
Definition at line 3729 of file ScalarEvolution.cpp.
References assert(), S, SCEVUnknown, and llvm::scUnknown.
Referenced by getSizeOfScalableVectorExpr(), llvm::InductionDescriptor::isFPInductionPHI(), and verify().
|
inline |
Determine the unsigned range for a particular SCEV.
NOTE: This returns a copy of the reference returned by getRangeRef.
Definition at line 851 of file ScalarEvolution.h.
References S.
Referenced by llvm::SCEVAAResult::alias(), getBoundsCheckCond(), getZeroExtendExpr(), mustBeFiniteCountedLoop(), print(), and StrengthenNoWrapFlags().
Determine the max of the unsigned range for a particular SCEV.
Definition at line 861 of file ScalarEvolution.h.
References llvm::ConstantRange::getUnsignedMax(), and S.
Referenced by getUnsignedOverflowLimitForStep(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), and SimplifyICmpOperands().
Determine the min of the unsigned range for a particular SCEV.
Definition at line 856 of file ScalarEvolution.h.
References llvm::ConstantRange::getUnsignedMin(), and S.
Referenced by SimplifyICmpOperands().
Represents an unsigned remainder expression based on unsigned division.
Definition at line 3093 of file ScalarEvolution.cpp.
References assert(), llvm::SCEV::FlagNUW, llvm::IntegerType::get(), getContext(), getEffectiveSCEVType(), getMinusSCEV(), getMulExpr(), getTruncateExpr(), llvm::SCEV::getType(), getUDivExpr(), getZero(), getZeroExtendExpr(), and llvm::MipsISD::Mult.
Referenced by llvm::LoopVectorizationCostModel::computeMaxVF(), and getNewAlignmentDiff().
Definition at line 3787 of file ScalarEvolution.cpp.
References getTypeSizeInBits(), and T1.
Referenced by llvm::IndexedReference::computeRefCost(), and getUMinFromMismatchedTypes().
const SCEVPredicate * ScalarEvolution::getWrapPredicate | ( | const SCEVAddRecExpr * | AR, |
SCEVWrapPredicate::IncrementWrapFlags | AddedFlags | ||
) |
Definition at line 12855 of file ScalarEvolution.cpp.
References llvm::SCEVPredicate::P_Wrap, and S.
Referenced by llvm::PredicatedScalarEvolution::setNoOverflow().
Return a SCEV for the constant 0 of a specific type.
Definition at line 593 of file ScalarEvolution.h.
References getConstant().
Referenced by llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(), getAddExpr(), getLosslessPtrToIntExpr(), getMinusSCEV(), getMulExpr(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), getTruncateExpr(), getURemExpr(), llvm::isKnownNegativeInLoop(), llvm::isKnownNonNegativeInLoop(), isLoopBackedgeGuardedByCond(), and WidenIV::pushNarrowIVUsers().
Definition at line 1566 of file ScalarEvolution.cpp.
References assert(), llvm::ConstantRange::contains(), llvm::Depth, getConstant(), getEffectiveSCEVType(), getTruncateOrZeroExtend(), getTypeSizeInBits(), getUnsignedRange(), llvm::ConstantExpr::getZExt(), isSCEVable(), MaxCastDepth, S, llvm::PPCISD::SC, llvm::scZeroExtend, llvm::ARM_MB::ST, llvm::ConstantRange::truncate(), X, llvm::ConstantRange::zeroExtend(), and llvm::ConstantRange::zextOrTrunc().
Referenced by WidenIV::cloneArithmeticIVUser(), WidenIV::createWideIV(), genLoopLimit(), getAnyExtendExpr(), WidenIV::getExtendedOperandRecurrence(), getNoopOrZeroExtend(), getNumBytes(), getSignExtendExpr(), getTruncateOrZeroExtend(), getUDivExpr(), getUMaxFromMismatchedTypes(), getURemExpr(), WidenIV::getWideRecurrence(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), IsIncrementNUW(), isSafeDependenceDistance(), optimizeLoopExitWithUnknownExitCount(), verify(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitZeroExtendExpr(), and willNotOverflow().
Return true if the given SCEV changes value in a known way in the specified loop.
This property being true implies that the value is variant in the loop AND that we can emit an expression to compute the value of the expression at any particular loop iteration.
Definition at line 12488 of file ScalarEvolution.cpp.
References getLoopDisposition(), LoopComputable, and S.
Return true if the specified loop has an analyzable loop-invariant backedge-taken count.
Definition at line 12216 of file ScalarEvolution.cpp.
References getBackedgeTakenCount().
Referenced by llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::IVUsers::print(), and PrintLoopInfo().
Test whether the given SCEV has Op as a direct or indirect operand.
Definition at line 12586 of file ScalarEvolution.cpp.
References S, and llvm::SCEVExprContains().
bool ScalarEvolution::invalidate | ( | Function & | F, |
const PreservedAnalyses & | PA, | ||
FunctionAnalysisManager::Invalidator & | Inv | ||
) |
Definition at line 12753 of file ScalarEvolution.cpp.
References F, llvm::PreservedAnalyses::getChecker(), and llvm::AnalysisManager< IRUnitT, ExtraArgTs >::Invalidator::invalidate().
Determine if the SCEV can be evaluated at loop's entry.
It is true if it doesn't depend on a SCEVUnknown of an instruction which is dominated by the header of loop L.
Definition at line 2308 of file ScalarEvolution.cpp.
References llvm::LoopBase< BlockT, LoopT >::getHeader(), isLoopInvariant(), properlyDominates(), and S.
Referenced by llvm::cannotBeMaxInLoop(), llvm::cannotBeMinInLoop(), getAddExpr(), getMulExpr(), llvm::isKnownNegativeInLoop(), llvm::isKnownNonNegativeInLoop(), isKnownViaInduction(), and isLoopEntryGuardedByCond().
Return true if the backedge taken count is either the value returned by getConstantMaxBackedgeTakenCount or zero.
Definition at line 7025 of file ScalarEvolution.cpp.
Referenced by PrintLoopInfo(), and tryToUnrollLoop().
bool ScalarEvolution::isBasicBlockEntryGuardedByCond | ( | const BasicBlock * | BB, |
ICmpInst::Predicate | Pred, | ||
const SCEV * | LHS, | ||
const SCEV * | RHS | ||
) |
Test whether entry to the basic block is protected by a conditional between LHS and RHS.
Definition at line 10101 of file ScalarEvolution.cpp.
References assert(), llvm::AssumptionCache::assumptions(), BB, Context, llvm::dbgs(), llvm::DominatorTree::dominates(), function, llvm::BranchInst::getCondition(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopPredecessor(), llvm::CmpInst::getNonStrictPredicate(), llvm::BranchInst::getSuccessor(), llvm::CmpInst::ICMP_NE, llvm::BranchInst::isUnconditional(), P, llvm::verifyFunction(), and VerifyIR.
Referenced by evaluatePredicateAt(), isKnownPredicateAt(), and isLoopEntryGuardedByCond().
Test if the given expression is known to be negative.
Definition at line 9528 of file ScalarEvolution.cpp.
References getSignedRangeMax(), llvm::APInt::isNegative(), and S.
Referenced by llvm::IndexedReference::computeRefCost(), getSignedOverflowLimitForStep(), isKnownNonZero(), and WidenIV::widenWithVariantUse().
Test if the given expression is known to be non-negative.
Definition at line 9536 of file ScalarEvolution.cpp.
References getSignedRangeMin(), llvm::APInt::isNegative(), and S.
Referenced by getGEPExpr(), getMinusSCEV(), and StrengthenNoWrapFlags().
Test if the given expression is known to be non-positive.
Definition at line 9540 of file ScalarEvolution.cpp.
References getSignedRangeMax(), llvm::APInt::isStrictlyPositive(), and S.
Test if the given expression is known to be non-zero.
Definition at line 9544 of file ScalarEvolution.cpp.
References isKnownNegative(), isKnownPositive(), and S.
bool ScalarEvolution::isKnownOnEveryIteration | ( | ICmpInst::Predicate | Pred, |
const SCEVAddRecExpr * | LHS, | ||
const SCEV * | RHS | ||
) |
Test if the condition described by Pred, LHS, RHS is known to be true on every iteration of the loop of the recurrency LHS.
Definition at line 9661 of file ScalarEvolution.cpp.
References llvm::SCEVAddRecExpr::getLoop(), llvm::SCEVAddRecExpr::getPostIncExpr(), llvm::SCEVAddRecExpr::getStart(), isLoopBackedgeGuardedByCond(), and isLoopEntryGuardedByCond().
Test if the given expression is known to be positive.
Definition at line 9532 of file ScalarEvolution.cpp.
References getSignedRangeMin(), llvm::APInt::isStrictlyPositive(), and S.
Referenced by getSignedOverflowLimitForStep(), isKnownNonZero(), and isSafeDependenceDistance().
bool ScalarEvolution::isKnownPredicate | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS | ||
) |
Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS.
Definition at line 9611 of file ScalarEvolution.cpp.
References isKnownViaInduction(), and SimplifyICmpOperands().
Referenced by countToEliminateCompares(), evaluatePredicate(), isKnownPredicateAt(), IsKnownPredicateViaAddRecStart(), normalizePredicate(), and WidenIV::pushNarrowIVUsers().
bool ScalarEvolution::isKnownPredicateAt | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS, | ||
const Instruction * | Context | ||
) |
Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS in the given Context.
Definition at line 9636 of file ScalarEvolution.cpp.
References Context, isBasicBlockEntryGuardedByCond(), and isKnownPredicate().
Referenced by optimizeLoopExitWithUnknownExitCount(), and WidenIV::widenWithVariantUse().
bool ScalarEvolution::isKnownViaInduction | ( | ICmpInst::Predicate | Pred, |
const SCEV * | LHS, | ||
const SCEV * | RHS | ||
) |
We'd like to check the predicate on every iteration of the most dominated loop between loops used in LHS and RHS.
To do this we use the following list of steps:
Definition at line 9560 of file ScalarEvolution.cpp.
References assert(), llvm::DominatorTree::dominates(), llvm::SmallPtrSetImplBase::empty(), getCouldNotCompute(), isAvailableAtLoopEntry(), isLoopBackedgeGuardedByCond(), isLoopEntryGuardedByCond(), L2, and SplitIntoInitAndPostInc().
Referenced by isKnownPredicate().
bool ScalarEvolution::isLoopBackedgeGuardedByCond | ( | const Loop * | L, |
ICmpInst::Predicate | Pred, | ||
const SCEV * | LHS, | ||
const SCEV * | RHS | ||
) |
Test whether the backedge of the loop is protected by a conditional between LHS and RHS.
isLoopBackedgeGuardedByCond - Test whether the backedge of the loop is protected by a conditional between LHS and RHS.
This is used to eliminate casts.
This is used to to eliminate casts.
Definition at line 9992 of file ScalarEvolution.cpp.
References assert(), llvm::AssumptionCache::assumptions(), BB, llvm::dbgs(), llvm::DominatorTree::dominates(), llvm::SCEV::FlagNUW, llvm::SCEV::FlagNW, getAddRecExpr(), llvm::BranchInst::getCondition(), getCouldNotCompute(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), getOne(), llvm::BasicBlock::getParent(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::SCEV::getType(), getZero(), llvm::CmpInst::ICMP_ULT, llvm::BranchInst::isConditional(), llvm::DominatorTree::isReachableFromEntry(), llvm::BasicBlockEdge::isSingleEdge(), llvm::verifyFunction(), and VerifyIR.
Referenced by getLoopInvariantExitCondDuringFirstIterations(), getLoopInvariantPredicate(), isKnownOnEveryIteration(), and isKnownViaInduction().
bool ScalarEvolution::isLoopEntryGuardedByCond | ( | const Loop * | L, |
ICmpInst::Predicate | Pred, | ||
const SCEV * | LHS, | ||
const SCEV * | RHS | ||
) |
Test whether entry to the loop is protected by a conditional between LHS and RHS.
This is used to help avoid max expressions in loop trip counts, and to eliminate casts.
Definition at line 10207 of file ScalarEvolution.cpp.
References assert(), llvm::LoopBase< BlockT, LoopT >::getHeader(), isAvailableAtLoopEntry(), and isBasicBlockEntryGuardedByCond().
Referenced by llvm::cannotBeMaxInLoop(), llvm::cannotBeMinInLoop(), getNumBytes(), llvm::isKnownNegativeInLoop(), llvm::isKnownNonNegativeInLoop(), isKnownOnEveryIteration(), and isKnownViaInduction().
Return true if the value of the given SCEV is unchanging in the specified loop.
Definition at line 12484 of file ScalarEvolution.cpp.
References getLoopDisposition(), LoopInvariant, and S.
Referenced by canTailPredicateLoop(), computeUnrollAndJamCount(), expandBounds(), genLoopLimit(), getAddRecExpr(), getLoopInvariantExitCondDuringFirstIterations(), getLoopInvariantPredicate(), hasComputableBounds(), llvm::RuntimePointerChecking::insert(), llvm::Loop::isAuxiliaryInductionVariable(), isAvailableAtLoopEntry(), llvm::isDereferenceableAndAlignedInLoop(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), llvm::InductionDescriptor::isInductionPHI(), isNoWrap(), llvm::LoopAccessInfo::isUniform(), mayUsePostIncMode(), print(), llvm::rewriteLoopExitValues(), SimplifyICmpOperands(), llvm::stripGetElementPtr(), and llvm::VPRecipeBuilder::tryToCreateWidenRecipe().
bool ScalarEvolution::isSCEVable | ( | Type * | Ty | ) | const |
Test if values of the given type are analyzable within the SCEV framework.
This primarily includes integer types, and it can optionally include pointer types if the ScalarEvolution class has access to target-specific information.
Definition at line 3759 of file ScalarEvolution.cpp.
References llvm::Type::isIntOrPtrTy().
Referenced by llvm::IVUsers::AddUsersImpl(), DbgGatherEqualValues(), findIVOperand(), getAnyExtendExpr(), getEffectiveSCEVType(), getSCEV(), getSignExtendExpr(), getTruncateExpr(), getTypeSizeInBits(), WidenIV::getWideRecurrence(), getZeroExtendExpr(), isExistingPhi(), isHighCostExpansion(), isLoopCounter(), isSimpleIVUser(), llvm::LoopAccessInfo::isUniform(), print(), llvm::PredicatedScalarEvolution::print(), and llvm::rewriteLoopExitValues().
|
inlinestatic |
Convenient NoWrapFlags manipulation that hides enum casts and is visible in the ScalarEvolution name space.
Definition at line 463 of file ScalarEvolution.h.
References llvm::BitmaskEnumDetail::Mask().
Referenced by getAddRecExpr(), getMinusSCEV(), getMulExpr(), and StrengthenNoWrapFlags().
void ScalarEvolution::print | ( | raw_ostream & | OS | ) | const |
Definition at line 12294 of file ScalarEvolution.cpp.
References ClassifyExpressions, llvm::depth_first(), First, getLoopDisposition(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), getSCEV(), getSCEVAtScope(), getSignedRange(), getUnsignedRange(), I, llvm::instructions(), isLoopInvariant(), isSCEVable(), loopDispositionToStr(), llvm::SCEV::print(), llvm::ConstantRange::print(), llvm::Value::printAsOperand(), and PrintLoopInfo().
Referenced by llvm::ScalarEvolutionWrapperPass::print().
bool ScalarEvolution::properlyDominates | ( | const SCEV * | S, |
const BasicBlock * | BB | ||
) |
Return true if elements that makes up the given SCEV properly dominate the specified basic block.
Definition at line 12582 of file ScalarEvolution.cpp.
References BB, getBlockDisposition(), ProperlyDominatesBlock, and S.
Referenced by WidenIV::createWideIV(), DoInitialMatch(), isAvailableAtLoopEntry(), llvm::isSafeToExpandAt(), and SimplifyICmpOperands().
const SCEV * ScalarEvolution::rewriteUsingPredicate | ( | const SCEV * | S, |
const Loop * | L, | ||
SCEVUnionPredicate & | A | ||
) |
Re-writes the SCEV according to the Predicates in A
.
Definition at line 12989 of file ScalarEvolution.cpp.
|
inlinestatic |
Definition at line 467 of file ScalarEvolution.h.
Referenced by getAddExpr(), llvm::SCEVWrapPredicate::getImpliedFlags(), llvm::SCEVWrapPredicate::isAlwaysTrue(), llvm::SCEVAddRecExpr::setNoWrapFlags(), and StrengthenNoWrapFlags().
void ScalarEvolution::setNoWrapFlags | ( | SCEVAddRecExpr * | AddRec, |
SCEV::NoWrapFlags | Flags | ||
) |
Update no-wrap flags of an AddRec.
This may drop the cached info about this AddRec (such as range info) in case if new flags may potentially sharpen it.
Definition at line 5643 of file ScalarEvolution.cpp.
References llvm::SCEVNAryExpr::getNoWrapFlags(), and llvm::SCEVAddRecExpr::setNoWrapFlags().
bool ScalarEvolution::SimplifyICmpOperands | ( | ICmpInst::Predicate & | Pred, |
const SCEV *& | LHS, | ||
const SCEV *& | RHS, | ||
unsigned | Depth = 0 |
||
) |
Simplify LHS and RHS in a comparison with predicate Pred.
Return true iff any changes were made. If the operands are provably equal or unequal, LHS and RHS are set to the same value and Pred is set to either ICMP_EQ or ICMP_NE.
Definition at line 9331 of file ScalarEvolution.cpp.
References assert(), llvm::Depth, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, getAddExpr(), getConstant(), getContext(), llvm::ConstantRange::getEquivalentICmp(), llvm::ConstantInt::getFalse(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::ConstantExpr::getICmp(), llvm::SCEVAddRecExpr::getLoop(), getSignedRangeMax(), getSignedRangeMin(), llvm::CmpInst::getSwappedPredicate(), llvm::SCEV::getType(), getUnsignedRangeMax(), getUnsignedRangeMin(), HasSameValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ConstantRange::isEmptySet(), llvm::ICmpInst::isEquality(), llvm::CmpInst::isFalseWhenEqual(), llvm::ConstantRange::isFullSet(), isLoopInvariant(), llvm::Constant::isNullValue(), llvm::CmpInst::isTrueWhenEqual(), llvm::ConstantRange::makeExactICmpRegion(), properlyDominates(), RA, and std::swap().
Referenced by isKnownPredicate().
std::pair< const SCEV *, const SCEV * > ScalarEvolution::SplitIntoInitAndPostInc | ( | const Loop * | L, |
const SCEV * | S | ||
) |
Splits SCEV expression S
into two SCEVs.
One of them is obtained from S
by substitution of all AddRec sub-expression related to loop L
with initial value of that SCEV. The second is obtained from S
by substitution of all AddRec sub-expressions related to loop L
with post increment of this AddRec in the loop L
. In both cases all other AddRec sub-expressions (not related to L
) remain the same. If the S
contains non-invariant unknown SCEV the function returns CouldNotCompute SCEV in both values of std::pair. For example, for SCEV S={0, +, 1}<L1> + {0, +, 1}<L2> and loop L=L1 the function returns pair: first = {0, +, 1}<L2> second = {1, +, 1}<L1> + {0, +, 1}<L2> We can see that for the first AddRec sub-expression it was replaced with 0 (initial value) for the first element and to {1, +, 1}<L1> (post increment value) for the second one. In both cases AddRec expression related to L2 remains the same.
Definition at line 9549 of file ScalarEvolution.cpp.
Referenced by isKnownViaInduction().
void ScalarEvolution::verify | ( | ) | const |
Definition at line 12661 of file ScalarEvolution.cpp.
References abort(), llvm::SmallVectorImpl< T >::append(), llvm::append_range(), assert(), llvm::LoopBase< BlockT, LoopT >::begin(), llvm::SmallPtrSetImpl< PtrType >::contains(), containsUndefs(), llvm::dbgs(), llvm::LoopBase< BlockT, LoopT >::end(), getBackedgeTakenCount(), getConstant(), getCouldNotCompute(), llvm::SCEVAddRecExpr::getLoop(), getMinusSCEV(), getTypeSizeInBits(), getUnknown(), llvm::SCEVUnknown::getValue(), getZeroExtendExpr(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SCEV::isZero(), llvm::SmallVectorImpl< T >::pop_back_val(), and VerifySCEVStrict.
Referenced by llvm::UnrollAndJamLoop(), and llvm::ScalarEvolutionWrapperPass::verifyAnalysis().
|
friend |
Definition at line 444 of file ScalarEvolution.h.
|
friend |
Definition at line 1209 of file ScalarEvolution.h.
Referenced by getSCEV().
|
friend |
Definition at line 1210 of file ScalarEvolution.h.
|
friend |
Definition at line 1211 of file ScalarEvolution.h.
Referenced by getUnknown().