21 #ifndef LLVM_ANALYSIS_SCALAREVOLUTION_H
22 #define LLVM_ANALYSIS_SCALAREVOLUTION_H
36 #include "llvm/Support/DataTypes.h"
40 class AssumptionCache;
45 class ScalarEvolution;
47 class TargetLibraryInfo;
58 template <>
struct FoldingSetTrait<SCEV>;
59 template <>
struct FoldingSetTrait<SCEVPredicate>;
72 const unsigned short SCEVType;
81 void operator=(
const SCEV &) =
delete;
149 return ID == X.FastID;
231 return ID == X.FastID;
317 assert((OffFlags & IncrementNoWrapMask) == OffFlags &&
318 "Invalid flags value!");
325 assert((Mask & IncrementNoWrapMask) == Mask &&
"Invalid mask value!");
334 assert((OnFlags & IncrementNoWrapMask) == OnFlags &&
335 "Invalid flags value!");
430 ProperlyDominatesBlock
451 class SCEVCallbackVH final :
public CallbackVH {
453 void deleted()
override;
454 void allUsesReplacedWith(
Value *New)
override;
460 friend class SCEVCallbackVH;
490 std::unique_ptr<SCEVCouldNotCompute> CouldNotCompute;
501 typedef std::pair<Value *, ConstantInt *> ValueOffsetPair;
540 bool WalkingBEDominatingConds;
544 bool ProvingSplitPredicate;
551 const SCEV *ExactNotTaken;
552 const SCEV *MaxNotTaken;
561 assert(!isa<SCEVUnionPredicate>(P) &&
"Only add leaf predicates here!");
562 Predicates.insert(P);
565 ExitLimit(
const SCEV *
E)
566 : ExactNotTaken(E), MaxNotTaken(E), MaxOrZero(
false) {}
569 const SCEV *
E,
const SCEV *M,
bool MaxOrZero,
570 ArrayRef<
const SmallPtrSetImpl<const SCEVPredicate *> *> PredSetList)
571 : ExactNotTaken(E), MaxNotTaken(M), MaxOrZero(MaxOrZero) {
572 assert((isa<SCEVCouldNotCompute>(ExactNotTaken) ||
573 !isa<SCEVCouldNotCompute>(MaxNotTaken)) &&
574 "Exact is not allowed to be less precise than Max");
575 for (
auto *PredSet : PredSetList)
576 for (
auto *P : *PredSet)
580 ExitLimit(
const SCEV *E,
const SCEV *M,
bool MaxOrZero,
581 const SmallPtrSetImpl<const SCEVPredicate *> &PredSet)
582 : ExitLimit(E, M, MaxOrZero, {&PredSet}) {}
584 ExitLimit(
const SCEV *E,
const SCEV *M,
bool MaxOrZero)
585 : ExitLimit(E, M, MaxOrZero,
None) {}
589 bool hasAnyInfo()
const {
590 return !isa<SCEVCouldNotCompute>(ExactNotTaken) ||
591 !isa<SCEVCouldNotCompute>(MaxNotTaken);
595 bool hasFullInfo()
const {
596 return !isa<SCEVCouldNotCompute>(ExactNotTaken);
602 struct ExitNotTakenInfo {
603 AssertingVH<BasicBlock> ExitingBlock;
604 const SCEV *ExactNotTaken;
605 std::unique_ptr<SCEVUnionPredicate>
Predicate;
606 bool hasAlwaysTruePredicate()
const {
610 explicit ExitNotTakenInfo(AssertingVH<BasicBlock> ExitingBlock,
611 const SCEV *ExactNotTaken,
612 std::unique_ptr<SCEVUnionPredicate>
Predicate)
613 : ExitingBlock(ExitingBlock), ExactNotTaken(ExactNotTaken),
614 Predicate(std::move(Predicate)) {}
620 class BackedgeTakenInfo {
623 SmallVector<ExitNotTakenInfo, 1> ExitNotTaken;
632 PointerIntPair<const SCEV *, 1> MaxAndComplete;
639 bool isComplete()
const {
return MaxAndComplete.getInt(); }
640 const SCEV *getMax()
const {
return MaxAndComplete.getPointer(); }
644 BackedgeTakenInfo() : MaxAndComplete(nullptr, 0) {}
646 BackedgeTakenInfo(BackedgeTakenInfo &&) =
default;
647 BackedgeTakenInfo &
operator=(BackedgeTakenInfo &&) =
default;
649 typedef std::pair<BasicBlock *, ExitLimit> EdgeExitInfo;
652 BackedgeTakenInfo(SmallVectorImpl<EdgeExitInfo> &&ExitCounts,
bool Complete,
653 const SCEV *MaxCount,
bool MaxOrZero);
657 bool hasAnyInfo()
const {
658 return !ExitNotTaken.empty() || !isa<SCEVCouldNotCompute>(getMax());
662 bool hasFullInfo()
const {
return isComplete(); }
680 const SCEV *getExact(ScalarEvolution *SE,
681 SCEVUnionPredicate *Predicates =
nullptr)
const;
687 const SCEV *getExact(
BasicBlock *ExitingBlock, ScalarEvolution *SE)
const;
690 const SCEV *getMax(ScalarEvolution *SE)
const;
694 bool isMaxOrZero(ScalarEvolution *SE)
const;
698 bool hasOperand(
const SCEV *S, ScalarEvolution *SE)
const;
706 DenseMap<const Loop *, BackedgeTakenInfo> BackedgeTakenCounts;
710 DenseMap<const Loop *, BackedgeTakenInfo> PredicatedBackedgeTakenCounts;
716 DenseMap<PHINode *, Constant *> ConstantEvolutionLoopExitValue;
721 DenseMap<const SCEV *, SmallVector<std::pair<const Loop *, const SCEV *>, 2>>
725 DenseMap<
const SCEV *,
726 SmallVector<PointerIntPair<const Loop *, 2, LoopDisposition>, 2>>
729 struct LoopProperties {
732 bool HasNoAbnormalExits;
739 bool HasNoSideEffects;
743 DenseMap<const Loop *, LoopProperties> LoopPropertiesCache;
746 LoopProperties getLoopProperties(
const Loop *
L);
748 bool loopHasNoSideEffects(
const Loop *
L) {
749 return getLoopProperties(L).HasNoSideEffects;
752 bool loopHasNoAbnormalExits(
const Loop *
L) {
753 return getLoopProperties(L).HasNoAbnormalExits;
757 LoopDisposition computeLoopDisposition(
const SCEV *S,
const Loop *
L);
762 SmallVector<PointerIntPair<const BasicBlock *, 2, BlockDisposition>, 2>>
766 BlockDisposition computeBlockDisposition(
const SCEV *S,
const BasicBlock *BB);
769 DenseMap<const SCEV *, ConstantRange> UnsignedRanges;
772 DenseMap<const SCEV *, ConstantRange> SignedRanges;
775 enum RangeSignHint { HINT_RANGE_UNSIGNED, HINT_RANGE_SIGNED };
778 const ConstantRange &setRange(
const SCEV *S, RangeSignHint Hint,
779 const ConstantRange &CR) {
780 DenseMap<const SCEV *, ConstantRange> &Cache =
781 Hint == HINT_RANGE_UNSIGNED ? UnsignedRanges : SignedRanges;
783 auto Pair = Cache.insert({S, CR});
785 Pair.first->second = CR;
786 return Pair.first->second;
790 ConstantRange getRange(
const SCEV *S, RangeSignHint Hint);
794 ConstantRange getRangeForAffineAR(
const SCEV *Start,
const SCEV *Stop,
795 const SCEV *MaxBECount,
unsigned BitWidth);
800 ConstantRange getRangeViaFactoring(
const SCEV *Start,
const SCEV *Stop,
801 const SCEV *MaxBECount,
unsigned BitWidth);
805 const SCEV *createSCEV(Value *V);
808 const SCEV *createNodeForPHI(PHINode *PN);
811 const SCEV *createAddRecFromPHI(PHINode *PN);
814 const SCEV *createNodeFromSelectLikePHI(PHINode *PN);
820 const SCEV *createNodeForSelectOrPHI(Instruction *
I, Value *Cond,
821 Value *TrueVal, Value *FalseVal);
824 const SCEV *createNodeForGEP(GEPOperator *
GEP);
829 const SCEV *computeSCEVAtScope(
const SCEV *S,
const Loop *
L);
834 void forgetSymbolicName(Instruction *
I,
const SCEV *SymName);
839 const BackedgeTakenInfo &getBackedgeTakenInfo(
const Loop *
L);
843 const BackedgeTakenInfo &getPredicatedBackedgeTakenInfo(
const Loop *
L);
848 BackedgeTakenInfo computeBackedgeTakenCount(
const Loop *
L,
849 bool AllowPredicates =
false);
855 ExitLimit computeExitLimit(
const Loop *
L,
BasicBlock *ExitingBlock,
856 bool AllowPredicates =
false);
869 ExitLimit computeExitLimitFromCond(
const Loop *
L, Value *ExitCond,
872 bool AllowPredicates =
false);
879 ExitLimit computeExitLimitFromICmp(
const Loop *
L, ICmpInst *ExitCond,
882 bool AllowPredicates =
false);
887 ExitLimit computeExitLimitFromSingleExitSwitch(
const Loop *
L,
894 ExitLimit computeLoadConstantCompareExitLimit(LoadInst *LI, Constant *RHS,
905 ExitLimit computeShiftCompareExitLimit(Value *LHS, Value *RHS,
const Loop *
L,
913 const SCEV *computeExitCountExhaustively(
const Loop *
L, Value *Cond,
920 ExitLimit howFarToZero(
const SCEV *V,
const Loop *
L,
bool IsSubExpr,
921 bool AllowPredicates =
false);
926 ExitLimit howFarToNonZero(
const SCEV *V,
const Loop *
L);
940 ExitLimit howManyLessThans(
const SCEV *LHS,
const SCEV *RHS,
const Loop *
L,
941 bool isSigned,
bool ControlsExit,
942 bool AllowPredicates =
false);
944 ExitLimit howManyGreaterThans(
const SCEV *LHS,
const SCEV *RHS,
const Loop *
L,
945 bool isSigned,
bool IsSubExpr,
946 bool AllowPredicates =
false);
951 std::pair<BasicBlock *, BasicBlock *>
952 getPredecessorWithUniqueSuccessorForBB(
BasicBlock *BB);
957 Value *FoundCondValue,
bool Inverse);
964 const SCEV *FoundRHS);
970 const SCEV *RHS,
const SCEV *FoundLHS,
971 const SCEV *FoundRHS);
977 const SCEV *RHS,
const SCEV *FoundLHS,
978 const SCEV *FoundRHS);
985 const SCEV *RHS,
const SCEV *FoundLHS,
986 const SCEV *FoundRHS);
991 const SCEV *LHS,
const SCEV *RHS);
1000 const SCEV *LHS,
const SCEV *RHS,
1001 const SCEV *FoundLHS,
1002 const SCEV *FoundRHS);
1007 Constant *getConstantEvolutionLoopExitValue(PHINode *PN,
const APInt &BEs,
1014 const SCEV *LHS,
const SCEV *RHS);
1030 bool splitBinaryAdd(
const SCEV *Expr,
const SCEV *&
L,
const SCEV *&R,
1040 Optional<APInt> computeConstantDifference(
const SCEV *LHS,
const SCEV *RHS);
1043 void forgetMemoizedResults(
const SCEV *S);
1046 const SCEV *getExistingSCEV(Value *V);
1050 bool checkValidity(
const SCEV *S)
const;
1058 template <
typename ExtendOpTy>
1059 bool proveNoWrapByVaryingStart(
const SCEV *Start,
const SCEV *Step,
1065 bool isMonotonicPredicateImpl(
const SCEVAddRecExpr *LHS,
1101 bool isSCEVExprNeverPoison(
const Instruction *
I);
1107 bool isAddRecNeverPoison(
const Instruction *
I,
const Loop *
L);
1110 ScalarEvolution(Function &
F, TargetLibraryInfo &TLI, AssumptionCache &AC,
1111 DominatorTree &DT, LoopInfo &LI);
1113 ScalarEvolution(ScalarEvolution &&Arg);
1121 bool isSCEVable(
Type *Ty)
const;
1125 uint64_t getTypeSizeInBits(
Type *Ty)
const;
1130 Type *getEffectiveSCEVType(
Type *Ty)
const;
1135 bool containsAddRecurrence(
const SCEV *S);
1141 void eraseValueFromMap(
Value *V);
1148 const SCEV *getConstant(
const APInt &Val);
1149 const SCEV *getConstant(
Type *Ty, uint64_t V,
bool isSigned =
false);
1159 return getAddExpr(Ops, Flags);
1164 return getAddExpr(Ops, Flags);
1171 return getMulExpr(Ops, Flags);
1176 return getMulExpr(Ops, Flags);
1178 const SCEV *getUDivExpr(
const SCEV *LHS,
const SCEV *RHS);
1179 const SCEV *getUDivExactExpr(
const SCEV *LHS,
const SCEV *RHS);
1187 return getAddRecExpr(NewOp, L, Flags);
1196 const SCEV *getSMaxExpr(
const SCEV *LHS,
const SCEV *RHS);
1198 const SCEV *getUMaxExpr(
const SCEV *LHS,
const SCEV *RHS);
1200 const SCEV *getSMinExpr(
const SCEV *LHS,
const SCEV *RHS);
1201 const SCEV *getUMinExpr(
const SCEV *LHS,
const SCEV *RHS);
1203 const SCEV *getCouldNotCompute();
1221 const SCEV *getNegativeSCEV(
const SCEV *V,
1226 const SCEV *getNotSCEV(
const SCEV *V);
1229 const SCEV *getMinusSCEV(
const SCEV *LHS,
const SCEV *RHS,
1234 const SCEV *getTruncateOrZeroExtend(
const SCEV *V,
Type *Ty);
1238 const SCEV *getTruncateOrSignExtend(
const SCEV *V,
Type *Ty);
1243 const SCEV *getNoopOrZeroExtend(
const SCEV *V,
Type *Ty);
1248 const SCEV *getNoopOrSignExtend(
const SCEV *V,
Type *Ty);
1253 const SCEV *getNoopOrAnyExtend(
const SCEV *V,
Type *Ty);
1257 const SCEV *getTruncateOrNoop(
const SCEV *V,
Type *Ty);
1261 const SCEV *getUMaxFromMismatchedTypes(
const SCEV *LHS,
const SCEV *RHS);
1265 const SCEV *getUMinFromMismatchedTypes(
const SCEV *LHS,
const SCEV *RHS);
1271 const SCEV *getPointerBase(
const SCEV *V);
1304 unsigned getSmallConstantTripCount(
Loop *
L);
1313 unsigned getSmallConstantTripCount(
Loop *
L,
BasicBlock *ExitingBlock);
1318 unsigned getSmallConstantMaxTripCount(
Loop *
L);
1326 unsigned getSmallConstantTripMultiple(
Loop *
L);
1334 unsigned getSmallConstantTripMultiple(
Loop *
L,
BasicBlock *ExitingBlock);
1352 const SCEV *getBackedgeTakenCount(
const Loop *
L);
1358 const SCEV *getPredicatedBackedgeTakenCount(
const Loop *
L,
1363 const SCEV *getMaxBackedgeTakenCount(
const Loop *
L);
1367 bool isBackedgeTakenCountMaxOrZero(
const Loop *
L);
1371 bool hasLoopInvariantBackedgeTakenCount(
const Loop *
L);
1377 void forgetLoop(
const Loop *
L);
1382 void forgetValue(
Value *V);
1400 return getRange(S, HINT_RANGE_UNSIGNED);
1406 return getRange(S, HINT_RANGE_SIGNED);
1423 bool isKnownNonPositive(
const SCEV *S);
1442 const SCEV *&InvariantLHS,
1443 const SCEV *&InvariantRHS);
1455 LoopDisposition getLoopDisposition(
const SCEV *S,
const Loop *
L);
1465 bool hasComputableLoopEvolution(
const SCEV *S,
const Loop *
L);
1469 BlockDisposition getBlockDisposition(
const SCEV *S,
const BasicBlock *BB);
1480 bool hasOperand(
const SCEV *S,
const SCEV *
Op)
const;
1490 const SCEV *ElementSize)
const;
1499 void collectParametricTerms(
const SCEV *Expr,
1504 void computeAccessFunctions(
const SCEV *Expr,
1574 const SCEV *ElementSize);
1579 return F.getParent()->getDataLayout();
1590 const SCEV *rewriteUsingPredicate(
const SCEV *S,
const Loop *
L,
1601 const SCEV *computeBECount(
const SCEV *Delta,
const SCEV *Stride,
1607 bool doesIVOverflowOnLT(
const SCEV *RHS,
const SCEV *Stride,
bool IsSigned,
1613 bool doesIVOverflowOnGT(
const SCEV *RHS,
const SCEV *Stride,
bool IsSigned,
1650 std::unique_ptr<ScalarEvolution> SE;
1660 bool runOnFunction(
Function &
F)
override;
1661 void releaseMemory()
override;
1664 void verifyAnalysis()
const override;
1692 const SCEV *getBackedgeTakenCount();
1723 void updateGeneration();
1727 typedef std::pair<unsigned, const SCEV *> RewriteEntry;
1753 unsigned Generation;
1756 const SCEV *BackedgeCount;
virtual const SCEV * getExpr() const =0
Returns the SCEV to which this predicate applies, or nullptr if this is a SCEVUnionPredicate.
IncrementWrapFlags getFlags() const
Returns the set assumed no overflow flags.
A parsed version of the target data layout string in and methods for querying it. ...
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...
bool isOne() const
Return true if the expression is a constant one.
static unsigned ComputeHash(const SCEVPredicate &X, FoldingSetNodeID &TempID)
A Module instance is used to store all the information related to an LLVM module. ...
LLVMContext & getContext() const
bool isZero() const
Return true if the expression is a constant zero.
virtual bool implies(const SCEVPredicate *N) const =0
Returns true if this predicate implies N.
const SCEV * getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
The main scalar evolution driver.
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)
const SCEV * getMulExpr(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
const SCEV * getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
A cache of .assume calls within a function.
An object of this class is returned by queries that could not be answered.
const SCEV * getExpr() const override
Returns the SCEV to which this predicate applies, or nullptr if this is a SCEVUnionPredicate.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
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.
const SCEV * getAddExpr(const SCEV *LHS, const SCEV *RHS, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags setFlags(SCEVWrapPredicate::IncrementWrapFlags Flags, SCEVWrapPredicate::IncrementWrapFlags OnFlags)
bool isAlwaysTrue() const override
Returns true if the predicate is always true.
const DataLayout & getDataLayout() const
Return the DataLayout associated with the module this SCEV instance is operating on.
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, used to lookup the node in th...
virtual unsigned getComplexity() const
Returns the estimated complexity of this predicate.
Class to represent struct types.
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...
ScalarEvolution & getSE()
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.
bool implies(const SCEVPredicate *N) const override
Implementation of the SCEVPredicate interface.
A CRTP mix-in to automatically provide informational APIs needed for passes.
Function Alias Analysis false
static bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
This function adds the integer array x to the integer array Y and places the result in dest...
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)...
static Optional< bool > isImpliedCondOperands(CmpInst::Predicate Pred, const Value *ALHS, const Value *ARHS, const Value *BLHS, const Value *BRHS, const DataLayout &DL, unsigned Depth, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred ALHS ARHS" is true.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
const SCEV * getAddRecExpr(const SmallVectorImpl< const SCEV * > &Operands, const Loop *L, SCEV::NoWrapFlags Flags)
void forgetLoopDispositions(const Loop *L)
Called when the client has changed the disposition of values in this loop.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Printer pass for the ScalarEvolutionAnalysis results.
virtual bool isAlwaysTrue() const =0
Returns true if the predicate is always true.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
This means that we are dealing with an entirely unknown SCEV value, and only represent it as its LLVM...
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)
LLVM Basic Block Representation.
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.
Type * getType() const
Return the LLVM type of this SCEV expression.
Allocate memory in an ever growing pool, as if by bump-pointer.
bool isKnownNonNegative(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Returns true if the give value is known to be non-negative.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
void print(raw_ostream &OS, unsigned Depth=0) const override
Prints a textual representation of this predicate with an indentation of Depth.
SCEVWrapPredicate(const FoldingSetNodeIDRef ID, const SCEVAddRecExpr *AR, IncrementWrapFlags Flags)
const SCEV * getExpr() const override
Implementation of the SCEVPredicate interface.
A CRTP mix-in that provides informational APIs needed for analysis passes.
ScalarEvolutionPrinterPass(raw_ostream &OS)
Represent the analysis usage information of a pass.
const SCEVUnknown * getLHS() const
Returns the left hand side of the equality.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
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)
bool isNonConstantNegative() const
Return true if the specified scev is negated, but not a constant.
SCEVPredicateKind getKind() const
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
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 dump() const
This method is used for debugging.
const SCEVConstant * getRHS() const
Returns the right hand side of the equality.
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.
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags clearFlags(SCEVWrapPredicate::IncrementWrapFlags Flags, SCEVWrapPredicate::IncrementWrapFlags OffFlags)
Convenient IncrementWrapFlags manipulation methods.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isAllOnesValue() const
Return true if the expression is a constant all-ones value.
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 getImpliedFlags(const SCEVAddRecExpr *AR, ScalarEvolution &SE)
Returns the set of SCEVWrapPredicate no wrap flags implied by a SCEVAddRecExpr.
static LLVM_NODISCARD SCEVWrapPredicate::IncrementWrapFlags maskFlags(SCEVWrapPredicate::IncrementWrapFlags Flags, int Mask)
static void Profile(const SCEV &X, FoldingSetNodeID &ID)
SCEVPredicate & operator=(const SCEVPredicate &)=default
static void Profile(const SCEVPredicate &X, FoldingSetNodeID &ID)
Node - This class is used to maintain the singly linked bucket list in a folding set.
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.
This class uses information about analyze scalars to rewrite expressions in canonical form...
static void clear(coro::Shape &Shape)
static bool classof(const SCEVPredicate *P)
Methods for support type inquiry through isa, cast, and dyn_cast:
SCEVPredicate(const SCEVPredicate &)=default
Analysis pass that exposes the ScalarEvolution for a function.
bool isKnownNegative(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Returns true if the given value is known be negative (i.e.
unsigned getComplexity() const override
We estimate the complexity of a union predicate as the size number of predicates in the union...
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.
This class represents an analyzed expression in the program.
const ScalarEvolution & getSE() const
SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy)
Represents a single loop in the control flow graph.
ScalarEvolution * getSE() const
Returns the ScalarEvolution analysis used.
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)
#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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents a composition of other SCEV predicates, and is the class that most clients will...
unsigned getSCEVType() const
void print(raw_ostream &OS) const
Print out the internal representation of this scalar to the specified stream.
LLVM Value Representation.
A vector that has set insertion semantics.
SCEVEqualPredicate(const FoldingSetNodeIDRef ID, const SCEVUnknown *LHS, const SCEVConstant *RHS)
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.
bool isKnownPositive(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Returns true if the given value is known be positive (i.e.
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...
bool implies(const SCEVPredicate *N) const override
Returns true if this predicate implies N.
bool isKnownNonZero(const Value *V, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return true if the given value is known to be non-zero when defined.
Value handle with callbacks on RAUW and destruction.
A container for analyses that lazily runs them and caches their results.
bool isAlwaysTrue() const override
Returns true if the predicate is always true.
This header defines various interfaces for pass management in LLVM.
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.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
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...
static bool classof(const SCEV *S)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SmallVectorImpl< const SCEVPredicate * > & getPredicates() const
void print(raw_ostream &OS, unsigned Depth=0) const override
Prints a textual representation of this predicate with an indentation of Depth.
This class represents a constant integer value.