21 #ifndef LLVM_ANALYSIS_SCALAREVOLUTION_H 22 #define LLVM_ANALYSIS_SCALAREVOLUTION_H 56 class AssumptionCache;
66 class ScalarEvolution;
70 class TargetLibraryInfo;
85 const unsigned short SCEVType;
120 : FastID(ID), SCEVType(SCEVTy) {}
156 return ID == X.FastID;
177 static bool classof(
const SCEV *S);
209 virtual bool isAlwaysTrue()
const = 0;
238 return ID == X.FastID;
261 bool isAlwaysTrue()
const override;
272 return P->
getKind() == P_Equal;
311 IncrementAnyWrap = 0,
312 IncrementNUSW = (1 << 0),
313 IncrementNSSW = (1 << 1),
315 IncrementNoWrapMask = (1 << 2) - 1
322 assert((Flags & IncrementNoWrapMask) == Flags &&
"Invalid flags value!");
323 assert((OffFlags & IncrementNoWrapMask) == OffFlags &&
324 "Invalid flags value!");
330 assert((Flags & IncrementNoWrapMask) == Flags &&
"Invalid flags value!");
331 assert((Mask & IncrementNoWrapMask) == Mask &&
"Invalid mask value!");
339 assert((Flags & IncrementNoWrapMask) == Flags &&
"Invalid flags value!");
340 assert((OnFlags & IncrementNoWrapMask) == OnFlags &&
341 "Invalid flags value!");
367 bool isAlwaysTrue()
const override;
407 bool isAlwaysTrue()
const override;
418 return P->
getKind() == P_Union;
424 : L(L), ExitingBlock(ExitingBlock), AllowPredicates(AllowPredicates) {}
467 ProperlyDominatesBlock
496 bool isSCEVable(
Type *Ty)
const;
500 uint64_t getTypeSizeInBits(
Type *Ty)
const;
505 Type *getEffectiveSCEVType(
Type *Ty)
const;
512 bool containsAddRecurrence(
const SCEV *S);
515 void eraseValueFromMap(
Value *V);
533 unsigned Depth = 0) {
535 return getAddExpr(Ops, Flags,
Depth);
539 unsigned Depth = 0) {
541 return getAddExpr(Ops, Flags,
Depth);
548 unsigned Depth = 0) {
550 return getMulExpr(Ops, Flags,
Depth);
554 unsigned Depth = 0) {
556 return getMulExpr(Ops, Flags,
Depth);
558 const SCEV *getUDivExpr(
const SCEV *LHS,
const SCEV *RHS);
559 const SCEV *getUDivExactExpr(
const SCEV *LHS,
const SCEV *RHS);
560 const SCEV *getURemExpr(
const SCEV *LHS,
const SCEV *RHS);
561 const SCEV *getAddRecExpr(
const SCEV *Start,
const SCEV *Step,
const Loop *L,
568 return getAddRecExpr(NewOp, L, Flags);
576 createAddRecFromPHIWithCasts(
const SCEVUnknown *SymbolicPHI);
585 const SCEV *getSMaxExpr(
const SCEV *LHS,
const SCEV *RHS);
587 const SCEV *getUMaxExpr(
const SCEV *LHS,
const SCEV *RHS);
589 const SCEV *getSMinExpr(
const SCEV *LHS,
const SCEV *RHS);
591 const SCEV *getUMinExpr(
const SCEV *LHS,
const SCEV *RHS);
594 const SCEV *getCouldNotCompute();
609 const SCEV *getNegativeSCEV(
const SCEV *V,
613 const SCEV *getNotSCEV(
const SCEV *V);
616 const SCEV *getMinusSCEV(
const SCEV *LHS,
const SCEV *RHS,
622 const SCEV *getTruncateOrZeroExtend(
const SCEV *V,
Type *Ty);
626 const SCEV *getTruncateOrSignExtend(
const SCEV *V,
Type *Ty);
631 const SCEV *getNoopOrZeroExtend(
const SCEV *V,
Type *Ty);
636 const SCEV *getNoopOrSignExtend(
const SCEV *V,
Type *Ty);
641 const SCEV *getNoopOrAnyExtend(
const SCEV *V,
Type *Ty);
649 const SCEV *getUMaxFromMismatchedTypes(
const SCEV *LHS,
const SCEV *RHS);
653 const SCEV *getUMinFromMismatchedTypes(
const SCEV *LHS,
const SCEV *RHS);
663 const SCEV *getPointerBase(
const SCEV *V);
675 const SCEV *getSCEVAtScope(
const SCEV *S,
const Loop *L);
696 unsigned getSmallConstantTripCount(
const Loop *L);
705 unsigned getSmallConstantTripCount(
const Loop *L,
BasicBlock *ExitingBlock);
710 unsigned getSmallConstantMaxTripCount(
const Loop *L);
718 unsigned getSmallConstantTripMultiple(
const Loop *L);
726 unsigned getSmallConstantTripMultiple(
const Loop *L,
744 const SCEV *getBackedgeTakenCount(
const Loop *L);
750 const SCEV *getPredicatedBackedgeTakenCount(
const Loop *L,
757 const SCEV *getMaxBackedgeTakenCount(
const Loop *L);
761 bool isBackedgeTakenCountMaxOrZero(
const Loop *L);
765 bool hasLoopInvariantBackedgeTakenCount(
const Loop *L);
771 void forgetLoop(
const Loop *L);
777 void forgetTopmostLoop(
const Loop *L);
782 void forgetValue(
Value *V);
800 return getRangeRef(S, HINT_RANGE_UNSIGNED);
805 return getRangeRef(S, HINT_RANGE_UNSIGNED).getUnsignedMin();
810 return getRangeRef(S, HINT_RANGE_UNSIGNED).getUnsignedMax();
816 return getRangeRef(S, HINT_RANGE_SIGNED);
821 return getRangeRef(S, HINT_RANGE_SIGNED).getSignedMin();
826 return getRangeRef(S, HINT_RANGE_SIGNED).getSignedMax();
839 bool isKnownNonPositive(
const SCEV *S);
860 std::pair<const SCEV *, const SCEV *> SplitIntoInitAndPostInc(
const Loop *L,
913 const SCEV *&InvariantLHS,
914 const SCEV *&InvariantRHS);
934 bool isAvailableAtLoopEntry(
const SCEV *S,
const Loop *L);
940 bool hasComputableLoopEvolution(
const SCEV *S,
const Loop *L);
955 bool hasOperand(
const SCEV *S,
const SCEV *Op)
const;
965 const SCEV *ElementSize);
974 void collectParametricTerms(
const SCEV *Expr,
979 void computeAccessFunctions(
const SCEV *Expr,
1049 const SCEV *ElementSize);
1064 const SCEV *rewriteUsingPredicate(
const SCEV *S,
const Loop *L,
1075 class SCEVCallbackVH final :
public CallbackVH {
1078 void deleted()
override;
1079 void allUsesReplacedWith(
Value *New)
override;
1085 friend class SCEVCallbackVH;
1110 std::unique_ptr<SCEVCouldNotCompute> CouldNotCompute;
1119 using ValueOffsetPair = std::pair<Value *, ConstantInt *>;
1162 bool WalkingBEDominatingConds =
false;
1166 bool ProvingSplitPredicate =
false;
1182 const SCEV *ExactNotTaken;
1183 const SCEV *MaxNotTaken;
1186 bool MaxOrZero =
false;
1194 assert(!isa<SCEVUnionPredicate>(P) &&
"Only add leaf predicates here!");
1198 ExitLimit(
const SCEV *
E);
1201 const SCEV *
E,
const SCEV *M,
bool MaxOrZero,
1204 ExitLimit(
const SCEV *
E,
const SCEV *M,
bool MaxOrZero,
1207 ExitLimit(
const SCEV *
E,
const SCEV *M,
bool MaxOrZero);
1211 bool hasAnyInfo()
const {
1212 return !isa<SCEVCouldNotCompute>(ExactNotTaken) ||
1213 !isa<SCEVCouldNotCompute>(MaxNotTaken);
1216 bool hasOperand(
const SCEV *S)
const;
1219 bool hasFullInfo()
const {
1220 return !isa<SCEVCouldNotCompute>(ExactNotTaken);
1226 struct ExitNotTakenInfo {
1228 const SCEV *ExactNotTaken;
1229 std::unique_ptr<SCEVUnionPredicate>
Predicate;
1232 const SCEV *ExactNotTaken,
1233 std::unique_ptr<SCEVUnionPredicate> Predicate)
1234 : ExitingBlock(ExitingBlock), ExactNotTaken(ExactNotTaken),
1235 Predicate(
std::move(Predicate)) {}
1237 bool hasAlwaysTruePredicate()
const {
1238 return !Predicate || Predicate->isAlwaysTrue();
1245 class BackedgeTakenInfo {
1260 bool MaxOrZero =
false;
1264 bool isComplete()
const {
return MaxAndComplete.
getInt(); }
1265 const SCEV *getMax()
const {
return MaxAndComplete.
getPointer(); }
1269 BackedgeTakenInfo() : MaxAndComplete(nullptr, 0) {}
1270 BackedgeTakenInfo(BackedgeTakenInfo &&) =
default;
1271 BackedgeTakenInfo &
operator=(BackedgeTakenInfo &&) =
default;
1273 using EdgeExitInfo = std::pair<BasicBlock *, ExitLimit>;
1277 const SCEV *MaxCount,
bool MaxOrZero);
1281 bool hasAnyInfo()
const {
1282 return !ExitNotTaken.
empty() || !isa<SCEVCouldNotCompute>(getMax());
1286 bool hasFullInfo()
const {
return isComplete(); }
1355 struct LoopProperties {
1358 bool HasNoAbnormalExits;
1365 bool HasNoSideEffects;
1372 LoopProperties getLoopProperties(
const Loop *L);
1374 bool loopHasNoSideEffects(
const Loop *L) {
1375 return getLoopProperties(L).HasNoSideEffects;
1378 bool loopHasNoAbnormalExits(
const Loop *L) {
1379 return getLoopProperties(L).HasNoAbnormalExits;
1401 enum RangeSignHint { HINT_RANGE_UNSIGNED, HINT_RANGE_SIGNED };
1404 const ConstantRange &setRange(
const SCEV *S, RangeSignHint Hint,
1407 Hint == HINT_RANGE_UNSIGNED ? UnsignedRanges : SignedRanges;
1411 Pair.first->second = std::move(CR);
1412 return Pair.first->second;
1418 const ConstantRange &getRangeRef(
const SCEV *S, RangeSignHint Hint);
1422 ConstantRange getRangeForAffineAR(
const SCEV *Start,
const SCEV *Stop,
1423 const SCEV *MaxBECount,
unsigned BitWidth);
1428 ConstantRange getRangeViaFactoring(
const SCEV *Start,
const SCEV *Stop,
1429 const SCEV *MaxBECount,
unsigned BitWidth);
1433 const SCEV *createSCEV(
Value *V);
1436 const SCEV *createNodeForPHI(
PHINode *PN);
1439 const SCEV *createAddRecFromPHI(
PHINode *PN);
1442 const SCEV *createSimpleAffineAddRec(
PHINode *PN,
Value *BEValueV,
1443 Value *StartValueV);
1446 const SCEV *createNodeFromSelectLikePHI(
PHINode *PN);
1460 const SCEV *computeSCEVAtScope(
const SCEV *S,
const Loop *L);
1465 void forgetSymbolicName(
Instruction *
I,
const SCEV *SymName);
1470 const BackedgeTakenInfo &getBackedgeTakenInfo(
const Loop *L);
1474 const BackedgeTakenInfo &getPredicatedBackedgeTakenInfo(
const Loop *L);
1479 BackedgeTakenInfo computeBackedgeTakenCount(
const Loop *L,
1480 bool AllowPredicates =
false);
1486 ExitLimit computeExitLimit(
const Loop *L,
BasicBlock *ExitingBlock,
1487 bool AllowPredicates =
false);
1499 ExitLimit computeExitLimitFromCond(
const Loop *L,
Value *ExitCond,
1500 bool ExitIfTrue,
bool ControlsExit,
1501 bool AllowPredicates =
false);
1506 class ExitLimitCache {
1516 bool AllowPredicates;
1519 ExitLimitCache(
const Loop *L,
bool ExitIfTrue,
bool AllowPredicates)
1520 : L(L), ExitIfTrue(ExitIfTrue), AllowPredicates(AllowPredicates) {}
1523 bool ControlsExit,
bool AllowPredicates);
1525 void insert(
const Loop *L,
Value *ExitCond,
bool ExitIfTrue,
1526 bool ControlsExit,
bool AllowPredicates,
const ExitLimit &EL);
1529 using ExitLimitCacheTy = ExitLimitCache;
1531 ExitLimit computeExitLimitFromCondCached(ExitLimitCacheTy &Cache,
1535 bool AllowPredicates);
1536 ExitLimit computeExitLimitFromCondImpl(ExitLimitCacheTy &Cache,
const Loop *L,
1537 Value *ExitCond,
bool ExitIfTrue,
1539 bool AllowPredicates);
1546 ExitLimit computeExitLimitFromICmp(
const Loop *L,
ICmpInst *ExitCond,
1549 bool AllowPredicates =
false);
1554 ExitLimit computeExitLimitFromSingleExitSwitch(
const Loop *L,
1572 ExitLimit computeShiftCompareExitLimit(
Value *LHS,
Value *RHS,
const Loop *L,
1580 const SCEV *computeExitCountExhaustively(
const Loop *L,
Value *Cond,
1587 ExitLimit howFarToZero(
const SCEV *V,
const Loop *L,
bool IsSubExpr,
1588 bool AllowPredicates =
false);
1593 ExitLimit howFarToNonZero(
const SCEV *V,
const Loop *L);
1607 ExitLimit howManyLessThans(
const SCEV *LHS,
const SCEV *RHS,
const Loop *L,
1608 bool isSigned,
bool ControlsExit,
1609 bool AllowPredicates =
false);
1611 ExitLimit howManyGreaterThans(
const SCEV *LHS,
const SCEV *RHS,
const Loop *L,
1612 bool isSigned,
bool IsSubExpr,
1613 bool AllowPredicates =
false);
1618 std::pair<BasicBlock *, BasicBlock *>
1619 getPredecessorWithUniqueSuccessorForBB(
BasicBlock *BB);
1631 const SCEV *FoundRHS);
1637 const SCEV *RHS,
const SCEV *FoundLHS,
1638 const SCEV *FoundRHS);
1645 const SCEV *LHS,
const SCEV *RHS,
1646 const SCEV *FoundLHS,
const SCEV *FoundRHS,
1647 unsigned Depth = 0);
1652 const SCEV *LHS,
const SCEV *RHS);
1658 const SCEV *RHS,
const SCEV *FoundLHS,
1659 const SCEV *FoundRHS);
1666 const SCEV *RHS,
const SCEV *FoundLHS,
1667 const SCEV *FoundRHS);
1672 const SCEV *LHS,
const SCEV *RHS);
1681 const SCEV *LHS,
const SCEV *RHS,
1682 const SCEV *FoundLHS,
1683 const SCEV *FoundRHS);
1693 const SCEV *LHS,
const SCEV *RHS,
1694 const SCEV *FoundLHS,
const SCEV *FoundRHS,
1706 const SCEV *LHS,
const SCEV *RHS);
1722 bool splitBinaryAdd(
const SCEV *Expr,
const SCEV *&L,
const SCEV *&R,
1732 Optional<APInt> computeConstantDifference(
const SCEV *LHS,
const SCEV *RHS);
1735 void forgetMemoizedResults(
const SCEV *S);
1738 const SCEV *getExistingSCEV(
Value *V);
1742 bool checkValidity(
const SCEV *S)
const;
1749 template <
typename ExtendOpTy>
1750 bool proveNoWrapByVaryingStart(
const SCEV *Start,
const SCEV *Step,
1799 createAddRecFromPHIWithCastsImpl(
const SCEVUnknown *SymbolicPHI);
1803 const SCEV *computeBECount(
const SCEV *Delta,
const SCEV *Stride,
1812 const SCEV *computeMaxBECountForLT(
const SCEV *Start,
const SCEV *Stride,
1813 const SCEV *End,
unsigned BitWidth,
1819 bool doesIVOverflowOnLT(
const SCEV *RHS,
const SCEV *Stride,
bool IsSigned,
1825 bool doesIVOverflowOnGT(
const SCEV *RHS,
const SCEV *Stride,
bool IsSigned,
1841 const SCEV *stripInjectiveFunctions(
const SCEV *Val)
const;
1850 void addToLoopUseLists(
const SCEV *S);
1854 bool matchURem(
const SCEV *Expr,
const SCEV *&LHS,
const SCEV *&RHS);
1867 std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
1868 PredicatedSCEVRewrites;
1901 std::unique_ptr<ScalarEvolution> SE;
1912 void releaseMemory()
override;
1915 void verifyAnalysis()
const override;
1941 const SCEV *getSCEV(
Value *V);
1944 const SCEV *getBackedgeTakenCount();
1980 void updateGeneration();
1984 using RewriteEntry = std::pair<unsigned, const SCEV *>;
2010 unsigned Generation = 0;
2013 const SCEV *BackedgeCount =
nullptr;
2018 #endif // LLVM_ANALYSIS_SCALAREVOLUTION_H ExitLimitQuery(const Loop *L, BasicBlock *ExitingBlock, bool AllowPredicates)
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. ...
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const ScalarEvolution & getSE() const
static Type * getWiderType(const DataLayout &DL, Type *Ty0, Type *Ty1)
static bool isLoopInvariant(Value *V, const Loop *L, const DominatorTree *DT)
Perform a quick domtree based check for loop invariance assuming that V is used within the loop...
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.
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)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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()
BasicBlock * ExitingBlock
This file implements a class to represent arbitrary precision integral constant values and operations...
static int64_t getConstant(const MachineInstr *MI)
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.
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...
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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.
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)
static ExitLimitQuery getEmptyKey()
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 bool isEqual(ExitLimitQuery LHS, ExitLimitQuery RHS)
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.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
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.
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:
amdgpu Simplify well known AMD library false Value Value * Arg
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...
static ExitLimitQuery getTombstoneKey()
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
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.
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)
SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy)
Represents a single loop in the control flow graph.
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.
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.
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...
static unsigned getHashValue(ExitLimitQuery Val)
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.
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.