Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Classes |Public Types |Public Member Functions |Static Public Member Functions |Friends |List of all members
llvm::ScalarEvolution Class Reference

The main scalar evolution driver.More...

#include "llvm/Analysis/ScalarEvolution.h"

Classes

struct  ExitLimit
 Information about the number of loop iterations for which a loop exit's branch condition evaluates to the not-taken path.More...
 
class  FoldID
 
class  LoopGuards
 
struct  LoopInvariantPredicate
 

Public Types

enum  LoopDisposition {LoopVariant,LoopInvariant,LoopComputable }
 An enum describing the relationship between aSCEV and a loop.More...
 
enum  BlockDisposition {DoesNotDominateBlock,DominatesBlock,ProperlyDominatesBlock }
 An enum describing the relationship between aSCEV 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 ()
 
LLVMContextgetContext ()const
 
bool isSCEVable (Type *Ty)const
 Test if values of the given type are analyzable within theSCEV framework.
 
uint64_t getTypeSizeInBits (Type *Ty)const
 Return the size in bits of the specified type, for which isSCEVable must return true.
 
TypegetEffectiveSCEVType (Type *Ty)const
 Return a type with the same bitwidth as the given type and which represents howSCEV will treat the given type, for which isSCEVable must return true.
 
TypegetWiderType (Type *Ty1,Type *Ty2)const
 
bool instructionCouldExistWithOperands (constSCEV *A,constSCEV *B)
 Return true if there exists a point in the program at which both A and B could be operands to the same instruction.
 
bool containsAddRecurrence (constSCEV *S)
 Return true if theSCEV is a scAddRecExpr or it contains scAddRecExpr.
 
bool willNotOverflow (Instruction::BinaryOps BinOp,boolSigned,constSCEV *LHS,constSCEV *RHS,constInstruction *CtxI=nullptr)
 Is operationBinOp betweenLHS andRHS provably does not have a signed/unsigned overflow (Signed)? IfCtxI is specified, the no-overflow fact should be true in the context of this instruction.
 
std::optional<SCEV::NoWrapFlagsgetStrengthenedNoWrapFlagsFromBinOp (constOverflowingBinaryOperator *OBO)
 Parse NSW/NUW flags from add/sub/mul IR binary operationOp intoSCEV no-wrap flags, and deduce flag[s] that aren't known yet.
 
void registerUser (constSCEV *User,ArrayRef<constSCEV * > Ops)
 Notify thisScalarEvolution thatUser directly uses SCEVs inOps.
 
bool containsUndefs (constSCEV *S)const
 Return true if theSCEV expression contains an undef value.
 
bool containsErasedValue (constSCEV *S)const
 Return true if theSCEV expression contains aValue that has been optimised out and is now a nullptr.
 
constSCEVgetSCEV (Value *V)
 Return aSCEV expression for the full generality of the specified expression.
 
constSCEVgetExistingSCEV (Value *V)
 Return an existingSCEV for V if there is one, otherwise return nullptr.
 
constSCEVgetConstant (ConstantInt *V)
 
constSCEVgetConstant (constAPInt &Val)
 
constSCEVgetConstant (Type *Ty,uint64_t V,boolisSigned=false)
 
constSCEVgetLosslessPtrToIntExpr (constSCEV *Op,unsignedDepth=0)
 
constSCEVgetPtrToIntExpr (constSCEV *Op,Type *Ty)
 
constSCEVgetTruncateExpr (constSCEV *Op,Type *Ty,unsignedDepth=0)
 
constSCEVgetVScale (Type *Ty)
 
constSCEVgetElementCount (Type *Ty,ElementCount EC)
 
constSCEVgetZeroExtendExpr (constSCEV *Op,Type *Ty,unsignedDepth=0)
 
constSCEVgetZeroExtendExprImpl (constSCEV *Op,Type *Ty,unsignedDepth=0)
 
constSCEVgetSignExtendExpr (constSCEV *Op,Type *Ty,unsignedDepth=0)
 
constSCEVgetSignExtendExprImpl (constSCEV *Op,Type *Ty,unsignedDepth=0)
 
constSCEVgetCastExpr (SCEVTypes Kind,constSCEV *Op,Type *Ty)
 
constSCEVgetAnyExtendExpr (constSCEV *Op,Type *Ty)
 getAnyExtendExpr - Return aSCEV for the given operand extended with unspecified bits out to the given type.
 
constSCEVgetAddExpr (SmallVectorImpl<constSCEV * > &Ops,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 Get a canonical add expression, or something simpler if possible.
 
constSCEVgetAddExpr (constSCEV *LHS,constSCEV *RHS,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 
constSCEVgetAddExpr (constSCEV *Op0,constSCEV *Op1,constSCEV *Op2,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 
constSCEVgetMulExpr (SmallVectorImpl<constSCEV * > &Ops,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 Get a canonical multiply expression, or something simpler if possible.
 
constSCEVgetMulExpr (constSCEV *LHS,constSCEV *RHS,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 
constSCEVgetMulExpr (constSCEV *Op0,constSCEV *Op1,constSCEV *Op2,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 
constSCEVgetUDivExpr (constSCEV *LHS,constSCEV *RHS)
 Get a canonical unsigned division expression, or something simpler if possible.
 
constSCEVgetUDivExactExpr (constSCEV *LHS,constSCEV *RHS)
 Get a canonical unsigned division expression, or something simpler if possible.
 
constSCEVgetURemExpr (constSCEV *LHS,constSCEV *RHS)
 Represents an unsigned remainder expression based on unsigned division.
 
constSCEVgetAddRecExpr (constSCEV *Start,constSCEV *Step,constLoop *L,SCEV::NoWrapFlags Flags)
 Get an add recurrence expression for the specified loop.
 
constSCEVgetAddRecExpr (SmallVectorImpl<constSCEV * > &Operands,constLoop *L,SCEV::NoWrapFlags Flags)
 Get an add recurrence expression for the specified loop.
 
constSCEVgetAddRecExpr (constSmallVectorImpl<constSCEV * > &Operands,constLoop *L,SCEV::NoWrapFlags Flags)
 
std::optional< std::pair<constSCEV *,SmallVector<constSCEVPredicate *, 3 > > > createAddRecFromPHIWithCasts (constSCEVUnknown *SymbolicPHI)
 Checks ifSymbolicPHI can be rewritten as an AddRecExpr under some Predicates.
 
constSCEVgetGEPExpr (GEPOperator *GEP,constSmallVectorImpl<constSCEV * > &IndexExprs)
 Returns an expression for a GEP.
 
constSCEVgetAbsExpr (constSCEV *Op,bool IsNSW)
 
constSCEVgetMinMaxExpr (SCEVTypes Kind,SmallVectorImpl<constSCEV * > &Operands)
 
constSCEVgetSequentialMinMaxExpr (SCEVTypes Kind,SmallVectorImpl<constSCEV * > &Operands)
 
constSCEVgetSMaxExpr (constSCEV *LHS,constSCEV *RHS)
 
constSCEVgetSMaxExpr (SmallVectorImpl<constSCEV * > &Operands)
 
constSCEVgetUMaxExpr (constSCEV *LHS,constSCEV *RHS)
 
constSCEVgetUMaxExpr (SmallVectorImpl<constSCEV * > &Operands)
 
constSCEVgetSMinExpr (constSCEV *LHS,constSCEV *RHS)
 
constSCEVgetSMinExpr (SmallVectorImpl<constSCEV * > &Operands)
 
constSCEVgetUMinExpr (constSCEV *LHS,constSCEV *RHS,bool Sequential=false)
 
constSCEVgetUMinExpr (SmallVectorImpl<constSCEV * > &Operands,bool Sequential=false)
 
constSCEVgetUnknown (Value *V)
 
constSCEVgetCouldNotCompute ()
 
constSCEVgetZero (Type *Ty)
 Return aSCEV for the constant 0 of a specific type.
 
constSCEVgetOne (Type *Ty)
 Return aSCEV for the constant 1 of a specific type.
 
constSCEVgetPowerOfTwo (Type *Ty,unsigned Power)
 Return aSCEV for the constantPower of two.
 
constSCEVgetMinusOne (Type *Ty)
 Return aSCEV for the constant -1 of a specific type.
 
constSCEVgetSizeOfExpr (Type *IntTy,TypeSizeSize)
 Return an expression for aTypeSize.
 
constSCEVgetSizeOfExpr (Type *IntTy,Type *AllocTy)
 Return an expression for the alloc size of AllocTy that is type IntTy.
 
constSCEVgetStoreSizeOfExpr (Type *IntTy,Type *StoreTy)
 Return an expression for the store size of StoreTy that is type IntTy.
 
constSCEVgetOffsetOfExpr (Type *IntTy,StructType *STy,unsigned FieldNo)
 Return an expression for offsetof on the given field with type IntTy.
 
constSCEVgetNegativeSCEV (constSCEV *V,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
 Return theSCEV object corresponding to -V.
 
constSCEVgetNotSCEV (constSCEV *V)
 Return theSCEV object corresponding to ~V.
 
constSCEVgetMinusSCEV (constSCEV *LHS,constSCEV *RHS,SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap,unsignedDepth=0)
 Return LHS-RHS.
 
constSCEVgetUDivCeilSCEV (constSCEV *N,constSCEV *D)
 Compute ceil(N / D).
 
constSCEVgetTruncateOrZeroExtend (constSCEV *V,Type *Ty,unsignedDepth=0)
 Return aSCEV corresponding to a conversion of the input value to the specified type.
 
constSCEVgetTruncateOrSignExtend (constSCEV *V,Type *Ty,unsignedDepth=0)
 Return aSCEV corresponding to a conversion of the input value to the specified type.
 
constSCEVgetNoopOrZeroExtend (constSCEV *V,Type *Ty)
 Return aSCEV corresponding to a conversion of the input value to the specified type.
 
constSCEVgetNoopOrSignExtend (constSCEV *V,Type *Ty)
 Return aSCEV corresponding to a conversion of the input value to the specified type.
 
constSCEVgetNoopOrAnyExtend (constSCEV *V,Type *Ty)
 Return aSCEV corresponding to a conversion of the input value to the specified type.
 
constSCEVgetTruncateOrNoop (constSCEV *V,Type *Ty)
 Return aSCEV corresponding to a conversion of the input value to the specified type.
 
constSCEVgetUMaxFromMismatchedTypes (constSCEV *LHS,constSCEV *RHS)
 Promote the operands to the wider of the types using zero-extension, and then perform a umax operation with them.
 
constSCEVgetUMinFromMismatchedTypes (constSCEV *LHS,constSCEV *RHS,bool Sequential=false)
 Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them.
 
constSCEVgetUMinFromMismatchedTypes (SmallVectorImpl<constSCEV * > &Ops,bool Sequential=false)
 Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them.
 
constSCEVgetPointerBase (constSCEV *V)
 Transitively follow the chain of pointer-type operands until reaching aSCEV that does not have a single pointer operand.
 
constSCEVremovePointerBase (constSCEV *S)
 Compute an expression equivalent to S - getPointerBase(S).
 
constSCEVgetSCEVAtScope (constSCEV *S,constLoop *L)
 Return aSCEV expression for the specified value at the specified scope in the program.
 
constSCEVgetSCEVAtScope (Value *V,constLoop *L)
 This is a convenience function which does getSCEVAtScope(getSCEV(V), L).
 
bool isLoopEntryGuardedByCond (constLoop *L,CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS)
 Test whether entry to the loop is protected by a conditional between LHS and RHS.
 
bool isBasicBlockEntryGuardedByCond (constBasicBlock *BB,CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS)
 Test whether entry to the basic block is protected by a conditional between LHS and RHS.
 
bool isLoopBackedgeGuardedByCond (constLoop *L,CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS)
 Test whether the backedge of the loop is protected by a conditional between LHS and RHS.
 
constSCEVgetTripCountFromExitCount (constSCEV *ExitCount)
 A version of getTripCountFromExitCount below which always picks an evaluation type which can not result in overflow.
 
constSCEVgetTripCountFromExitCount (constSCEV *ExitCount,Type *EvalTy,constLoop *L)
 Convert from an "exit count" (i.e.
 
unsigned getSmallConstantTripCount (constLoop *L)
 Returns the exact trip count of the loop if we can compute it, and the result is a small constant.
 
unsigned getSmallConstantTripCount (constLoop *L,constBasicBlock *ExitingBlock)
 Return the exact trip count for this loop if we exit through ExitingBlock.
 
unsigned getSmallConstantMaxTripCount (constLoop *L,SmallVectorImpl<constSCEVPredicate * > *Predicates=nullptr)
 Returns the upper bound of the loop trip count as a normal unsigned value.
 
unsigned getSmallConstantTripMultiple (constLoop *L,constSCEV *ExitCount)
 Returns the largest constant divisor of the trip count as a normal unsigned value, if possible.
 
unsigned getSmallConstantTripMultiple (constLoop *L)
 Returns the largest constant divisor of the trip count of the loop.
 
unsigned getSmallConstantTripMultiple (constLoop *L,constBasicBlock *ExitingBlock)
 Returns the largest constant divisor of the trip count of this loop as a normal unsigned value, if possible.
 
constSCEVgetExitCount (constLoop *L,constBasicBlock *ExitingBlock,ExitCountKind Kind=Exact)
 Return the number of times the backedge executes before the given exit would be taken; if not exactly computable, returnSCEVCouldNotCompute.
 
constSCEVgetPredicatedExitCount (constLoop *L,constBasicBlock *ExitingBlock,SmallVectorImpl<constSCEVPredicate * > *Predicates,ExitCountKind Kind=Exact)
 Same as above except this uses the predicated backedge taken info and may require predicates.
 
constSCEVgetBackedgeTakenCount (constLoop *L,ExitCountKind Kind=Exact)
 If the specified loop has a predictable backedge-taken count, return it, otherwise return aSCEVCouldNotCompute object.
 
constSCEVgetPredicatedBackedgeTakenCount (constLoop *L,SmallVectorImpl<constSCEVPredicate * > &Predicates)
 Similar to getBackedgeTakenCount, except it will add a set ofSCEV predicates to Predicates that are required to be true in order for the answer to be correct.
 
constSCEVgetConstantMaxBackedgeTakenCount (constLoop *L)
 When successful, this returns aSCEVConstant that is greater than or equal to (i.e.
 
constSCEVgetPredicatedConstantMaxBackedgeTakenCount (constLoop *L,SmallVectorImpl<constSCEVPredicate * > &Predicates)
 Similar to getConstantMaxBackedgeTakenCount, except it will add a set ofSCEV predicates to Predicates that are required to be true in order for the answer to be correct.
 
constSCEVgetSymbolicMaxBackedgeTakenCount (constLoop *L)
 When successful, this returns aSCEV that is greater than or equal to (i.e.
 
constSCEVgetPredicatedSymbolicMaxBackedgeTakenCount (constLoop *L,SmallVectorImpl<constSCEVPredicate * > &Predicates)
 Similar to getSymbolicMaxBackedgeTakenCount, except it will add a set ofSCEV predicates to Predicates that are required to be true in order for the answer to be correct.
 
bool isBackedgeTakenCountMaxOrZero (constLoop *L)
 Return true if the backedge taken count is either the value returned by getConstantMaxBackedgeTakenCount or zero.
 
bool hasLoopInvariantBackedgeTakenCount (constLoop *L)
 Return true if the specified loop has an analyzable loop-invariant backedge-taken count.
 
void forgetAllLoops ()
 
void forgetLoop (constLoop *L)
 This method should be called by the client when it has changed a loop in a way that may effectScalarEvolution's ability to compute a trip count, or if the loop is deleted.
 
void forgetTopmostLoop (constLoop *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.
 
void forgetLcssaPhiWithNewPredecessor (Loop *L,PHINode *V)
 Forget LCSSA phi node V of loop L to which a new predecessor was added, such that it may no longer be trivial.
 
void forgetLoopDispositions ()
 Called when the client has changed the disposition of values in this loop.
 
void forgetBlockAndLoopDispositions (Value *V=nullptr)
 Called when the client has changed the disposition of values in a loop or block.
 
uint32_t getMinTrailingZeros (constSCEV *S)
 Determine the minimum number of zero bits that S is guaranteed to end in (at every loop iteration).
 
APInt getConstantMultiple (constSCEV *S)
 Returns the max constant multiple of S.
 
APInt getNonZeroConstantMultiple (constSCEV *S)
 
ConstantRange getUnsignedRange (constSCEV *S)
 Determine the unsigned range for a particularSCEV.
 
APInt getUnsignedRangeMin (constSCEV *S)
 Determine the min of the unsigned range for a particularSCEV.
 
APInt getUnsignedRangeMax (constSCEV *S)
 Determine the max of the unsigned range for a particularSCEV.
 
ConstantRange getSignedRange (constSCEV *S)
 Determine the signed range for a particularSCEV.
 
APInt getSignedRangeMin (constSCEV *S)
 Determine the min of the signed range for a particularSCEV.
 
APInt getSignedRangeMax (constSCEV *S)
 Determine the max of the signed range for a particularSCEV.
 
bool isKnownNegative (constSCEV *S)
 Test if the given expression is known to be negative.
 
bool isKnownPositive (constSCEV *S)
 Test if the given expression is known to be positive.
 
bool isKnownNonNegative (constSCEV *S)
 Test if the given expression is known to be non-negative.
 
bool isKnownNonPositive (constSCEV *S)
 Test if the given expression is known to be non-positive.
 
bool isKnownNonZero (constSCEV *S)
 Test if the given expression is known to be non-zero.
 
bool isKnownToBeAPowerOfTwo (constSCEV *S,bool OrZero=false,bool OrNegative=false)
 Test if the given expression is known to be a power of 2.
 
std::pair<constSCEV *,constSCEV * > SplitIntoInitAndPostInc (constLoop *L,constSCEV *S)
 SplitsSCEV expressionS into two SCEVs.
 
bool isKnownViaInduction (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS)
 We'd like to check the predicate on every iteration of the most dominated loop between loops used in LHS and RHS.
 
bool isKnownPredicate (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS)
 Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS.
 
std::optional<boolevaluatePredicate (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS)
 Check whether the condition described by Pred, LHS, and RHS is true or false.
 
bool isKnownPredicateAt (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS,constInstruction *CtxI)
 Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS in the given Context.
 
std::optional<boolevaluatePredicateAt (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS,constInstruction *CtxI)
 Check whether the condition described by Pred, LHS, and RHS is true or false in the givenContext.
 
bool isKnownOnEveryIteration (CmpPredicate Pred,constSCEVAddRecExpr *LHS,constSCEV *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.
 
ExitLimit computeExitLimitFromCond (constLoop *L,Value *ExitCond,bool ExitIfTrue,bool ControlsOnlyExit,bool AllowPredicates=false)
 Compute the number of times the backedge of the specified loop will execute if its exit condition were a conditional branch of ExitCond.
 
std::optional<MonotonicPredicateTypegetMonotonicPredicateType (constSCEVAddRecExpr *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.
 
std::optional<LoopInvariantPredicategetLoopInvariantPredicate (ICmpInst::Predicate Pred,constSCEV *LHS,constSCEV *RHS,constLoop *L,constInstruction *CtxI=nullptr)
 If the result of the predicate LHSPred RHS is loop invariant with respect to L, return aLoopInvariantPredicate with LHS and RHS being invariants, available at L's entry.
 
std::optional<LoopInvariantPredicategetLoopInvariantExitCondDuringFirstIterations (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS,constLoop *L,constInstruction *CtxI,constSCEV *MaxIter)
 If the result of the predicate LHSPred RHS is loop invariant with respect to L at given Context during at least first MaxIter iterations, return aLoopInvariantPredicate with LHS and RHS being invariants, available at L's entry.
 
std::optional<LoopInvariantPredicategetLoopInvariantExitCondDuringFirstIterationsImpl (CmpPredicate Pred,constSCEV *LHS,constSCEV *RHS,constLoop *L,constInstruction *CtxI,constSCEV *MaxIter)
 
bool SimplifyICmpOperands (CmpPredicate &Pred,constSCEV *&LHS,constSCEV *&RHS,unsignedDepth=0)
 Simplify LHS and RHS in a comparison with predicate Pred.
 
LoopDisposition getLoopDisposition (constSCEV *S,constLoop *L)
 Return the "disposition" of the givenSCEV with respect to the given loop.
 
bool isLoopInvariant (constSCEV *S,constLoop *L)
 Return true if the value of the givenSCEV is unchanging in the specified loop.
 
bool isAvailableAtLoopEntry (constSCEV *S,constLoop *L)
 Determine if theSCEV can be evaluated at loop's entry.
 
bool hasComputableLoopEvolution (constSCEV *S,constLoop *L)
 Return true if the givenSCEV changes value in a known way in the specified loop.
 
BlockDisposition getBlockDisposition (constSCEV *S,constBasicBlock *BB)
 Return the "disposition" of the givenSCEV with respect to the given block.
 
bool dominates (constSCEV *S,constBasicBlock *BB)
 Return true if elements that makes up the givenSCEV dominate the specified basic block.
 
bool properlyDominates (constSCEV *S,constBasicBlock *BB)
 Return true if elements that makes up the givenSCEV properly dominate the specified basic block.
 
bool hasOperand (constSCEV *S,constSCEV *Op)const
 Test whether the givenSCEV has Op as a direct or indirect operand.
 
constSCEVgetElementSize (Instruction *Inst)
 Return the size of an element read or written by Inst.
 
void print (raw_ostream &OS)const
 
void verify ()const
 
bool invalidate (Function &F,constPreservedAnalyses &PA,FunctionAnalysisManager::Invalidator &Inv)
 
constDataLayoutgetDataLayout ()const
 Return theDataLayout associated with the module thisSCEV instance is operating on.
 
constSCEVPredicategetEqualPredicate (constSCEV *LHS,constSCEV *RHS)
 
constSCEVPredicategetComparePredicate (ICmpInst::Predicate Pred,constSCEV *LHS,constSCEV *RHS)
 
constSCEVPredicategetWrapPredicate (constSCEVAddRecExpr *AR,SCEVWrapPredicate::IncrementWrapFlags AddedFlags)
 
constSCEVrewriteUsingPredicate (constSCEV *S,constLoop *L,constSCEVPredicate &A)
 Re-writes theSCEV according to the Predicates inA.
 
constSCEVAddRecExprconvertSCEVToAddRecWithPredicates (constSCEV *S,constLoop *L,SmallVectorImpl<constSCEVPredicate * > &Preds)
 Tries to convert theS expression to an AddRec expression, adding additional predicates toPreds as required.
 
std::optional<APIntcomputeConstantDifference (constSCEV *LHS,constSCEV *RHS)
 ComputeLHS -RHS and returns the result as anAPInt if it is a constant, and std::nullopt if it isn't.
 
void setNoWrapFlags (SCEVAddRecExpr *AddRec,SCEV::NoWrapFlags Flags)
 Update no-wrap flags of an AddRec.
 
constSCEVapplyLoopGuards (constSCEV *Expr,constLoop *L)
 Try to apply information from loop guards forL toExpr.
 
constSCEVapplyLoopGuards (constSCEV *Expr,constLoopGuards &Guards)
 
bool loopHasNoAbnormalExits (constLoop *L)
 Return true if the loop has no abnormal exits.
 
bool loopIsFiniteByAssumption (constLoop *L)
 Return true if this loop is finite by assumption.
 
void getPoisonGeneratingValues (SmallPtrSetImpl<constValue * > &Result,constSCEV *S)
 Return the set of Values that, if poison, will definitively result in S being poison as well.
 
bool canReuseInstruction (constSCEV *S,Instruction *I,SmallVectorImpl<Instruction * > &DropPoisonGeneratingInsts)
 Check whether it is poison-safe to represent the expression S using the instruction I.
 

Static Public Member Functions

staticSCEV::NoWrapFlags maskFlags (SCEV::NoWrapFlags Flags, int Mask)
 Convenient NoWrapFlags manipulation that hides enum casts and is visible in theScalarEvolution name space.
 
staticSCEV::NoWrapFlags setFlags (SCEV::NoWrapFlags Flags,SCEV::NoWrapFlags OnFlags)
 
staticSCEV::NoWrapFlags clearFlags (SCEV::NoWrapFlags Flags,SCEV::NoWrapFlags OffFlags)
 
staticbool hasFlags (SCEV::NoWrapFlags Flags,SCEV::NoWrapFlags TestFlags)
 

Friends

class ScalarEvolutionsTest
 
class SCEVCallbackVH
 
class SCEVExpander
 
class SCEVUnknown
 

Detailed Description

The main scalar evolution driver.

Because client code (intentionally) can't do much with theSCEV objects directly, they must ask this class for services.

Definition at line447 of fileScalarEvolution.h.

Member Enumeration Documentation

◆ BlockDisposition

enumllvm::ScalarEvolution::BlockDisposition

An enum describing the relationship between aSCEV and a basic block.

Enumerator
DoesNotDominateBlock 

TheSCEV does not dominate the block.

DominatesBlock 

TheSCEV dominates the block.

ProperlyDominatesBlock 

TheSCEV properly dominates the block.

Definition at line459 of fileScalarEvolution.h.

◆ ExitCountKind

enumllvm::ScalarEvolution::ExitCountKind

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.

Enumerator
Exact 

An expression exactly describing the number of times the backedge has executed when a loop is exited.

ConstantMaximum 

A constant which provides an upper bound on the exact trip count.

SymbolicMaximum 

An expression which provides an upper bound on the exact trip count.

Definition at line858 of fileScalarEvolution.h.

◆ LoopDisposition

enumllvm::ScalarEvolution::LoopDisposition

An enum describing the relationship between aSCEV and a loop.

Enumerator
LoopVariant 

TheSCEV is loop-variant (unknown).

LoopInvariant 

TheSCEV is loop-invariant.

LoopComputable 

TheSCEV varies predictably with the loop.

Definition at line452 of fileScalarEvolution.h.

◆ MonotonicPredicateType

enumllvm::ScalarEvolution::MonotonicPredicateType

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 line1176 of fileScalarEvolution.h.

Constructor & Destructor Documentation

◆ ScalarEvolution()[1/2]

ScalarEvolution::ScalarEvolution(FunctionF,
TargetLibraryInfoTLI,
AssumptionCacheAC,
DominatorTreeDT,
LoopInfoLI 
)

Definition at line13637 of fileScalarEvolution.cpp.

ReferencesF, andllvm::Intrinsic::getDeclarationIfExists().

◆ ScalarEvolution()[2/2]

ScalarEvolution::ScalarEvolution(ScalarEvolution && Arg)

Definition at line13658 of fileScalarEvolution.cpp.

◆ ~ScalarEvolution()

ScalarEvolution::~ScalarEvolution()

Definition at line13689 of fileScalarEvolution.cpp.

Referencesassert(), andllvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear().

Member Function Documentation

◆ applyLoopGuards()[1/2]

constSCEV * ScalarEvolution::applyLoopGuards(constSCEVExpr,
constLoopL 
)

Try to apply information from loop guards forL toExpr.

Definition at line15967 of fileScalarEvolution.cpp.

ReferencesapplyLoopGuards(), andllvm::ScalarEvolution::LoopGuards::collect().

Referenced byapplyLoopGuards(),llvm::LoopVectorizationCostModel::computeMaxVF(),llvm::InnerLoopVectorizer::emitIterationCountCheck(),expandBounds(),getSmallConstantTripMultiple(),isSafeDecreasingBound(), andisSafeIncreasingBound().

◆ applyLoopGuards()[2/2]

constSCEV * ScalarEvolution::applyLoopGuards(constSCEVExpr,
constLoopGuardsGuards 
)

Definition at line15971 of fileScalarEvolution.cpp.

Referencesllvm::ScalarEvolution::LoopGuards::rewrite().

◆ canReuseInstruction()

bool ScalarEvolution::canReuseInstruction(constSCEVS,
InstructionI,
SmallVectorImpl<Instruction * > & DropPoisonGeneratingInsts 
)

Check whether it is poison-safe to represent the expression S using the instruction I.

If such a replacement is performed, the poison flags of instructions in DropPoisonGeneratingInsts must be dropped.

Definition at line4168 of fileScalarEvolution.cpp.

Referencesllvm::canCreatePoison(),llvm::SmallPtrSetImpl< PtrType >::contains(),llvm::SmallVectorBase< Size_T >::empty(),getPoisonGeneratingValues(),I,II,llvm::SmallPtrSetImpl< PtrType >::insert(),llvm::SmallVectorImpl< T >::pop_back_val(),llvm::programUndefinedIfPoison(),llvm::SmallVectorTemplateBase< T, bool >::push_back(), andllvm::SmallPtrSetImplBase::size().

◆ clearFlags()

staticSCEV::NoWrapFlags llvm::ScalarEvolution::clearFlags(SCEV::NoWrapFlags Flags,
SCEV::NoWrapFlags OffFlags 
)
inlinestatic

Definition at line476 of fileScalarEvolution.h.

Referenced bygetMulExpr().

◆ computeConstantDifference()

std::optional<APInt > ScalarEvolution::computeConstantDifference(constSCEVLHS,
constSCEVRHS 
)

ComputeLHS -RHS and returns the result as anAPInt if it is a constant, and std::nullopt 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 line12059 of fileScalarEvolution.cpp.

Referencesllvm::Add,assert(),llvm::CallingConv::C,llvm::SCEV::getType(),getTypeSizeInBits(),I,llvm::Less,llvm::Mul, andllvm::SCEV::operands().

Referenced bygetMinFromExprs(),llvm::getPointersDiff(),IsSimplerBaseSCEVForTarget(), andSalvageDVI().

◆ computeExitLimitFromCond()

ScalarEvolution::ExitLimit ScalarEvolution::computeExitLimitFromCond(constLoopL,
ValueExitCond,
bool ExitIfTrue,
bool ControlsOnlyExit,
bool AllowPredicates =false 
)

Compute the number of times the backedge of the specified loop will execute if its exit condition were a conditional branch of ExitCond.

ControlsOnlyExit is true if ExitCond directly controls the only exit branch. In this case, we can assume that the loop exits only if the condition is true and can infer that failing to meet the condition prior to integer wraparound results in undefined behavior.

IfAllowPredicates is set, this call will try to use a minimal set ofSCEV predicates in order to return an exact answer.

Definition at line8973 of fileScalarEvolution.cpp.

Referenced byoptimizeLoopExitWithUnknownExitCount().

◆ containsAddRecurrence()

bool ScalarEvolution::containsAddRecurrence(constSCEVS)

Return true if theSCEV is a scAddRecExpr or it contains scAddRecExpr.

The result will be cached in HasRecMap.

Definition at line4500 of fileScalarEvolution.cpp.

Referencesllvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(),I,llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), andllvm::SCEVExprContains().

◆ containsErasedValue()

bool ScalarEvolution::containsErasedValue(constSCEVS) const

Return true if theSCEV expression contains aValue that has been optimised out and is now a nullptr.

Definition at line13586 of fileScalarEvolution.cpp.

Referencesllvm::SCEVUnknown::getValue(), andllvm::SCEVExprContains().

Referenced bySalvageDVI().

◆ containsUndefs()

bool ScalarEvolution::containsUndefs(constSCEVS) const

Return true if theSCEV expression contains an undef value.

Definition at line13577 of fileScalarEvolution.cpp.

Referencesllvm::SCEVUnknown::getValue(), andllvm::SCEVExprContains().

Referenced byDbgGatherSalvagableDVI(),GetInductionVariable(),SalvageDVI(), andverify().

◆ convertSCEVToAddRecWithPredicates()

constSCEVAddRecExpr * ScalarEvolution::convertSCEVToAddRecWithPredicates(constSCEVS,
constLoopL,
SmallVectorImpl<constSCEVPredicate * > & Preds 
)

Tries to convert theS expression to an AddRec expression, adding additional predicates toPreds as required.

Definition at line14902 of fileScalarEvolution.cpp.

Referencesllvm::SmallVectorImpl< T >::append(),llvm::SmallVectorTemplateCommon< T, typename >::begin(), andllvm::SmallVectorTemplateCommon< T, typename >::end().

Referenced byllvm::PredicatedScalarEvolution::getAsAddRec().

◆ createAddRecFromPHIWithCasts()

std::optional< std::pair<constSCEV *,SmallVector<constSCEVPredicate *, 3 > > > ScalarEvolution::createAddRecFromPHIWithCasts(constSCEVUnknownSymbolicPHI)

Checks ifSymbolicPHI 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 line5663 of fileScalarEvolution.cpp.

Referencesassert(),llvm::SCEVUnknown::getValue(),I, andisIntegerLoopHeaderPHI().

◆ dominates()

bool ScalarEvolution::dominates(constSCEVS,
constBasicBlockBB 
)

Return true if elements that makes up the givenSCEV dominate the specified basic block.

Definition at line14183 of fileScalarEvolution.cpp.

ReferencesDominatesBlock, andgetBlockDisposition().

Referenced byllvm::SCEVExpander::isSafeToExpandAt().

◆ evaluatePredicate()

std::optional<bool > ScalarEvolution::evaluatePredicate(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS 
)

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 std::nullopt.

Definition at line11065 of fileScalarEvolution.cpp.

Referencesllvm::ICmpInst::getInverseCmpPredicate(),isKnownPredicate(),LHS, andRHS.

Referenced bycountToEliminateCompares(), andevaluatePredicateAt().

◆ evaluatePredicateAt()

std::optional<bool > ScalarEvolution::evaluatePredicateAt(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS,
constInstructionCtxI 
)

Check whether the condition described by Pred, LHS, and RHS is true or false in the givenContext.

If we know it, return the evaluation of this condition. If neither is proved, return std::nullopt.

Definition at line11084 of fileScalarEvolution.cpp.

ReferencesevaluatePredicate(),llvm::ICmpInst::getInverseCmpPredicate(),llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),isBasicBlockEntryGuardedByCond(),LHS, andRHS.

Referenced bycreateReplacement().

◆ forgetAllLoops()

void ScalarEvolution::forgetAllLoops()

Definition at line8449 of fileScalarEvolution.cpp.

Referencesllvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear().

Referenced byllvm::UnrollLoop().

◆ forgetBlockAndLoopDispositions()

void ScalarEvolution::forgetBlockAndLoopDispositions(ValueV =nullptr)

Called when the client has changed the disposition of values in a loop or block.

We don't have a way to invalidate per-loop/per-block dispositions. Clear and recompute is simpler.

Definition at line8597 of fileScalarEvolution.cpp.

Referencesllvm::SmallVectorBase< Size_T >::empty(),getExistingSCEV(),llvm::SmallPtrSetImpl< PtrType >::insert(),isSCEVable(),llvm::SmallVectorImpl< T >::pop_back_val(),llvm::SmallVectorTemplateBase< T, bool >::push_back(), andUsers.

Referenced byllvm::breakLoopBackedge(),deleteDeadBlocksFromLoop(),llvm::deleteDeadLoop(),DoFlattenLoopPair(),llvm::InnerLoopVectorizer::fixVectorizedLoop(),llvm::Loop::makeLoopInvariant(),mergeBlocksIntoPredecessors(),moveInstructionBefore(),llvm::peelLoop(),rebuildLoopAfterUnswitch(),sinkLoopInvariantInstructions(),llvm::UnrollAndJamLoop(),llvm::UnrollLoop(),unswitchNontrivialInvariants(), andunswitchTrivialBranch().

◆ forgetLcssaPhiWithNewPredecessor()

void ScalarEvolution::forgetLcssaPhiWithNewPredecessor(LoopL,
PHINodeV 
)

Forget LCSSA phi node V of loop L to which a new predecessor was added, such that it may no longer be trivial.

Definition at line8557 of fileScalarEvolution.cpp.

Referencesllvm::CallingConv::C,forgetValue(),getExistingSCEV(),llvm::SCEVAddRecExpr::getLoop(),I,isSCEVable(),llvm::SmallVectorTemplateBase< T, bool >::push_back(), andllvm::visitAll().

Referenced bybuildClonedLoopBlocks(),cloneLoopBlocks(),ConnectProlog(),llvm::InnerLoopVectorizer::fixVectorizedLoop(), andllvm::UnrollLoop().

◆ forgetLoop()

void ScalarEvolution::forgetLoop(constLoopL)

This method should be called by the client when it has changed a loop in a way that may effectScalarEvolution's ability to compute a trip count, or if the loop is deleted.

This call is potentially expensive for large loop bodies.

Definition at line8496 of fileScalarEvolution.cpp.

Referencesllvm::SmallVectorImpl< T >::append(),llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorTemplateCommon< T, typename >::end(),I,llvm::SmallVectorImpl< T >::insert(),llvm::SmallVectorImpl< T >::pop_back_val(), andPushLoopPHIs().

Referenced byllvm::breakLoopBackedge(),llvm::deleteDeadLoop(),deleteLoopIfDead(),DoFlattenLoopPair(),llvm::InnerLoopVectorizer::fixVectorizedLoop(),forgetTopmostLoop(),separateNestedLoop(),llvm::splitLoopBound(),llvm::UnrollAndJamLoop(),unswitchNontrivialInvariants(),unswitchTrivialBranch(), andunswitchTrivialSwitch().

◆ forgetLoopDispositions()

void ScalarEvolution::forgetLoopDispositions()

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 line8595 of fileScalarEvolution.cpp.

◆ forgetTopmostLoop()

void ScalarEvolution::forgetTopmostLoop(constLoopL)

Definition at line8538 of fileScalarEvolution.cpp.

ReferencesforgetLoop().

Referenced byllvm::peelLoop(),llvm::simplifyLoop(),simplifyLoopCFG(),llvm::UnrollLoop(),llvm::UnrollRuntimeLoopRemainder(),unswitchNontrivialInvariants(),unswitchTrivialBranch(), andunswitchTrivialSwitch().

◆ forgetValue()

void ScalarEvolution::forgetValue(ValueV)

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 line8542 of fileScalarEvolution.cpp.

ReferencesI,llvm::SmallPtrSetImpl< PtrType >::insert(), andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced byConnectEpilog(),forgetLcssaPhiWithNewPredecessor(),llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(),llvm::SCEVExpander::replaceCongruentIVs(),replaceLoopPHINodesWithPreheaderValues(),llvm::rewriteLoopExitValues(),RewriteUsesOfClonedInstructions(), andsimplifyOneLoop().

◆ getAbsExpr()

constSCEV * ScalarEvolution::getAbsExpr(constSCEVOp,
bool IsNSW 
)

Definition at line3823 of fileScalarEvolution.cpp.

Referencesllvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,getNegativeSCEV(), andgetSMaxExpr().

◆ getAddExpr()[1/3]

constSCEV * llvm::ScalarEvolution::getAddExpr(constSCEVLHS,
constSCEVRHS,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)
inline

Definition at line580 of fileScalarEvolution.h.

Referencesllvm::Depth,getAddExpr(),LHS, andRHS.

◆ getAddExpr()[2/3]

constSCEV * llvm::ScalarEvolution::getAddExpr(constSCEVOp0,
constSCEVOp1,
constSCEVOp2,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)
inline

Definition at line586 of fileScalarEvolution.h.

Referencesllvm::Depth, andgetAddExpr().

◆ getAddExpr()[3/3]

constSCEV * ScalarEvolution::getAddExpr(SmallVectorImpl<constSCEV * > & Ops,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)

Get a canonical add expression, or something simpler if possible.

Definition at line2526 of fileScalarEvolution.cpp.

ReferencesA,llvm::APInt::abs(),llvm::Add,AddOpsInlineThreshold,llvm::append_range(),assert(),B,llvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::BasicBlock::begin(),llvm::BitWidth,llvm::CallingConv::C,llvm::SmallVectorImpl< T >::clear(),CollectAddOperandsWithScales(),constantFoldAndGroupOps(),llvm::count_if(),llvm::Depth,llvm::DominatorTree::dominates(),llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorImpl< T >::erase(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,llvm::SCEV::FlagNW,getAddExpr(),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(),getType(),getTypeSizeInBits(),getUDivExpr(),getZero(),hasFlags(),hasHugeExpression(),Idx,isAvailableAtLoopEntry(),llvm::isPointerTy(),llvm::APInt::isSignBitSet(),LHS,maskFlags(),MaxArithDepth,llvm::Mul,llvm::SCEVNAryExpr::operands(),llvm::SmallVectorTemplateBase< T, bool >::pop_back(),llvm::SmallVectorTemplateBase< T, bool >::push_back(),RHS,llvm::scAddExpr,llvm::scAddRecExpr,llvm::scMulExpr,setFlags(),llvm::SmallVectorBase< Size_T >::size(),StrengthenNoWrapFlags(),llvm::APInt::ule(),X, andY.

Referenced bycalculateRtStride(),calculateSubRanges(),llvm::calculateUpperBound(),llvm::LoopVectorizationCostModel::computeMaxVF(),countToEliminateCompares(),createNodeForSelectViaUMinSeq(),llvm::SCEVAddRecExpr::evaluateAtIteration(),ExtractImmediate(),ExtractSymbol(),findForkedSCEVs(),getAddExpr(),getExactSDiv(),getExtendAddRecStart(),getGEPExpr(),getLosslessPtrToIntExpr(),getMinusSCEV(),getMulExpr(),getNewAlignment(),llvm::SCEVAddRecExpr::getPostIncExpr(),getPreStartForExtend(),getSignExtendExprImpl(),llvm::getStartAndEndForAccess(),getTripCountFromExitCount(),getTruncateExpr(),getUDivCeilSCEV(),getUDivExpr(),getZeroExtendExprImpl(),llvm::ARMTTIImpl::isHardwareLoopProfitable(),IsIncrementNSW(),IsIncrementNUW(),isSafeDecreasingBound(),isSafeIncreasingBound(),llvm::LoopStructure::parseLoopStructure(),removePointerBase(),llvm::ScalarEvolution::LoopGuards::rewrite(),llvm::LoopConstrainer::run(),SimplifyICmpOperands(),llvm::UnrollRuntimeLoopRemainder(),llvm::SCEVRewriteVisitor< SC >::visitAddExpr(),llvm::SCEVDivision::visitAddExpr(), andwillNotOverflow().

◆ getAddRecExpr()[1/3]

constSCEV * ScalarEvolution::getAddRecExpr(constSCEVStart,
constSCEVStep,
constLoopL,
SCEV::NoWrapFlags Flags 
)

Get an add recurrence expression for the specified loop.

Simplify the expression as much as possible.

Definition at line3641 of fileScalarEvolution.cpp.

Referencesllvm::append_range(),llvm::SCEV::FlagNW,getAddRecExpr(),maskFlags(), andOperands.

Referenced byCollectSubexprs(),DoInitialMatch(),ExtractImmediate(),ExtractSymbol(),getAddExpr(),getAddRecExpr(),getAnyExtendExpr(),getExactSDiv(),getMulExpr(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),llvm::SCEVAddRecExpr::getPostIncExpr(),getPreStartForExtend(),getSignExtendExprImpl(),llvm::SCEVAddRecExpr::getStepRecurrence(),getTruncateExpr(),getUDivExpr(),getZeroExtendExprImpl(),isLoopBackedgeGuardedByCond(),removePointerBase(),llvm::SCEVRewriteVisitor< SC >::visitAddRecExpr(),llvm::SCEVLoopAddRecRewriter::visitAddRecExpr(), andllvm::SCEVDivision::visitAddRecExpr().

◆ getAddRecExpr()[2/3]

constSCEV * llvm::ScalarEvolution::getAddRecExpr(constSmallVectorImpl<constSCEV * > & Operands,
constLoopL,
SCEV::NoWrapFlags Flags 
)
inline

Definition at line614 of fileScalarEvolution.h.

ReferencesgetAddRecExpr(), andOperands.

◆ getAddRecExpr()[3/3]

constSCEV * ScalarEvolution::getAddRecExpr(SmallVectorImpl<constSCEV * > & Operands,
constLoopL,
SCEV::NoWrapFlags Flags 
)

Get an add recurrence expression for the specified loop.

Simplify the expression as much as possible.

Definition at line3659 of fileScalarEvolution.cpp.

Referencesllvm::all_of(),assert(),llvm::LoopBase< BlockT, LoopT >::contains(),llvm::DominatorTree::dominates(),llvm::drop_begin(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNW,getAddRecExpr(),getEffectiveSCEVType(),llvm::LoopBase< BlockT, LoopT >::getHeader(),llvm::LoopBase< BlockT, LoopT >::getLoopDepth(),getType(),isAvailableAtLoopEntry(),isLoopInvariant(),maskFlags(),Operands,llvm::scAddRecExpr, andStrengthenNoWrapFlags().

◆ getAnyExtendExpr()

constSCEV * ScalarEvolution::getAnyExtendExpr(constSCEVOp,
TypeTy 
)

getAnyExtendExpr - Return aSCEV for the given operand extended with unspecified bits out to the given type.

Definition at line2180 of fileScalarEvolution.cpp.

Referencesassert(),llvm::SCEV::FlagNW,getAddRecExpr(),getAnyExtendExpr(),getEffectiveSCEVType(),getSignExtendExpr(),getTruncateOrNoop(),llvm::SCEV::getType(),getTypeSizeInBits(),getZeroExtendExpr(),isSCEVable(), andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced bygetAddExpr(),getAnyExtendConsideringPostIncUses(),getAnyExtendExpr(), andgetNoopOrAnyExtend().

◆ getBackedgeTakenCount()

constSCEV * ScalarEvolution::getBackedgeTakenCount(constLoopL,
ExitCountKind Kind =Exact 
)

If the specified loop has a predictable backedge-taken count, return it, otherwise return aSCEVCouldNotCompute 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 line8350 of fileScalarEvolution.cpp.

ReferencesConstantMaximum,Exact,llvm_unreachable, andSymbolicMaximum.

Referenced bybreakBackedgeIfNotTaken(),canFoldTermCondOfLoop(),llvm::LoopVectorizationCostModel::computeMaxVF(),computeTripCount(),getAppleRuntimeUnrollPreferences(),getConstantMaxBackedgeTakenCount(),getPreStartForExtend(),getSmallConstantTripCount(),getSymbolicMaxBackedgeTakenCount(),llvm::ARMTTIImpl::getUnrollingPreferences(),hasLoopInvariantBackedgeTakenCount(),llvm::ARMTTIImpl::isHardwareLoopProfitable(),llvm::IVUsers::print(),PrintLoopInfo(),verify(), andverifyTripCount().

◆ getBlockDisposition()

ScalarEvolution::BlockDisposition ScalarEvolution::getBlockDisposition(constSCEVS,
constBasicBlockBB 
)

Return the "disposition" of the givenSCEV with respect to the given block.

Definition at line14109 of fileScalarEvolution.cpp.

ReferencesD,DoesNotDominateBlock, andllvm::reverse().

Referenced bydominates(),properlyDominates(), andverify().

◆ getCastExpr()

constSCEV * ScalarEvolution::getCastExpr(SCEVTypes Kind,
constSCEVOp,
TypeTy 
)

Definition at line2162 of fileScalarEvolution.cpp.

ReferencesgetPtrToIntExpr(),getSignExtendExpr(),getTruncateExpr(),getZeroExtendExpr(),llvm_unreachable,llvm::scPtrToInt,llvm::scSignExtend,llvm::scTruncate, andllvm::scZeroExtend.

◆ getComparePredicate()

constSCEVPredicate * ScalarEvolution::getComparePredicate(ICmpInst::Predicate Pred,
constSCEVLHS,
constSCEVRHS 
)

Definition at line14736 of fileScalarEvolution.cpp.

Referencesassert(),llvm::Value::getType(),LHS,llvm::SCEVPredicate::P_Compare, andRHS.

Referenced bygetEqualPredicate().

◆ getConstant()[1/3]

constSCEV * ScalarEvolution::getConstant(constAPIntVal)

Definition at line484 of fileScalarEvolution.cpp.

ReferencesgetConstant(), andgetContext().

◆ getConstant()[2/3]

constSCEV * ScalarEvolution::getConstant(ConstantIntV)

Definition at line473 of fileScalarEvolution.cpp.

Referencesllvm::scConstant.

Referenced byBinomialCoefficient(),calculateRtStride(),llvm::calculateUpperBound(),llvm::cannotBeMaxInLoop(),llvm::cannotBeMinInLoop(),CollectSubexprs(),llvm::LoopVectorizationCostModel::computeMaxVF(),llvm::IndexedReference::computeRefCost(),computeTripCount(),constantFoldAndGroupOps(),countToEliminateCompares(),DoInitialMatch(),EvaluateConstantChrecAtConstant(),ExtractImmediate(),ExtractSymbol(),getAddExpr(),getConstant(),getElementCount(),getExactSDiv(),getMinusOne(),getMulExpr(),getNegativeSCEV(),getNotSCEV(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),getOffsetOfExpr(),getOne(),getPowerOfTwo(),getSignedOverflowLimitForStep(),getSignExtendExprImpl(),getSizeOfExpr(),getTruncateExpr(),getUDivExactExpr(),getUDivExpr(),getUnsignedOverflowLimitForStep(),getZero(),getZeroExtendExprImpl(),isSafeDecreasingBound(),isSafeDependenceDistance(),isSafeIncreasingBound(),llvm::LoopConstrainer::run(),llvm::LoopVectorizationPlanner::selectEpilogueVectorizationFactor(),SimplifyICmpOperands(),SolveLinEquationWithOverflow(),llvm::UnrolledInstAnalyzer::UnrolledInstAnalyzer(),llvm::UnrollRuntimeLoopRemainder(),verify(),llvm::SCEVDivision::visitConstant(), andwillNotOverflow().

◆ getConstant()[3/3]

constSCEV * ScalarEvolution::getConstant(TypeTy,
uint64_t V,
bool isSigned =false 
)

Definition at line489 of fileScalarEvolution.cpp.

ReferencesgetConstant(),getEffectiveSCEVType(), andisSigned().

◆ getConstantMaxBackedgeTakenCount()

constSCEV * llvm::ScalarEvolution::getConstantMaxBackedgeTakenCount(constLoopL)
inline

When successful, this returns aSCEVConstant 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 theSCEVCouldNotCompute object.

Definition at line907 of fileScalarEvolution.h.

ReferencesConstantMaximum, andgetBackedgeTakenCount().

Referenced bybreakBackedgeIfNotTaken(),countToEliminateCompares(),getSignExtendExprImpl(),getSmallConstantMaxTripCount(),getZeroExtendExprImpl(),llvm::isDereferenceableAndAlignedInLoop(),isLoopDead(),mustBeFiniteCountedLoop(), andPrintLoopInfo().

◆ getConstantMultiple()

APInt ScalarEvolution::getConstantMultiple(constSCEVS)

Returns the max constant multiple of S.

Definition at line6395 of fileScalarEvolution.cpp.

Referencesassert(), andI.

Referenced bygetMinTrailingZeros(),getNonZeroConstantMultiple(), andverify().

◆ getContext()

LLVMContext & llvm::ScalarEvolution::getContext() const
inline

Definition at line489 of fileScalarEvolution.h.

ReferencesF.

Referenced byBinomialCoefficient(),getConstant(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),llvm::sandboxir::Utils::getPointerDiffInBytes(),getPreStartForExtend(),getSignExtendExprImpl(),getUDivExpr(),getURemExpr(),getZeroExtendExprImpl(),isAddRecSExtable(),isAddSExtable(),isMulSExtable(),llvm::VPlanTransforms::optimizeForVFAndUF(),llvm::ScalarEvolution::LoopGuards::rewrite(),SimplifyICmpOperands(),SolveQuadraticAddRecExact(), andSolveQuadraticAddRecRange().

◆ getCouldNotCompute()

constSCEV * ScalarEvolution::getCouldNotCompute()

Definition at line4487 of fileScalarEvolution.cpp.

Referenced byBinomialCoefficient(),getLosslessPtrToIntExpr(),getMinAnalyzeableBackedgeTakenCount(),getMinusSCEV(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),llvm::vputils::getSCEVExprForVPValue(),getSmallConstantTripMultiple(),llvm::getStartAndEndForAccess(),getTripCountFromExitCount(),isKnownViaInduction(),isLoopBackedgeGuardedByCond(),SolveLinEquationWithOverflow(),SplitIntoInitAndPostInc(), andverify().

◆ getDataLayout()

constDataLayout & llvm::ScalarEvolution::getDataLayout() const
inline

Return theDataLayout associated with the module thisSCEV instance is operating on.

Definition at line1275 of fileScalarEvolution.h.

Referenced bygetEffectiveSCEVType(),getLosslessPtrToIntExpr(),getOffsetOfExpr(),getSizeOfExpr(),getStoreSizeOfExpr(),getTypeSizeInBits(), andllvm::simplifyLoopIVs().

◆ getEffectiveSCEVType()

Type * ScalarEvolution::getEffectiveSCEVType(TypeTy) const

Return a type with the same bitwidth as the given type and which represents howSCEV 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 line4458 of fileScalarEvolution.cpp.

Referencesassert(),getDataLayout(),llvm::DataLayout::getIndexType(),llvm::Type::isIntegerTy(),llvm::Type::isPointerTy(), andisSCEVable().

Referenced byllvm::SCEVAAResult::alias(),canComputePointerDiff(),DoInitialMatch(),findForkedSCEVs(),getAddExpr(),getAddRecExpr(),getAnyExtendExpr(),getConstant(),getElementSize(),getGEPExpr(),getLosslessPtrToIntExpr(),getMinMaxExpr(),getNegativeSCEV(),getNotSCEV(),getSequentialMinMaxExpr(),getSignExtendExpr(),getSignExtendExprImpl(),getTruncateExpr(),getURemExpr(),getZeroExtendExpr(),isExistingPhi(), andvisitIVCast().

◆ getElementCount()

constSCEV * ScalarEvolution::getElementCount(TypeTy,
ElementCount EC 
)

Definition at line506 of fileScalarEvolution.cpp.

ReferencesgetConstant(),getMulExpr(), andgetVScale().

Referenced byllvm::VPlanTransforms::optimizeForVFAndUF().

◆ getElementSize()

constSCEV * ScalarEvolution::getElementSize(InstructionInst)

Return the size of an element read or written by Inst.

Definition at line13595 of fileScalarEvolution.cpp.

Referencesllvm::Value::getContext(),getEffectiveSCEVType(),getSizeOfExpr(), andllvm::PointerType::getUnqual().

◆ getEqualPredicate()

constSCEVPredicate * ScalarEvolution::getEqualPredicate(constSCEVLHS,
constSCEVRHS 
)

Definition at line14730 of fileScalarEvolution.cpp.

ReferencesgetComparePredicate(),llvm::CmpInst::ICMP_EQ,LHS, andRHS.

Referenced byllvm::PredicatedScalarEvolution::areAddRecsEqualWithPreds(),llvm::replaceSymbolicStrideSCEV(), andSolveLinEquationWithOverflow().

◆ getExistingSCEV()

constSCEV * ScalarEvolution::getExistingSCEV(ValueV)

Return an existingSCEV for V if there is one, otherwise return nullptr.

Definition at line4555 of fileScalarEvolution.cpp.

Referencesassert(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find_as(),I, andisSCEVable().

Referenced byforgetBlockAndLoopDispositions(),forgetLcssaPhiWithNewPredecessor(),formLCSSAForInstructionsImpl(), andgetSCEV().

◆ getExitCount()

constSCEV * ScalarEvolution::getExitCount(constLoopL,
constBasicBlockExitingBlock,
ExitCountKind Kind =Exact 
)

Return the number of times the backedge executes before the given exit would be taken; if not exactly computable, returnSCEVCouldNotCompute.

For a single exit loop, this value is equivelent to the result of getBackedgeTakenCount. The loop is guaranteed to exit (viasome exit) before the backedge is executed (ExitCount + 1) times. Note that there is no guarantee aboutwhich exit is taken on the exiting iteration.

Definition at line8314 of fileScalarEvolution.cpp.

ReferencesConstantMaximum,Exact,llvm_unreachable, andSymbolicMaximum.

Referenced byllvm::calculateUpperBound(),expandBounds(),getMinAnalyzeableBackedgeTakenCount(),getNarrowestLatchMaxTakenCountEstimate(),getSmallConstantTripCount(),getSmallConstantTripMultiple(),llvm::hasIterationCountInvariantInParent(),llvm::HardwareLoopInfo::isHardwareLoopCandidate(),mustBeFiniteCountedLoop(),optimizeLoopExitWithUnknownExitCount(),PrintLoopInfo(),llvm::rewriteLoopExitValues(), andllvm::UnrollRuntimeLoopRemainder().

◆ getGEPExpr()

constSCEV * ScalarEvolution::getGEPExpr(GEPOperatorGEP,
constSmallVectorImpl<constSCEV * > & 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 line3736 of fileScalarEvolution.cpp.

Referencesassert(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,GEP,getAddExpr(),getEffectiveSCEVType(),getMulExpr(),getOffsetOfExpr(),getSCEV(),getSizeOfExpr(),getTruncateOrSignExtend(),llvm::SCEV::getType(),llvm::GetElementPtrInst::getTypeAtIndex(),llvm::GEPNoWrapFlags::hasNoUnsignedSignedWrap(),llvm::GEPNoWrapFlags::hasNoUnsignedWrap(),isKnownNonNegative(),llvm::GEPNoWrapFlags::none(),llvm::Offset, andsetFlags().

◆ getLoopDisposition()

ScalarEvolution::LoopDisposition ScalarEvolution::getLoopDisposition(constSCEVS,
constLoopL 
)

Return the "disposition" of the givenSCEV with respect to the given loop.

Definition at line14010 of fileScalarEvolution.cpp.

ReferencesD,LoopVariant, andllvm::reverse().

Referenced byhasComputableLoopEvolution(),llvm::hasIterationCountInvariantInParent(),isLoopInvariant(),llvm::LoopStructure::parseLoopStructure(),print(), andverify().

◆ getLoopInvariantExitCondDuringFirstIterations()

std::optional<ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS,
constLoopL,
constInstructionCtxI,
constSCEVMaxIter 
)

If the result of the predicate LHSPred RHS is loop invariant with respect to L at given Context during at least first MaxIter iterations, return aLoopInvariantPredicate with LHS and RHS being invariants, available at L's entry.

Otherwise, return std::nullopt. The predicate should be the loop's exit condition.

Definition at line11256 of fileScalarEvolution.cpp.

ReferencesgetLoopInvariantExitCondDuringFirstIterationsImpl(),LHS,RHS, andllvm::UMin.

Referenced bycreateReplacement().

◆ getLoopInvariantExitCondDuringFirstIterationsImpl()

std::optional<ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantExitCondDuringFirstIterationsImpl(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS,
constLoopL,
constInstructionCtxI,
constSCEVMaxIter 
)

Definition at line11276 of fileScalarEvolution.cpp.

Referencesllvm::SCEVAddRecExpr::evaluateAtIteration(),llvm::SCEVAddRecExpr::getLoop(),getNegativeSCEV(),getOne(),llvm::SCEVAddRecExpr::getStart(),llvm::SCEVAddRecExpr::getStepRecurrence(),llvm::ICmpInst::getSwappedCmpPredicate(),llvm::SCEV::getType(),llvm::SCEVAddRecExpr::getType(),llvm::CmpInst::ICMP_SLE,llvm::CmpInst::ICMP_ULE,isKnownPredicateAt(),isLoopBackedgeGuardedByCond(),isLoopInvariant(),llvm::ICmpInst::isRelational(),llvm::CmpInst::isSigned(),llvm::Last,LHS,RHS, andstd::swap().

Referenced bygetLoopInvariantExitCondDuringFirstIterations().

◆ getLoopInvariantPredicate()

std::optional<ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantPredicate(ICmpInst::Predicate Pred,
constSCEVLHS,
constSCEVRHS,
constLoopL,
constInstructionCtxI =nullptr 
)

If the result of the predicate LHSPred RHS is loop invariant with respect to L, return aLoopInvariantPredicate with LHS and RHS being invariants, available at L's entry.

Otherwise, return std::nullopt.

Definition at line11170 of fileScalarEvolution.cpp.

Referencesassert(),llvm::ICmpInst::getFlippedSignednessPredicate(),llvm::CmpInst::getInversePredicate(),llvm::SCEVAddRecExpr::getLoop(),getMonotonicPredicateType(),llvm::SCEVAddRecExpr::getStart(),llvm::SCEVAddRecExpr::getStepRecurrence(),llvm::CmpInst::getSwappedPredicate(),llvm::SCEVNAryExpr::hasNoSignedWrap(),llvm::SCEVNAryExpr::hasNoUnsignedWrap(),llvm::CmpInst::ICMP_ULE,llvm::CmpInst::ICMP_ULT,llvm::SCEVAddRecExpr::isAffine(),isKnownNonNegative(),isKnownPositive(),isKnownPredicateAt(),isLoopBackedgeGuardedByCond(),isLoopInvariant(),LHS,MonotonicallyIncreasing,P,RHS, andstd::swap().

◆ getLosslessPtrToIntExpr()

constSCEV * ScalarEvolution::getLosslessPtrToIntExpr(constSCEVOp,
unsigned Depth =0 
)

The SCEVPtrToIntSinkingRewriter takes a scalar evolution expression, which computes a pointer-typed value, and rewrites the whole expression tree so thatall the computations are done on integers, and the only pointer-typed operands in the expression areSCEVUnknown.

Definition at line1016 of fileScalarEvolution.cpp.

Referencesassert(),llvm::sampleprof::Base,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(),llvm::SCEVNAryExpr::operands(),Operands,registerUser(),Rewriter,llvm::scPtrToInt, andvisit().

Referenced bygetLosslessPtrToIntExpr(), andgetPtrToIntExpr().

◆ getMinMaxExpr()

constSCEV * ScalarEvolution::getMinMaxExpr(SCEVTypes Kind,
SmallVectorImpl<constSCEV * > & Operands 
)

Definition at line3828 of fileScalarEvolution.cpp.

Referencesllvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(),llvm::append_range(),assert(),llvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::CallingConv::C,constantFoldAndGroupOps(),llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorTemplateCommon< T, typename >::end(),llvm::SmallVectorImpl< T >::erase(),getEffectiveSCEVType(),getMinMaxExpr(),getType(),llvm::CmpInst::ICMP_SGE,llvm::CmpInst::ICMP_SLE,llvm::CmpInst::ICMP_UGE,llvm::CmpInst::ICMP_ULE,Idx,llvm::isPointerTy(),llvm_unreachable,llvm::SCEVNAryExpr::operands(),registerUser(),llvm::scSMaxExpr,llvm::scSMinExpr,llvm::scUMaxExpr,llvm::scUMinExpr,llvm::SmallVectorBase< Size_T >::size(),llvm::APIntOps::smax(),llvm::APIntOps::smin(),llvm::APIntOps::umax(), andllvm::APIntOps::umin().

Referenced bygetMinMaxExpr(),getNotSCEV(),getSequentialMinMaxExpr(),getSMaxExpr(),getSMinExpr(),getUMaxExpr(), andgetUMinExpr().

◆ getMinTrailingZeros()

uint32_t ScalarEvolution::getMinTrailingZeros(constSCEVS)

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 line6411 of fileScalarEvolution.cpp.

ReferencesgetConstantMultiple(),llvm::SCEV::getType(), andgetTypeSizeInBits().

Referenced byextractConstantWithoutWrapping(),getTruncateExpr(), andSolveLinEquationWithOverflow().

◆ getMinusOne()

constSCEV * llvm::ScalarEvolution::getMinusOne(TypeTy)
inline

Return aSCEV for the constant -1 of a specific type.

Definition at line665 of fileScalarEvolution.h.

ReferencesgetConstant().

Referenced byllvm::LoopVectorizationCostModel::computeMaxVF(),createReplacement(),getNegativeSCEV(),getNotSCEV(), andgetTripCountFromExitCount().

◆ getMinusSCEV()

constSCEV * ScalarEvolution::getMinusSCEV(constSCEVLHS,
constSCEVRHS,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)

Return LHS-RHS.

Minus is represented inSCEV as A+B*-1.

If the LHS and RHS are pointers which don't share a common base (according togetPointerBase()), this returns aSCEVCouldNotCompute. To compute the difference between two unrelated pointers, you can explicitly convert the arguments usinggetPtrToIntExpr(), for pointer types that support it.

Definition at line4655 of fileScalarEvolution.cpp.

Referencesllvm::Depth,llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,getAddExpr(),getCouldNotCompute(),getNegativeSCEV(),getPointerBase(),getSignedRangeMin(),llvm::Value::getType(),getZero(),hasFlags(),isKnownNonNegative(),llvm::APInt::isMinSignedValue(),llvm::Type::isPointerTy(),LHS,removePointerBase(), andRHS.

Referenced byllvm::SCEVAAResult::alias(),llvm::InterleavedAccessInfo::analyzeInterleaving(),BinomialCoefficient(),calculateRtStride(),calculateSubRanges(),canBeCheaplyTransformed(),createNodeForSelectViaUMinSeq(),createReplacement(),findForkedSCEVs(),getNewAlignment(),getNotSCEV(),getStartForNegStride(),getUDivCeilSCEV(),getURemExpr(),llvm::IndexedReference::hasSpacialReuse(),llvm::isDereferenceableAndAlignedInLoop(),isSafeDecreasingBound(),isSafeDependenceDistance(),isSafeIncreasingBound(),llvm::LoopStructure::parseLoopStructure(),verify(),llvm::SCEVDivision::visitMulExpr(), andwillNotOverflow().

◆ getMonotonicPredicateType()

std::optional<ScalarEvolution::MonotonicPredicateType > ScalarEvolution::getMonotonicPredicateType(constSCEVAddRecExprLHS,
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 std::nullopt.

Definition at line11107 of fileScalarEvolution.cpp.

Referencesassert(),llvm::CmpInst::getSwappedPredicate(), andLHS.

Referenced bycountToEliminateCompares(),getLoopInvariantPredicate(), andisSafeToTruncateWideIVType().

◆ getMulExpr()[1/3]

constSCEV * llvm::ScalarEvolution::getMulExpr(constSCEVLHS,
constSCEVRHS,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)
inline

Definition at line595 of fileScalarEvolution.h.

Referencesllvm::Depth,getMulExpr(),LHS, andRHS.

◆ getMulExpr()[2/3]

constSCEV * llvm::ScalarEvolution::getMulExpr(constSCEVOp0,
constSCEVOp1,
constSCEVOp2,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)
inline

Definition at line601 of fileScalarEvolution.h.

Referencesllvm::Depth, andgetMulExpr().

◆ getMulExpr()[3/3]

constSCEV * ScalarEvolution::getMulExpr(SmallVectorImpl<constSCEV * > & Ops,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap,
unsigned Depth =0 
)

Get a canonical multiply expression, or something simpler if possible.

Definition at line3106 of fileScalarEvolution.cpp.

Referencesllvm::Add,llvm::append_range(),assert(),llvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::CallingConv::C,Choose(),clearFlags(),constantFoldAndGroupOps(),llvm::ConstantRange::contains(),containsConstantInAddMulChain(),llvm::Depth,llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorImpl< T >::erase(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,llvm::SCEV::FlagNW,getAddExpr(),getAddRecExpr(),getConstant(),llvm::SCEVAddRecExpr::getLoop(),getMulExpr(),llvm::SCEVNAryExpr::getNoWrapFlags(),llvm::SCEVNAryExpr::getNumOperands(),llvm::SCEVNAryExpr::getOperand(),llvm::APInt::getSignedMinValue(),getSignedRange(),getSignedRangeMin(),llvm::SCEVAddRecExpr::getType(),getType(),getTypeSizeInBits(),getZero(),hasFlags(),hasHugeExpression(),Idx,isAvailableAtLoopEntry(),llvm::Type::isPointerTy(),LHS,llvm::ConstantRange::makeGuaranteedNoWrapRegion(),maskFlags(),MaxAddRecSize,MaxArithDepth,llvm::Mul,MulOpsInlineThreshold,llvm::OverflowingBinaryOperator::NoSignedWrap,llvm::SCEV::operands(),Operands,llvm::SmallVectorTemplateBase< T, bool >::push_back(),llvm::SmallVectorImpl< T >::reserve(),RHS,llvm::scAddRecExpr,llvm::scMulExpr,setFlags(),llvm::SmallVectorBase< Size_T >::size(),StrengthenNoWrapFlags(), andumul_ov().

Referenced byBinomialCoefficient(),calculateRtStride(),CollectAddOperandsWithScales(),CollectSubexprs(),llvm::IndexedReference::computeRefCost(),DoInitialMatch(),llvm::SCEVAddRecExpr::evaluateAtIteration(),findArrayDimensionsRec(),findForkedSCEVs(),getAddExpr(),getElementCount(),getExactSDiv(),getGEPExpr(),getLosslessPtrToIntExpr(),getMulExpr(),getNegativeSCEV(),getNumBytes(),getSignExtendExprImpl(),getSizeOfExpr(),getStartForNegStride(),getTruncateExpr(),getUDivExactExpr(),getUDivExpr(),getURemExpr(),getZeroExtendExprImpl(),isSafeDependenceDistance(),removeConstantFactors(),llvm::ScalarEvolution::LoopGuards::rewrite(),SolveLinEquationWithOverflow(),llvm::SCEVRewriteVisitor< SC >::visitMulExpr(),llvm::SCEVDivision::visitMulExpr(), andwillNotOverflow().

◆ getNegativeSCEV()

constSCEV * ScalarEvolution::getNegativeSCEV(constSCEVV,
SCEV::NoWrapFlags Flags =SCEV::FlagAnyWrap 
)

Return theSCEV object corresponding to -V.

Return aSCEV corresponding to -V = -1*V.

Definition at line4569 of fileScalarEvolution.cpp.

ReferencesgetConstant(),getEffectiveSCEVType(),getMinusOne(),getMulExpr(), andllvm::ConstantExpr::getNeg().

Referenced bydetectShiftUntilZeroIdiom(),llvm::SCEVExpander::generateOverflowCheck(),getAbsExpr(),getLoopInvariantExitCondDuringFirstIterationsImpl(),getMinusSCEV(),isOneDimensionalArray(),isSafeDependenceDistance(),llvm::FullDependence::normalize(), andllvm::LoopStructure::parseLoopStructure().

◆ getNonZeroConstantMultiple()

APInt ScalarEvolution::getNonZeroConstantMultiple(constSCEVS)

Definition at line6406 of fileScalarEvolution.cpp.

Referencesllvm::APInt::getBitWidth(), andgetConstantMultiple().

Referenced bygetSmallConstantTripMultiple().

◆ getNoopOrAnyExtend()

constSCEV * ScalarEvolution::getNoopOrAnyExtend(constSCEVV,
TypeTy 
)

Return aSCEV 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 line4754 of fileScalarEvolution.cpp.

Referencesassert(),getAnyExtendExpr(),getTypeSizeInBits(), andllvm::Type::isIntOrPtrTy().

Referenced byllvm::IndexedReference::computeRefCost().

◆ getNoopOrSignExtend()

constSCEV * ScalarEvolution::getNoopOrSignExtend(constSCEVV,
TypeTy 
)

Return aSCEV 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 line4742 of fileScalarEvolution.cpp.

Referencesassert(),getSignExtendExpr(),getTypeSizeInBits(), andllvm::Type::isIntOrPtrTy().

Referenced bygetNewAlignment(),llvm::SCEVWrapPredicate::implies(),isSafeDependenceDistance(), andNoopOrExtend().

◆ getNoopOrZeroExtend()

constSCEV * ScalarEvolution::getNoopOrZeroExtend(constSCEVV,
TypeTy 
)

Return aSCEV 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 line4730 of fileScalarEvolution.cpp.

Referencesassert(),getTypeSizeInBits(),getZeroExtendExpr(), andllvm::Type::isIntOrPtrTy().

Referenced byllvm::IndexedReference::computeRefCost(),getUMaxFromMismatchedTypes(),getUMinFromMismatchedTypes(),llvm::SCEVWrapPredicate::implies(),NoopOrExtend(), andoptimizeLoopExitWithUnknownExitCount().

◆ getNotSCEV()

constSCEV * ScalarEvolution::getNotSCEV(constSCEVV)

Return theSCEV object corresponding to ~V.

Return aSCEV corresponding to ~V = -1-V.

Definition at line4596 of fileScalarEvolution.cpp.

Referencesassert(),getConstant(),getEffectiveSCEVType(),getMinMaxExpr(),getMinusOne(),getMinusSCEV(),llvm::ConstantExpr::getNot(),MatchNotExpr(),llvm::SCEVMinMaxExpr::negate(),llvm::SCEV::operands(), andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced bycreateNodeForSelectViaUMinSeq().

◆ getOffsetOfExpr()

constSCEV * ScalarEvolution::getOffsetOfExpr(TypeIntTy,
StructTypeSTy,
unsigned FieldNo 
)

Return an expression for offsetof on the given field with type IntTy.

Definition at line4399 of fileScalarEvolution.cpp.

Referencesassert(),getConstant(),getDataLayout(),llvm::StructLayout::getElementOffset(),llvm::StructLayout::getSizeInBits(),llvm::DataLayout::getStructLayout(), andllvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable().

Referenced bygetGEPExpr().

◆ getOne()

constSCEV * llvm::ScalarEvolution::getOne(TypeTy)
inline

Return aSCEV for the constant 1 of a specific type.

Definition at line656 of fileScalarEvolution.h.

ReferencesgetConstant().

Referenced bycalculateSubRanges(),llvm::calculateUpperBound(),llvm::LoopVectorizationCostModel::computeMaxVF(),createReplacement(),getAddExpr(),getLoopInvariantExitCondDuringFirstIterationsImpl(),getTripCountFromExitCount(),getUDivCeilSCEV(),llvm::ARMTTIImpl::isHardwareLoopProfitable(),isLoopBackedgeGuardedByCond(),isSafeDecreasingBound(),isSafeIncreasingBound(),llvm::LoopStructure::parseLoopStructure(), andllvm::replaceSymbolicStrideSCEV().

◆ getPointerBase()

constSCEV * ScalarEvolution::getPointerBase(constSCEVV)

Transitively follow the chain of pointer-type operands until reaching aSCEV that does not have a single pointer operand.

This returns aSCEVUnknown pointer for well-formed pointer-type expressions, but corner cases do exist.

Definition at line4823 of fileScalarEvolution.cpp.

Referencesllvm::Add, andassert().

Referenced byllvm::DependenceInfo::depends(),getMinusSCEV(), andllvm::tryDelinearizeFixedSizeImpl().

◆ getPoisonGeneratingValues()

void ScalarEvolution::getPoisonGeneratingValues(SmallPtrSetImpl<constValue * > & Result,
constSCEVS 
)

Return the set of Values that, if poison, will definitively result in S being poison as well.

The returned set may be incomplete, i.e. there can be additional Values that also result in S being poison.

Definition at line4160 of fileScalarEvolution.cpp.

Referencesllvm::SCEVUnknown::getValue(), andllvm::visitAll().

Referenced bycanReuseInstruction().

◆ getPowerOfTwo()

constSCEV * llvm::ScalarEvolution::getPowerOfTwo(TypeTy,
unsigned Power 
)
inline

Return aSCEV for the constantPower of two.

Definition at line659 of fileScalarEvolution.h.

Referencesassert(),getConstant(),llvm::APInt::getOneBitSet(), andgetTypeSizeInBits().

◆ getPredicatedBackedgeTakenCount()

constSCEV * ScalarEvolution::getPredicatedBackedgeTakenCount(constLoopL,
SmallVectorImpl<constSCEVPredicate * > & Predicates 
)

Similar to getBackedgeTakenCount, except it will add a set ofSCEV 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 line8345 of fileScalarEvolution.cpp.

Referenced byllvm::PredicatedScalarEvolution::getBackedgeTakenCount(), andPrintLoopInfo().

◆ getPredicatedConstantMaxBackedgeTakenCount()

constSCEV * ScalarEvolution::getPredicatedConstantMaxBackedgeTakenCount(constLoopL,
SmallVectorImpl<constSCEVPredicate * > & Predicates 
)

Similar to getConstantMaxBackedgeTakenCount, except it will add a set ofSCEV 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 line8368 of fileScalarEvolution.cpp.

Referenced bygetSmallConstantMaxTripCount(),llvm::isDereferenceableAndAlignedInLoop(), andPrintLoopInfo().

◆ getPredicatedExitCount()

constSCEV * ScalarEvolution::getPredicatedExitCount(constLoopL,
constBasicBlockExitingBlock,
SmallVectorImpl<constSCEVPredicate * > * Predicates,
ExitCountKind Kind =Exact 
)

Same as above except this uses the predicated backedge taken info and may require predicates.

Definition at line8328 of fileScalarEvolution.cpp.

ReferencesConstantMaximum,Exact,llvm_unreachable, andSymbolicMaximum.

Referenced byPrintLoopInfo().

◆ getPredicatedSymbolicMaxBackedgeTakenCount()

constSCEV * ScalarEvolution::getPredicatedSymbolicMaxBackedgeTakenCount(constLoopL,
SmallVectorImpl<constSCEVPredicate * > & Predicates 
)

Similar to getSymbolicMaxBackedgeTakenCount, except it will add a set ofSCEV 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 line8363 of fileScalarEvolution.cpp.

Referenced byllvm::SCEVExpander::generateOverflowCheck(),llvm::PredicatedScalarEvolution::getSymbolicMaxBackedgeTakenCount(), andPrintLoopInfo().

◆ getPtrToIntExpr()

constSCEV * ScalarEvolution::getPtrToIntExpr(constSCEVOp,
TypeTy 
)

Definition at line1140 of fileScalarEvolution.cpp.

Referencesassert(),getLosslessPtrToIntExpr(),getTruncateOrZeroExtend(), andllvm::Type::isIntegerTy().

Referenced byllvm::SCEVAAResult::alias(),getCastExpr(), andllvm::SCEVRewriteVisitor< SC >::visitPtrToIntExpr().

◆ getSCEV()

constSCEV * ScalarEvolution::getSCEV(ValueV)

Return aSCEV expression for the full generality of the specified expression.

Return an existingSCEV if it exists, otherwise analyze the expression and create a new one.

Definition at line4547 of fileScalarEvolution.cpp.

Referencesassert(),getExistingSCEV(), andisSCEVable().

Referenced byllvm::RecurrenceDescriptor::AddReductionVar(),llvm::IVUsers::AddUsersIfInteresting(),llvm::SCEVAAResult::alias(),llvm::analyzeICmp(),calculateRtStride(),calculateSubRanges(),canFoldTermCondOfLoop(),canOverlap(),canTailPredicateLoop(),countToEliminateCompares(),createNodeForSelectViaUMinSeq(),DbgGatherSalvagableDVI(),DbgRewriteSalvageableDVIs(),llvm::DependenceInfo::depends(),detectShiftUntilZeroIdiom(),DoInitialMatch(),llvm::InnerLoopVectorizer::emitIterationCountCheck(),llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(),findForkedSCEVs(),llvm::findHistogram(),findIVOperand(),FindLoopCounter(),formLCSSAForInstructionsImpl(),genLoopLimit(),getAddressAccessSCEV(),getAppleRuntimeUnrollPreferences(),llvm::PredicatedScalarEvolution::getAsAddRec(),llvm::Loop::LoopBounds::getBounds(),getBoundsCheckCond(),getFalkorUnrollingPreferences(),getGEPExpr(),llvm::getIndexExpressionsFromGEP(),GetInductionVariable(),llvm::LoopVectorizationCostModel::getInstructionCost(),getNewAlignment(),llvm::getPointersDiff(),llvm::IVUsers::getReplacementExpr(),llvm::PredicatedScalarEvolution::getSCEV(),getSCEVAtScope(),llvm::vputils::getSCEVExprForVPValue(),llvm::DependenceInfo::getSplitIteration(),getStrengthenedNoWrapFlagsFromBinOp(),getStrideFromPointer(),llvm::SCEVExpander::hasRelatedExistingExpansion(),llvm::isDereferenceableAndAlignedInLoop(),isExistingPhi(),llvm::RecurrenceDescriptor::isFindLastIVPattern(),isHighCostExpansion(),llvm::InductionDescriptor::isInductionPHI(),llvm::LoopAccessInfo::isInvariant(),llvm::LoopVectorizationLegality::isInvariantAddressOfReduction(),isLoopCounter(),isProfitableChain(),isSimpleIVUser(),llvm::LoopVectorizationLegality::isUniform(),loadCSE(),llvm::LoopStructure::parseLoopStructure(),print(),llvm::PredicatedScalarEvolution::print(),llvm::AlignmentFromAssumptionsPass::processAssumption(),llvm::SCEVExpander::replaceCongruentIVs(),llvm::rewriteLoopExitValues(),llvm::LoopVectorizationCostModel::setVectorizedCallDecision(),llvm::splitLoopBound(),llvm::storeToSameAddress(),stripGetElementPtr(),verify(), andverifyTripCount().

◆ getSCEVAtScope()[1/2]

constSCEV * ScalarEvolution::getSCEVAtScope(constSCEVS,
constLoopL 
)

Return aSCEV 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 line9856 of fileScalarEvolution.cpp.

Referencesllvm::CallingConv::C,llvm::SmallVectorImpl< T >::emplace_back(), andllvm::reverse().

Referenced bycomputeUnrollAndJamCount(),createReplacement(),getSCEVAtScope(),isInteresting(),print(), andllvm::rewriteLoopExitValues().

◆ getSCEVAtScope()[2/2]

constSCEV * ScalarEvolution::getSCEVAtScope(ValueV,
constLoopL 
)

This is a convenience function which does getSCEVAtScope(getSCEV(V), L).

Definition at line10178 of fileScalarEvolution.cpp.

ReferencesgetSCEV(), andgetSCEVAtScope().

◆ getSequentialMinMaxExpr()

constSCEV * ScalarEvolution::getSequentialMinMaxExpr(SCEVTypes Kind,
SmallVectorImpl<constSCEV * > & Operands 
)

Definition at line4231 of fileScalarEvolution.cpp.

Referencesllvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(),assert(),llvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::SmallVectorBase< Size_T >::empty(),llvm::SmallVectorTemplateCommon< T, typename >::end(),llvm::SmallVectorImpl< T >::erase(),getEffectiveSCEVType(),llvm::SCEVSequentialMinMaxExpr::getEquivalentNonSequentialSCEVType(),getMinMaxExpr(),getSequentialMinMaxExpr(),getType(),getZero(),llvm::CmpInst::ICMP_NE,llvm::CmpInst::ICMP_ULE,Idx,llvm::impliesPoison(),llvm::SmallVectorImpl< T >::insert(),llvm::isPointerTy(),llvm_unreachable,registerUser(),llvm::scSequentialUMinExpr, andllvm::SmallVectorBase< Size_T >::size().

Referenced bygetSequentialMinMaxExpr(), andgetUMinExpr().

◆ getSignedRange()

ConstantRange llvm::ScalarEvolution::getSignedRange(constSCEVS)
inline

Determine the signed range for a particularSCEV.

NOTE: This returns a copy of the reference returned by getRangeRef.

Definition at line1013 of fileScalarEvolution.h.

Referenced bygetMulExpr(),getSignExtendExprImpl(),llvm::RecurrenceDescriptor::isFindLastIVPattern(),print(), andStrengthenNoWrapFlags().

◆ getSignedRangeMax()

APInt llvm::ScalarEvolution::getSignedRangeMax(constSCEVS)
inline

Determine the max of the signed range for a particularSCEV.

Definition at line1023 of fileScalarEvolution.h.

Referencesllvm::ConstantRange::getSignedMax().

Referenced bygetSignedOverflowLimitForStep(),isKnownNegative(),isKnownNonPositive(), andSimplifyICmpOperands().

◆ getSignedRangeMin()

APInt llvm::ScalarEvolution::getSignedRangeMin(constSCEVS)
inline

Determine the min of the signed range for a particularSCEV.

Definition at line1018 of fileScalarEvolution.h.

Referencesllvm::ConstantRange::getSignedMin().

Referenced bygetMinusSCEV(),getMulExpr(),getSignedOverflowLimitForStep(),getZeroExtendExprImpl(),isKnownNonNegative(),isKnownPositive(), andSimplifyICmpOperands().

◆ getSignExtendExpr()

constSCEV * ScalarEvolution::getSignExtendExpr(constSCEVOp,
TypeTy,
unsigned Depth =0 
)

Definition at line1900 of fileScalarEvolution.cpp.

Referencesassert(),llvm::Depth,getEffectiveSCEVType(),getSignExtendExprImpl(),getTypeSizeInBits(),insertFoldCacheEntry(),isSCEVable(), andllvm::scSignExtend.

Referenced bygetAnyExtendExpr(),getCastExpr(),getNoopOrSignExtend(),getSignExtendExprImpl(),getTruncateOrSignExtend(),getZeroExtendExprImpl(),isAddRecSExtable(),isAddSExtable(),IsIncrementNSW(),isMulSExtable(),llvm::LoopStructure::parseLoopStructure(),llvm::SCEVRewriteVisitor< SC >::visitSignExtendExpr(), andwillNotOverflow().

◆ getSignExtendExprImpl()

constSCEV * ScalarEvolution::getSignExtendExprImpl(constSCEVOp,
TypeTy,
unsigned Depth =0 
)

Definition at line1919 of fileScalarEvolution.cpp.

Referencesassert(),llvm::BitWidth,llvm::CallingConv::C,llvm::ConstantRange::contains(),D,llvm::Depth,extractConstantWithoutWrapping(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,llvm::SCEV::FlagNW,llvm::IntegerType::get(),getAddExpr(),getAddRecExpr(),getConstant(),getConstantMaxBackedgeTakenCount(),getContext(),getEffectiveSCEVType(),getMulExpr(),getSignedRange(),getSignExtendExpr(),getSMaxExpr(),getSMinExpr(),getTruncateOrSignExtend(),getTruncateOrZeroExtend(),llvm::SCEV::getType(),getTypeSizeInBits(),getZeroExtendExpr(),isKnownNonNegative(),isSCEVable(),MaxCastDepth,Operands,llvm::SmallVectorTemplateBase< T, bool >::push_back(),registerUser(),llvm::scSignExtend,setNoWrapFlags(),llvm::ConstantRange::sextOrTrunc(),llvm::ConstantRange::signExtend(),llvm::ConstantRange::truncate(), andX.

Referenced bygetSignExtendExpr().

◆ getSizeOfExpr()[1/2]

constSCEV * ScalarEvolution::getSizeOfExpr(TypeIntTy,
TypeAllocTy 
)

Return an expression for the alloc size of AllocTy that is type IntTy.

Definition at line4391 of fileScalarEvolution.cpp.

ReferencesgetDataLayout(), andgetSizeOfExpr().

◆ getSizeOfExpr()[2/2]

constSCEV * ScalarEvolution::getSizeOfExpr(TypeIntTy,
TypeSize Size 
)

Return an expression for aTypeSize.

Definition at line4384 of fileScalarEvolution.cpp.

ReferencesgetConstant(),getMulExpr(),getVScale(), andSize.

Referenced byfindForkedSCEVs(),getElementSize(),getGEPExpr(),getSizeOfExpr(), andgetStoreSizeOfExpr().

◆ getSmallConstantMaxTripCount()

unsigned ScalarEvolution::getSmallConstantMaxTripCount(constLoopL,
SmallVectorImpl<constSCEVPredicate * > * Predicates =nullptr 
)

Returns the upper bound of the loop trip count as a normal unsigned value.

Returns 0 if the trip count is unknown, not constant or requiresSCEV predicates andPredicates is nullptr.

Definition at line8253 of fileScalarEvolution.cpp.

ReferencesgetConstantMaxBackedgeTakenCount(),getConstantTripCount(), andgetPredicatedConstantMaxBackedgeTakenCount().

Referenced bycanFoldTermCondOfLoop(),getAppleRuntimeUnrollPreferences(),llvm::HexagonTTIImpl::getPeelingPreferences(),llvm::PredicatedScalarEvolution::getSmallConstantMaxTripCount(),tryToUnrollLoop(), andllvm::UnrollLoop().

◆ getSmallConstantTripCount()[1/2]

unsigned ScalarEvolution::getSmallConstantTripCount(constLoopL)

Returns the exact trip count of the loop if we can compute it, and the result is a small constant.

'0' is used to represent an unknown or non-constant trip count. Note that a trip count is simply one more than the backedge taken count for the loop.

Definition at line8237 of fileScalarEvolution.cpp.

ReferencesExact,getBackedgeTakenCount(), andgetConstantTripCount().

Referenced byllvm::CacheCost::CacheCost(),llvm::LoopVectorizationCostModel::computeMaxVF(),llvm::LoopVectorizationCostModel::expectedCost(),llvm::HexagonTTIImpl::getPeelingPreferences(),getSmallBestKnownTC(),llvm::PPCTTIImpl::isHardwareLoopProfitable(),llvm::LoopVectorizationCostModel::selectInterleaveCount(),tryToUnrollAndJamLoop(),tryToUnrollLoop(), andllvm::UnrollLoop().

◆ getSmallConstantTripCount()[2/2]

unsigned ScalarEvolution::getSmallConstantTripCount(constLoopL,
constBasicBlockExitingBlock 
)

Return the exact trip count for this loop if we exit through ExitingBlock.

'0' is used to represent an unknown or non-constant trip count. Note that a trip count is simply one more than the backedge taken count for the same exit. This "trip count" assumes that control exits via ExitingBlock. More precisely, it is the number of times that control will 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 line8243 of fileScalarEvolution.cpp.

Referencesassert(),getConstantTripCount(), andgetExitCount().

◆ getSmallConstantTripMultiple()[1/3]

unsigned ScalarEvolution::getSmallConstantTripMultiple(constLoopL)

Returns the largest constant divisor of the trip count of the loop.

Will return 1 if no trip count could be computed, or if a divisor could not be found.

Definition at line8262 of fileScalarEvolution.cpp.

ReferencesgetSmallConstantTripMultiple().

◆ getSmallConstantTripMultiple()[2/3]

unsigned ScalarEvolution::getSmallConstantTripMultiple(constLoopL,
constBasicBlockExitingBlock 
)

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 line8305 of fileScalarEvolution.cpp.

Referencesassert(),getExitCount(), andgetSmallConstantTripMultiple().

◆ getSmallConstantTripMultiple()[3/3]

unsigned ScalarEvolution::getSmallConstantTripMultiple(constLoopL,
constSCEVExitCount 
)

Returns the largest constant divisor of the trip count as a normal unsigned value, if possible.

This means that the actual trip count is always a multiple of the returned value. Returns 1 if the trip count is unknown or not guaranteed to be the multiple of a constant., Will also return 1 if the trip count is very large (>= 2^32). Note that the argument is an exit count for loop L, NOT a trip count.

Definition at line8276 of fileScalarEvolution.cpp.

ReferencesapplyLoopGuards(),llvm::APInt::countTrailingZeros(),llvm::APInt::getActiveBits(),getCouldNotCompute(),getNonZeroConstantMultiple(),getTripCountFromExitCount(),llvm::APInt::getZExtValue(), andllvm::APInt::zextOrTrunc().

Referenced bygetSmallConstantTripMultiple(),PrintLoopInfo(),tryToUnrollAndJamLoop(),tryToUnrollLoop(), andllvm::UnrollLoop().

◆ getSMaxExpr()[1/2]

constSCEV * ScalarEvolution::getSMaxExpr(constSCEVLHS,
constSCEVRHS 
)

Definition at line4343 of fileScalarEvolution.cpp.

ReferencesgetSMaxExpr(),LHS, andRHS.

Referenced bycalculateSubRanges(),getAbsExpr(),getSignExtendExprImpl(),getSMaxExpr(),IntersectSignedRange(), andllvm::SCEVRewriteVisitor< SC >::visitSMaxExpr().

◆ getSMaxExpr()[2/2]

constSCEV * ScalarEvolution::getSMaxExpr(SmallVectorImpl<constSCEV * > & Operands)

Definition at line4348 of fileScalarEvolution.cpp.

ReferencesgetMinMaxExpr(), andllvm::scSMaxExpr.

◆ getSMinExpr()[1/2]

constSCEV * ScalarEvolution::getSMinExpr(constSCEVLHS,
constSCEVRHS 
)

Definition at line4361 of fileScalarEvolution.cpp.

ReferencesgetSMinExpr(),LHS, andRHS.

Referenced bycalculateSubRanges(),getSignExtendExprImpl(),getSMinExpr(),IntersectSignedRange(),llvm::splitLoopBound(), andllvm::SCEVRewriteVisitor< SC >::visitSMinExpr().

◆ getSMinExpr()[2/2]

constSCEV * ScalarEvolution::getSMinExpr(SmallVectorImpl<constSCEV * > & Operands)

Definition at line4367 of fileScalarEvolution.cpp.

ReferencesgetMinMaxExpr(), andllvm::scSMinExpr.

◆ getStoreSizeOfExpr()

constSCEV * ScalarEvolution::getStoreSizeOfExpr(TypeIntTy,
TypeStoreTy 
)

Return an expression for the store size of StoreTy that is type IntTy.

Definition at line4395 of fileScalarEvolution.cpp.

ReferencesgetDataLayout(), andgetSizeOfExpr().

Referenced byllvm::getStartAndEndForAccess().

◆ getStrengthenedNoWrapFlagsFromBinOp()

std::optional<SCEV::NoWrapFlags > ScalarEvolution::getStrengthenedNoWrapFlagsFromBinOp(constOverflowingBinaryOperatorOBO)

Parse NSW/NUW flags from add/sub/mul IR binary operationOp intoSCEV no-wrap flags, and deduce flag[s] that aren't known yet.

Does not mutate the original instruction. Returns std::nullopt if it could not deduce more precise flags than the instruction already has, otherwise returns proven flags.

Definition at line2391 of fileScalarEvolution.cpp.

Referencesllvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,llvm::Operator::getOpcode(),llvm::User::getOperand(),getSCEV(),llvm::OverflowingBinaryOperator::hasNoSignedWrap(),llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(),LHS,RHS,setFlags(),UseContextForNoWrapFlagInference, andwillNotOverflow().

Referenced byllvm::SCEVExpander::hoistIVInc().

◆ getSymbolicMaxBackedgeTakenCount()

constSCEV * llvm::ScalarEvolution::getSymbolicMaxBackedgeTakenCount(constLoopL)
inline

When successful, this returns aSCEV 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 theSCEVCouldNotCompute object.

Definition at line922 of fileScalarEvolution.h.

ReferencesgetBackedgeTakenCount(), andSymbolicMaximum.

Referenced bygetNarrowestLatchMaxTakenCountEstimate(), andPrintLoopInfo().

◆ getTripCountFromExitCount()[1/2]

constSCEV * ScalarEvolution::getTripCountFromExitCount(constSCEVExitCount)

A version of getTripCountFromExitCount below which always picks an evaluation type which can not result in overflow.

Definition at line8182 of fileScalarEvolution.cpp.

Referencesassert(),getCouldNotCompute(),llvm::Type::getIntNTy(),getTripCountFromExitCount(), andllvm::SCEV::getType().

Referenced bycomputeTripCount(),llvm::VPlan::createInitialVPlan(),getNumBytes(),getSmallConstantTripMultiple(),getTripCountFromExitCount(), andverifyTripCount().

◆ getTripCountFromExitCount()[2/2]

constSCEV * ScalarEvolution::getTripCountFromExitCount(constSCEVExitCount,
TypeEvalTy,
constLoopL 
)

Convert from an "exit count" (i.e.

"backedge taken count") to a "tripcount". A "trip count" is the number of times the header of the loop will execute if an exit is taken after the specified number of backedges have been taken. (e.g. TripCount = ExitCount + 1). Note that the expression can overflow if ExitCount = UINT_MAX. If EvalTy is not wide enough to hold the result without overflow, result unsigned wraps with 2s-complement semantics. ex: EC = 255 (i8), TC = 0 (i8)

Definition at line8193 of fileScalarEvolution.cpp.

Referencesllvm::ConstantRange::contains(),getAddExpr(),getCouldNotCompute(),llvm::APInt::getMaxValue(),getMinusOne(),getOne(),llvm::Type::getPrimitiveSizeInBits(),getTruncateOrZeroExtend(),llvm::SCEV::getType(),getTypeSizeInBits(),getZeroExtendExpr(),llvm::CmpInst::ICMP_NE, andisLoopEntryGuardedByCond().

◆ getTruncateExpr()

constSCEV * ScalarEvolution::getTruncateExpr(constSCEVOp,
TypeTy,
unsigned Depth =0 
)

Definition at line1150 of fileScalarEvolution.cpp.

Referencesassert(),llvm::Depth,llvm::SCEV::FlagAnyWrap,getAddExpr(),getAddRecExpr(),getConstant(),getEffectiveSCEVType(),getMinTrailingZeros(),getMulExpr(),llvm::ConstantExpr::getTrunc(),getTruncateExpr(),getTruncateOrSignExtend(),getTruncateOrZeroExtend(),getTypeSizeInBits(),getZero(),isSCEVable(),llvm_unreachable,MaxCastDepth,Operands,registerUser(), andllvm::scTruncate.

Referenced bycreateReplacement(),generateLoopLatchCheck(),genLoopLimit(),getAddExpr(),getCastExpr(),getTruncateExpr(),getTruncateOrNoop(),getTruncateOrSignExtend(),getTruncateOrZeroExtend(),getURemExpr(),getZeroExtendExprImpl(),llvm::SCEVExpander::replaceCongruentIVs(), andllvm::SCEVRewriteVisitor< SC >::visitTruncateExpr().

◆ getTruncateOrNoop()

constSCEV * ScalarEvolution::getTruncateOrNoop(constSCEVV,
TypeTy 
)

Return aSCEV corresponding to a conversion of the input value to the specified type.

The conversion must not be widening.

Definition at line4766 of fileScalarEvolution.cpp.

Referencesassert(),getTruncateExpr(),getTypeSizeInBits(), andllvm::Type::isIntOrPtrTy().

Referenced bycanBeCheaplyTransformed(), andgetAnyExtendExpr().

◆ getTruncateOrSignExtend()

constSCEV * ScalarEvolution::getTruncateOrSignExtend(constSCEVV,
TypeTy,
unsigned Depth =0 
)

Return aSCEV corresponding to a conversion of the input value to the specified type.

If the type must be extended, it is sign extended.

Definition at line4717 of fileScalarEvolution.cpp.

Referencesassert(),llvm::Depth,getSignExtendExpr(),getTruncateExpr(),getTypeSizeInBits(), andllvm::Type::isIntOrPtrTy().

Referenced byfindForkedSCEVs(),getGEPExpr(),getSignExtendExprImpl(), andgetTruncateExpr().

◆ getTruncateOrZeroExtend()

constSCEV * ScalarEvolution::getTruncateOrZeroExtend(constSCEVV,
TypeTy,
unsigned Depth =0 
)

Return aSCEV corresponding to a conversion of the input value to the specified type.

If the type must be extended, it is zero extended.

Definition at line4705 of fileScalarEvolution.cpp.

Referencesassert(),llvm::Depth,getTruncateExpr(),getTypeSizeInBits(),getZeroExtendExpr(), andllvm::Type::isIntOrPtrTy().

Referenced byBinomialCoefficient(),llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(),getNumBytes(),getPtrToIntExpr(),getSignExtendExprImpl(),getStartForNegStride(),getTripCountFromExitCount(),getTruncateExpr(), andgetZeroExtendExprImpl().

◆ getTypeSizeInBits()

uint64_t ScalarEvolution::getTypeSizeInBits(TypeTy) const

Return the size in bits of the specified type, for which isSCEVable must return true.

Definition at line4448 of fileScalarEvolution.cpp.

Referencesassert(),getDataLayout(),llvm::DataLayout::getIndexTypeSizeInBits(),llvm::DataLayout::getTypeSizeInBits(),llvm::Type::isPointerTy(), andisSCEVable().

Referenced byllvm::IVUsers::AddUsersIfInteresting(),llvm::SCEVAAResult::alias(),BinomialCoefficient(),computeConstantDifference(),createReplacement(),llvm::SCEVExpander::expandCodeFor(),FindLoopCounter(),llvm::SCEVExpander::generateOverflowCheck(),genLoopLimit(),getAddExpr(),getAnyExtendExpr(),getLosslessPtrToIntExpr(),getMinTrailingZeros(),getMulExpr(),getNoopOrAnyExtend(),getNoopOrSignExtend(),getNoopOrZeroExtend(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),getPowerOfTwo(),getPreStartForExtend(),getSignedOverflowLimitForStep(),getSignExtendExpr(),getSignExtendExprImpl(),getTripCountFromExitCount(),getTruncateExpr(),getTruncateOrNoop(),getTruncateOrSignExtend(),getTruncateOrZeroExtend(),getUDivExpr(),getUMaxFromMismatchedTypes(),getUnsignedOverflowLimitForStep(),getWiderType(),getZeroExtendExpr(),getZeroExtendExprImpl(),isAddRecSExtable(),isAddSExtable(),llvm::HardwareLoopInfo::isHardwareLoopCandidate(),isMulSExtable(),isSimpleCastedPHI(),SolveLinEquationWithOverflow(),SolveQuadraticAddRecRange(),verify(), andvisitIVCast().

◆ getUDivCeilSCEV()

constSCEV * ScalarEvolution::getUDivCeilSCEV(constSCEVN,
constSCEVD 
)

Compute ceil(N / D).

N and D are treated as unsigned values.

SinceSCEV doesn't have native ceiling division, this generates aSCEV expression of the following form:

umin(N, 1) + floor((N - umin(N, 1)) / D)

A denominator of zero or poison is handled the same way asgetUDivExpr().

Definition at line12882 of fileScalarEvolution.cpp.

ReferencesD,getAddExpr(),getMinusSCEV(),getOne(),getUDivExpr(),getUMinExpr(), andN.

Referenced byllvm::IndexedReference::computeRefCost().

◆ getUDivExactExpr()

constSCEV * ScalarEvolution::getUDivExactExpr(constSCEVLHS,
constSCEVRHS 
)

Get a canonical unsigned division expression, or something simpler if possible.

There is no representation for an exact udiv inSCEV 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 line3587 of fileScalarEvolution.cpp.

Referencesllvm::append_range(),llvm::drop_begin(),llvm::gcd(),getConstant(),getMulExpr(),getUDivExactExpr(),getUDivExpr(),llvm::APInt::isIntN(),LHS,llvm::Mul,Operands, andRHS.

Referenced bycalculateRtStride(),getUDivExactExpr(), andSolveLinEquationWithOverflow().

◆ getUDivExpr()

constSCEV * ScalarEvolution::getUDivExpr(constSCEVLHS,
constSCEVRHS 
)

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 line3400 of fileScalarEvolution.cpp.

ReferencesA,assert(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNW,llvm::IntegerType::get(),getAddExpr(),getAddRecExpr(),llvm::SCEVConstant::getAPInt(),getConstant(),getContext(),getMulExpr(),llvm::Value::getType(),getTypeSizeInBits(),getUDivExpr(),getZero(),getZeroExtendExpr(),llvm::APInt::isMinSignedValue(),llvm::APInt::isNegative(),llvm::Type::isPointerTy(),LHS,llvm::SCEVPatternMatch::m_scev_Zero(),llvm::PatternMatch::match(),Operands,registerUser(),RHS,llvm::scUDivExpr,llvm::APInt::umul_ov(), andllvm::APInt::urem().

Referenced byBinomialCoefficient(),getAddExpr(),getUDivCeilSCEV(),getUDivExactExpr(),getUDivExpr(),getURemExpr(),getZeroExtendExprImpl(), andllvm::SCEVRewriteVisitor< SC >::visitUDivExpr().

◆ getUMaxExpr()[1/2]

constSCEV * ScalarEvolution::getUMaxExpr(constSCEVLHS,
constSCEVRHS 
)

Definition at line4352 of fileScalarEvolution.cpp.

ReferencesgetUMaxExpr(),LHS, andRHS.

Referenced bycalculateSubRanges(),llvm::getStartAndEndForAccess(),getUMaxExpr(),getUMaxFromMismatchedTypes(),getZeroExtendExprImpl(),IntersectUnsignedRange(), andllvm::SCEVRewriteVisitor< SC >::visitUMaxExpr().

◆ getUMaxExpr()[2/2]

constSCEV * ScalarEvolution::getUMaxExpr(SmallVectorImpl<constSCEV * > & Operands)

Definition at line4357 of fileScalarEvolution.cpp.

ReferencesgetMinMaxExpr(), andllvm::scUMaxExpr.

◆ getUMaxFromMismatchedTypes()

constSCEV * ScalarEvolution::getUMaxFromMismatchedTypes(constSCEVLHS,
constSCEVRHS 
)

Promote the operands to the wider of the types using zero-extension, and then perform a umax operation with them.

Definition at line4777 of fileScalarEvolution.cpp.

ReferencesgetNoopOrZeroExtend(),llvm::Value::getType(),getTypeSizeInBits(),getUMaxExpr(),getZeroExtendExpr(),LHS, andRHS.

◆ getUMinExpr()[1/2]

constSCEV * ScalarEvolution::getUMinExpr(constSCEVLHS,
constSCEVRHS,
bool Sequential =false 
)

Definition at line4371 of fileScalarEvolution.cpp.

ReferencesgetUMinExpr(),LHS, andRHS.

Referenced bycalculateSubRanges(),createNodeForSelectViaUMinSeq(),llvm::getStartAndEndForAccess(),getUDivCeilSCEV(),getUMinExpr(),getUMinFromMismatchedTypes(),getZeroExtendExprImpl(),IntersectUnsignedRange(),llvm::splitLoopBound(),llvm::SCEVRewriteVisitor< SC >::visitSequentialUMinExpr(), andllvm::SCEVRewriteVisitor< SC >::visitUMinExpr().

◆ getUMinExpr()[2/2]

constSCEV * ScalarEvolution::getUMinExpr(SmallVectorImpl<constSCEV * > & Operands,
bool Sequential =false 
)

Definition at line4377 of fileScalarEvolution.cpp.

ReferencesgetMinMaxExpr(),getSequentialMinMaxExpr(),llvm::scSequentialUMinExpr, andllvm::scUMinExpr.

◆ getUMinFromMismatchedTypes()[1/2]

constSCEV * ScalarEvolution::getUMinFromMismatchedTypes(constSCEVLHS,
constSCEVRHS,
bool Sequential =false 
)

Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them.

Definition at line4790 of fileScalarEvolution.cpp.

ReferencesgetUMinFromMismatchedTypes(),LHS, andRHS.

Referenced bycreateReplacement(),getMinAnalyzeableBackedgeTakenCount(), andgetUMinFromMismatchedTypes().

◆ getUMinFromMismatchedTypes()[2/2]

constSCEV * ScalarEvolution::getUMinFromMismatchedTypes(SmallVectorImpl<constSCEV * > & Ops,
bool Sequential =false 
)

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 line4798 of fileScalarEvolution.cpp.

Referencesassert(),llvm::SmallVectorBase< Size_T >::empty(),getNoopOrZeroExtend(),llvm::SCEV::getType(),getUMinExpr(),getWiderType(),llvm::SmallVectorTemplateBase< T, bool >::push_back(), andllvm::SmallVectorBase< Size_T >::size().

◆ getUnknown()

constSCEV * ScalarEvolution::getUnknown(ValueV)

Definition at line4411 of fileScalarEvolution.cpp.

Referencesassert(),SCEVUnknown, andllvm::scUnknown.

Referenced byllvm::InductionDescriptor::isFPInductionPHI(), andverify().

◆ getUnsignedRange()

ConstantRange llvm::ScalarEvolution::getUnsignedRange(constSCEVS)
inline

Determine the unsigned range for a particularSCEV.

NOTE: This returns a copy of the reference returned by getRangeRef.

Definition at line997 of fileScalarEvolution.h.

Referenced byllvm::SCEVAAResult::alias(),getBoundsCheckCond(),getZeroExtendExprImpl(),mustBeFiniteCountedLoop(),print(), andStrengthenNoWrapFlags().

◆ getUnsignedRangeMax()

APInt llvm::ScalarEvolution::getUnsignedRangeMax(constSCEVS)
inline

Determine the max of the unsigned range for a particularSCEV.

Definition at line1007 of fileScalarEvolution.h.

Referencesllvm::ConstantRange::getUnsignedMax().

Referenced bygetUnsignedOverflowLimitForStep(),llvm::isDereferenceableAndAlignedInLoop(),llvm::ARMTTIImpl::isHardwareLoopProfitable(),llvm::LoopVectorizationPlanner::selectEpilogueVectorizationFactor(), andSimplifyICmpOperands().

◆ getUnsignedRangeMin()

APInt llvm::ScalarEvolution::getUnsignedRangeMin(constSCEVS)
inline

Determine the min of the unsigned range for a particularSCEV.

Definition at line1002 of fileScalarEvolution.h.

Referencesllvm::ConstantRange::getUnsignedMin().

Referenced byisKnownNonZero(), andSimplifyICmpOperands().

◆ getURemExpr()

constSCEV * ScalarEvolution::getURemExpr(constSCEVLHS,
constSCEVRHS 
)

Represents an unsigned remainder expression based on unsigned division.

Definition at line3371 of fileScalarEvolution.cpp.

Referencesassert(),llvm::SCEV::FlagNUW,llvm::IntegerType::get(),getContext(),getEffectiveSCEVType(),getMinusSCEV(),getMulExpr(),getTruncateExpr(),llvm::Value::getType(),getUDivExpr(),getZero(),getZeroExtendExpr(),LHS, andRHS.

Referenced byllvm::LoopVectorizationCostModel::computeMaxVF(),getNewAlignmentDiff(),getZeroExtendExprImpl(),llvm::LoopVectorizationPlanner::selectEpilogueVectorizationFactor(), andSolveLinEquationWithOverflow().

◆ getVScale()

constSCEV * ScalarEvolution::getVScale(TypeTy)

Definition at line494 of fileScalarEvolution.cpp.

Referencesllvm::scVScale.

Referenced bygetElementCount(), andgetSizeOfExpr().

◆ getWiderType()

Type * ScalarEvolution::getWiderType(TypeTy1,
TypeTy2 
) const

Definition at line4469 of fileScalarEvolution.cpp.

ReferencesgetTypeSizeInBits(), andT1.

Referenced byllvm::IndexedReference::computeRefCost(),getUMinFromMismatchedTypes(),llvm::SCEVWrapPredicate::implies(), andoptimizeLoopExitWithUnknownExitCount().

◆ getWrapPredicate()

constSCEVPredicate * ScalarEvolution::getWrapPredicate(constSCEVAddRecExprAR,
SCEVWrapPredicate::IncrementWrapFlags AddedFlags 
)

Definition at line14755 of fileScalarEvolution.cpp.

Referencesllvm::SCEVPredicate::P_Wrap.

Referenced byllvm::PredicatedScalarEvolution::setNoOverflow().

◆ getZero()

constSCEV * llvm::ScalarEvolution::getZero(TypeTy)
inline

Return aSCEV for the constant 0 of a specific type.

Definition at line653 of fileScalarEvolution.h.

ReferencesgetConstant().

Referenced bydetectShiftUntilZeroIdiom(),llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(),getAddExpr(),getLosslessPtrToIntExpr(),getMinusSCEV(),getMulExpr(),llvm::SCEVAddRecExpr::getNumIterationsInRange(),getSequentialMinMaxExpr(),getTruncateExpr(),getUDivExpr(),getURemExpr(),llvm::isKnownNegativeInLoop(),llvm::isKnownNonNegativeInLoop(),llvm::isKnownNonPositiveInLoop(),llvm::isKnownPositiveInLoop(),isLoopBackedgeGuardedByCond(),removePointerBase(), andSolveLinEquationWithOverflow().

◆ getZeroExtendExpr()

constSCEV * ScalarEvolution::getZeroExtendExpr(constSCEVOp,
TypeTy,
unsigned Depth =0 
)

Definition at line1565 of fileScalarEvolution.cpp.

Referencesassert(),llvm::Depth,getEffectiveSCEVType(),getTypeSizeInBits(),getZeroExtendExprImpl(),insertFoldCacheEntry(),isSCEVable(), andllvm::scZeroExtend.

Referenced bycreateReplacement(),getAnyExtendExpr(),getCastExpr(),getNoopOrZeroExtend(),getSignExtendExprImpl(),getTripCountFromExitCount(),getTruncateOrZeroExtend(),getUDivExpr(),getUMaxFromMismatchedTypes(),getURemExpr(),getZeroExtendExprImpl(),IsIncrementNUW(),isSafeDependenceDistance(),llvm::ScalarEvolution::LoopGuards::rewrite(),verify(),verifyTripCount(),llvm::SCEVRewriteVisitor< SC >::visitZeroExtendExpr(), andwillNotOverflow().

◆ getZeroExtendExprImpl()

constSCEV * ScalarEvolution::getZeroExtendExprImpl(constSCEVOp,
TypeTy,
unsigned Depth =0 
)

Definition at line1584 of fileScalarEvolution.cpp.

Referencesassert(),llvm::AssumptionCache::assumptions(),llvm::BitWidth,llvm::CallingConv::C,llvm::ConstantRange::contains(),D,llvm::Depth,extractConstantWithoutWrapping(),llvm::SCEV::FlagAnyWrap,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,llvm::SCEV::FlagNW,llvm::IntegerType::get(),getAddExpr(),getAddRecExpr(),getConstant(),getConstantMaxBackedgeTakenCount(),getContext(),llvm::APInt::getMaxValue(),getMulExpr(),getSignedRangeMin(),getSignExtendExpr(),getTruncateExpr(),getTruncateOrZeroExtend(),llvm::SCEV::getType(),getTypeSizeInBits(),getUDivExpr(),getUMaxExpr(),getUMinExpr(),getUnsignedRange(),getURemExpr(),getZeroExtendExpr(),llvm::CmpInst::ICMP_UGT,isKnownNegative(),isKnownOnEveryIteration(),isLoopBackedgeGuardedByCond(),isSCEVable(),LHS,MaxCastDepth,N,Operands,llvm::SmallVectorTemplateBase< T, bool >::push_back(),registerUser(),RHS,llvm::scZeroExtend,setNoWrapFlags(),llvm::ConstantRange::truncate(),X,llvm::ConstantRange::zeroExtend(), andllvm::ConstantRange::zextOrTrunc().

Referenced bygetZeroExtendExpr().

◆ hasComputableLoopEvolution()

bool ScalarEvolution::hasComputableLoopEvolution(constSCEVS,
constLoopL 
)

Return true if the givenSCEV 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 line14104 of fileScalarEvolution.cpp.

ReferencesgetLoopDisposition(), andLoopComputable.

◆ hasFlags()

staticbool llvm::ScalarEvolution::hasFlags(SCEV::NoWrapFlags Flags,
SCEV::NoWrapFlags TestFlags 
)
inlinestatic

Definition at line479 of fileScalarEvolution.h.

ReferencesmaskFlags().

Referenced bygetAddExpr(),getMinusSCEV(),getMulExpr(), andStrengthenNoWrapFlags().

◆ hasLoopInvariantBackedgeTakenCount()

bool ScalarEvolution::hasLoopInvariantBackedgeTakenCount(constLoopL)

Return true if the specified loop has an analyzable loop-invariant backedge-taken count.

Definition at line13712 of fileScalarEvolution.cpp.

ReferencesgetBackedgeTakenCount().

Referenced bycanFoldTermCondOfLoop(),llvm::ARMTTIImpl::getUnrollingPreferences(),llvm::ARMTTIImpl::isHardwareLoopProfitable(),llvm::IVUsers::print(), andPrintLoopInfo().

◆ hasOperand()

bool ScalarEvolution::hasOperand(constSCEVS,
constSCEVOp 
) const

Test whether the givenSCEV has Op as a direct or indirect operand.

Definition at line14191 of fileScalarEvolution.cpp.

Referencesllvm::SCEVExprContains().

◆ instructionCouldExistWithOperands()

bool ScalarEvolution::instructionCouldExistWithOperands(constSCEVA,
constSCEVB 
)

Return true if there exists a point in the program at which both A and B could be operands to the same instruction.

SCEV expressions are generally assumed to correspond to instructions which could exists in IR. In general, this requires that there exists a use point in the program where all operands dominate the use.

Example: loop { if loop { v1 = load @global1; } else loop { v2 = load @global2; } } NoSCEV with operand V1, and v2 can exist in this program.

For a valid use point to exist, the defining scope of one operand must dominate the other.

Definition at line4473 of fileScalarEvolution.cpp.

ReferencesA,B, andllvm::DominatorTree::dominates().

Referenced bycanComputePointerDiff().

◆ invalidate()

bool ScalarEvolution::invalidate(FunctionF,
constPreservedAnalysesPA,
FunctionAnalysisManager::InvalidatorInv 
)

Definition at line14645 of fileScalarEvolution.cpp.

ReferencesF,llvm::PreservedAnalyses::getChecker(), andllvm::AnalysisManager< IRUnitT, ExtraArgTs >::Invalidator::invalidate().

◆ isAvailableAtLoopEntry()

bool ScalarEvolution::isAvailableAtLoopEntry(constSCEVS,
constLoopL 
)

Determine if theSCEV can be evaluated at loop's entry.

It is true if it doesn't depend on aSCEVUnknown of an instruction which is dominated by the header of loop L.

Definition at line2521 of fileScalarEvolution.cpp.

ReferencesisLoopInvariant(), andproperlyDominates().

Referenced byllvm::cannotBeMaxInLoop(),llvm::cannotBeMinInLoop(),getAddExpr(),getAddRecExpr(),getMulExpr(),llvm::hasProcessableCondition(),llvm::isKnownNegativeInLoop(),llvm::isKnownNonNegativeInLoop(),llvm::isKnownNonPositiveInLoop(),llvm::isKnownPositiveInLoop(),isKnownViaInduction(),isLoopEntryGuardedByCond(),isSafeDecreasingBound(), andisSafeIncreasingBound().

◆ isBackedgeTakenCountMaxOrZero()

bool ScalarEvolution::isBackedgeTakenCountMaxOrZero(constLoopL)

Return true if the backedge taken count is either the value returned by getConstantMaxBackedgeTakenCount or zero.

Definition at line8373 of fileScalarEvolution.cpp.

Referenced byPrintLoopInfo(),tryToUnrollLoop(), andllvm::UnrollLoop().

◆ isBasicBlockEntryGuardedByCond()

bool ScalarEvolution::isBasicBlockEntryGuardedByCond(constBasicBlockBB,
CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS 
)

Test whether entry to the basic block is protected by a conditional between LHS and RHS.

Definition at line11622 of fileScalarEvolution.cpp.

Referencesassert(),llvm::AssumptionCache::assumptions(),llvm::dbgs(),llvm::DominatorTree::dominates(),llvm::BasicBlock::front(),llvm::BranchInst::getCondition(),llvm::Intrinsic::getDeclarationIfExists(),llvm::LoopBase< BlockT, LoopT >::getHeader(),llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(),llvm::LoopBase< BlockT, LoopT >::getLoopPredecessor(),llvm::CmpInst::getNonStrictPredicate(),llvm::GlobalValue::getParent(),llvm::BasicBlock::getParent(),llvm::BasicBlock::getSinglePredecessor(),llvm::BranchInst::getSuccessor(),llvm::CmpInst::ICMP_NE,llvm::DominatorTree::isReachableFromEntry(),llvm::BranchInst::isUnconditional(),LHS,P,RHS,llvm::verifyFunction(), andVerifyIR.

Referenced byevaluatePredicateAt(),isKnownPredicateAt(), andisLoopEntryGuardedByCond().

◆ isKnownNegative()

bool ScalarEvolution::isKnownNegative(constSCEVS)

Test if the given expression is known to be negative.

Definition at line10944 of fileScalarEvolution.cpp.

ReferencesgetSignedRangeMax(), andllvm::APInt::isNegative().

Referenced bycountToEliminateCompares(),llvm::SCEVExpander::generateOverflowCheck(),getSignedOverflowLimitForStep(),getZeroExtendExprImpl(),isOneDimensionalArray(), andisSafeDecreasingBound().

◆ isKnownNonNegative()

bool ScalarEvolution::isKnownNonNegative(constSCEVS)

Test if the given expression is known to be non-negative.

Definition at line10952 of fileScalarEvolution.cpp.

ReferencesgetSignedRangeMin(), andllvm::APInt::isNegative().

Referenced bydetectShiftUntilZeroIdiom(),expandBounds(),getGEPExpr(),getLoopInvariantPredicate(),getMinusSCEV(),getSignExtendExprImpl(), andStrengthenNoWrapFlags().

◆ isKnownNonPositive()

bool ScalarEvolution::isKnownNonPositive(constSCEVS)

Test if the given expression is known to be non-positive.

Definition at line10956 of fileScalarEvolution.cpp.

ReferencesgetSignedRangeMax(), andllvm::APInt::isStrictlyPositive().

◆ isKnownNonZero()

bool ScalarEvolution::isKnownNonZero(constSCEVS)

Test if the given expression is known to be non-zero.

Definition at line10960 of fileScalarEvolution.cpp.

ReferencesgetUnsignedRangeMin(), andisKnownNonZero().

Referenced bybreakBackedgeIfNotTaken(),canFoldTermCondOfLoop(),isKnownNonZero(), andisKnownToBeAPowerOfTwo().

◆ isKnownOnEveryIteration()

bool ScalarEvolution::isKnownOnEveryIteration(CmpPredicate Pred,
constSCEVAddRecExprLHS,
constSCEVRHS 
)

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 line11098 of fileScalarEvolution.cpp.

ReferencesisLoopBackedgeGuardedByCond(),isLoopEntryGuardedByCond(),LHS, andRHS.

Referenced bygetZeroExtendExprImpl().

◆ isKnownPositive()

bool ScalarEvolution::isKnownPositive(constSCEVS)

Test if the given expression is known to be positive.

Definition at line10948 of fileScalarEvolution.cpp.

ReferencesgetSignedRangeMin(), andllvm::APInt::isStrictlyPositive().

Referenced bycountToEliminateCompares(),llvm::SCEVExpander::generateOverflowCheck(),getLoopInvariantPredicate(),getPreStartForExtend(),getSignedOverflowLimitForStep(),llvm::SCEVWrapPredicate::implies(),llvm::RecurrenceDescriptor::isFindLastIVPattern(), andisSafeDependenceDistance().

◆ isKnownPredicate()

bool ScalarEvolution::isKnownPredicate(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS 
)

Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS.

Definition at line11050 of fileScalarEvolution.cpp.

ReferencesisKnownViaInduction(),LHS,RHS, andSimplifyICmpOperands().

Referenced bycalculateSubRanges(),llvm::calculateUpperBound(),llvm::LoopVectorizationCostModel::computeMaxVF(),countToEliminateCompares(),llvm::InnerLoopVectorizer::emitIterationCountCheck(),evaluatePredicate(),llvm::SCEVWrapPredicate::implies(),isKnownPredicateAt(),IsKnownPredicateViaAddRecStart(),normalizePredicate(),llvm::VPlanTransforms::optimizeForVFAndUF(),llvm::LoopVectorizationPlanner::selectEpilogueVectorizationFactor(), andSolveLinEquationWithOverflow().

◆ isKnownPredicateAt()

bool ScalarEvolution::isKnownPredicateAt(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS,
constInstructionCtxI 
)

Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS in the given Context.

Definition at line11075 of fileScalarEvolution.cpp.

Referencesllvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),isBasicBlockEntryGuardedByCond(),isKnownPredicate(),LHS, andRHS.

Referenced bycanOverlap(),createReplacement(),getLoopInvariantExitCondDuringFirstIterationsImpl(),getLoopInvariantPredicate(), andwillNotOverflow().

◆ isKnownToBeAPowerOfTwo()

bool ScalarEvolution::isKnownToBeAPowerOfTwo(constSCEVS,
bool OrZero =false,
bool OrNegative =false 
)

Test if the given expression is known to be a power of 2.

OrNegative allows matching negative power of 2s, and OrZero allows matching 0.

Definition at line10968 of fileScalarEvolution.cpp.

Referencesllvm::all_of(),llvm::CallingConv::C,llvm::Function::hasFnAttribute(),isKnownNonZero(), andllvm::Mul.

◆ isKnownViaInduction()

bool ScalarEvolution::isKnownViaInduction(CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS 
)

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:

  1. Collect set S all loops on which either LHS or RHS depend.
  2. If S is non-empty a. Let PD be the element of S which is dominated by all other elements. b. LetE(LHS) be value of LHS on entry of PD. To getE(LHS), we should just take LHS and replace all AddRecs that are attached to PD on with their entry values. DefineE(RHS) in the same way. c. LetB(LHS) be value of L on backedge of PD. To getB(LHS), we should just take LHS and replace all AddRecs that are attached to PD on with their backedge values. DefineB(RHS) in the same way. d. Note thatE(LHS) andE(RHS) are automatically available on entry of PD, so we can assert on that. e. Return true if isLoopEntryGuardedByCond(Pred,E(LHS),E(RHS)) && isLoopBackedgeGuardedByCond(Pred,B(LHS),B(RHS))

Definition at line11000 of fileScalarEvolution.cpp.

Referencesassert(),llvm::DominatorTree::dominates(),llvm::SmallPtrSetImplBase::empty(),getCouldNotCompute(),llvm::LoopBase< BlockT, LoopT >::getHeader(),isAvailableAtLoopEntry(),isLoopBackedgeGuardedByCond(),isLoopEntryGuardedByCond(),LHS,llvm::max_element(),llvm::DominatorTreeBase< NodeT, IsPostDom >::properlyDominates(),RHS, andSplitIntoInitAndPostInc().

Referenced byisKnownPredicate().

◆ isLoopBackedgeGuardedByCond()

bool ScalarEvolution::isLoopBackedgeGuardedByCond(constLoopL,
CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS 
)

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 line11516 of fileScalarEvolution.cpp.

Referencesassert(),llvm::AssumptionCache::assumptions(),llvm::dbgs(),llvm::DominatorTree::dominates(),llvm::SCEV::FlagNUW,llvm::SCEV::FlagNW,getAddRecExpr(),llvm::BranchInst::getCondition(),getCouldNotCompute(),getOne(),llvm::BasicBlock::getSinglePredecessor(),llvm::BranchInst::getSuccessor(),llvm::BasicBlock::getTerminator(),llvm::SCEV::getType(),getZero(),llvm::CmpInst::ICMP_ULT,llvm::BranchInst::isConditional(),llvm::DominatorTree::isReachableFromEntry(),llvm::BasicBlockEdge::isSingleEdge(),LHS,RHS,llvm::verifyFunction(), andVerifyIR.

Referenced bygetLoopInvariantExitCondDuringFirstIterationsImpl(),getLoopInvariantPredicate(),getZeroExtendExprImpl(),isKnownOnEveryIteration(), andisKnownViaInduction().

◆ isLoopEntryGuardedByCond()

bool ScalarEvolution::isLoopEntryGuardedByCond(constLoopL,
CmpPredicate Pred,
constSCEVLHS,
constSCEVRHS 
)

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 line11721 of fileScalarEvolution.cpp.

Referencesassert(),isAvailableAtLoopEntry(),isBasicBlockEntryGuardedByCond(),LHS, andRHS.

Referenced byllvm::cannotBeMaxInLoop(),llvm::cannotBeMinInLoop(),llvm::findSplitCandidate(),getPreStartForExtend(),getTripCountFromExitCount(),llvm::isKnownNegativeInLoop(),llvm::isKnownNonNegativeInLoop(),llvm::isKnownNonPositiveInLoop(),isKnownOnEveryIteration(),llvm::isKnownPositiveInLoop(),isKnownViaInduction(),isSafeDecreasingBound(), andisSafeIncreasingBound().

◆ isLoopInvariant()

bool ScalarEvolution::isLoopInvariant(constSCEVS,
constLoopL 
)

Return true if the value of the givenSCEV is unchanging in the specified loop.

Definition at line14100 of fileScalarEvolution.cpp.

ReferencesgetLoopDisposition(), andLoopInvariant.

Referenced byllvm::RecurrenceDescriptor::AddReductionVar(),canTailPredicateLoop(),computeUnrollAndJamCount(),createWidenInductionRecipes(),findForkedPointer(),genLoopLimit(),getAddRecExpr(),getAddressAccessSCEV(),getAppleRuntimeUnrollPreferences(),llvm::LoopVectorizationCostModel::getInstructionCost(),getLoopInvariantExitCondDuringFirstIterationsImpl(),getLoopInvariantPredicate(),llvm::getPtrStride(),llvm::getStartAndEndForAccess(),getStrideFromPointer(),llvm::ARMTTIImpl::getUnrollingPreferences(),hasComputableBounds(),llvm::Loop::isAuxiliaryInductionVariable(),isAvailableAtLoopEntry(),llvm::HardwareLoopInfo::isHardwareLoopCandidate(),llvm::InductionDescriptor::isInductionPHI(),llvm::LoopAccessInfo::isInvariant(),isNoWrap(),isOneDimensionalArray(),mayUsePostIncMode(),print(),llvm::rewriteLoopExitValues(),llvm::LoopVectorizationCostModel::setVectorizedCallDecision(),SimplifyICmpOperands(), andstripGetElementPtr().

◆ isSCEVable()

bool ScalarEvolution::isSCEVable(TypeTy) const

Test if values of the given type are analyzable within theSCEV framework.

This primarily includes integer types, and it can optionally include pointer types if theScalarEvolution class has access to target-specific information.

Definition at line4441 of fileScalarEvolution.cpp.

Referencesllvm::Type::isIntOrPtrTy().

Referenced byllvm::IVUsers::AddUsersIfInteresting(),canFoldTermCondOfLoop(),DbgGatherSalvagableDVI(),findForkedPointer(),findIVOperand(),forgetBlockAndLoopDispositions(),forgetLcssaPhiWithNewPredecessor(),formLCSSAForInstructionsImpl(),getAnyExtendExpr(),getEffectiveSCEVType(),getExistingSCEV(),GetInductionVariable(),llvm::LoopVectorizationCostModel::getInstructionCost(),getSCEV(),getSignExtendExpr(),getSignExtendExprImpl(),getTruncateExpr(),getTypeSizeInBits(),getZeroExtendExpr(),getZeroExtendExprImpl(),isExistingPhi(),llvm::RecurrenceDescriptor::isFindLastIVPattern(),isHighCostExpansion(),llvm::InductionDescriptor::isInductionPHI(),llvm::LoopAccessInfo::isInvariant(),isLoopCounter(),llvm::isProcessableCondBI(),isSimpleIVUser(),llvm::LoopVectorizationLegality::isUniform(),print(),llvm::PredicatedScalarEvolution::print(),llvm::SCEVExpander::replaceCongruentIVs(),llvm::rewriteLoopExitValues(), andllvm::splitLoopBound().

◆ loopHasNoAbnormalExits()

bool llvm::ScalarEvolution::loopHasNoAbnormalExits(constLoopL)
inline

Return true if the loop has no abnormal exits.

That is, if the loop is not infinite, it must exit through an explicit edge in the CFG. (As opposed to either a) throwing out of the function or b) entering a well defined infinite loop in some callee.)

Definition at line1353 of fileScalarEvolution.h.

Referenced byllvm::UnrollRuntimeLoopRemainder().

◆ loopIsFiniteByAssumption()

bool ScalarEvolution::loopIsFiniteByAssumption(constLoopL)

Return true if this loop is finite by assumption.

That is, to be infinite, it must also be undefined.

Definition at line7467 of fileScalarEvolution.cpp.

Referencesllvm::isFinite(), andllvm::isMustProgress().

◆ maskFlags()

staticSCEV::NoWrapFlags llvm::ScalarEvolution::maskFlags(SCEV::NoWrapFlags Flags,
int Mask 
)
inlinestatic

Convenient NoWrapFlags manipulation that hides enum casts and is visible in theScalarEvolution name space.

Definition at line467 of fileScalarEvolution.h.

Referenced bygetAddExpr(),getAddRecExpr(),getMulExpr(),getPreStartForExtend(),hasFlags(),llvm::SCEVExpander::hoistIVInc(),llvm::ScalarEvolution::LoopGuards::rewrite(), andStrengthenNoWrapFlags().

◆ print()

void ScalarEvolution::print(raw_ostreamOS) const

Definition at line13919 of fileScalarEvolution.cpp.

ReferencesClassifyExpressions,llvm::depth_first(),llvm::First,getLoopDisposition(),llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(),getSCEV(),getSCEVAtScope(),getSignedRange(),getUnsignedRange(),I,instructions,isLoopInvariant(),isSCEVable(),OS,llvm::SCEV::print(),llvm::ConstantRange::print(),llvm::Value::printAsOperand(), andPrintLoopInfo().

Referenced byllvm::ScalarEvolutionWrapperPass::print().

◆ properlyDominates()

bool ScalarEvolution::properlyDominates(constSCEVS,
constBasicBlockBB 
)

Return true if elements that makes up the givenSCEV properly dominate the specified basic block.

Definition at line14187 of fileScalarEvolution.cpp.

ReferencesgetBlockDisposition(), andProperlyDominatesBlock.

Referenced byDoInitialMatch(),isAvailableAtLoopEntry(),llvm::SCEVExpander::isSafeToExpandAt(), andSimplifyICmpOperands().

◆ registerUser()

void ScalarEvolution::registerUser(constSCEVUser,
ArrayRef<constSCEV * > Ops 
)

Notify thisScalarEvolution thatUser directly uses SCEVs inOps.

Definition at line15101 of fileScalarEvolution.cpp.

Referenced bygetLosslessPtrToIntExpr(),getMinMaxExpr(),getSequentialMinMaxExpr(),getSignExtendExprImpl(),getTruncateExpr(),getUDivExpr(), andgetZeroExtendExprImpl().

◆ removePointerBase()

constSCEV * ScalarEvolution::removePointerBase(constSCEVS)

Compute an expression equivalent to S - getPointerBase(S).

Definition at line4625 of fileScalarEvolution.cpp.

Referencesllvm::Add,assert(),llvm::SCEV::FlagAnyWrap,getAddExpr(),getAddRecExpr(),getZero(),P, andremovePointerBase().

Referenced bygetMinusSCEV(), andremovePointerBase().

◆ rewriteUsingPredicate()

constSCEV * ScalarEvolution::rewriteUsingPredicate(constSCEVS,
constLoopL,
constSCEVPredicateA 
)

Re-writes theSCEV according to the Predicates inA.

Definition at line14897 of fileScalarEvolution.cpp.

Referenced byllvm::PredicatedScalarEvolution::getSCEV().

◆ setFlags()

staticSCEV::NoWrapFlags llvm::ScalarEvolution::setFlags(SCEV::NoWrapFlags Flags,
SCEV::NoWrapFlags OnFlags 
)
inlinestatic

Definition at line471 of fileScalarEvolution.h.

Referenced bygetAddExpr(),getGEPExpr(),llvm::SCEVWrapPredicate::getImpliedFlags(),getMulExpr(),getStrengthenedNoWrapFlagsFromBinOp(),llvm::SCEVWrapPredicate::isAlwaysTrue(),llvm::ScalarEvolution::LoopGuards::rewrite(),llvm::SCEVAddRecExpr::setNoWrapFlags(), andStrengthenNoWrapFlags().

◆ setNoWrapFlags()

void ScalarEvolution::setNoWrapFlags(SCEVAddRecExprAddRec,
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 line6432 of fileScalarEvolution.cpp.

Referencesllvm::SCEVNAryExpr::getNoWrapFlags(), andllvm::SCEVAddRecExpr::setNoWrapFlags().

Referenced bygetPreStartForExtend(),getSignExtendExprImpl(), andgetZeroExtendExprImpl().

◆ SimplifyICmpOperands()

bool ScalarEvolution::SimplifyICmpOperands(CmpPredicatePred,
constSCEV *& LHS,
constSCEV *& 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 line10760 of fileScalarEvolution.cpp.

Referencesassert(),llvm::ICmpInst::compare(),llvm::Depth,llvm::SCEV::FlagNSW,llvm::SCEV::FlagNUW,getAddExpr(),getConstant(),getContext(),llvm::ConstantRange::getEquivalentICmp(),llvm::ConstantInt::getFalse(),llvm::SCEVAddRecExpr::getLoop(),getSignedRangeMax(),getSignedRangeMin(),llvm::ICmpInst::getSwappedCmpPredicate(),llvm::Value::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::CmpInst::isTrueWhenEqual(),LHS,llvm::ConstantRange::makeExactICmpRegion(),MatchBinarySub(),properlyDominates(),RA,RHS,SimplifyICmpOperands(), andstd::swap().

Referenced byisKnownPredicate(), andSimplifyICmpOperands().

◆ SplitIntoInitAndPostInc()

std::pair<constSCEV *,constSCEV * > ScalarEvolution::SplitIntoInitAndPostInc(constLoopL,
constSCEVS 
)

SplitsSCEV expressionS into two SCEVs.

One of them is obtained fromS by substitution of all AddRec sub-expression related to loopL with initial value of thatSCEV. The second is obtained fromS by substitution of all AddRec sub-expressions related to loopL with post increment of this AddRec in the loopL. In both cases all other AddRec sub-expressions (not related toL) remain the same. If theS contains non-invariant unknownSCEV the function returns CouldNotComputeSCEV in both values of std::pair. For example, forSCEV 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 line10989 of fileScalarEvolution.cpp.

Referencesassert(),getCouldNotCompute(), andPostInc.

Referenced byisKnownViaInduction().

◆ verify()

void ScalarEvolution::verify() const

Definition at line14352 of fileScalarEvolution.cpp.

Referencesllvm::SmallVectorImpl< T >::append(),llvm::append_range(),assert(),llvm::LoopInfoBase< BlockT, LoopT >::begin(),llvm::SmallPtrSetImpl< PtrType >::contains(),containsUndefs(),llvm::dbgs(),llvm::SmallVectorBase< Size_T >::empty(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(),llvm::LoopInfoBase< BlockT, LoopT >::end(),F,llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(),getBackedgeTakenCount(),getBlockDisposition(),getConstant(),getConstantMultiple(),getCouldNotCompute(),llvm::SCEVAddRecExpr::getLoop(),getLoopDisposition(),getMinusSCEV(),llvm::Value::getName(),getSCEV(),getTypeSizeInBits(),getUnknown(),llvm::SCEVUnknown::getValue(),getZeroExtendExpr(),I,llvm::SmallPtrSetImpl< PtrType >::insert(),llvm::is_contained(),llvm::SCEV::isZero(),llvm::SCEV::operands(),llvm::SmallVectorImpl< T >::pop_back_val(),llvm::Predicated,llvm::APInt::urem(), andVerifySCEVStrict.

Referenced byllvm::FunctionToLoopPassAdaptor::run(),llvm::LoopVectorizePass::runImpl(),llvm::UnrollAndJamLoop(), andllvm::ScalarEvolutionWrapperPass::verifyAnalysis().

◆ willNotOverflow()

bool ScalarEvolution::willNotOverflow(Instruction::BinaryOps BinOp,
bool Signed,
constSCEVLHS,
constSCEVRHS,
constInstructionCtxI =nullptr 
)

Is operationBinOp betweenLHS andRHS provably does not have a signed/unsigned overflow (Signed)? IfCtxI is specified, the no-overflow fact should be true in the context of this instruction.

Definition at line2314 of fileScalarEvolution.cpp.

ReferencesA,B,llvm::CallingConv::C,llvm::SCEV::FlagAnyWrap,llvm::IntegerType::get(),getAddExpr(),getConstant(),llvm::APInt::getMaxValue(),getMinusSCEV(),llvm::APInt::getMinValue(),getMulExpr(),llvm::APInt::getSignedMaxValue(),llvm::APInt::getSignedMinValue(),getSignExtendExpr(),llvm::Value::getType(),getZeroExtendExpr(),llvm::CmpInst::ICMP_SLE,llvm::CmpInst::ICMP_ULE,isKnownPredicateAt(),LHS,llvm_unreachable,Operation,RHS, andSigned.

Referenced bygetStrengthenedNoWrapFlagsFromBinOp().

Friends And Related Function Documentation

◆ ScalarEvolutionsTest

friend class ScalarEvolutionsTest
friend

Definition at line448 of fileScalarEvolution.h.

◆ SCEVCallbackVH

friend class SCEVCallbackVH
friend

Definition at line1411 of fileScalarEvolution.h.

◆ SCEVExpander

friend classSCEVExpander
friend

Definition at line1412 of fileScalarEvolution.h.

◆ SCEVUnknown

friend classSCEVUnknown
friend

Definition at line1413 of fileScalarEvolution.h.

Referenced bygetUnknown().


The documentation for this class was generated from the following files:

Generated on Sun Jul 20 2025 19:49:31 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp