LLVM  14.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  LoopInvariantPredicate
 

Public Types

enum  LoopDisposition { LoopVariant, LoopInvariant, LoopComputable }
 An enum describing the relationship between a SCEV and a loop. More...
 
enum  BlockDisposition { DoesNotDominateBlock, DominatesBlock, ProperlyDominatesBlock }
 An enum describing the relationship between a SCEV and a basic block. More...
 
enum  ExitCountKind { Exact, ConstantMaximum, SymbolicMaximum }
 The terms "backedge taken count" and "exit count" are used interchangeably to refer to the number of times the backedge of a loop has executed before the loop is exited. More...
 
enum  MonotonicPredicateType { MonotonicallyIncreasing, MonotonicallyDecreasing }
 A predicate is said to be monotonically increasing if may go from being false to being true as the loop iterates, but never the other way around. More...
 

Public Member Functions

 ScalarEvolution (Function &F, TargetLibraryInfo &TLI, AssumptionCache &AC, DominatorTree &DT, LoopInfo &LI)
 
 ScalarEvolution (ScalarEvolution &&Arg)
 
 ~ScalarEvolution ()
 
LLVMContextgetContext () const
 
bool isSCEVable (Type *Ty) const
 Test if values of the given type are analyzable within the SCEV framework. More...
 
uint64_t getTypeSizeInBits (Type *Ty) const
 Return the size in bits of the specified type, for which isSCEVable must return true. More...
 
TypegetEffectiveSCEVType (Type *Ty) const
 Return a type with the same bitwidth as the given type and which represents how SCEV will treat the given type, for which isSCEVable must return true. More...
 
TypegetWiderType (Type *Ty1, Type *Ty2) const
 
bool instructionCouldExistWitthOperands (const SCEV *A, const SCEV *B)
 Return true if there exists a point in the program at which both A and B could be operands to the same instruction. More...
 
bool containsAddRecurrence (const SCEV *S)
 Return true if the SCEV is a scAddRecExpr or it contains scAddRecExpr. More...
 
bool willNotOverflow (Instruction::BinaryOps BinOp, bool Signed, const SCEV *LHS, const SCEV *RHS)
 Is operation BinOp between LHS and RHS provably does not have a signed/unsigned overflow (Signed)? More...
 
std::pair< SCEV::NoWrapFlags, bool > getStrengthenedNoWrapFlagsFromBinOp (const OverflowingBinaryOperator *OBO)
 Parse NSW/NUW flags from add/sub/mul IR binary operation Op into SCEV no-wrap flags, and deduce flag[s] that aren't known yet. More...
 
void registerUser (const SCEV *User, ArrayRef< const SCEV * > Ops)
 Notify this ScalarEvolution that User directly uses SCEVs in Ops. More...
 
bool containsUndefs (const SCEV *S) const
 Return true if the SCEV expression contains an undef value. More...
 
const SCEVgetSCEV (Value *V)
 Return a SCEV expression for the full generality of the specified expression. More...
 
const SCEVgetConstant (ConstantInt *V)
 
const SCEVgetConstant (const APInt &Val)
 
const SCEVgetConstant (Type *Ty, uint64_t V, bool isSigned=false)
 
const SCEVgetLosslessPtrToIntExpr (const SCEV *Op, unsigned Depth=0)
 
const SCEVgetPtrToIntExpr (const SCEV *Op, Type *Ty)
 
const SCEVgetTruncateExpr (const SCEV *Op, Type *Ty, unsigned Depth=0)
 
const SCEVgetZeroExtendExpr (const SCEV *Op, Type *Ty, unsigned Depth=0)
 
const SCEVgetSignExtendExpr (const SCEV *Op, Type *Ty, unsigned Depth=0)
 
const SCEVgetCastExpr (SCEVTypes Kind, const SCEV *Op, Type *Ty)
 
const SCEVgetAnyExtendExpr (const SCEV *Op, Type *Ty)
 getAnyExtendExpr - Return a SCEV for the given operand extended with unspecified bits out to the given type. More...
 
const SCEVgetAddExpr (SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 Get a canonical add expression, or something simpler if possible. More...
 
const SCEVgetAddExpr (const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 
const SCEVgetAddExpr (const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 
const SCEVgetMulExpr (SmallVectorImpl< const SCEV * > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 Get a canonical multiply expression, or something simpler if possible. More...
 
const SCEVgetMulExpr (const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 
const SCEVgetMulExpr (const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 
const SCEVgetUDivExpr (const SCEV *LHS, const SCEV *RHS)
 Get a canonical unsigned division expression, or something simpler if possible. More...
 
const SCEVgetUDivExactExpr (const SCEV *LHS, const SCEV *RHS)
 Get a canonical unsigned division expression, or something simpler if possible. More...
 
const SCEVgetURemExpr (const SCEV *LHS, const SCEV *RHS)
 Represents an unsigned remainder expression based on unsigned division. More...
 
const SCEVgetAddRecExpr (const SCEV *Start, const SCEV *Step, const Loop *L, SCEV::NoWrapFlags Flags)
 Get an add recurrence expression for the specified loop. More...
 
const SCEVgetAddRecExpr (SmallVectorImpl< const SCEV * > &Operands, const Loop *L, SCEV::NoWrapFlags Flags)
 Get an add recurrence expression for the specified loop. More...
 
const SCEVgetAddRecExpr (const SmallVectorImpl< const SCEV * > &Operands, const Loop *L, SCEV::NoWrapFlags Flags)
 
Optional< std::pair< const SCEV *, SmallVector< const SCEVPredicate *, 3 > > > createAddRecFromPHIWithCasts (const SCEVUnknown *SymbolicPHI)
 Checks if SymbolicPHI can be rewritten as an AddRecExpr under some Predicates. More...
 
const SCEVgetGEPExpr (GEPOperator *GEP, const SmallVectorImpl< const SCEV * > &IndexExprs)
 Returns an expression for a GEP. More...
 
const SCEVgetAbsExpr (const SCEV *Op, bool IsNSW)
 
const SCEVgetMinMaxExpr (SCEVTypes Kind, SmallVectorImpl< const SCEV * > &Operands)
 
const SCEVgetSequentialMinMaxExpr (SCEVTypes Kind, SmallVectorImpl< const SCEV * > &Operands)
 
const SCEVgetSMaxExpr (const SCEV *LHS, const SCEV *RHS)
 
const SCEVgetSMaxExpr (SmallVectorImpl< const SCEV * > &Operands)
 
const SCEVgetUMaxExpr (const SCEV *LHS, const SCEV *RHS)
 
const SCEVgetUMaxExpr (SmallVectorImpl< const SCEV * > &Operands)
 
const SCEVgetSMinExpr (const SCEV *LHS, const SCEV *RHS)
 
const SCEVgetSMinExpr (SmallVectorImpl< const SCEV * > &Operands)
 
const SCEVgetUMinExpr (const SCEV *LHS, const SCEV *RHS, bool Sequential=false)
 
const SCEVgetUMinExpr (SmallVectorImpl< const SCEV * > &Operands, bool Sequential=false)
 
const SCEVgetUnknown (Value *V)
 
const SCEVgetCouldNotCompute ()
 
const SCEVgetZero (Type *Ty)
 Return a SCEV for the constant 0 of a specific type. More...
 
const SCEVgetOne (Type *Ty)
 Return a SCEV for the constant 1 of a specific type. More...
 
const SCEVgetMinusOne (Type *Ty)
 Return a SCEV for the constant -1 of a specific type. More...
 
const SCEVgetSizeOfScalableVectorExpr (Type *IntTy, ScalableVectorType *ScalableTy)
 Return an expression for sizeof ScalableTy that is type IntTy, where ScalableTy is a scalable vector type. More...
 
const SCEVgetSizeOfExpr (Type *IntTy, Type *AllocTy)
 Return an expression for the alloc size of AllocTy that is type IntTy. More...
 
const SCEVgetStoreSizeOfExpr (Type *IntTy, Type *StoreTy)
 Return an expression for the store size of StoreTy that is type IntTy. More...
 
const SCEVgetOffsetOfExpr (Type *IntTy, StructType *STy, unsigned FieldNo)
 Return an expression for offsetof on the given field with type IntTy. More...
 
const SCEVgetNegativeSCEV (const SCEV *V, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
 Return the SCEV object corresponding to -V. More...
 
const SCEVgetNotSCEV (const SCEV *V)
 Return the SCEV object corresponding to ~V. More...
 
const SCEVgetMinusSCEV (const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
 Return LHS-RHS. More...
 
const SCEVgetUDivCeilSCEV (const SCEV *N, const SCEV *D)
 Compute ceil(N / D). More...
 
const SCEVgetTruncateOrZeroExtend (const SCEV *V, Type *Ty, unsigned Depth=0)
 Return a SCEV corresponding to a conversion of the input value to the specified type. More...
 
const SCEVgetTruncateOrSignExtend (const SCEV *V, Type *Ty, unsigned Depth=0)
 Return a SCEV corresponding to a conversion of the input value to the specified type. More...
 
const SCEVgetNoopOrZeroExtend (const SCEV *V, Type *Ty)
 Return a SCEV corresponding to a conversion of the input value to the specified type. More...
 
const SCEVgetNoopOrSignExtend (const SCEV *V, Type *Ty)
 Return a SCEV corresponding to a conversion of the input value to the specified type. More...
 
const SCEVgetNoopOrAnyExtend (const SCEV *V, Type *Ty)
 Return a SCEV corresponding to a conversion of the input value to the specified type. More...
 
const SCEVgetTruncateOrNoop (const SCEV *V, Type *Ty)
 Return a SCEV corresponding to a conversion of the input value to the specified type. More...
 
const SCEVgetUMaxFromMismatchedTypes (const SCEV *LHS, const SCEV *RHS)
 Promote the operands to the wider of the types using zero-extension, and then perform a umax operation with them. More...
 
const SCEVgetUMinFromMismatchedTypes (const SCEV *LHS, const SCEV *RHS, bool Sequential=false)
 Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them. More...
 
const SCEVgetUMinFromMismatchedTypes (SmallVectorImpl< const SCEV * > &Ops, bool Sequential=false)
 Promote the operands to the wider of the types using zero-extension, and then perform a umin operation with them. More...
 
const SCEVgetPointerBase (const SCEV *V)
 Transitively follow the chain of pointer-type operands until reaching a SCEV that does not have a single pointer operand. More...
 
const SCEVremovePointerBase (const SCEV *S)
 Compute an expression equivalent to S - getPointerBase(S). More...
 
const SCEVgetSCEVAtScope (const SCEV *S, const Loop *L)
 Return a SCEV expression for the specified value at the specified scope in the program. More...
 
const SCEVgetSCEVAtScope (Value *V, const Loop *L)
 This is a convenience function which does getSCEVAtScope(getSCEV(V), L). More...
 
bool isLoopEntryGuardedByCond (const Loop *L, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
 Test whether entry to the loop is protected by a conditional between LHS and RHS. More...
 
bool isBasicBlockEntryGuardedByCond (const BasicBlock *BB, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
 Test whether entry to the basic block is protected by a conditional between LHS and RHS. More...
 
bool isLoopBackedgeGuardedByCond (const Loop *L, ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
 Test whether the backedge of the loop is protected by a conditional between LHS and RHS. More...
 
const SCEVgetTripCountFromExitCount (const SCEV *ExitCount, bool Extend=true)
 Convert from an "exit count" (i.e. More...
 
unsigned getSmallConstantTripCount (const Loop *L)
 Returns the exact trip count of the loop if we can compute it, and the result is a small constant. More...
 
unsigned getSmallConstantTripCount (const Loop *L, const BasicBlock *ExitingBlock)
 Return the exact trip count for this loop if we exit through ExitingBlock. More...
 
unsigned getSmallConstantMaxTripCount (const Loop *L)
 Returns the upper bound of the loop trip count as a normal unsigned value. More...
 
const SCEVgetConstantMaxTripCountFromArray (const Loop *L)
 Returns the upper bound of the loop trip count infered from array size. More...
 
unsigned getSmallConstantTripMultiple (const Loop *L, const SCEV *ExitCount)
 Returns the largest constant divisor of the trip count as a normal unsigned value, if possible. More...
 
unsigned getSmallConstantTripMultiple (const Loop *L)
 Returns the largest constant divisor of the trip count of the loop. More...
 
unsigned getSmallConstantTripMultiple (const Loop *L, const BasicBlock *ExitingBlock)
 Returns the largest constant divisor of the trip count of this loop as a normal unsigned value, if possible. More...
 
const SCEVgetExitCount (const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact)
 Return the number of times the backedge executes before the given exit would be taken; if not exactly computable, return SCEVCouldNotCompute. More...
 
const SCEVgetBackedgeTakenCount (const Loop *L, ExitCountKind Kind=Exact)
 If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCouldNotCompute object. More...
 
const SCEVgetPredicatedBackedgeTakenCount (const Loop *L, SCEVUnionPredicate &Predicates)
 Similar to getBackedgeTakenCount, except it will add a set of SCEV predicates to Predicates that are required to be true in order for the answer to be correct. More...
 
const SCEVgetConstantMaxBackedgeTakenCount (const Loop *L)
 When successful, this returns a SCEVConstant that is greater than or equal to (i.e. More...
 
const SCEVgetSymbolicMaxBackedgeTakenCount (const Loop *L)
 When successful, this returns a SCEV that is greater than or equal to (i.e. More...
 
bool isBackedgeTakenCountMaxOrZero (const Loop *L)
 Return true if the backedge taken count is either the value returned by getConstantMaxBackedgeTakenCount or zero. More...
 
bool hasLoopInvariantBackedgeTakenCount (const Loop *L)
 Return true if the specified loop has an analyzable loop-invariant backedge-taken count. More...
 
void forgetAllLoops ()
 
void forgetLoop (const Loop *L)
 This method should be called by the client when it has changed a loop in a way that may effect ScalarEvolution's ability to compute a trip count, or if the loop is deleted. More...
 
void forgetTopmostLoop (const Loop *L)
 
void forgetValue (Value *V)
 This method should be called by the client when it has changed a value in a way that may effect its value, or which may disconnect it from a def-use chain linking it to a loop. More...
 
void forgetLoopDispositions (const Loop *L)
 Called when the client has changed the disposition of values in this loop. More...
 
uint32_t GetMinTrailingZeros (const SCEV *S)
 Determine the minimum number of zero bits that S is guaranteed to end in (at every loop iteration). More...
 
ConstantRange getUnsignedRange (const SCEV *S)
 Determine the unsigned range for a particular SCEV. More...
 
APInt getUnsignedRangeMin (const SCEV *S)
 Determine the min of the unsigned range for a particular SCEV. More...
 
APInt getUnsignedRangeMax (const SCEV *S)
 Determine the max of the unsigned range for a particular SCEV. More...
 
ConstantRange getSignedRange (const SCEV *S)
 Determine the signed range for a particular SCEV. More...
 
APInt getSignedRangeMin (const SCEV *S)
 Determine the min of the signed range for a particular SCEV. More...
 
APInt getSignedRangeMax (const SCEV *S)
 Determine the max of the signed range for a particular SCEV. More...
 
bool isKnownNegative (const SCEV *S)
 Test if the given expression is known to be negative. More...
 
bool isKnownPositive (const SCEV *S)
 Test if the given expression is known to be positive. More...
 
bool isKnownNonNegative (const SCEV *S)
 Test if the given expression is known to be non-negative. More...
 
bool isKnownNonPositive (const SCEV *S)
 Test if the given expression is known to be non-positive. More...
 
bool isKnownNonZero (const SCEV *S)
 Test if the given expression is known to be non-zero. More...
 
std::pair< const SCEV *, const SCEV * > SplitIntoInitAndPostInc (const Loop *L, const SCEV *S)
 Splits SCEV expression S into two SCEVs. More...
 
bool isKnownViaInduction (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
 We'd like to check the predicate on every iteration of the most dominated loop between loops used in LHS and RHS. More...
 
bool isKnownPredicate (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
 Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS. More...
 
Optional< bool > evaluatePredicate (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS)
 Check whether the condition described by Pred, LHS, and RHS is true or false. More...
 
bool isKnownPredicateAt (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *CtxI)
 Test if the given expression is known to satisfy the condition described by Pred, LHS, and RHS in the given Context. More...
 
Optional< bool > evaluatePredicateAt (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *CtxI)
 Check whether the condition described by Pred, LHS, and RHS is true or false in the given Context. More...
 
bool isKnownOnEveryIteration (ICmpInst::Predicate Pred, const SCEVAddRecExpr *LHS, const SCEV *RHS)
 Test if the condition described by Pred, LHS, RHS is known to be true on every iteration of the loop of the recurrency LHS. More...
 
Optional< MonotonicPredicateTypegetMonotonicPredicateType (const SCEVAddRecExpr *LHS, ICmpInst::Predicate Pred)
 If, for all loop invariant X, the predicate "LHS `Pred` X" is monotonically increasing or decreasing, returns Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing) respectively. More...
 
Optional< LoopInvariantPredicategetLoopInvariantPredicate (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L)
 If the result of the predicate LHS Pred RHS is loop invariant with respect to L, return a LoopInvariantPredicate with LHS and RHS being invariants, available at L's entry. More...
 
Optional< LoopInvariantPredicategetLoopInvariantExitCondDuringFirstIterations (ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L, const Instruction *CtxI, const SCEV *MaxIter)
 If the result of the predicate LHS Pred RHS is loop invariant with respect to L at given Context during at least first MaxIter iterations, return a LoopInvariantPredicate with LHS and RHS being invariants, available at L's entry. More...
 
bool SimplifyICmpOperands (ICmpInst::Predicate &Pred, const SCEV *&LHS, const SCEV *&RHS, unsigned Depth=0)
 Simplify LHS and RHS in a comparison with predicate Pred. More...
 
LoopDisposition getLoopDisposition (const SCEV *S, const Loop *L)
 Return the "disposition" of the given SCEV with respect to the given loop. More...
 
bool isLoopInvariant (const SCEV *S, const Loop *L)
 Return true if the value of the given SCEV is unchanging in the specified loop. More...
 
bool isAvailableAtLoopEntry (const SCEV *S, const Loop *L)
 Determine if the SCEV can be evaluated at loop's entry. More...
 
bool hasComputableLoopEvolution (const SCEV *S, const Loop *L)
 Return true if the given SCEV changes value in a known way in the specified loop. More...
 
BlockDisposition getBlockDisposition (const SCEV *S, const BasicBlock *BB)
 Return the "disposition" of the given SCEV with respect to the given block. More...
 
bool dominates (const SCEV *S, const BasicBlock *BB)
 Return true if elements that makes up the given SCEV dominate the specified basic block. More...
 
bool properlyDominates (const SCEV *S, const BasicBlock *BB)
 Return true if elements that makes up the given SCEV properly dominate the specified basic block. More...
 
bool hasOperand (const SCEV *S, const SCEV *Op) const
 Test whether the given SCEV has Op as a direct or indirect operand. More...
 
const SCEVgetElementSize (Instruction *Inst)
 Return the size of an element read or written by Inst. More...
 
void print (raw_ostream &OS) const
 
void verify () const
 
bool invalidate (Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
 
const DataLayoutgetDataLayout () const
 Return the DataLayout associated with the module this SCEV instance is operating on. More...
 
const SCEVPredicategetEqualPredicate (const SCEV *LHS, const SCEV *RHS)
 
const SCEVPredicategetWrapPredicate (const SCEVAddRecExpr *AR, SCEVWrapPredicate::IncrementWrapFlags AddedFlags)
 
const SCEVrewriteUsingPredicate (const SCEV *S, const Loop *L, SCEVUnionPredicate &A)
 Re-writes the SCEV according to the Predicates in A. More...
 
const SCEVAddRecExprconvertSCEVToAddRecWithPredicates (const SCEV *S, const Loop *L, SmallPtrSetImpl< const SCEVPredicate * > &Preds)
 Tries to convert the S expression to an AddRec expression, adding additional predicates to Preds as required. More...
 
Optional< APIntcomputeConstantDifference (const SCEV *LHS, const SCEV *RHS)
 Compute LHS - RHS and returns the result as an APInt if it is a constant, and None if it isn't. More...
 
void setNoWrapFlags (SCEVAddRecExpr *AddRec, SCEV::NoWrapFlags Flags)
 Update no-wrap flags of an AddRec. More...
 
const SCEVapplyLoopGuards (const SCEV *Expr, const Loop *L)
 Try to apply information from loop guards for L to Expr. More...
 
bool loopHasNoAbnormalExits (const Loop *L)
 Return true if the loop has no abnormal exits. More...
 
bool loopIsFiniteByAssumption (const Loop *L)
 Return true if this loop is finite by assumption. More...
 

Static Public Member Functions

static LLVM_NODISCARD SCEV::NoWrapFlags maskFlags (SCEV::NoWrapFlags Flags, int Mask)
 Convenient NoWrapFlags manipulation that hides enum casts and is visible in the ScalarEvolution name space. More...
 
static LLVM_NODISCARD SCEV::NoWrapFlags setFlags (SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags)
 
static LLVM_NODISCARD SCEV::NoWrapFlags clearFlags (SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags)
 
static LLVM_NODISCARD bool 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 the SCEV objects directly, they must ask this class for services.

Definition at line 460 of file ScalarEvolution.h.

Member Enumeration Documentation

◆ BlockDisposition

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

Enumerator
DoesNotDominateBlock 

The SCEV does not dominate the block.

DominatesBlock 

The SCEV dominates the block.

ProperlyDominatesBlock 

The SCEV properly dominates the block.

Definition at line 472 of file ScalarEvolution.h.

◆ 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 line 852 of file ScalarEvolution.h.

◆ LoopDisposition

An enum describing the relationship between a SCEV and a loop.

Enumerator
LoopVariant 

The SCEV is loop-variant (unknown).

LoopInvariant 

The SCEV is loop-invariant.

LoopComputable 

The SCEV varies predictably with the loop.

Definition at line 465 of file ScalarEvolution.h.

◆ 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 line 1070 of file ScalarEvolution.h.

Constructor & Destructor Documentation

◆ ScalarEvolution() [1/2]

ScalarEvolution::ScalarEvolution ( Function F,
TargetLibraryInfo TLI,
AssumptionCache AC,
DominatorTree DT,
LoopInfo LI 
)

Definition at line 12652 of file ScalarEvolution.cpp.

References F, and llvm::Intrinsic::getName().

Referenced by willNotOverflow().

◆ ScalarEvolution() [2/2]

ScalarEvolution::ScalarEvolution ( ScalarEvolution &&  Arg)

Definition at line 12673 of file ScalarEvolution.cpp.

References Arg.

◆ ~ScalarEvolution()

ScalarEvolution::~ScalarEvolution ( )

Member Function Documentation

◆ applyLoopGuards()

const SCEV * ScalarEvolution::applyLoopGuards ( const SCEV Expr,
const Loop L 
)

Try to apply information from loop guards for L to Expr.

Definition at line 14060 of file ScalarEvolution.cpp.

References llvm::AssumptionCache::assumptions(), C1, Cond, containsAddRecurrence(), llvm::DominatorTree::dominates(), E, llvm::SmallVectorImpl< T >::emplace_back(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::empty(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::erase(), getAddExpr(), llvm::BranchInst::getCondition(), getConstant(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopPredecessor(), getMinusSCEV(), getMulExpr(), getOne(), getSCEV(), getSMaxExpr(), getSMinExpr(), llvm::BranchInst::getSuccessor(), llvm::CmpInst::getSwappedPredicate(), llvm::Value::getType(), getUDivExpr(), getUMaxExpr(), getUMinExpr(), llvm::SCEVConstant::getValue(), I, 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::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Constant::isNullValue(), llvm::BranchInst::isUnconditional(), LHS, llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOr(), llvm::PatternMatch::m_Value(), llvm::ConstantRange::makeExactICmpRegion(), llvm::PatternMatch::match(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::reverse(), Rewriter, RHS, llvm::ConstantRange::sub(), and std::swap().

Referenced by llvm::LoopVectorizationCostModel::computeMaxVF(), and getSmallConstantTripMultiple().

◆ clearFlags()

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

Definition at line 489 of file ScalarEvolution.h.

◆ computeConstantDifference()

Optional< APInt > ScalarEvolution::computeConstantDifference ( const SCEV LHS,
const SCEV RHS 
)

Compute LHS - RHS and returns the result as an APInt if it is a constant, and None if it isn't.

This is intended to be a cheaper version of getMinusSCEV. We can be frugal here since we just bail out of actually constructing and canonicalizing an expression in the cases where the result isn't going to be a constant.

Definition at line 11176 of file ScalarEvolution.cpp.

References C1, llvm::SCEV::getType(), getTypeSizeInBits(), llvm::CodeGenOpt::Less, M, and llvm::None.

Referenced by DbgRewriteSalvageableDVIs().

◆ containsAddRecurrence()

bool ScalarEvolution::containsAddRecurrence ( const SCEV S)

◆ containsUndefs()

bool ScalarEvolution::containsUndefs ( const SCEV S) const

Return true if the SCEV expression contains an undef value.

Definition at line 12582 of file ScalarEvolution.cpp.

References S, and llvm::SCEVExprContains().

Referenced by DbgGatherSalvagableDVI(), GetInductionVariable(), and verify().

◆ convertSCEVToAddRecWithPredicates()

const SCEVAddRecExpr * ScalarEvolution::convertSCEVToAddRecWithPredicates ( const SCEV S,
const Loop L,
SmallPtrSetImpl< const SCEVPredicate * > &  Preds 
)

Tries to convert the S expression to an AddRec expression, adding additional predicates to Preds as required.

Definition at line 13646 of file ScalarEvolution.cpp.

References llvm::SmallPtrSetImpl< PtrType >::insert(), P, rewrite(), and S.

Referenced by llvm::PredicatedScalarEvolution::getAsAddRec().

◆ createAddRecFromPHIWithCasts()

Optional< std::pair< const SCEV *, SmallVector< const SCEVPredicate *, 3 > > > ScalarEvolution::createAddRecFromPHIWithCasts ( const SCEVUnknown SymbolicPHI)

Checks if SymbolicPHI can be rewritten as an AddRecExpr under some Predicates.

If successful return these <AddRecExpr, Predicates>; The function is intended to be called from PSCEV (the caller will decide whether to actually add the predicates and carry out the rewrites).

Definition at line 5446 of file ScalarEvolution.cpp.

References assert(), llvm::SCEVUnknown::getValue(), I, isIntegerLoopHeaderPHI(), and llvm::None.

◆ dominates()

bool ScalarEvolution::dominates ( const SCEV S,
const BasicBlock BB 
)

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

Definition at line 13091 of file ScalarEvolution.cpp.

References BB, DominatesBlock, getBlockDisposition(), and S.

Referenced by llvm::isSafeToExpandAt().

◆ evaluatePredicate()

Optional< bool > ScalarEvolution::evaluatePredicate ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS 
)

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

If we know it, return the evaluation of this condition. If neither is proved, return None.

Definition at line 10241 of file ScalarEvolution.cpp.

References llvm::CmpInst::getInversePredicate(), isKnownPredicate(), LHS, llvm::None, and RHS.

Referenced by countToEliminateCompares(), and evaluatePredicateAt().

◆ evaluatePredicateAt()

Optional< bool > ScalarEvolution::evaluatePredicateAt ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS,
const Instruction CtxI 
)

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

If we know it, return the evaluation of this condition. If neither is proved, return None.

Definition at line 10259 of file ScalarEvolution.cpp.

References evaluatePredicate(), llvm::CmpInst::getInversePredicate(), llvm::Instruction::getParent(), isBasicBlockEntryGuardedByCond(), LHS, llvm::None, and RHS.

◆ forgetAllLoops()

void ScalarEvolution::forgetAllLoops ( )

◆ forgetLoop()

void ScalarEvolution::forgetLoop ( const Loop L)

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

This call is potentially expensive for large loop bodies.

Definition at line 7850 of file ScalarEvolution.cpp.

References I, and llvm::SmallVectorImpl< T >::pop_back_val().

Referenced by llvm::breakLoopBackedge(), llvm::deleteDeadLoop(), deleteLoopIfDead(), DoFlattenLoopPair(), llvm::InnerLoopVectorizer::fixVectorizedLoop(), forgetTopmostLoop(), llvm::formLCSSA(), separateNestedLoop(), llvm::splitLoopBound(), llvm::UnrollAndJamLoop(), unswitchNontrivialInvariants(), unswitchTrivialBranch(), and unswitchTrivialSwitch().

◆ forgetLoopDispositions()

void ScalarEvolution::forgetLoopDispositions ( const Loop L)

Called when the client has changed the disposition of values in this loop.

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

Definition at line 7940 of file ScalarEvolution.cpp.

Referenced by isLoopDead(), simplifyOneLoop(), and sinkLoopInvariantInstructions().

◆ forgetTopmostLoop()

void ScalarEvolution::forgetTopmostLoop ( const Loop L)

◆ forgetValue()

void ScalarEvolution::forgetValue ( Value V)

◆ getAbsExpr()

const SCEV * ScalarEvolution::getAbsExpr ( const SCEV Op,
bool  IsNSW 
)

◆ getAddExpr() [1/3]

const SCEV* llvm::ScalarEvolution::getAddExpr ( const SCEV LHS,
const SCEV RHS,
SCEV::NoWrapFlags  Flags = SCEV::FlagAnyWrap,
unsigned  Depth = 0 
)
inline

Definition at line 576 of file ScalarEvolution.h.

References llvm::Depth, getAddExpr(), LHS, and RHS.

◆ getAddExpr() [2/3]

const SCEV* llvm::ScalarEvolution::getAddExpr ( const SCEV Op0,
const SCEV Op1,
const SCEV Op2,
SCEV::NoWrapFlags  Flags = SCEV::FlagAnyWrap,
unsigned  Depth = 0 
)
inline

Definition at line 582 of file ScalarEvolution.h.

References llvm::Depth, and getAddExpr().

◆ getAddExpr() [3/3]

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

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

Definition at line 2440 of file ScalarEvolution.cpp.

References llvm::APInt::abs(), AddOpsInlineThreshold, llvm::SmallVectorImpl< T >::append(), assert(), B, llvm::BasicBlock::begin(), llvm::BitWidth, C1, llvm::SmallVectorImpl< T >::clear(), CollectAddOperandsWithScales(), llvm::count_if(), llvm::Depth, llvm::DominatorTree::dominates(), llvm::numbers::e, llvm::SmallVectorImpl< T >::erase(), f(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::SCEV::FlagNW, getAddRecExpr(), getAnyExtendExpr(), getConstant(), getEffectiveSCEVType(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::SCEVAddRecExpr::getLoop(), getMulExpr(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::User::getNumOperands(), llvm::SCEVNAryExpr::getNumOperands(), getOne(), llvm::User::getOperand(), llvm::SCEVNAryExpr::getOperand(), llvm::SCEVAddRecExpr::getStart(), getTruncateExpr(), llvm::Intrinsic::getType(), getTypeSizeInBits(), getUDivExpr(), getZero(), GroupByComplexity(), hasFlags(), hasHugeExpression(), i, isAvailableAtLoopEntry(), llvm::APInt::isSignBitSet(), j(), LHS, M, maskFlags(), MaxArithDepth, Mul, llvm::SCEVNAryExpr::op_begin(), llvm::User::op_begin(), llvm::SCEVNAryExpr::op_end(), llvm::User::op_end(), llvm::SCEVNAryExpr::operands(), RHS, S, llvm::scAddExpr, llvm::scAddRecExpr, llvm::scMulExpr, setFlags(), StrengthenNoWrapFlags(), llvm::APInt::ule(), X, and Y.

Referenced by applyLoopGuards(), llvm::calculateUpperBound(), llvm::LoopVectorizationCostModel::computeMaxVF(), countToEliminateCompares(), llvm::SCEVAddRecExpr::evaluateAtIteration(), ExtractImmediate(), ExtractSymbol(), FactorOutConstant(), genLoopLimit(), getAddExpr(), getConstantMaxTripCountFromArray(), getExtendAddRecStart(), getGEPExpr(), getLosslessPtrToIntExpr(), getMinusSCEV(), getMulExpr(), getNewAlignment(), llvm::InnerLoopVectorizer::getOrCreateTripCount(), llvm::SCEVAddRecExpr::getPostIncExpr(), getSignExtendExpr(), getTripCount(), getTripCountFromExitCount(), getTruncateExpr(), getUDivCeilSCEV(), getUDivExpr(), llvm::RuntimePointerChecking::insert(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), IsIncrementNSW(), IsIncrementNUW(), removePointerBase(), SimplifyAddOperands(), SimplifyICmpOperands(), llvm::UnrollRuntimeLoopRemainder(), llvm::SCEVDivision::visitAddExpr(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitAddExpr(), and willNotOverflow().

◆ getAddRecExpr() [1/3]

const SCEV * ScalarEvolution::getAddRecExpr ( const SCEV Start,
const SCEV Step,
const Loop L,
SCEV::NoWrapFlags  Flags 
)

◆ getAddRecExpr() [2/3]

const SCEV* llvm::ScalarEvolution::getAddRecExpr ( const SmallVectorImpl< const SCEV * > &  Operands,
const Loop L,
SCEV::NoWrapFlags  Flags 
)
inline

Definition at line 610 of file ScalarEvolution.h.

References getAddRecExpr(), and Operands.

◆ getAddRecExpr() [3/3]

const SCEV * ScalarEvolution::getAddRecExpr ( SmallVectorImpl< const SCEV * > &  Operands,
const Loop L,
SCEV::NoWrapFlags  Flags 
)

◆ getAnyExtendExpr()

const SCEV * ScalarEvolution::getAnyExtendExpr ( const SCEV Op,
Type Ty 
)

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

Definition at line 2138 of file ScalarEvolution.cpp.

References assert(), llvm::SCEV::FlagNW, getAddRecExpr(), getEffectiveSCEVType(), getSignExtendExpr(), getTruncateOrNoop(), llvm::SCEV::getType(), getTypeSizeInBits(), getZeroExtendExpr(), isSCEVable(), and llvm::PPCISD::SC.

Referenced by getAddExpr(), and getNoopOrAnyExtend().

◆ getBackedgeTakenCount()

const SCEV * ScalarEvolution::getBackedgeTakenCount ( const Loop L,
ExitCountKind  Kind = Exact 
)

If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCouldNotCompute object.

The backedge-taken count is the number of times the loop header will be branched to from within the loop, assuming there are no abnormal exists like exception throws. This is one less than the trip count of the loop, since it doesn't count the first iteration, when the header is branched to from outside the loop.

Note that it is not valid to call this method on a loop without a loop-invariant backedge-taken count (see hasLoopInvariantBackedgeTakenCount).

Definition at line 7720 of file ScalarEvolution.cpp.

References ConstantMaximum, Exact, llvm_unreachable, and SymbolicMaximum.

Referenced by breakBackedgeIfNotTaken(), computeTripCount(), findLoopComponents(), getConstantMaxBackedgeTakenCount(), getSmallConstantTripCount(), getSymbolicMaxBackedgeTakenCount(), hasLoopInvariantBackedgeTakenCount(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::IVUsers::print(), PrintLoopInfo(), and verify().

◆ getBlockDisposition()

ScalarEvolution::BlockDisposition ScalarEvolution::getBlockDisposition ( const SCEV S,
const BasicBlock BB 
)

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

Definition at line 13005 of file ScalarEvolution.cpp.

References BB, D, DoesNotDominateBlock, llvm::reverse(), and S.

Referenced by dominates(), and properlyDominates().

◆ getCastExpr()

const SCEV * ScalarEvolution::getCastExpr ( SCEVTypes  Kind,
const SCEV Op,
Type Ty 
)

◆ getConstant() [1/3]

const SCEV * ScalarEvolution::getConstant ( const APInt Val)

Definition at line 461 of file ScalarEvolution.cpp.

References llvm::ConstantInt::get(), getConstant(), and getContext().

◆ getConstant() [2/3]

const SCEV * ScalarEvolution::getConstant ( ConstantInt V)

◆ getConstant() [3/3]

const SCEV * ScalarEvolution::getConstant ( Type Ty,
uint64_t  V,
bool  isSigned = false 
)

◆ getConstantMaxBackedgeTakenCount()

const SCEV* llvm::ScalarEvolution::getConstantMaxBackedgeTakenCount ( const Loop L)
inline

When successful, this returns a SCEVConstant that is greater than or equal to (i.e.

a "conservative over-approximation") of the value returend by getBackedgeTakenCount. If such a value cannot be computed, it returns the SCEVCouldNotCompute object.

Definition at line 894 of file ScalarEvolution.h.

References ConstantMaximum, and getBackedgeTakenCount().

Referenced by breakBackedgeIfNotTaken(), getSmallConstantMaxTripCount(), isLoopDead(), mustBeFiniteCountedLoop(), and PrintLoopInfo().

◆ getConstantMaxTripCountFromArray()

const SCEV * ScalarEvolution::getConstantMaxTripCountFromArray ( const Loop L)

◆ getContext()

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

◆ getCouldNotCompute()

const SCEV * ScalarEvolution::getCouldNotCompute ( )

◆ getDataLayout()

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

◆ getEffectiveSCEVType()

Type * ScalarEvolution::getEffectiveSCEVType ( Type Ty) const

Return a type with the same bitwidth as the given type and which represents how SCEV will treat the given type, for which isSCEVable must return true.

For pointer types, this is the pointer-sized integer type.

For pointer types, this is the pointer index sized integer type.

Definition at line 4214 of file ScalarEvolution.cpp.

References assert(), getDataLayout(), llvm::DataLayout::getIndexType(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), and isSCEVable().

Referenced by canBeCheaplyTransformed(), canComputePointerDiff(), DoInitialMatch(), genLoopLimit(), getAddExpr(), getAddRecExpr(), getAnyExtendExpr(), getConstant(), getElementSize(), getGEPExpr(), getLosslessPtrToIntExpr(), getMinMaxExpr(), getNegativeSCEV(), getNewAlignment(), getNotSCEV(), getSequentialMinMaxExpr(), getSignExtendExpr(), getTruncateExpr(), getURemExpr(), getZeroExtendExpr(), isExistingPhi(), and visitIVCast().

◆ getElementSize()

const SCEV * ScalarEvolution::getElementSize ( Instruction Inst)

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

Definition at line 12591 of file ScalarEvolution.cpp.

References getEffectiveSCEVType(), getSizeOfExpr(), llvm::PointerType::getUnqual(), llvm::SPII::Load, and llvm::SPII::Store.

Referenced by getConstantMaxTripCountFromArray().

◆ getEqualPredicate()

const SCEVPredicate * ScalarEvolution::getEqualPredicate ( const SCEV LHS,
const SCEV RHS 
)

◆ getExitCount()

const SCEV * ScalarEvolution::getExitCount ( const Loop L,
const BasicBlock ExitingBlock,
ExitCountKind  Kind = Exact 
)

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

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

Definition at line 7701 of file ScalarEvolution.cpp.

References ConstantMaximum, Exact, llvm_unreachable, and SymbolicMaximum.

Referenced by llvm::calculateUpperBound(), getMinAnalyzeableBackedgeTakenCount(), getSmallConstantTripCount(), getSmallConstantTripMultiple(), llvm::hasIterationCountInvariantInParent(), llvm::HardwareLoopInfo::isHardwareLoopCandidate(), mustBeFiniteCountedLoop(), PrintLoopInfo(), llvm::rewriteLoopExitValues(), and llvm::UnrollRuntimeLoopRemainder().

◆ getGEPExpr()

const SCEV * ScalarEvolution::getGEPExpr ( GEPOperator GEP,
const SmallVectorImpl< const SCEV * > &  IndexExprs 
)

Returns an expression for a GEP.

GEP The GEP. The indices contained in the GEP itself are ignored, instead we use IndexExprs. IndexExprs The expressions for the indices.

Definition at line 3656 of file ScalarEvolution.cpp.

References assert(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, GEP, getAddExpr(), getEffectiveSCEVType(), getMulExpr(), getOffsetOfExpr(), getSCEV(), getSizeOfExpr(), getTruncateOrSignExtend(), llvm::SCEV::getType(), llvm::GetElementPtrInst::getTypeAtIndex(), Index, isKnownNonNegative(), and Offset.

◆ getLoopDisposition()

ScalarEvolution::LoopDisposition ScalarEvolution::getLoopDisposition ( const SCEV S,
const Loop L 
)

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

Definition at line 12896 of file ScalarEvolution.cpp.

References D, LoopVariant, llvm::reverse(), and S.

Referenced by hasComputableLoopEvolution(), llvm::hasIterationCountInvariantInParent(), isLoopInvariant(), and print().

◆ getLoopInvariantExitCondDuringFirstIterations()

Optional< ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantExitCondDuringFirstIterations ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS,
const Loop L,
const Instruction CtxI,
const SCEV MaxIter 
)

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

Otherwise, return None. The predicate should be the loop's exit condition.

Definition at line 10397 of file ScalarEvolution.cpp.

References llvm::SCEVAddRecExpr::evaluateAtIteration(), llvm::SCEVAddRecExpr::getLoop(), getNegativeSCEV(), getOne(), llvm::SCEVAddRecExpr::getStepRecurrence(), llvm::CmpInst::getSwappedPredicate(), llvm::SCEV::getType(), llvm::SCEVAddRecExpr::getType(), llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_ULE, isLoopBackedgeGuardedByCond(), isLoopInvariant(), llvm::ICmpInst::isRelational(), llvm::CmpInst::isSigned(), LHS, llvm::None, RHS, and std::swap().

Referenced by optimizeLoopExitWithUnknownExitCount().

◆ getLoopInvariantPredicate()

Optional< ScalarEvolution::LoopInvariantPredicate > ScalarEvolution::getLoopInvariantPredicate ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS,
const Loop L 
)

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

Otherwise, return None.

Definition at line 10350 of file ScalarEvolution.cpp.

References llvm::CmpInst::getInversePredicate(), llvm::SCEVAddRecExpr::getLoop(), getMonotonicPredicateType(), llvm::SCEVAddRecExpr::getStart(), llvm::CmpInst::getSwappedPredicate(), isLoopBackedgeGuardedByCond(), isLoopInvariant(), LHS, MonotonicallyIncreasing, llvm::None, P, RHS, and std::swap().

◆ getLosslessPtrToIntExpr()

const SCEV * ScalarEvolution::getLosslessPtrToIntExpr ( const SCEV Op,
unsigned  Depth = 0 
)

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

Definition at line 1057 of file ScalarEvolution.cpp.

References assert(), 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(), Operands, llvm::SCEVNAryExpr::operands(), registerUser(), rewrite(), Rewriter, S, and llvm::scPtrToInt.

Referenced by getLosslessPtrToIntExpr(), and getPtrToIntExpr().

◆ getMinMaxExpr()

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

◆ GetMinTrailingZeros()

uint32_t ScalarEvolution::GetMinTrailingZeros ( const SCEV S)

Determine the minimum number of zero bits that S is guaranteed to end in (at every loop iteration).

It is, at the same time, the minimum number of times S is divisible by 2. For example, given {4,+,8} it returns 2. If S is guaranteed to be 0, it returns the bitwidth of S.

Definition at line 6086 of file ScalarEvolution.cpp.

References assert(), I, and S.

Referenced by extractConstantWithoutWrapping(), getSmallConstantTripMultiple(), getTruncateExpr(), and SolveLinEquationWithOverflow().

◆ getMinusOne()

const SCEV* llvm::ScalarEvolution::getMinusOne ( Type Ty)
inline

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

Definition at line 655 of file ScalarEvolution.h.

References getConstant().

Referenced by getNegativeSCEV(), getNotSCEV(), and optimizeLoopExitWithUnknownExitCount().

◆ getMinusSCEV()

const SCEV * ScalarEvolution::getMinusSCEV ( const SCEV LHS,
const SCEV RHS,
SCEV::NoWrapFlags  Flags = SCEV::FlagAnyWrap,
unsigned  Depth = 0 
)

◆ getMonotonicPredicateType()

Optional< ScalarEvolution::MonotonicPredicateType > ScalarEvolution::getMonotonicPredicateType ( const SCEVAddRecExpr LHS,
ICmpInst::Predicate  Pred 
)

If, for all loop invariant X, the predicate "LHS `Pred` X" is monotonically increasing or decreasing, returns Some(MonotonicallyIncreasing) and Some(MonotonicallyDecreasing) respectively.

If we could not prove either of these facts, returns None.

Definition at line 10285 of file ScalarEvolution.cpp.

References assert(), llvm::CmpInst::getSwappedPredicate(), and LHS.

Referenced by countToEliminateCompares(), and getLoopInvariantPredicate().

◆ getMulExpr() [1/3]

const SCEV* llvm::ScalarEvolution::getMulExpr ( const SCEV LHS,
const SCEV RHS,
SCEV::NoWrapFlags  Flags = SCEV::FlagAnyWrap,
unsigned  Depth = 0 
)
inline

Definition at line 591 of file ScalarEvolution.h.

References llvm::Depth, getMulExpr(), LHS, and RHS.

◆ getMulExpr() [2/3]

const SCEV* llvm::ScalarEvolution::getMulExpr ( const SCEV Op0,
const SCEV Op1,
const SCEV Op2,
SCEV::NoWrapFlags  Flags = SCEV::FlagAnyWrap,
unsigned  Depth = 0 
)
inline

Definition at line 597 of file ScalarEvolution.h.

References llvm::Depth, and getMulExpr().

◆ getMulExpr() [3/3]

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

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

Definition at line 3037 of file ScalarEvolution.cpp.

References llvm::SmallVectorImpl< T >::append(), assert(), Choose(), containsConstantInAddMulChain(), llvm::Depth, llvm::numbers::e, llvm::SmallVectorImpl< T >::erase(), llvm::SCEV::FlagAnyWrap, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::SCEV::FlagNW, getAddExpr(), getAddRecExpr(), getConstant(), llvm::SCEVAddRecExpr::getLoop(), llvm::SCEVNAryExpr::getNoWrapFlags(), llvm::SCEVNAryExpr::getNumOperands(), llvm::SCEVNAryExpr::getOperand(), llvm::Intrinsic::getType(), llvm::SCEVAddRecExpr::getType(), getTypeSizeInBits(), getZero(), GroupByComplexity(), hasHugeExpression(), i, isAvailableAtLoopEntry(), llvm::Type::isPointerTy(), maskFlags(), llvm::max(), MaxAddRecSize, MaxArithDepth, llvm::min(), Mul, MulOpsInlineThreshold, llvm::User::op_begin(), llvm::User::op_end(), Operands, llvm::SmallVectorImpl< T >::reserve(), S, llvm::scAddRecExpr, llvm::scMulExpr, StrengthenNoWrapFlags(), umul_ov(), x, y, and z.

Referenced by applyLoopGuards(), BinomialCoefficient(), CollectAddOperandsWithScales(), CollectSubexprs(), llvm::IndexedReference::computeRefCost(), DoInitialMatch(), llvm::SCEVAddRecExpr::evaluateAtIteration(), FactorOutConstant(), findArrayDimensionsRec(), getAddExpr(), getExactSDiv(), getGEPExpr(), getLosslessPtrToIntExpr(), getMulExpr(), getNegativeSCEV(), getNumBytes(), getTruncateExpr(), getUDivExactExpr(), getUDivExpr(), getURemExpr(), isSafeDependenceDistance(), removeConstantFactors(), SolveLinEquationWithOverflow(), llvm::SCEVDivision::visitMulExpr(), llvm::SCEVRewriteVisitor< SCEVLoopGuardRewriter >::visitMulExpr(), and willNotOverflow().

◆ getNegativeSCEV()

const SCEV * ScalarEvolution::getNegativeSCEV ( const SCEV V,
SCEV::NoWrapFlags  Flags = SCEV::FlagAnyWrap 
)

◆ getNoopOrAnyExtend()

const SCEV * ScalarEvolution::getNoopOrAnyExtend ( const SCEV V,
Type Ty 
)

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

If the type must be extended, it is extended with unspecified bits. The conversion must not be narrowing.

Definition at line 4570 of file ScalarEvolution.cpp.

References assert(), getAnyExtendExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().

Referenced by llvm::IndexedReference::computeRefCost().

◆ getNoopOrSignExtend()

const SCEV * ScalarEvolution::getNoopOrSignExtend ( const SCEV V,
Type Ty 
)

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

If the type must be extended, it is sign extended. The conversion must not be narrowing.

Definition at line 4558 of file ScalarEvolution.cpp.

References assert(), getSignExtendExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().

Referenced by getNewAlignment(), isSafeDependenceDistance(), and NoopOrExtend().

◆ getNoopOrZeroExtend()

const SCEV * ScalarEvolution::getNoopOrZeroExtend ( const SCEV V,
Type Ty 
)

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

If the type must be extended, it is zero extended. The conversion must not be narrowing.

Definition at line 4546 of file ScalarEvolution.cpp.

References assert(), llvm::SCEV::getType(), getTypeSizeInBits(), getZeroExtendExpr(), and llvm::Type::isIntOrPtrTy().

Referenced by llvm::InnerLoopVectorizer::getOrCreateTripCount(), getTripCountFromExitCount(), getUMaxFromMismatchedTypes(), getUMinFromMismatchedTypes(), and NoopOrExtend().

◆ getNotSCEV()

const SCEV * ScalarEvolution::getNotSCEV ( const SCEV V)

◆ getOffsetOfExpr()

const SCEV * ScalarEvolution::getOffsetOfExpr ( Type IntTy,
StructType STy,
unsigned  FieldNo 
)

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

Definition at line 4157 of file ScalarEvolution.cpp.

References getConstant(), and getDataLayout().

Referenced by getGEPExpr().

◆ getOne()

const SCEV* llvm::ScalarEvolution::getOne ( Type Ty)
inline

◆ getPointerBase()

const SCEV * ScalarEvolution::getPointerBase ( const SCEV V)

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

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

Definition at line 4639 of file ScalarEvolution.cpp.

References assert(), llvm::SCEV::getType(), and llvm::Type::isPointerTy().

Referenced by llvm::DependenceInfo::depends(), getConstantMaxTripCountFromArray(), and getMinusSCEV().

◆ getPredicatedBackedgeTakenCount()

const SCEV * ScalarEvolution::getPredicatedBackedgeTakenCount ( const Loop L,
SCEVUnionPredicate Predicates 
)

Similar to getBackedgeTakenCount, except it will add a set of SCEV predicates to Predicates that are required to be true in order for the answer to be correct.

Predicates can be checked with run-time checks and can be used to perform loop versioning.

Definition at line 7715 of file ScalarEvolution.cpp.

Referenced by llvm::PredicatedScalarEvolution::getBackedgeTakenCount(), and PrintLoopInfo().

◆ getPtrToIntExpr()

const SCEV * ScalarEvolution::getPtrToIntExpr ( const SCEV Op,
Type Ty 
)

◆ getSCEV()

const SCEV * ScalarEvolution::getSCEV ( Value V)

Return a SCEV expression for the full generality of the specified expression.

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

Definition at line 4339 of file ScalarEvolution.cpp.

References assert(), llvm::Value::getType(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), isSCEVable(), Offset, S, SCEVCallbackVH, and splitAddExpr().

Referenced by llvm::IVUsers::AddUsersIfInteresting(), llvm::SCEVAAResult::alias(), llvm::analyzeICmp(), applyLoopGuards(), canTailPredicateLoop(), countToEliminateCompares(), DbgGatherSalvagableDVI(), DbgRewriteSalvageableDVIs(), llvm::DependenceInfo::depends(), DoInitialMatch(), llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(), findIVOperand(), findLoopComponents(), FindLoopCounter(), genLoopLimit(), llvm::PredicatedScalarEvolution::getAsAddRec(), llvm::Loop::LoopBounds::getBounds(), getBoundsCheckCond(), getConstantMaxTripCountFromArray(), getFalkorUnrollingPreferences(), getGEPExpr(), llvm::getIndexExpressionsFromGEP(), GetInductionVariable(), getNewAlignment(), llvm::getPointersDiff(), llvm::IVUsers::getReplacementExpr(), llvm::PredicatedScalarEvolution::getSCEV(), getSCEVAtScope(), llvm::DependenceInfo::getSplitIteration(), getStrengthenedNoWrapFlagsFromBinOp(), llvm::getStrideFromPointer(), llvm::isDereferenceableAndAlignedInLoop(), isExistingPhi(), isHighCostExpansion(), llvm::InductionDescriptor::isInductionPHI(), isLoopCounter(), isProfitableChain(), isSimpleIVUser(), llvm::LoopAccessInfo::isUniform(), print(), llvm::PredicatedScalarEvolution::print(), llvm::AlignmentFromAssumptionsPass::processAssumption(), llvm::replaceSymbolicStrideSCEV(), llvm::rewriteLoopExitValues(), llvm::splitLoopBound(), and llvm::stripGetElementPtr().

◆ getSCEVAtScope() [1/2]

const SCEV * ScalarEvolution::getSCEVAtScope ( const SCEV S,
const Loop L 
)

Return a SCEV expression for the specified value at the specified scope in the program.

The L value specifies a loop nest to evaluate the expression at, where null is the top-level or a specified loop is immediately inside of the loop.

This method can be used to compute the exit value for a variable defined in a loop by querying what the value will hold in the parent loop.

In the case that a relevant loop exit value cannot be computed, the original value V is returned.

Definition at line 9066 of file ScalarEvolution.cpp.

References llvm::AArch64CC::LS, and llvm::reverse().

Referenced by computeUnrollAndJamCount(), getSCEVAtScope(), isInteresting(), optimizeLoopExitWithUnknownExitCount(), print(), and llvm::rewriteLoopExitValues().

◆ getSCEVAtScope() [2/2]

const SCEV * ScalarEvolution::getSCEVAtScope ( Value V,
const Loop L 
)

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

Definition at line 9419 of file ScalarEvolution.cpp.

References getSCEV(), and getSCEVAtScope().

◆ getSequentialMinMaxExpr()

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

◆ getSignedRange()

ConstantRange llvm::ScalarEvolution::getSignedRange ( const SCEV S)
inline

Determine the signed range for a particular SCEV.

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

Definition at line 969 of file ScalarEvolution.h.

References S.

Referenced by getSignExtendExpr(), print(), and StrengthenNoWrapFlags().

◆ getSignedRangeMax()

APInt llvm::ScalarEvolution::getSignedRangeMax ( const SCEV S)
inline

Determine the max of the signed range for a particular SCEV.

Definition at line 979 of file ScalarEvolution.h.

References llvm::ConstantRange::getSignedMax(), and S.

Referenced by getSignedOverflowLimitForStep(), isKnownNegative(), isKnownNonPositive(), and SimplifyICmpOperands().

◆ getSignedRangeMin()

APInt llvm::ScalarEvolution::getSignedRangeMin ( const SCEV S)
inline

Determine the min of the signed range for a particular SCEV.

Definition at line 974 of file ScalarEvolution.h.

References llvm::ConstantRange::getSignedMin(), and S.

Referenced by getMinusSCEV(), getSignedOverflowLimitForStep(), isKnownNonNegative(), isKnownPositive(), and SimplifyICmpOperands().

◆ getSignExtendExpr()

const SCEV * ScalarEvolution::getSignExtendExpr ( const SCEV Op,
Type Ty,
unsigned  Depth = 0 
)

◆ getSizeOfExpr()

const SCEV * ScalarEvolution::getSizeOfExpr ( Type IntTy,
Type AllocTy 
)

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

Definition at line 4139 of file ScalarEvolution.cpp.

References getConstant(), getDataLayout(), and getSizeOfScalableVectorExpr().

Referenced by getElementSize(), and getGEPExpr().

◆ getSizeOfScalableVectorExpr()

const SCEV * ScalarEvolution::getSizeOfScalableVectorExpr ( Type IntTy,
ScalableVectorType ScalableTy 
)

Return an expression for sizeof ScalableTy that is type IntTy, where ScalableTy is a scalable vector type.

Definition at line 4128 of file ScalarEvolution.cpp.

References GEP, llvm::ConstantInt::get(), llvm::ConstantExpr::getGetElementPtr(), llvm::Constant::getNullValue(), llvm::Type::getPointerTo(), llvm::ConstantExpr::getPtrToInt(), and getUnknown().

Referenced by getSizeOfExpr(), and getStoreSizeOfExpr().

◆ getSmallConstantMaxTripCount()

unsigned ScalarEvolution::getSmallConstantMaxTripCount ( const Loop L)

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

Returns 0 if the trip count is unknown or not constant.

Definition at line 7506 of file ScalarEvolution.cpp.

References getConstantMaxBackedgeTakenCount(), and getConstantTripCount().

Referenced by llvm::HexagonTTIImpl::getPeelingPreferences(), getSmallBestKnownTC(), llvm::isDereferenceableAndAlignedInLoop(), llvm::LoopVectorizationCostModel::isMoreProfitable(), tryToUnrollLoop(), and llvm::UnrollLoop().

◆ getSmallConstantTripCount() [1/2]

unsigned ScalarEvolution::getSmallConstantTripCount ( const Loop L)

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 line 7490 of file ScalarEvolution.cpp.

References Exact, getBackedgeTakenCount(), and getConstantTripCount().

Referenced by llvm::CacheCost::CacheCost(), llvm::LoopVectorizationCostModel::computeMaxVF(), llvm::HexagonTTIImpl::getPeelingPreferences(), getSmallBestKnownTC(), llvm::PPCTTIImpl::isHardwareLoopProfitable(), tryToUnrollAndJamLoop(), tryToUnrollLoop(), and llvm::UnrollLoop().

◆ getSmallConstantTripCount() [2/2]

unsigned ScalarEvolution::getSmallConstantTripCount ( const Loop L,
const BasicBlock ExitingBlock 
)

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 line 7496 of file ScalarEvolution.cpp.

References assert(), getConstantTripCount(), getExitCount(), and llvm::LoopBase< BlockT, LoopT >::isLoopExiting().

◆ getSmallConstantTripMultiple() [1/3]

unsigned ScalarEvolution::getSmallConstantTripMultiple ( const Loop L)

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 line 7637 of file ScalarEvolution.cpp.

References llvm::LoopBase< BlockT, LoopT >::getExitingBlocks(), getSmallConstantTripMultiple(), llvm::Optional< T >::getValueOr(), llvm::GreatestCommonDivisor64(), and llvm::None.

◆ getSmallConstantTripMultiple() [2/3]

unsigned ScalarEvolution::getSmallConstantTripMultiple ( const Loop L,
const BasicBlock ExitingBlock 
)

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

This means that the actual trip count is always a multiple of the returned value (don't forget the trip count could very well be zero as well!). As explained in the comments for getSmallConstantTripCount, this assumes that control exits the loop via ExitingBlock.

This means that the actual trip count is always a multiple of the returned value (don't forget the trip count could very well be zero as well!).

Returns 1 if the trip count is unknown or not guaranteed to be the multiple of a constant (which is also the case if the trip count is simply constant, use getSmallConstantTripCount for that case), Will also return 1 if the trip count is very large (>= 2^32).

As explained in the comments for getSmallConstantTripCount, this assumes that control exits the loop via ExitingBlock.

Definition at line 7692 of file ScalarEvolution.cpp.

References assert(), getExitCount(), getSmallConstantTripMultiple(), and llvm::LoopBase< BlockT, LoopT >::isLoopExiting().

◆ getSmallConstantTripMultiple() [3/3]

unsigned ScalarEvolution::getSmallConstantTripMultiple ( const Loop L,
const SCEV ExitCount 
)

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 line 7651 of file ScalarEvolution.cpp.

References applyLoopGuards(), getCouldNotCompute(), GetMinTrailingZeros(), getTripCountFromExitCount(), llvm::SCEVConstant::getValue(), and llvm::min().

Referenced by getSmallConstantTripMultiple(), PrintLoopInfo(), tryToUnrollAndJamLoop(), tryToUnrollLoop(), and llvm::UnrollLoop().

◆ getSMaxExpr() [1/2]

const SCEV * ScalarEvolution::getSMaxExpr ( const SCEV LHS,
const SCEV RHS 
)

◆ getSMaxExpr() [2/2]

const SCEV * ScalarEvolution::getSMaxExpr ( SmallVectorImpl< const SCEV * > &  Operands)

Definition at line 4092 of file ScalarEvolution.cpp.

References getMinMaxExpr(), and llvm::scSMaxExpr.

◆ getSMinExpr() [1/2]

const SCEV * ScalarEvolution::getSMinExpr ( const SCEV LHS,
const SCEV RHS 
)

◆ getSMinExpr() [2/2]

const SCEV * ScalarEvolution::getSMinExpr ( SmallVectorImpl< const SCEV * > &  Operands)

Definition at line 4111 of file ScalarEvolution.cpp.

References getMinMaxExpr(), and llvm::scSMinExpr.

◆ getStoreSizeOfExpr()

const SCEV * ScalarEvolution::getStoreSizeOfExpr ( Type IntTy,
Type StoreTy 
)

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

Definition at line 4148 of file ScalarEvolution.cpp.

References getConstant(), getDataLayout(), and getSizeOfScalableVectorExpr().

Referenced by llvm::RuntimePointerChecking::insert().

◆ getStrengthenedNoWrapFlagsFromBinOp()

std::pair< SCEV::NoWrapFlags, bool > ScalarEvolution::getStrengthenedNoWrapFlagsFromBinOp ( const OverflowingBinaryOperator OBO)

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

Does not mutate the original instruction.

Definition at line 2310 of file ScalarEvolution.cpp.

References llvm::MCID::Add, llvm::SCEV::FlagNSW, llvm::SCEV::FlagNUW, llvm::Operator::getOpcode(), llvm::User::getOperand(), getSCEV(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), LHS, Mul, RHS, setFlags(), and willNotOverflow().

◆ getSymbolicMaxBackedgeTakenCount()

const SCEV* llvm::ScalarEvolution::getSymbolicMaxBackedgeTakenCount ( const Loop L)
inline

When successful, this returns a SCEV that is greater than or equal to (i.e.

a "conservative over-approximation") of the value returend by getBackedgeTakenCount. If such a value cannot be computed, it returns the SCEVCouldNotCompute object.

Definition at line 902 of file ScalarEvolution.h.

References getBackedgeTakenCount(), and SymbolicMaximum.

◆ getTripCountFromExitCount()

const SCEV * ScalarEvolution::getTripCountFromExitCount ( const SCEV ExitCount,
bool  Extend = true 
)

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

"backedge taken count") to a "trip count". 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. Extend controls how potential overflow is handled. If true, a wider result type is returned. ex: EC = 255 (i8), TC = 256 (i9). If false, result unsigned wraps with 2s-complement semantics. ex: EC = 255 (i8), TC = 0 (i8)

Definition at line 7459 of file ScalarEvolution.cpp.

References assert(), getAddExpr(), getCouldNotCompute(), llvm::Type::getIntNTy(), getNoopOrZeroExtend(), getOne(), and llvm::SCEV::getType().

Referenced by computeTripCount(), findLoopComponents(), and getSmallConstantTripMultiple().

◆ getTruncateExpr()

const SCEV * ScalarEvolution::getTruncateExpr ( const SCEV Op,
Type Ty,
unsigned  Depth = 0 
)

◆ getTruncateOrNoop()

const SCEV * ScalarEvolution::getTruncateOrNoop ( const SCEV V,
Type Ty 
)

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

The conversion must not be widening.

Definition at line 4582 of file ScalarEvolution.cpp.

References assert(), getTruncateExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().

Referenced by canBeCheaplyTransformed(), getAnyExtendExpr(), and llvm::InnerLoopVectorizer::getOrCreateTripCount().

◆ getTruncateOrSignExtend()

const SCEV * ScalarEvolution::getTruncateOrSignExtend ( const SCEV V,
Type Ty,
unsigned  Depth = 0 
)

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

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

Definition at line 4533 of file ScalarEvolution.cpp.

References assert(), llvm::Depth, getSignExtendExpr(), getTruncateExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), and llvm::Type::isIntOrPtrTy().

Referenced by getGEPExpr(), getSignExtendExpr(), and getTruncateExpr().

◆ getTruncateOrZeroExtend()

const SCEV * ScalarEvolution::getTruncateOrZeroExtend ( const SCEV V,
Type Ty,
unsigned  Depth = 0 
)

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

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

Definition at line 4521 of file ScalarEvolution.cpp.

References assert(), llvm::Depth, getTruncateExpr(), llvm::SCEV::getType(), getTypeSizeInBits(), getZeroExtendExpr(), and llvm::Type::isIntOrPtrTy().

Referenced by BinomialCoefficient(), llvm::AlignmentFromAssumptionsPass::extractAlignmentInfo(), genLoopLimit(), getNewAlignment(), getNumBytes(), getPtrToIntExpr(), getTripCount(), getTruncateExpr(), and getZeroExtendExpr().

◆ getTypeSizeInBits()

uint64_t ScalarEvolution::getTypeSizeInBits ( Type Ty) const

◆ getUDivCeilSCEV()

const SCEV * ScalarEvolution::getUDivCeilSCEV ( const SCEV N,
const SCEV D 
)

Compute ceil(N / D).

N and D are treated as unsigned values.

Since SCEV doesn't have native ceiling division, this generates a SCEV 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 as getUDivExpr().

Definition at line 11901 of file ScalarEvolution.cpp.

References D, getAddExpr(), getMinusSCEV(), getOne(), getUDivExpr(), getUMinExpr(), and N.

Referenced by getConstantMaxTripCountFromArray().

◆ getUDivExactExpr()

const SCEV * ScalarEvolution::getUDivExactExpr ( const SCEV LHS,
const SCEV RHS 
)

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

There is no representation for an exact udiv in SCEV IR, but we can attempt to remove factors from the LHS and RHS. We can't do this when it's not exact because the udiv may be clearing bits.

Definition at line 3507 of file ScalarEvolution.cpp.

References llvm::drop_begin(), llvm::numbers::e, gcd(), getConstant(), getMulExpr(), llvm::User::getNumOperands(), llvm::User::getOperand(), getUDivExpr(), llvm::Instruction::hasNoUnsignedWrap(), i, llvm::APInt::isIntN(), LHS, Mul, llvm::User::op_begin(), llvm::User::op_end(), Operands, llvm::User::operands(), and RHS.

Referenced by SolveLinEquationWithOverflow().

◆ getUDivExpr()

const SCEV * ScalarEvolution::getUDivExpr ( const SCEV LHS,
const SCEV RHS 
)

◆ getUMaxExpr() [1/2]

const SCEV * ScalarEvolution::getUMaxExpr ( const SCEV LHS,
const SCEV RHS 
)

◆ getUMaxExpr() [2/2]

const SCEV * ScalarEvolution::getUMaxExpr ( SmallVectorImpl< const SCEV * > &  Operands)

Definition at line 4101 of file ScalarEvolution.cpp.

References getMinMaxExpr(), and llvm::scUMaxExpr.

◆ getUMaxFromMismatchedTypes()

const SCEV * ScalarEvolution::getUMaxFromMismatchedTypes ( const SCEV LHS,
const SCEV RHS 
)

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

Definition at line 4593 of file ScalarEvolution.cpp.

References getNoopOrZeroExtend(), llvm::Value::getType(), getTypeSizeInBits(), getUMaxExpr(), getZeroExtendExpr(), LHS, and RHS.

◆ getUMinExpr() [1/2]

const SCEV * ScalarEvolution::getUMinExpr ( const SCEV LHS,
const SCEV RHS,
bool  Sequential = false 
)

◆ getUMinExpr() [2/2]

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

◆ getUMinFromMismatchedTypes() [1/2]

const SCEV * ScalarEvolution::getUMinFromMismatchedTypes ( const SCEV LHS,
const SCEV RHS,
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 line 4606 of file ScalarEvolution.cpp.

References LHS, and RHS.

Referenced by getConstantMaxTripCountFromArray(), and getMinAnalyzeableBackedgeTakenCount().

◆ getUMinFromMismatchedTypes() [2/2]

const SCEV * ScalarEvolution::getUMinFromMismatchedTypes ( SmallVectorImpl< const SCEV * > &  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 line 4614 of file ScalarEvolution.cpp.

References assert(), getNoopOrZeroExtend(), getUMinExpr(), getWiderType(), and S.

◆ getUnknown()

const SCEV * ScalarEvolution::getUnknown ( Value V)

◆ getUnsignedRange()

ConstantRange llvm::ScalarEvolution::getUnsignedRange ( const SCEV S)
inline

Determine the unsigned range for a particular SCEV.

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

Definition at line 953 of file ScalarEvolution.h.

References S.

Referenced by llvm::SCEVAAResult::alias(), getBoundsCheckCond(), getZeroExtendExpr(), mustBeFiniteCountedLoop(), print(), and StrengthenNoWrapFlags().

◆ getUnsignedRangeMax()

APInt llvm::ScalarEvolution::getUnsignedRangeMax ( const SCEV S)
inline

Determine the max of the unsigned range for a particular SCEV.

Definition at line 963 of file ScalarEvolution.h.

References llvm::ConstantRange::getUnsignedMax(), and S.

Referenced by getUnsignedOverflowLimitForStep(), llvm::ARMTTIImpl::isHardwareLoopProfitable(), and SimplifyICmpOperands().

◆ getUnsignedRangeMin()

APInt llvm::ScalarEvolution::getUnsignedRangeMin ( const SCEV S)
inline

Determine the min of the unsigned range for a particular SCEV.

Definition at line 958 of file ScalarEvolution.h.

References llvm::ConstantRange::getUnsignedMin(), and S.

Referenced by isKnownNonZero(), and SimplifyICmpOperands().

◆ getURemExpr()

const SCEV * ScalarEvolution::getURemExpr ( const SCEV LHS,
const SCEV RHS 
)

◆ getWiderType()

Type * ScalarEvolution::getWiderType ( Type Ty1,
Type Ty2 
) const

◆ getWrapPredicate()

const SCEVPredicate * ScalarEvolution::getWrapPredicate ( const SCEVAddRecExpr AR,
SCEVWrapPredicate::IncrementWrapFlags  AddedFlags 
)

◆ getZero()

const SCEV* llvm::ScalarEvolution::getZero ( Type Ty)
inline

◆ getZeroExtendExpr()

const SCEV * ScalarEvolution::getZeroExtendExpr ( const SCEV Op,
Type Ty,
unsigned  Depth = 0 
)

◆ hasComputableLoopEvolution()

bool ScalarEvolution::hasComputableLoopEvolution ( const SCEV S,
const Loop L 
)

Return true if the given SCEV changes value in a known way in the specified loop.

This property being true implies that the value is variant in the loop AND that we can emit an expression to compute the value of the expression at any particular loop iteration.

Definition at line 13000 of file ScalarEvolution.cpp.

References getLoopDisposition(), LoopComputable, and S.

◆ hasFlags()

static LLVM_NODISCARD bool llvm::ScalarEvolution::hasFlags ( SCEV::NoWrapFlags  Flags,
SCEV::NoWrapFlags  TestFlags 
)
inlinestatic

Definition at line 492 of file ScalarEvolution.h.

References maskFlags().

Referenced by getAddExpr(), getMinusSCEV(), and StrengthenNoWrapFlags().

◆ hasLoopInvariantBackedgeTakenCount()

bool ScalarEvolution::hasLoopInvariantBackedgeTakenCount ( const Loop L)

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

Definition at line 12727 of file ScalarEvolution.cpp.

References getBackedgeTakenCount().

Referenced by llvm::ARMTTIImpl::isHardwareLoopProfitable(), llvm::IVUsers::print(), and PrintLoopInfo().

◆ hasOperand()

bool ScalarEvolution::hasOperand ( const SCEV S,
const SCEV Op 
) const

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

Definition at line 13099 of file ScalarEvolution.cpp.

References S, and llvm::SCEVExprContains().

◆ instructionCouldExistWitthOperands()

bool ScalarEvolution::instructionCouldExistWitthOperands ( const SCEV A,
const SCEV B 
)

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; } } No SCEV 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 line 4229 of file ScalarEvolution.cpp.

References B, and llvm::DominatorTree::dominates().

Referenced by canComputePointerDiff().

◆ invalidate()

bool ScalarEvolution::invalidate ( Function F,
const PreservedAnalyses PA,
FunctionAnalysisManager::Invalidator Inv 
)

◆ isAvailableAtLoopEntry()

bool ScalarEvolution::isAvailableAtLoopEntry ( const SCEV S,
const Loop L 
)

Determine if the SCEV can be evaluated at loop's entry.

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

Definition at line 2435 of file ScalarEvolution.cpp.

References llvm::LoopBase< BlockT, LoopT >::getHeader(), isLoopInvariant(), properlyDominates(), and S.

Referenced by llvm::cannotBeMaxInLoop(), llvm::cannotBeMinInLoop(), getAddExpr(), getMulExpr(), llvm::hasProcessableCondition(), llvm::isKnownNegativeInLoop(), llvm::isKnownNonNegativeInLoop(), isKnownViaInduction(), and isLoopEntryGuardedByCond().

◆ isBackedgeTakenCountMaxOrZero()

bool ScalarEvolution::isBackedgeTakenCountMaxOrZero ( const Loop L)

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

Definition at line 7733 of file ScalarEvolution.cpp.

Referenced by PrintLoopInfo(), tryToUnrollLoop(), and llvm::UnrollLoop().

◆ isBasicBlockEntryGuardedByCond()

bool ScalarEvolution::isBasicBlockEntryGuardedByCond ( const BasicBlock BB,
ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS 
)

◆ isKnownNegative()

bool ScalarEvolution::isKnownNegative ( const SCEV S)

Test if the given expression is known to be negative.

Definition at line 10143 of file ScalarEvolution.cpp.

References getSignedRangeMax(), llvm::APInt::isNegative(), and S.

Referenced by llvm::IndexedReference::computeRefCost(), and getSignedOverflowLimitForStep().

◆ isKnownNonNegative()

bool ScalarEvolution::isKnownNonNegative ( const SCEV S)

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

Definition at line 10151 of file ScalarEvolution.cpp.

References getSignedRangeMin(), llvm::APInt::isNegative(), and S.

Referenced by getGEPExpr(), getMinusSCEV(), and StrengthenNoWrapFlags().

◆ isKnownNonPositive()

bool ScalarEvolution::isKnownNonPositive ( const SCEV S)

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

Definition at line 10155 of file ScalarEvolution.cpp.

References getSignedRangeMax(), llvm::APInt::isStrictlyPositive(), and S.

◆ isKnownNonZero()

bool ScalarEvolution::isKnownNonZero ( const SCEV S)

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

Definition at line 10159 of file ScalarEvolution.cpp.

References getUnsignedRangeMin(), and S.

Referenced by breakBackedgeIfNotTaken().

◆ isKnownOnEveryIteration()

bool ScalarEvolution::isKnownOnEveryIteration ( ICmpInst::Predicate  Pred,
const SCEVAddRecExpr LHS,
const SCEV RHS 
)

Test if the condition described by Pred, LHS, RHS is known to be true on every iteration of the loop of the recurrency LHS.

Definition at line 10276 of file ScalarEvolution.cpp.

References isLoopBackedgeGuardedByCond(), isLoopEntryGuardedByCond(), LHS, and RHS.

◆ isKnownPositive()

bool ScalarEvolution::isKnownPositive ( const SCEV S)

Test if the given expression is known to be positive.

Definition at line 10147 of file ScalarEvolution.cpp.

References getSignedRangeMin(), llvm::APInt::isStrictlyPositive(), and S.

Referenced by getSignedOverflowLimitForStep(), and isSafeDependenceDistance().

◆ isKnownPredicate()

bool ScalarEvolution::isKnownPredicate ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS 
)

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

Definition at line 10226 of file ScalarEvolution.cpp.

References isKnownViaInduction(), LHS, RHS, and SimplifyICmpOperands().

Referenced by llvm::calculateUpperBound(), countToEliminateCompares(), evaluatePredicate(), isKnownPredicateAt(), IsKnownPredicateViaAddRecStart(), and normalizePredicate().

◆ isKnownPredicateAt()

bool ScalarEvolution::isKnownPredicateAt ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS,
const Instruction CtxI 
)

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

Definition at line 10251 of file ScalarEvolution.cpp.

References llvm::Instruction::getParent(), isBasicBlockEntryGuardedByCond(), isKnownPredicate(), LHS, and RHS.

Referenced by optimizeLoopExitWithUnknownExitCount().

◆ isKnownViaInduction()

bool ScalarEvolution::isKnownViaInduction ( ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS 
)

We'd like to check the predicate on every iteration of the most dominated loop between loops used in LHS and RHS.

To do this we use the following list of steps:

  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. Let E(LHS) be value of LHS on entry of PD. To get E(LHS), we should just take LHS and replace all AddRecs that are attached to PD on with their entry values. Define E(RHS) in the same way. c. Let B(LHS) be value of L on backedge of PD. To get B(LHS), we should just take LHS and replace all AddRecs that are attached to PD on with their backedge values. Define B(RHS) in the same way. d. Note that E(LHS) and E(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 line 10175 of file ScalarEvolution.cpp.

References assert(), llvm::DominatorTree::dominates(), llvm::SmallPtrSetImplBase::empty(), getCouldNotCompute(), isAvailableAtLoopEntry(), isLoopBackedgeGuardedByCond(), isLoopEntryGuardedByCond(), L2, LHS, RHS, and SplitIntoInitAndPostInc().

Referenced by isKnownPredicate().

◆ isLoopBackedgeGuardedByCond()

bool ScalarEvolution::isLoopBackedgeGuardedByCond ( const Loop L,
ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS 
)

◆ isLoopEntryGuardedByCond()

bool ScalarEvolution::isLoopEntryGuardedByCond ( const Loop L,
ICmpInst::Predicate  Pred,
const SCEV LHS,
const SCEV RHS 
)

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

This is used to help avoid max expressions in loop trip counts, and to eliminate casts.

Definition at line 10843 of file ScalarEvolution.cpp.

References assert(), llvm::LoopBase< BlockT, LoopT >::getHeader(), isAvailableAtLoopEntry(), isBasicBlockEntryGuardedByCond(), LHS, and RHS.

Referenced by llvm::cannotBeMaxInLoop(), llvm::cannotBeMinInLoop(), llvm::findSplitCandidate(), getTripCount(), llvm::isKnownNegativeInLoop(), llvm::isKnownNonNegativeInLoop(), isKnownOnEveryIteration(), and isKnownViaInduction().

◆ isLoopInvariant()

bool ScalarEvolution::isLoopInvariant ( const SCEV S,
const Loop L 
)

◆ isSCEVable()

bool ScalarEvolution::isSCEVable ( Type Ty) const

◆ loopHasNoAbnormalExits()

bool llvm::ScalarEvolution::loopHasNoAbnormalExits ( const Loop L)
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 line 1202 of file ScalarEvolution.h.

◆ loopIsFiniteByAssumption()

bool ScalarEvolution::loopIsFiniteByAssumption ( const Loop L)

Return true if this loop is finite by assumption.

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

Definition at line 7016 of file ScalarEvolution.cpp.

References llvm::isMustProgress().

◆ maskFlags()

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

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

Definition at line 480 of file ScalarEvolution.h.

References llvm::BitmaskEnumDetail::Mask().

Referenced by getAddExpr(), getAddRecExpr(), getMulExpr(), hasFlags(), and StrengthenNoWrapFlags().

◆ print()

void ScalarEvolution::print ( raw_ostream OS) const

◆ properlyDominates()

bool ScalarEvolution::properlyDominates ( const SCEV S,
const BasicBlock BB 
)

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

Definition at line 13095 of file ScalarEvolution.cpp.

References BB, getBlockDisposition(), ProperlyDominatesBlock, and S.

Referenced by DoInitialMatch(), isAvailableAtLoopEntry(), llvm::isSafeToExpandAt(), and SimplifyICmpOperands().

◆ registerUser()

void ScalarEvolution::registerUser ( const SCEV User,
ArrayRef< const SCEV * >  Ops 
)

◆ removePointerBase()

const SCEV * ScalarEvolution::removePointerBase ( const SCEV S)

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

Definition at line 4441 of file ScalarEvolution.cpp.

References assert(), llvm::SCEV::FlagAnyWrap, getAddExpr(), getAddRecExpr(), getZero(), and P.

Referenced by getMinusSCEV().

◆ rewriteUsingPredicate()

const SCEV * ScalarEvolution::rewriteUsingPredicate ( const SCEV S,
const Loop L,
SCEVUnionPredicate A 
)

Re-writes the SCEV according to the Predicates in A.

Definition at line 13641 of file ScalarEvolution.cpp.

References rewrite(), and S.

◆ setFlags()

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

◆ setNoWrapFlags()

void ScalarEvolution::setNoWrapFlags ( SCEVAddRecExpr AddRec,
SCEV::NoWrapFlags  Flags 
)

Update no-wrap flags of an AddRec.

This may drop the cached info about this AddRec (such as range info) in case if new flags may potentially sharpen it.

Definition at line 6106 of file ScalarEvolution.cpp.

References llvm::SCEVNAryExpr::getNoWrapFlags(), and llvm::SCEVAddRecExpr::setNoWrapFlags().

◆ SimplifyICmpOperands()

bool ScalarEvolution::SimplifyICmpOperands ( ICmpInst::Predicate Pred,
const SCEV *&  LHS,
const SCEV *&  RHS,
unsigned  Depth = 0 
)

◆ SplitIntoInitAndPostInc()

std::pair< const SCEV *, const SCEV * > ScalarEvolution::SplitIntoInitAndPostInc ( const Loop L,
const SCEV S 
)

Splits SCEV expression S into two SCEVs.

One of them is obtained from S by substitution of all AddRec sub-expression related to loop L with initial value of that SCEV. The second is obtained from S by substitution of all AddRec sub-expressions related to loop L with post increment of this AddRec in the loop L. In both cases all other AddRec sub-expressions (not related to L) remain the same. If the S contains non-invariant unknown SCEV the function returns CouldNotCompute SCEV in both values of std::pair. For example, for SCEV S={0, +, 1}<L1> + {0, +, 1}<L2> and loop L=L1 the function returns pair: first = {0, +, 1}<L2> second = {1, +, 1}<L1> + {0, +, 1}<L2> We can see that for the first AddRec sub-expression it was replaced with 0 (initial value) for the first element and to {1, +, 1}<L1> (post increment value) for the second one. In both cases AddRec expression related to L2 remains the same.

Definition at line 10164 of file ScalarEvolution.cpp.

Referenced by isKnownViaInduction().

◆ verify()

void ScalarEvolution::verify ( ) const

◆ willNotOverflow()

bool ScalarEvolution::willNotOverflow ( Instruction::BinaryOps  BinOp,
bool  Signed,
const SCEV LHS,
const SCEV RHS 
)

Is operation BinOp between LHS and RHS provably does not have a signed/unsigned overflow (Signed)?

Definition at line 2274 of file ScalarEvolution.cpp.

References llvm::MCID::Add, B, llvm::SCEV::FlagAnyWrap, llvm::IntegerType::get(), getAddExpr(), getMinusSCEV(), getMulExpr(), getSignExtendExpr(), llvm::Value::getType(), getZeroExtendExpr(), LHS, llvm_unreachable, Mul, Operation, RHS, ScalarEvolution(), and Signed.

Referenced by getStrengthenedNoWrapFlagsFromBinOp().

Friends And Related Function Documentation

◆ ScalarEvolutionsTest

friend class ScalarEvolutionsTest
friend

Definition at line 461 of file ScalarEvolution.h.

◆ SCEVCallbackVH

friend class SCEVCallbackVH
friend

Definition at line 1223 of file ScalarEvolution.h.

Referenced by getSCEV().

◆ SCEVExpander

friend class SCEVExpander
friend

Definition at line 1224 of file ScalarEvolution.h.

◆ SCEVUnknown

friend class SCEVUnknown
friend

Definition at line 1225 of file ScalarEvolution.h.

Referenced by getUnknown().


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