20 #ifndef LLVM_ANALYSIS_SCALAREVOLUTION_H 21 #define LLVM_ANALYSIS_SCALAREVOLUTION_H 55 class AssumptionCache;
65 class ScalarEvolution;
69 class TargetLibraryInfo;
84 const unsigned short SCEVType;
122 unsigned short ExpressionSize)
123 : FastID(ID), SCEVType(SCEVTy), ExpressionSize(ExpressionSize) {}
172 return ID == X.FastID;
193 static bool classof(
const SCEV *S);
225 virtual bool isAlwaysTrue()
const = 0;
254 return ID == X.FastID;
277 bool isAlwaysTrue()
const override;
288 return P->
getKind() == P_Equal;
327 IncrementAnyWrap = 0,
328 IncrementNUSW = (1 << 0),
329 IncrementNSSW = (1 << 1),
331 IncrementNoWrapMask = (1 << 2) - 1
338 assert((Flags & IncrementNoWrapMask) == Flags &&
"Invalid flags value!");
339 assert((OffFlags & IncrementNoWrapMask) == OffFlags &&
340 "Invalid flags value!");
346 assert((Flags & IncrementNoWrapMask) == Flags &&
"Invalid flags value!");
347 assert((Mask & IncrementNoWrapMask) == Mask &&
"Invalid mask value!");
355 assert((Flags & IncrementNoWrapMask) == Flags &&
"Invalid flags value!");
356 assert((OnFlags & IncrementNoWrapMask) == OnFlags &&
357 "Invalid flags value!");
383 bool isAlwaysTrue()
const override;
423 bool isAlwaysTrue()
const override;
434 return P->
getKind() == P_Union;
442 friend class ScalarEvolutionsTest;
456 ProperlyDominatesBlock
485 bool isSCEVable(
Type *Ty)
const;
489 uint64_t getTypeSizeInBits(
Type *Ty)
const;
494 Type *getEffectiveSCEVType(
Type *Ty)
const;
501 bool containsAddRecurrence(
const SCEV *S);
504 void eraseValueFromMap(
Value *V);
511 const SCEV *getConstant(
const APInt &Val);
512 const SCEV *getConstant(
Type *Ty, uint64_t V,
bool isSigned =
false);
522 unsigned Depth = 0) {
524 return getAddExpr(Ops, Flags,
Depth);
528 unsigned Depth = 0) {
530 return getAddExpr(Ops, Flags,
Depth);
537 unsigned Depth = 0) {
539 return getMulExpr(Ops, Flags,
Depth);
543 unsigned Depth = 0) {
545 return getMulExpr(Ops, Flags,
Depth);
547 const SCEV *getUDivExpr(
const SCEV *LHS,
const SCEV *RHS);
548 const SCEV *getUDivExactExpr(
const SCEV *LHS,
const SCEV *RHS);
549 const SCEV *getURemExpr(
const SCEV *LHS,
const SCEV *RHS);
550 const SCEV *getAddRecExpr(
const SCEV *Start,
const SCEV *Step,
const Loop *L,
557 return getAddRecExpr(NewOp, L, Flags);
565 createAddRecFromPHIWithCasts(
const SCEVUnknown *SymbolicPHI);
574 const SCEV *getMinMaxExpr(
unsigned Kind,
576 const SCEV *getSMaxExpr(
const SCEV *LHS,
const SCEV *RHS);
578 const SCEV *getUMaxExpr(
const SCEV *LHS,
const SCEV *RHS);
580 const SCEV *getSMinExpr(
const SCEV *LHS,
const SCEV *RHS);
582 const SCEV *getUMinExpr(
const SCEV *LHS,
const SCEV *RHS);
585 const SCEV *getCouldNotCompute();
600 const SCEV *getNegativeSCEV(
const SCEV *V,
604 const SCEV *getNotSCEV(
const SCEV *V);
607 const SCEV *getMinusSCEV(
const SCEV *LHS,
const SCEV *RHS,
613 const SCEV *getTruncateOrZeroExtend(
const SCEV *V,
Type *Ty,
618 const SCEV *getTruncateOrSignExtend(
const SCEV *V,
Type *Ty,
624 const SCEV *getNoopOrZeroExtend(
const SCEV *V,
Type *Ty);
629 const SCEV *getNoopOrSignExtend(
const SCEV *V,
Type *Ty);
634 const SCEV *getNoopOrAnyExtend(
const SCEV *V,
Type *Ty);
642 const SCEV *getUMaxFromMismatchedTypes(
const SCEV *LHS,
const SCEV *RHS);
646 const SCEV *getUMinFromMismatchedTypes(
const SCEV *LHS,
const SCEV *RHS);
656 const SCEV *getPointerBase(
const SCEV *V);
668 const SCEV *getSCEVAtScope(
const SCEV *S,
const Loop *L);
689 unsigned getSmallConstantTripCount(
const Loop *L);
698 unsigned getSmallConstantTripCount(
const Loop *L,
BasicBlock *ExitingBlock);
703 unsigned getSmallConstantMaxTripCount(
const Loop *L);
711 unsigned getSmallConstantTripMultiple(
const Loop *L);
719 unsigned getSmallConstantTripMultiple(
const Loop *L,
759 const SCEV *getPredicatedBackedgeTakenCount(
const Loop *L,
767 return getBackedgeTakenCount(L, ConstantMaximum);
772 bool isBackedgeTakenCountMaxOrZero(
const Loop *L);
776 bool hasLoopInvariantBackedgeTakenCount(
const Loop *L);
783 void forgetAllLoops();
789 void forgetLoop(
const Loop *L);
795 void forgetTopmostLoop(
const Loop *L);
800 void forgetValue(
Value *V);
818 return getRangeRef(S, HINT_RANGE_UNSIGNED);
823 return getRangeRef(S, HINT_RANGE_UNSIGNED).getUnsignedMin();
828 return getRangeRef(S, HINT_RANGE_UNSIGNED).getUnsignedMax();
834 return getRangeRef(S, HINT_RANGE_SIGNED);
839 return getRangeRef(S, HINT_RANGE_SIGNED).getSignedMin();
844 return getRangeRef(S, HINT_RANGE_SIGNED).getSignedMax();
857 bool isKnownNonPositive(
const SCEV *S);
878 std::pair<const SCEV *, const SCEV *> SplitIntoInitAndPostInc(
const Loop *L,
931 const SCEV *&InvariantLHS,
932 const SCEV *&InvariantRHS);
947 bool isLoopInvariant(
const SCEV *S,
const Loop *L);
952 bool isAvailableAtLoopEntry(
const SCEV *S,
const Loop *L);
958 bool hasComputableLoopEvolution(
const SCEV *S,
const Loop *L);
973 bool hasOperand(
const SCEV *S,
const SCEV *Op)
const;
983 const SCEV *ElementSize);
992 void collectParametricTerms(
const SCEV *Expr,
997 void computeAccessFunctions(
const SCEV *Expr,
1067 const SCEV *ElementSize);
1082 const SCEV *rewriteUsingPredicate(
const SCEV *S,
const Loop *L,
1093 class SCEVCallbackVH final :
public CallbackVH {
1096 void deleted()
override;
1097 void allUsesReplacedWith(
Value *New)
override;
1103 friend class SCEVCallbackVH;
1128 std::unique_ptr<SCEVCouldNotCompute> CouldNotCompute;
1137 using ValueOffsetPair = std::pair<Value *, ConstantInt *>;
1180 bool WalkingBEDominatingConds =
false;
1184 bool ProvingSplitPredicate =
false;
1200 const SCEV *ExactNotTaken;
1201 const SCEV *MaxNotTaken;
1204 bool MaxOrZero =
false;
1212 assert(!isa<SCEVUnionPredicate>(P) &&
"Only add leaf predicates here!");
1219 ExitLimit(
const SCEV *
E);
1222 const SCEV *
E,
const SCEV *M,
bool MaxOrZero,
1225 ExitLimit(
const SCEV *
E,
const SCEV *M,
bool MaxOrZero,
1228 ExitLimit(
const SCEV *
E,
const SCEV *M,
bool MaxOrZero);
1232 bool hasAnyInfo()
const {
1233 return !isa<SCEVCouldNotCompute>(ExactNotTaken) ||
1234 !isa<SCEVCouldNotCompute>(MaxNotTaken);
1237 bool hasOperand(
const SCEV *S)
const;
1240 bool hasFullInfo()
const {
1241 return !isa<SCEVCouldNotCompute>(ExactNotTaken);
1247 struct ExitNotTakenInfo {
1249 const SCEV *ExactNotTaken;
1250 const SCEV *MaxNotTaken;
1251 std::unique_ptr<SCEVUnionPredicate>
Predicate;
1254 const SCEV *ExactNotTaken,
1255 const SCEV *MaxNotTaken,
1256 std::unique_ptr<SCEVUnionPredicate> Predicate)
1257 : ExitingBlock(ExitingBlock), ExactNotTaken(ExactNotTaken),
1258 MaxNotTaken(ExactNotTaken), Predicate(
std::move(Predicate)) {}
1260 bool hasAlwaysTruePredicate()
const {
1261 return !Predicate || Predicate->isAlwaysTrue();
1268 class BackedgeTakenInfo {
1283 bool MaxOrZero =
false;
1287 bool isComplete()
const {
return MaxAndComplete.
getInt(); }
1288 const SCEV *getMax()
const {
return MaxAndComplete.
getPointer(); }
1292 BackedgeTakenInfo() : MaxAndComplete(nullptr, 0) {}
1293 BackedgeTakenInfo(BackedgeTakenInfo &&) =
default;
1294 BackedgeTakenInfo &
operator=(BackedgeTakenInfo &&) =
default;
1296 using EdgeExitInfo = std::pair<BasicBlock *, ExitLimit>;
1300 const SCEV *MaxCount,
bool MaxOrZero);
1304 bool hasAnyInfo()
const {
1305 return !ExitNotTaken.
empty() || !isa<SCEVCouldNotCompute>(getMax());
1309 bool hasFullInfo()
const {
return isComplete(); }
1381 struct LoopProperties {
1384 bool HasNoAbnormalExits;
1391 bool HasNoSideEffects;
1398 LoopProperties getLoopProperties(
const Loop *L);
1400 bool loopHasNoSideEffects(
const Loop *L) {
1401 return getLoopProperties(L).HasNoSideEffects;
1404 bool loopHasNoAbnormalExits(
const Loop *L) {
1405 return getLoopProperties(L).HasNoAbnormalExits;
1427 enum RangeSignHint { HINT_RANGE_UNSIGNED, HINT_RANGE_SIGNED };
1430 const ConstantRange &setRange(
const SCEV *S, RangeSignHint Hint,
1433 Hint == HINT_RANGE_UNSIGNED ? UnsignedRanges : SignedRanges;
1437 Pair.first->second = std::move(CR);
1438 return Pair.first->second;
1444 const ConstantRange &getRangeRef(
const SCEV *S, RangeSignHint Hint);
1448 ConstantRange getRangeForAffineAR(
const SCEV *Start,
const SCEV *Stop,
1449 const SCEV *MaxBECount,
unsigned BitWidth);
1454 ConstantRange getRangeViaFactoring(
const SCEV *Start,
const SCEV *Stop,
1455 const SCEV *MaxBECount,
unsigned BitWidth);
1459 const SCEV *createSCEV(
Value *V);
1462 const SCEV *createNodeForPHI(
PHINode *PN);
1465 const SCEV *createAddRecFromPHI(
PHINode *PN);
1468 const SCEV *createSimpleAffineAddRec(
PHINode *PN,
Value *BEValueV,
1469 Value *StartValueV);
1472 const SCEV *createNodeFromSelectLikePHI(
PHINode *PN);
1486 const SCEV *computeSCEVAtScope(
const SCEV *S,
const Loop *L);
1491 void forgetSymbolicName(
Instruction *
I,
const SCEV *SymName);
1496 const BackedgeTakenInfo &getBackedgeTakenInfo(
const Loop *L);
1500 const BackedgeTakenInfo &getPredicatedBackedgeTakenInfo(
const Loop *L);
1505 BackedgeTakenInfo computeBackedgeTakenCount(
const Loop *L,
1506 bool AllowPredicates =
false);
1512 ExitLimit computeExitLimit(
const Loop *L,
BasicBlock *ExitingBlock,
1513 bool AllowPredicates =
false);
1525 ExitLimit computeExitLimitFromCond(
const Loop *L,
Value *ExitCond,
1526 bool ExitIfTrue,
bool ControlsExit,
1527 bool AllowPredicates =
false);
1532 class ExitLimitCache {
1542 bool AllowPredicates;
1545 ExitLimitCache(
const Loop *L,
bool ExitIfTrue,
bool AllowPredicates)
1546 : L(L), ExitIfTrue(ExitIfTrue), AllowPredicates(AllowPredicates) {}
1549 bool ControlsExit,
bool AllowPredicates);
1551 void insert(
const Loop *L,
Value *ExitCond,
bool ExitIfTrue,
1552 bool ControlsExit,
bool AllowPredicates,
const ExitLimit &EL);
1555 using ExitLimitCacheTy = ExitLimitCache;
1557 ExitLimit computeExitLimitFromCondCached(ExitLimitCacheTy &Cache,
1561 bool AllowPredicates);
1562 ExitLimit computeExitLimitFromCondImpl(ExitLimitCacheTy &Cache,
const Loop *L,
1563 Value *ExitCond,
bool ExitIfTrue,
1565 bool AllowPredicates);
1572 ExitLimit computeExitLimitFromICmp(
const Loop *L,
ICmpInst *ExitCond,
1575 bool AllowPredicates =
false);
1580 ExitLimit computeExitLimitFromSingleExitSwitch(
const Loop *L,
1598 ExitLimit computeShiftCompareExitLimit(
Value *LHS,
Value *RHS,
const Loop *L,
1606 const SCEV *computeExitCountExhaustively(
const Loop *L,
Value *Cond,
1613 ExitLimit howFarToZero(
const SCEV *V,
const Loop *L,
bool IsSubExpr,
1614 bool AllowPredicates =
false);
1619 ExitLimit howFarToNonZero(
const SCEV *V,
const Loop *L);
1633 ExitLimit howManyLessThans(
const SCEV *LHS,
const SCEV *RHS,
const Loop *L,
1634 bool isSigned,
bool ControlsExit,
1635 bool AllowPredicates =
false);
1637 ExitLimit howManyGreaterThans(
const SCEV *LHS,
const SCEV *RHS,
const Loop *L,
1638 bool isSigned,
bool IsSubExpr,
1639 bool AllowPredicates =
false);
1644 std::pair<BasicBlock *, BasicBlock *>
1645 getPredecessorWithUniqueSuccessorForBB(
BasicBlock *BB);
1657 const SCEV *FoundRHS);
1663 const SCEV *RHS,
const SCEV *FoundLHS,
1664 const SCEV *FoundRHS);
1671 const SCEV *LHS,
const SCEV *RHS,
1672 const SCEV *FoundLHS,
const SCEV *FoundRHS,
1673 unsigned Depth = 0);
1678 const SCEV *LHS,
const SCEV *RHS);
1684 const SCEV *RHS,
const SCEV *FoundLHS,
1685 const SCEV *FoundRHS);
1692 const SCEV *RHS,
const SCEV *FoundLHS,
1693 const SCEV *FoundRHS);
1698 const SCEV *LHS,
const SCEV *RHS);
1707 const SCEV *LHS,
const SCEV *RHS,
1708 const SCEV *FoundLHS,
1709 const SCEV *FoundRHS);
1719 const SCEV *LHS,
const SCEV *RHS,
1720 const SCEV *FoundLHS,
const SCEV *FoundRHS,
1732 const SCEV *LHS,
const SCEV *RHS);
1748 bool splitBinaryAdd(
const SCEV *Expr,
const SCEV *&L,
const SCEV *&R,
1758 Optional<APInt> computeConstantDifference(
const SCEV *LHS,
const SCEV *RHS);
1761 void forgetMemoizedResults(
const SCEV *S);
1764 const SCEV *getExistingSCEV(
Value *V);
1768 bool checkValidity(
const SCEV *S)
const;
1775 template <
typename ExtendOpTy>
1776 bool proveNoWrapByVaryingStart(
const SCEV *Start,
const SCEV *Step,
1825 createAddRecFromPHIWithCastsImpl(
const SCEVUnknown *SymbolicPHI);
1829 const SCEV *computeBECount(
const SCEV *Delta,
const SCEV *Stride,
1838 const SCEV *computeMaxBECountForLT(
const SCEV *Start,
const SCEV *Stride,
1839 const SCEV *End,
unsigned BitWidth,
1845 bool doesIVOverflowOnLT(
const SCEV *RHS,
const SCEV *Stride,
bool IsSigned,
1851 bool doesIVOverflowOnGT(
const SCEV *RHS,
const SCEV *Stride,
bool IsSigned,
1867 const SCEV *stripInjectiveFunctions(
const SCEV *Val)
const;
1876 void addToLoopUseLists(
const SCEV *S);
1880 bool matchURem(
const SCEV *Expr,
const SCEV *&LHS,
const SCEV *&RHS);
1889 std::tuple<const SCEV *, FoldingSetNodeID, void *>
1903 std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
1904 PredicatedSCEVRewrites;
1944 std::unique_ptr<ScalarEvolution> SE;
1955 void releaseMemory()
override;
1958 void verifyAnalysis()
const override;
1984 const SCEV *getSCEV(
Value *V);
1987 const SCEV *getBackedgeTakenCount();
2023 void updateGeneration();
2027 using RewriteEntry = std::pair<unsigned, const SCEV *>;
2053 unsigned Generation = 0;
2056 const SCEV *BackedgeCount =
nullptr;
2061 #endif // LLVM_ANALYSIS_SCALAREVOLUTION_H
bool isKnownPositive(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Returns true if the given value is known be positive (i.e.
A parsed version of the target data layout string in and methods for querying it. ...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const ScalarEvolution & getSE() const
static Type * getWiderType(const DataLayout &DL, Type *Ty0, Type *Ty1)
This class represents lattice values for constants.
SCEV & operator=(const SCEV &)=delete
PointerTy getPointer() const
static unsigned ComputeHash(const SCEVPredicate &X, FoldingSetNodeID &TempID)
A Module instance is used to store all the information related to an LLVM module. ...
void dump() const
This method is used for debugging.
const unsigned short ExpressionSize
The main scalar evolution driver.
bool isZero() const
Return true if the expression is a constant zero.
const SCEV * getAddRecExpr(const SmallVectorImpl< const SCEV *> &Operands, const Loop *L, SCEV::NoWrapFlags Flags)
IncrementWrapFlags
Similar to SCEV::NoWrapFlags, but with slightly different semantics for FlagNUSW. ...
static LLVM_NODISCARD SCEV::NoWrapFlags setFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags)
static bool Equals(const SCEVPredicate &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
A cache of @llvm.assume calls within a function.
APInt getSignedRangeMin(const SCEV *S)
Determine the min of the signed range for a particular SCEV.
An instruction for reading from memory.
An object of this class is returned by queries that could not be answered.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
APInt getSignedRangeMax(const SCEV *S)
Determine the max of the signed range for a particular SCEV.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
const SCEV * getZero(Type *Ty)
Return a SCEV for the constant 0 of a specific type.
The SCEV is loop-invariant.
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags setFlags(SCEVWrapPredicate::IncrementWrapFlags Flags, SCEVWrapPredicate::IncrementWrapFlags OnFlags)
const SCEV * getAddExpr(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Class to represent struct types.
APInt getUnsignedRangeMax(const SCEV *S)
Determine the max of the unsigned range for a particular SCEV.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned short SubclassData
This field is initialized to zero and may be used in subclasses to store miscellaneous information...
LLVMContext & getContext() const
ScalarEvolution & getSE()
mir Rename Register Operands
This file implements a class to represent arbitrary precision integral constant values and operations...
ExitCountKind
The terms "backedge taken count" and "exit count" are used interchangeably to refer to the number of ...
ConstantRange getSignedRange(const SCEV *S)
Determine the signed range for a particular SCEV.
This node represents a polynomial recurrence on the trip count of the specified loop.
A CRTP mix-in to automatically provide informational APIs needed for passes.
Verifier pass for the ScalarEvolutionAnalysis results.
static bool classof(const SCEVPredicate *P)
Methods for support type inquiry through isa, cast, and dyn_cast:
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isKnownNonNegative(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Returns true if the give value is known to be non-negative.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
void forgetLoopDispositions(const Loop *L)
Called when the client has changed the disposition of values in this loop.
Value handle that poisons itself if the Value is deleted.
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, used to lookup the node in th...
unsigned short getExpressionSize() const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Printer pass for the ScalarEvolutionAnalysis results.
static bool runOnFunction(Function &F, bool PostInlining)
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
APInt getUnsignedRangeMin(const SCEV *S)
Determine the min of the unsigned range for a particular SCEV.
FoldingSetTrait - This trait class is used to define behavior of how to "profile" (in the FoldingSet ...
A set of analyses that are preserved following a run of a transformation pass.
const SCEV * getOne(Type *Ty)
Return a SCEV for the constant 1 of a specific type.
static bool Equals(const SCEV &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
SCEVPredicateKind getKind() const
LLVM Basic Block Representation.
PointerIntPair - This class implements a pair of a pointer and small integer.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Allocate memory in an ever growing pool, as if by bump-pointer.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
A CRTP mix-in that provides informational APIs needed for analysis passes.
ScalarEvolutionPrinterPass(raw_ostream &OS)
Represent the analysis usage information of a pass.
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
FunctionPass class - This class is used to implement most global optimizations.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static LLVM_NODISCARD SCEV::NoWrapFlags clearFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags)
const SCEV * getLHS() const
Returns the left hand side of the equality.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
const SCEV * getRHS() const
Returns the right hand side of the equality.
ScalarEvolution * getSE() const
Returns the ScalarEvolution analysis used.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID)
The SCEV is loop-variant (unknown).
This class represents an assumption made using SCEV expressions which can be checked at run-time...
void print(raw_ostream &OS) const
Print out the internal representation of this scalar to the specified stream.
unsigned getSCEVType() const
bool isNonConstantNegative() const
Return true if the specified scev is negated, but not a constant.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
bool isAllOnesValue() const
Return true if the expression is a constant all-ones value.
Type * getType() const
Return the LLVM type of this SCEV expression.
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags clearFlags(SCEVWrapPredicate::IncrementWrapFlags Flags, SCEVWrapPredicate::IncrementWrapFlags OffFlags)
Convenient IncrementWrapFlags manipulation methods.
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
The SCEV dominates the block.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
This class represents a range of values.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags maskFlags(SCEVWrapPredicate::IncrementWrapFlags Flags, int Mask)
static void Profile(const SCEV &X, FoldingSetNodeID &ID)
static void Profile(const SCEVPredicate &X, FoldingSetNodeID &ID)
LoopDisposition
An enum describing the relationship between a SCEV and a loop.
Class for arbitrary precision integers.
virtual void print(raw_ostream &OS, unsigned Depth=0) const =0
Prints a textual representation of this predicate with an indentation of Depth.
bool isKnownNonZero(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if the given value is known to be non-zero when defined.
An expression exactly describing the number of times the backedge has executed when a loop is exited...
This class uses information about analyze scalars to rewrite expressions in canonical form...
static void clear(coro::Shape &Shape)
const DataLayout & getDataLayout() const
Return the DataLayout associated with the module this SCEV instance is operating on.
static bool classof(const SCEVPredicate *P)
Methods for support type inquiry through isa, cast, and dyn_cast:
Analysis pass that exposes the ScalarEvolution for a function.
unsigned getComplexity() const override
We estimate the complexity of a union predicate as the size number of predicates in the union...
The SCEV does not dominate the block.
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID, which can be a useful to store node id data rather than using plain FoldingSetNodeIDs, since the 32-element SmallVector is often much larger than necessary, and the possibility of heap allocation means it requires a non-trivial destructor call.
MCExpr const & getExpr(MCExpr const &Expr)
Node - This class is used to maintain the singly linked bucket list in a folding set.
This class represents an analyzed expression in the program.
const SCEV * getConstantMaxBackedgeTakenCount(const Loop *L)
When successful, this returns a SCEVConstant that is greater than or equal to (i.e.
bool isKnownNegative(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Returns true if the given value is known be negative (i.e.
LLVM_NODISCARD bool empty() const
const SCEV * getMulExpr(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Represents a single loop in the control flow graph.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
BlockDisposition
An enum describing the relationship between a SCEV and a basic block.
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 ...
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
virtual unsigned getComplexity() const
Returns the estimated complexity of this predicate.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
API to communicate dependencies between analyses during invalidation.
ConstantRange getUnsignedRange(const SCEV *S)
Determine the unsigned range for a particular SCEV.
const SmallVectorImpl< const SCEVPredicate * > & getPredicates() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents a composition of other SCEV predicates, and is the class that most clients will...
bool isOne() const
Return true if the expression is a constant one.
const SCEV * getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
A vector that has set insertion semantics.
A constant which provides an upper bound on the exact trip count.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
DefaultFoldingSetTrait - This class provides default implementations for FoldingSetTrait implementati...
This class implements an extremely fast bulk output stream that can only output to a stream...
Value handle with callbacks on RAUW and destruction.
A container for analyses that lazily runs them and caches their results.
static Optional< bool > isImpliedCondOperands(CmpInst::Predicate Pred, const Value *ALHS, const Value *ARHS, const Value *BLHS, const Value *BRHS, const DataLayout &DL, unsigned Depth)
Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred ALHS ARHS" is true.
SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy, unsigned short ExpressionSize)
This header defines various interfaces for pass management in LLVM.
const SCEV * getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
This class represents an assumption made on an AddRec expression.
static bool classof(const SCEVPredicate *P)
Methods for support type inquiry through isa, cast, and dyn_cast:
NoWrapFlags
NoWrapFlags are bitfield indices into SubclassData.
This class represents an assumption that two SCEV expressions are equal, and this can be checked at r...
A special type used by analysis passes to provide an address that identifies that particular analysis...
IncrementWrapFlags getFlags() const
Returns the set assumed no overflow flags.