Lines Matching defs:SCEV

13 // SCEV class.  Given this analysis, trip counts of loops and other important
50 class SCEV;
51 template<> struct FoldingSetTrait<SCEV>;
53 /// SCEV - This class represents an analyzed expression in the program. These
57 class SCEV : public FoldingSetNode {
58 friend struct FoldingSetTrait<SCEV>;
64 // The SCEV baseclass this node corresponds to
73 SCEV(const SCEV &) LLVM_DELETED_FUNCTION;
74 void operator=(const SCEV &) LLVM_DELETED_FUNCTION;
100 explicit SCEV(const FoldingSetNodeIDRef ID, unsigned SCEVTy) :
105 /// getType - Return the LLVM type of this SCEV expression.
136 // Specialize FoldingSetTrait for SCEV to avoid needing to compute
138 template<> struct FoldingSetTrait<SCEV> : DefaultFoldingSetTrait<SCEV> {
139 static void Profile(const SCEV &X, FoldingSetNodeID& ID) {
142 static bool Equals(const SCEV &X, const FoldingSetNodeID &ID,
146 static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID) {
151 inline raw_ostream &operator<<(raw_ostream &OS, const SCEV &S) {
159 /// None of the standard SCEV operations are valid on this class, it is just a
161 struct SCEVCouldNotCompute : public SCEV {
165 static bool classof(const SCEV *S);
169 /// client code (intentionally) can't do much with the SCEV objects directly,
175 /// SCEV and a loop.
177 LoopVariant, ///< The SCEV is loop-variant (unknown).
178 LoopInvariant, ///< The SCEV is loop-invariant.
179 LoopComputable ///< The SCEV varies predictably with the loop.
183 /// SCEV and a basic block.
185 DoesNotDominateBlock, ///< The SCEV does not dominate the block.
186 DominatesBlock, ///< The SCEV dominates the block.
187 ProperlyDominatesBlock ///< The SCEV properly dominates the block.
192 static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT
193 maskFlags(SCEV::NoWrapFlags Flags, int Mask) {
194 return (SCEV::NoWrapFlags)(Flags & Mask);
196 static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT
197 setFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags) {
198 return (SCEV::NoWrapFlags)(Flags | OnFlags);
200 static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT
201 clearFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags) {
202 return (SCEV::NoWrapFlags)(Flags & ~OffFlags);
240 /// CouldNotCompute - This SCEV is used to represent unknown trip
246 typedef DenseMap<SCEVCallbackVH, const SCEV *, DenseMapInfo<Value *> >
269 const SCEV *Exact;
270 const SCEV *Max;
273 /*implicit*/ ExitLimit(const SCEV *E)
276 ExitLimit(const SCEV *E, const SCEV *M, bool MustExit)
291 const SCEV *ExactNotTaken;
321 const SCEV *Max;
328 SmallVectorImpl< std::pair<BasicBlock *, const SCEV *> > &ExitCounts,
329 bool Complete, const SCEV *MaxCount);
342 const SCEV *getExact(ScalarEvolution *SE) const;
348 const SCEV *getExact(BasicBlock *ExitingBlock, ScalarEvolution *SE) const;
351 const SCEV *getMax(ScalarEvolution *SE) const;
355 bool hasOperand(const SCEV *S, ScalarEvolution *SE) const;
375 DenseMap<const SCEV *,
376 SmallVector<std::pair<const Loop *, const SCEV *>, 2> > ValuesAtScopes;
379 DenseMap<const SCEV *,
383 LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
386 DenseMap<const SCEV *,
390 BlockDisposition computeBlockDisposition(const SCEV *S, const BasicBlock *BB);
393 DenseMap<const SCEV *, ConstantRange> UnsignedRanges;
396 DenseMap<const SCEV *, ConstantRange> SignedRanges;
398 /// setUnsignedRange - Set the memoized unsigned range for the given SCEV.
399 const ConstantRange &setUnsignedRange(const SCEV *S,
401 std::pair<DenseMap<const SCEV *, ConstantRange>::iterator, bool> Pair =
408 /// setUnsignedRange - Set the memoized signed range for the given SCEV.
409 const ConstantRange &setSignedRange(const SCEV *S,
411 std::pair<DenseMap<const SCEV *, ConstantRange>::iterator, bool> Pair =
418 /// createSCEV - We know that there is no SCEV for the specified value.
420 const SCEV *createSCEV(Value *V);
424 const SCEV *createNodeForPHI(PHINode *PN);
428 const SCEV *createNodeForGEP(GEPOperator *GEP);
431 /// at most once for each SCEV+Loop pair.
433 const SCEV *computeSCEVAtScope(const SCEV *S, const Loop *L);
435 /// ForgetSymbolicValue - This looks up computed SCEV values for all
439 void ForgetSymbolicName(Instruction *I, const SCEV *SymName);
492 const SCEV *ComputeExitCountExhaustively(const Loop *L,
499 ExitLimit HowFarToZero(const SCEV *V, const Loop *L, bool IsSubExpr);
504 ExitLimit HowFarToNonZero(const SCEV *V, const Loop *L);
510 ExitLimit HowManyLessThans(const SCEV *LHS, const SCEV *RHS,
512 ExitLimit HowManyGreaterThans(const SCEV *LHS, const SCEV *RHS,
525 const SCEV *LHS, const SCEV *RHS,
533 const SCEV *LHS, const SCEV *RHS,
534 const SCEV *FoundLHS, const SCEV *FoundRHS);
540 const SCEV *LHS, const SCEV *RHS,
541 const SCEV *FoundLHS,
542 const SCEV *FoundRHS);
556 const SCEV *LHS, const SCEV *RHS);
559 void forgetMemoizedResults(const SCEV *S);
561 /// Return false iff given SCEV contains a SCEVUnknown with NULL value-
563 bool checkValidity(const SCEV *S) const;
572 /// the SCEV framework. This primarily includes integer types, and it
582 /// the given type and which represents how SCEV will treat the given
587 /// getSCEV - Return a SCEV expression for the full generality of the
589 const SCEV *getSCEV(Value *V);
591 const SCEV *getConstant(ConstantInt *V);
592 const SCEV *getConstant(const APInt& Val);
593 const SCEV *getConstant(Type *Ty, uint64_t V, bool isSigned = false);
594 const SCEV *getTruncateExpr(const SCEV *Op, Type *Ty);
595 const SCEV *getZeroExtendExpr(const SCEV *Op, Type *Ty);
596 const SCEV *getSignExtendExpr(const SCEV *Op, Type *Ty);
597 const SCEV *getAnyExtendExpr(const SCEV *Op, Type *Ty);
598 const SCEV *getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
599 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
600 const SCEV *getAddExpr(const SCEV *LHS, const SCEV *RHS,
601 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap) {
602 SmallVector<const SCEV *, 2> Ops;
607 const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
608 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap) {
609 SmallVector<const SCEV *, 3> Ops;
615 const SCEV *getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
616 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
617 const SCEV *getMulExpr(const SCEV *LHS, const SCEV *RHS,
618 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap)
620 SmallVector<const SCEV *, 2> Ops;
625 const SCEV *getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
626 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap) {
627 SmallVector<const SCEV *, 3> Ops;
633 const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS);
634 const SCEV *getUDivExactExpr(const SCEV *LHS, const SCEV *RHS);
635 const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step,
636 const Loop *L, SCEV::NoWrapFlags Flags);
637 const SCEV *getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
638 const Loop *L, SCEV::NoWrapFlags Flags);
639 const SCEV *getAddRecExpr(const SmallVectorImpl<const SCEV *> &Operands,
640 const Loop *L, SCEV::NoWrapFlags Flags) {
641 SmallVector<const SCEV *, 4> NewOp(Operands.begin(), Operands.end());
644 const SCEV *getSMaxExpr(const SCEV *LHS, const SCEV *RHS);
645 const SCEV *getSMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
646 const SCEV *getUMaxExpr(const SCEV *LHS, const SCEV *RHS);
647 const SCEV *getUMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
648 const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS);
649 const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS);
650 const SCEV *getUnknown(Value *V);
651 const SCEV *getCouldNotCompute();
656 const SCEV *getSizeOfExpr(Type *IntTy, Type *AllocTy);
661 const SCEV *getOffsetOfExpr(Type *IntTy, StructType *STy, unsigned FieldNo);
663 /// getNegativeSCEV - Return the SCEV object corresponding to -V.
665 const SCEV *getNegativeSCEV(const SCEV *V);
667 /// getNotSCEV - Return the SCEV object corresponding to ~V.
669 const SCEV *getNotSCEV(const SCEV *V);
671 /// getMinusSCEV - Return LHS-RHS. Minus is represented in SCEV as A+B*-1.
672 const SCEV *getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
673 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
675 /// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion
678 const SCEV *getTruncateOrZeroExtend(const SCEV *V, Type *Ty);
680 /// getTruncateOrSignExtend - Return a SCEV corresponding to a conversion
683 const SCEV *getTruncateOrSignExtend(const SCEV *V, Type *Ty);
685 /// getNoopOrZeroExtend - Return a SCEV corresponding to a conversion of
688 const SCEV *getNoopOrZeroExtend(const SCEV *V, Type *Ty);
690 /// getNoopOrSignExtend - Return a SCEV corresponding to a conversion of
693 const SCEV *getNoopOrSignExtend(const SCEV *V, Type *Ty);
695 /// getNoopOrAnyExtend - Return a SCEV corresponding to a conversion of
699 const SCEV *getNoopOrAnyExtend(const SCEV *V, Type *Ty);
701 /// getTruncateOrNoop - Return a SCEV corresponding to a conversion of the
704 const SCEV *getTruncateOrNoop(const SCEV *V, Type *Ty);
709 const SCEV *getUMaxFromMismatchedTypes(const SCEV *LHS,
710 const SCEV *RHS);
715 const SCEV *getUMinFromMismatchedTypes(const SCEV *LHS,
716 const SCEV *RHS);
719 /// until reaching a SCEV that does not have a single pointer operand. This
722 const SCEV *getPointerBase(const SCEV *V);
724 /// getSCEVAtScope - Return a SCEV expression for the specified value
734 const SCEV *getSCEVAtScope(const SCEV *S, const Loop *L);
738 const SCEV *getSCEVAtScope(Value *V, const Loop *L);
744 const SCEV *LHS, const SCEV *RHS);
750 const SCEV *LHS, const SCEV *RHS);
772 const SCEV *getExitCount(Loop *L, BasicBlock *ExitingBlock);
785 const SCEV *getBackedgeTakenCount(const Loop *L);
788 /// return the least SCEV value that is known never to be less than the
790 const SCEV *getMaxBackedgeTakenCount(const Loop *L);
818 uint32_t GetMinTrailingZeros(const SCEV *S);
820 /// getUnsignedRange - Determine the unsigned range for a particular SCEV.
822 ConstantRange getUnsignedRange(const SCEV *S);
824 /// getSignedRange - Determine the signed range for a particular SCEV.
826 ConstantRange getSignedRange(const SCEV *S);
830 bool isKnownNegative(const SCEV *S);
834 bool isKnownPositive(const SCEV *S);
839 bool isKnownNonNegative(const SCEV *S);
844 bool isKnownNonPositive(const SCEV *S);
849 bool isKnownNonZero(const SCEV *S);
855 const SCEV *LHS, const SCEV *RHS);
863 const SCEV *&LHS,
864 const SCEV *&RHS,
867 /// getLoopDisposition - Return the "disposition" of the given SCEV with
869 LoopDisposition getLoopDisposition(const SCEV *S, const Loop *L);
871 /// isLoopInvariant - Return true if the value of the given SCEV is
873 bool isLoopInvariant(const SCEV *S, const Loop *L);
875 /// hasComputableLoopEvolution - Return true if the given SCEV changes value
879 bool hasComputableLoopEvolution(const SCEV *S, const Loop *L);
881 /// getLoopDisposition - Return the "disposition" of the given SCEV with
883 BlockDisposition getBlockDisposition(const SCEV *S, const BasicBlock *BB);
885 /// dominates - Return true if elements that makes up the given SCEV
887 bool dominates(const SCEV *S, const BasicBlock *BB);
889 /// properlyDominates - Return true if elements that makes up the given SCEV
891 bool properlyDominates(const SCEV *S, const BasicBlock *BB);
893 /// hasOperand - Test whether the given SCEV has Op as a direct or
895 bool hasOperand(const SCEV *S, const SCEV *Op) const;
898 const SCEV *getElementSize(Instruction *Inst);
902 void findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
903 SmallVectorImpl<const SCEV *> &Sizes,
904 const SCEV *ElementSize) const;
915 const SCEV *computeBECount(const SCEV *Delta, const SCEV *Stride,
921 bool doesIVOverflowOnLT(const SCEV *RHS, const SCEV *Stride,
927 bool doesIVOverflowOnGT(const SCEV *RHS, const SCEV *Stride,
931 FoldingSet<SCEV> UniqueSCEVs;