|
reference, declaration → definition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
|
Derived Classes
include/llvm/Analysis/ScalarEvolution.h 189 struct SCEVCouldNotCompute : public SCEV {
include/llvm/Analysis/ScalarEvolutionExpressions.h 47 class SCEVConstant : public SCEV {
75 class SCEVCastExpr : public SCEV {
142 class SCEVNAryExpr : public SCEV {
259 class SCEVUDivExpr : public SCEV {
466 class SCEVUnknown final : public SCEV, private CallbackVH {
Declarations
include/llvm/Analysis/DependenceAnalysis.h 52 class SCEV;
include/llvm/Analysis/IVDescriptors.h 46 class SCEV;
include/llvm/Analysis/IVUsers.h 29 class SCEV;
include/llvm/Analysis/LoopAccessAnalysis.h 35 class SCEV;
include/llvm/Analysis/ScalarEvolutionNormalization.h 46 class SCEV;
include/llvm/Analysis/TargetTransformInfo.h 49 class SCEV;
include/llvm/CodeGen/BasicTTIImpl.h 62 class SCEV;
include/llvm/Transforms/Scalar/NaryReassociate.h 96 class SCEV;
include/llvm/Transforms/Utils/LoopUtils.h 49 class SCEV;
lib/Target/AArch64/AArch64TargetTransformInfo.h 35 class SCEV;
lib/Target/ARM/ARMTargetTransformInfo.h 36 class SCEV;
tools/polly/include/polly/CodeGen/IRBuilder.h 22 class SCEV;
tools/polly/include/polly/ScopDetectionDiagnostic.h 36 class SCEV;
tools/polly/include/polly/Support/ScopHelper.h 25 class SCEV;
References
include/llvm/ADT/FoldingSet.h 221 static void Profile(const T &X, FoldingSetNodeID &ID) {
224 static void Profile(T &X, FoldingSetNodeID &ID) {
232 static inline bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash,
240 static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID);
410 using iterator = FoldingSetIterator<T>;
415 using const_iterator = FoldingSetIterator<const T>;
420 using bucket_iterator = FoldingSetBucketIterator<T>;
432 bool RemoveNode(T *N) { return FoldingSetBase::RemoveNode(N); }
437 T *GetOrInsertNode(T *N) {
437 T *GetOrInsertNode(T *N) {
444 T *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos) {
451 void InsertNode(T *N, void *InsertPos) {
457 void InsertNode(T *N) {
473 template <class T> class FoldingSet final : public FoldingSetImpl<T> {
474 using Super = FoldingSetImpl<T>;
480 T *TN = static_cast<T *>(N);
481 FoldingSetTrait<T>::Profile(*TN, ID);
488 T *TN = static_cast<T *>(N);
489 return FoldingSetTrait<T>::Equals(*TN, ID, IDHash, TempID);
495 T *TN = static_cast<T *>(N);
496 return FoldingSetTrait<T>::ComputeHash(*TN, TempID);
include/llvm/Analysis/DependenceAnalysis.h 101 const SCEV *Distance; // NULL implies no distance available.
161 virtual const SCEV *getDistance(unsigned Level) const { return nullptr; }
242 const SCEV *getDistance(unsigned Level) const override;
331 const SCEV *getSplitIteration(const Dependence &Dep, unsigned Level);
345 const SCEV *Src;
346 const SCEV *Dst;
354 const SCEV *Coeff;
355 const SCEV *PosPart;
356 const SCEV *NegPart;
357 const SCEV *Iterations;
361 const SCEV *Iterations;
362 const SCEV *Upper[8];
363 const SCEV *Lower[8];
387 const SCEV *A;
388 const SCEV *B;
389 const SCEV *C;
412 const SCEV *getX() const;
416 const SCEV *getY() const;
420 const SCEV *getA() const;
424 const SCEV *getB() const;
428 const SCEV *getC() const;
432 const SCEV *getD() const;
438 void setPoint(const SCEV *X, const SCEV *Y, const Loop *CurrentLoop);
438 void setPoint(const SCEV *X, const SCEV *Y, const Loop *CurrentLoop);
441 void setLine(const SCEV *A, const SCEV *B,
441 void setLine(const SCEV *A, const SCEV *B,
442 const SCEV *C, const Loop *CurrentLoop);
445 void setDistance(const SCEV *D, const Loop *CurrentLoop);
523 bool isLoopInvariant(const SCEV *Expression, const Loop *LoopNest) const;
539 void collectCommonLoops(const SCEV *Expression,
545 bool checkSrcSubscript(const SCEV *Src,
551 bool checkDstSubscript(const SCEV *Dst,
560 const SCEV *X,
561 const SCEV *Y) const;
567 bool isKnownLessThan(const SCEV *S, const SCEV *Size) const;
567 bool isKnownLessThan(const SCEV *S, const SCEV *Size) const;
572 bool isKnownNonNegative(const SCEV *S, const Value *Ptr) const;
579 const SCEV *collectUpperBound(const Loop *l, Type *T) const;
589 Subscript::ClassificationKind classifyPair(const SCEV *Src,
591 const SCEV *Dst,
600 bool testZIV(const SCEV *Src,
601 const SCEV *Dst,
614 bool testSIV(const SCEV *Src,
615 const SCEV *Dst,
619 const SCEV *&SplitIter) const;
630 bool testRDIV(const SCEV *Src,
631 const SCEV *Dst,
637 bool testMIV(const SCEV *Src,
638 const SCEV *Dst,
650 bool strongSIVtest(const SCEV *Coeff,
651 const SCEV *SrcConst,
652 const SCEV *DstConst,
668 bool weakCrossingSIVtest(const SCEV *SrcCoeff,
669 const SCEV *SrcConst,
670 const SCEV *DstConst,
675 const SCEV *&SplitIter) const;
686 bool exactSIVtest(const SCEV *SrcCoeff,
687 const SCEV *DstCoeff,
688 const SCEV *SrcConst,
689 const SCEV *DstConst,
705 bool weakZeroSrcSIVtest(const SCEV *DstCoeff,
706 const SCEV *SrcConst,
707 const SCEV *DstConst,
723 bool weakZeroDstSIVtest(const SCEV *SrcCoeff,
724 const SCEV *SrcConst,
725 const SCEV *DstConst,
739 bool exactRDIVtest(const SCEV *SrcCoeff,
740 const SCEV *DstCoeff,
741 const SCEV *SrcConst,
742 const SCEV *DstConst,
756 bool symbolicRDIVtest(const SCEV *SrcCoeff,
757 const SCEV *DstCoeff,
758 const SCEV *SrcConst,
759 const SCEV *DstConst,
769 bool gcdMIVtest(const SCEV *Src,
770 const SCEV *Dst,
777 bool banerjeeMIVtest(const SCEV *Src,
778 const SCEV *Dst,
785 CoefficientInfo *collectCoeffInfo(const SCEV *Subscript,
787 const SCEV *&Constant) const;
791 const SCEV *getPositivePart(const SCEV *X) const;
791 const SCEV *getPositivePart(const SCEV *X) const;
795 const SCEV *getNegativePart(const SCEV *X) const;
795 const SCEV *getNegativePart(const SCEV *X) const;
800 const SCEV *getLowerBound(BoundInfo *Bound) const;
805 const SCEV *getUpperBound(BoundInfo *Bound) const;
818 const SCEV *Delta) const;
824 const SCEV *Delta) const;
864 bool propagate(const SCEV *&Src,
865 const SCEV *&Dst,
875 bool propagateDistance(const SCEV *&Src,
876 const SCEV *&Dst,
883 bool propagatePoint(const SCEV *&Src,
884 const SCEV *&Dst,
892 bool propagateLine(const SCEV *&Src,
893 const SCEV *&Dst,
902 const SCEV *findCoefficient(const SCEV *Expr,
902 const SCEV *findCoefficient(const SCEV *Expr,
910 const SCEV *zeroCoefficient(const SCEV *Expr,
910 const SCEV *zeroCoefficient(const SCEV *Expr,
918 const SCEV *addToCoefficient(const SCEV *Expr,
918 const SCEV *addToCoefficient(const SCEV *Expr,
920 const SCEV *Value) const;
include/llvm/Analysis/IVDescriptors.h 282 const SCEV *getStep() const { return Step; }
295 InductionDescriptor &D, const SCEV *Expr = nullptr,
348 InductionDescriptor(Value *Start, InductionKind K, const SCEV *Step,
357 const SCEV *Step = nullptr;
include/llvm/Analysis/IVUsers.h 135 const SCEV *getReplacementExpr(const IVStrideUse &IU) const;
138 const SCEV *getExpr(const IVStrideUse &IU) const;
140 const SCEV *getStride(const IVStrideUse &IU, const Loop *L) const;
include/llvm/Analysis/LoopAccessAnalysis.h 341 const SCEV *Start;
344 const SCEV *End;
353 const SCEV *Expr;
355 PointerInfo(Value *PointerValue, const SCEV *Start, const SCEV *End,
355 PointerInfo(Value *PointerValue, const SCEV *Start, const SCEV *End,
357 const SCEV *Expr)
408 const SCEV *High;
411 const SCEV *Low;
679 const SCEV *replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
include/llvm/Analysis/LoopCacheAnalysis.h 53 const SCEV *getBasePointer() const { return BasePointer; }
55 const SCEV *getSubscript(unsigned SubNum) const {
59 const SCEV *getFirstSubscript() const {
63 const SCEV *getLastSubscript() const {
108 const SCEV *getLastCoefficient() const;
112 bool isCoeffForLoopZeroOrInvariant(const SCEV &Subscript,
117 bool isSimpleAddRecurrence(const SCEV &Subscript, const Loop &L) const;
131 const SCEV *BasePointer = nullptr;
134 SmallVector<const SCEV *, 3> Subscripts;
137 SmallVector<const SCEV *, 3> Sizes;
include/llvm/Analysis/LoopUnrollAnalyzer.h 69 const SCEV *IterationNumber;
include/llvm/Analysis/ScalarEvolution.h 124 SCEV(const SCEV &) = delete;
125 SCEV &operator=(const SCEV &) = delete;
125 SCEV &operator=(const SCEV &) = delete;
167 template <> struct FoldingSetTrait<SCEV> : DefaultFoldingSetTrait<SCEV> {
168 static void Profile(const SCEV &X, FoldingSetNodeID &ID) { ID = X.FastID; }
170 static bool Equals(const SCEV &X, const FoldingSetNodeID &ID, unsigned IDHash,
175 static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID) {
180 inline raw_ostream &operator<<(raw_ostream &OS, const SCEV &S) {
189 struct SCEVCouldNotCompute : public SCEV {
193 static bool classof(const SCEV *S);
236 virtual const SCEV *getExpr() const = 0;
267 const SCEV *LHS;
268 const SCEV *RHS;
271 SCEVEqualPredicate(const FoldingSetNodeIDRef ID, const SCEV *LHS,
272 const SCEV *RHS);
278 const SCEV *getExpr() const override;
281 const SCEV *getLHS() const { return LHS; }
284 const SCEV *getRHS() const { return RHS; }
380 const SCEV *getExpr() const override;
400 DenseMap<const SCEV *, SmallVector<const SCEVPredicate *, 4>>;
420 ArrayRef<const SCEVPredicate *> getPredicatesForExpr(const SCEV *Expr);
426 const SCEV *getExpr() const override;
461 LLVM_NODISCARD static SCEV::NoWrapFlags maskFlags(SCEV::NoWrapFlags Flags,
461 LLVM_NODISCARD static SCEV::NoWrapFlags maskFlags(SCEV::NoWrapFlags Flags,
465 LLVM_NODISCARD static SCEV::NoWrapFlags setFlags(SCEV::NoWrapFlags Flags,
465 LLVM_NODISCARD static SCEV::NoWrapFlags setFlags(SCEV::NoWrapFlags Flags,
466 SCEV::NoWrapFlags OnFlags) {
469 LLVM_NODISCARD static SCEV::NoWrapFlags
470 clearFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags) {
470 clearFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags) {
501 bool containsAddRecurrence(const SCEV *S);
508 const SCEV *getSCEV(Value *V);
510 const SCEV *getConstant(ConstantInt *V);
511 const SCEV *getConstant(const APInt &Val);
512 const SCEV *getConstant(Type *Ty, uint64_t V, bool isSigned = false);
513 const SCEV *getTruncateExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
513 const SCEV *getTruncateExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
514 const SCEV *getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
514 const SCEV *getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
515 const SCEV *getSignExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
515 const SCEV *getSignExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth = 0);
516 const SCEV *getAnyExtendExpr(const SCEV *Op, Type *Ty);
516 const SCEV *getAnyExtendExpr(const SCEV *Op, Type *Ty);
517 const SCEV *getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
517 const SCEV *getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
518 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
518 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
520 const SCEV *getAddExpr(const SCEV *LHS, const SCEV *RHS,
520 const SCEV *getAddExpr(const SCEV *LHS, const SCEV *RHS,
520 const SCEV *getAddExpr(const SCEV *LHS, const SCEV *RHS,
521 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
521 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
523 SmallVector<const SCEV *, 2> Ops = {LHS, RHS};
526 const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
526 const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
526 const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
526 const SCEV *getAddExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
527 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
527 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
529 SmallVector<const SCEV *, 3> Ops = {Op0, Op1, Op2};
532 const SCEV *getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
532 const SCEV *getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
533 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
533 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
535 const SCEV *getMulExpr(const SCEV *LHS, const SCEV *RHS,
535 const SCEV *getMulExpr(const SCEV *LHS, const SCEV *RHS,
535 const SCEV *getMulExpr(const SCEV *LHS, const SCEV *RHS,
536 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
536 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
538 SmallVector<const SCEV *, 2> Ops = {LHS, RHS};
541 const SCEV *getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
541 const SCEV *getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
541 const SCEV *getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
541 const SCEV *getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2,
542 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
542 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
544 SmallVector<const SCEV *, 3> Ops = {Op0, Op1, Op2};
547 const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS);
547 const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS);
547 const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS);
548 const SCEV *getUDivExactExpr(const SCEV *LHS, const SCEV *RHS);
548 const SCEV *getUDivExactExpr(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);
549 const SCEV *getURemExpr(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,
550 const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L,
550 const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L,
551 SCEV::NoWrapFlags Flags);
552 const SCEV *getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
552 const SCEV *getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
553 const Loop *L, SCEV::NoWrapFlags Flags);
554 const SCEV *getAddRecExpr(const SmallVectorImpl<const SCEV *> &Operands,
554 const SCEV *getAddRecExpr(const SmallVectorImpl<const SCEV *> &Operands,
555 const Loop *L, SCEV::NoWrapFlags Flags) {
556 SmallVector<const SCEV *, 4> NewOp(Operands.begin(), Operands.end());
564 Optional<std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
572 const SCEV *getGEPExpr(GEPOperator *GEP,
573 const SmallVectorImpl<const SCEV *> &IndexExprs);
574 const SCEV *getMinMaxExpr(unsigned Kind,
575 SmallVectorImpl<const SCEV *> &Operands);
576 const SCEV *getSMaxExpr(const SCEV *LHS, const SCEV *RHS);
576 const SCEV *getSMaxExpr(const SCEV *LHS, const SCEV *RHS);
576 const SCEV *getSMaxExpr(const SCEV *LHS, const SCEV *RHS);
577 const SCEV *getSMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
577 const SCEV *getSMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
578 const SCEV *getUMaxExpr(const SCEV *LHS, const SCEV *RHS);
578 const SCEV *getUMaxExpr(const SCEV *LHS, const SCEV *RHS);
578 const SCEV *getUMaxExpr(const SCEV *LHS, const SCEV *RHS);
579 const SCEV *getUMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
579 const SCEV *getUMaxExpr(SmallVectorImpl<const SCEV *> &Operands);
580 const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS);
580 const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS);
580 const SCEV *getSMinExpr(const SCEV *LHS, const SCEV *RHS);
581 const SCEV *getSMinExpr(SmallVectorImpl<const SCEV *> &Operands);
581 const SCEV *getSMinExpr(SmallVectorImpl<const SCEV *> &Operands);
582 const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS);
582 const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS);
582 const SCEV *getUMinExpr(const SCEV *LHS, const SCEV *RHS);
583 const SCEV *getUMinExpr(SmallVectorImpl<const SCEV *> &Operands);
583 const SCEV *getUMinExpr(SmallVectorImpl<const SCEV *> &Operands);
584 const SCEV *getUnknown(Value *V);
585 const SCEV *getCouldNotCompute();
588 const SCEV *getZero(Type *Ty) { return getConstant(Ty, 0); }
591 const SCEV *getOne(Type *Ty) { return getConstant(Ty, 1); }
594 const SCEV *getSizeOfExpr(Type *IntTy, Type *AllocTy);
597 const SCEV *getOffsetOfExpr(Type *IntTy, StructType *STy, unsigned FieldNo);
600 const SCEV *getNegativeSCEV(const SCEV *V,
600 const SCEV *getNegativeSCEV(const SCEV *V,
601 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
601 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap);
604 const SCEV *getNotSCEV(const SCEV *V);
604 const SCEV *getNotSCEV(const SCEV *V);
607 const SCEV *getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
607 const SCEV *getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
607 const SCEV *getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
608 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
608 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap,
613 const SCEV *getTruncateOrZeroExtend(const SCEV *V, Type *Ty,
613 const SCEV *getTruncateOrZeroExtend(const SCEV *V, Type *Ty,
618 const SCEV *getTruncateOrSignExtend(const SCEV *V, Type *Ty,
618 const SCEV *getTruncateOrSignExtend(const SCEV *V, Type *Ty,
624 const SCEV *getNoopOrZeroExtend(const SCEV *V, Type *Ty);
624 const SCEV *getNoopOrZeroExtend(const SCEV *V, Type *Ty);
629 const SCEV *getNoopOrSignExtend(const SCEV *V, Type *Ty);
629 const SCEV *getNoopOrSignExtend(const SCEV *V, Type *Ty);
634 const SCEV *getNoopOrAnyExtend(const SCEV *V, Type *Ty);
634 const SCEV *getNoopOrAnyExtend(const SCEV *V, Type *Ty);
638 const SCEV *getTruncateOrNoop(const SCEV *V, Type *Ty);
638 const SCEV *getTruncateOrNoop(const SCEV *V, Type *Ty);
642 const SCEV *getUMaxFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS);
642 const SCEV *getUMaxFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS);
642 const SCEV *getUMaxFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS);
646 const SCEV *getUMinFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS);
646 const SCEV *getUMinFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS);
646 const SCEV *getUMinFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS);
650 const SCEV *getUMinFromMismatchedTypes(SmallVectorImpl<const SCEV *> &Ops);
650 const SCEV *getUMinFromMismatchedTypes(SmallVectorImpl<const SCEV *> &Ops);
656 const SCEV *getPointerBase(const SCEV *V);
656 const SCEV *getPointerBase(const SCEV *V);
668 const SCEV *getSCEVAtScope(const SCEV *S, const Loop *L);
668 const SCEV *getSCEVAtScope(const SCEV *S, const Loop *L);
671 const SCEV *getSCEVAtScope(Value *V, const Loop *L);
677 const SCEV *LHS, const SCEV *RHS);
677 const SCEV *LHS, const SCEV *RHS);
682 const SCEV *LHS, const SCEV *RHS);
682 const SCEV *LHS, const SCEV *RHS);
740 const SCEV *getExitCount(const Loop *L, BasicBlock *ExitingBlock,
753 const SCEV *getBackedgeTakenCount(const Loop *L, ExitCountKind Kind = Exact);
759 const SCEV *getPredicatedBackedgeTakenCount(const Loop *L,
766 const SCEV *getConstantMaxBackedgeTakenCount(const Loop *L) {
813 uint32_t GetMinTrailingZeros(const SCEV *S);
817 ConstantRange getUnsignedRange(const SCEV *S) {
822 APInt getUnsignedRangeMin(const SCEV *S) {
827 APInt getUnsignedRangeMax(const SCEV *S) {
833 ConstantRange getSignedRange(const SCEV *S) {
838 APInt getSignedRangeMin(const SCEV *S) {
843 APInt getSignedRangeMax(const SCEV *S) {
848 bool isKnownNegative(const SCEV *S);
851 bool isKnownPositive(const SCEV *S);
854 bool isKnownNonNegative(const SCEV *S);
857 bool isKnownNonPositive(const SCEV *S);
860 bool isKnownNonZero(const SCEV *S);
878 std::pair<const SCEV *, const SCEV *> SplitIntoInitAndPostInc(const Loop *L,
878 std::pair<const SCEV *, const SCEV *> SplitIntoInitAndPostInc(const Loop *L,
879 const SCEV *S);
899 bool isKnownViaInduction(ICmpInst::Predicate Pred, const SCEV *LHS,
900 const SCEV *RHS);
904 bool isKnownPredicate(ICmpInst::Predicate Pred, const SCEV *LHS,
905 const SCEV *RHS);
910 const SCEVAddRecExpr *LHS, const SCEV *RHS);
928 bool isLoopInvariantPredicate(ICmpInst::Predicate Pred, const SCEV *LHS,
929 const SCEV *RHS, const Loop *L,
931 const SCEV *&InvariantLHS,
932 const SCEV *&InvariantRHS);
938 bool SimplifyICmpOperands(ICmpInst::Predicate &Pred, const SCEV *&LHS,
939 const SCEV *&RHS, unsigned Depth = 0);
943 LoopDisposition getLoopDisposition(const SCEV *S, const Loop *L);
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);
962 BlockDisposition getBlockDisposition(const SCEV *S, const BasicBlock *BB);
966 bool dominates(const SCEV *S, const BasicBlock *BB);
970 bool properlyDominates(const SCEV *S, const BasicBlock *BB);
973 bool hasOperand(const SCEV *S, const SCEV *Op) const;
973 bool hasOperand(const SCEV *S, const SCEV *Op) const;
976 const SCEV *getElementSize(Instruction *Inst);
981 void findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
982 SmallVectorImpl<const SCEV *> &Sizes,
983 const SCEV *ElementSize);
992 void collectParametricTerms(const SCEV *Expr,
993 SmallVectorImpl<const SCEV *> &Terms);
997 void computeAccessFunctions(const SCEV *Expr,
998 SmallVectorImpl<const SCEV *> &Subscripts,
999 SmallVectorImpl<const SCEV *> &Sizes);
1065 void delinearize(const SCEV *Expr, SmallVectorImpl<const SCEV *> &Subscripts,
1065 void delinearize(const SCEV *Expr, SmallVectorImpl<const SCEV *> &Subscripts,
1066 SmallVectorImpl<const SCEV *> &Sizes,
1067 const SCEV *ElementSize);
1075 const SCEVPredicate *getEqualPredicate(const SCEV *LHS, const SCEV *RHS);
1075 const SCEVPredicate *getEqualPredicate(const SCEV *LHS, const SCEV *RHS);
1082 const SCEV *rewriteUsingPredicate(const SCEV *S, const Loop *L,
1082 const SCEV *rewriteUsingPredicate(const SCEV *S, const Loop *L,
1087 const SCEV *S, const Loop *L,
1131 using HasRecMapType = DenseMap<const SCEV *, bool>;
1138 using ExprValueMapType = DenseMap<const SCEV *, SetVector<ValueOffsetPair>>;
1164 DenseMap<SCEVCallbackVH, const SCEV *, DenseMapInfo<Value *>>;
1187 DenseMap<const SCEV *, uint32_t> MinTrailingZerosCache;
1190 SetVector<ValueOffsetPair> *getSCEVValues(const SCEV *S);
1193 uint32_t GetMinTrailingZerosImpl(const SCEV *S);
1200 const SCEV *ExactNotTaken; // The exit is not taken exactly this many times
1201 const SCEV *MaxNotTaken; // The exit is not taken at most this many times
1219 /*implicit*/ ExitLimit(const SCEV *E);
1222 const SCEV *E, const SCEV *M, bool MaxOrZero,
1222 const SCEV *E, const SCEV *M, bool MaxOrZero,
1225 ExitLimit(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);
1228 ExitLimit(const SCEV *E, const SCEV *M, bool MaxOrZero);
1237 bool hasOperand(const SCEV *S) const;
1249 const SCEV *ExactNotTaken;
1250 const SCEV *MaxNotTaken;
1254 const SCEV *ExactNotTaken,
1255 const SCEV *MaxNotTaken,
1280 PointerIntPair<const SCEV *, 1> MaxAndComplete;
1288 const SCEV *getMax() const { return MaxAndComplete.getPointer(); }
1300 const SCEV *MaxCount, bool MaxOrZero);
1329 const SCEV *getExact(const Loop *L, ScalarEvolution *SE,
1336 const SCEV *getExact(BasicBlock *ExitingBlock, ScalarEvolution *SE) const;
1339 const SCEV *getMax(ScalarEvolution *SE) const;
1342 const SCEV *getMax(BasicBlock *ExitingBlock, ScalarEvolution *SE) const;
1350 bool hasOperand(const SCEV *S, ScalarEvolution *SE) const;
1373 DenseMap<const SCEV *, SmallVector<std::pair<const Loop *, const SCEV *>, 2>>
1373 DenseMap<const SCEV *, SmallVector<std::pair<const Loop *, const SCEV *>, 2>>
1377 DenseMap<const SCEV *,
1409 LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
1413 const SCEV *,
1418 BlockDisposition computeBlockDisposition(const SCEV *S, const BasicBlock *BB);
1421 DenseMap<const SCEV *, ConstantRange> UnsignedRanges;
1424 DenseMap<const SCEV *, ConstantRange> SignedRanges;
1430 const ConstantRange &setRange(const SCEV *S, RangeSignHint Hint,
1432 DenseMap<const SCEV *, ConstantRange> &Cache =
1444 const ConstantRange &getRangeRef(const SCEV *S, RangeSignHint Hint);
1448 ConstantRange getRangeForAffineAR(const SCEV *Start, const SCEV *Stop,
1448 ConstantRange getRangeForAffineAR(const SCEV *Start, const SCEV *Stop,
1449 const SCEV *MaxBECount, unsigned BitWidth);
1454 ConstantRange getRangeViaFactoring(const SCEV *Start, const SCEV *Stop,
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,
1472 const SCEV *createNodeFromSelectLikePHI(PHINode *PN);
1478 const SCEV *createNodeForSelectOrPHI(Instruction *I, Value *Cond,
1482 const SCEV *createNodeForGEP(GEPOperator *GEP);
1486 const SCEV *computeSCEVAtScope(const SCEV *S, const Loop *L);
1486 const SCEV *computeSCEVAtScope(const SCEV *S, const Loop *L);
1491 void forgetSymbolicName(Instruction *I, const SCEV *SymName);
1606 const SCEV *computeExitCountExhaustively(const Loop *L, Value *Cond,
1613 ExitLimit howFarToZero(const SCEV *V, const Loop *L, bool IsSubExpr,
1619 ExitLimit howFarToNonZero(const SCEV *V, const Loop *L);
1633 ExitLimit howManyLessThans(const SCEV *LHS, const SCEV *RHS, const Loop *L,
1633 ExitLimit howManyLessThans(const SCEV *LHS, const SCEV *RHS, const Loop *L,
1637 ExitLimit howManyGreaterThans(const SCEV *LHS, const SCEV *RHS, const Loop *L,
1637 ExitLimit howManyGreaterThans(const SCEV *LHS, const SCEV *RHS, const Loop *L,
1649 bool isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
1649 bool isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
1655 bool isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
1655 bool isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
1656 ICmpInst::Predicate FoundPred, const SCEV *FoundLHS,
1657 const SCEV *FoundRHS);
1662 bool isImpliedCondOperands(ICmpInst::Predicate Pred, const SCEV *LHS,
1663 const SCEV *RHS, const SCEV *FoundLHS,
1663 const SCEV *RHS, const SCEV *FoundLHS,
1664 const SCEV *FoundRHS);
1671 const SCEV *LHS, const SCEV *RHS,
1671 const SCEV *LHS, const SCEV *RHS,
1672 const SCEV *FoundLHS, const SCEV *FoundRHS,
1672 const SCEV *FoundLHS, const SCEV *FoundRHS,
1678 const SCEV *LHS, const SCEV *RHS);
1678 const SCEV *LHS, const SCEV *RHS);
1683 bool isImpliedCondOperandsHelper(ICmpInst::Predicate Pred, const SCEV *LHS,
1684 const SCEV *RHS, const SCEV *FoundLHS,
1684 const SCEV *RHS, const SCEV *FoundLHS,
1685 const SCEV *FoundRHS);
1691 bool isImpliedCondOperandsViaRanges(ICmpInst::Predicate Pred, const SCEV *LHS,
1692 const SCEV *RHS, const SCEV *FoundLHS,
1692 const SCEV *RHS, const SCEV *FoundLHS,
1693 const SCEV *FoundRHS);
1698 const SCEV *LHS, const SCEV *RHS);
1698 const SCEV *LHS, const SCEV *RHS);
1707 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,
1719 const SCEV *LHS, const SCEV *RHS,
1720 const SCEV *FoundLHS, const SCEV *FoundRHS,
1720 const SCEV *FoundLHS, const SCEV *FoundRHS,
1732 const SCEV *LHS, const SCEV *RHS);
1732 const SCEV *LHS, const SCEV *RHS);
1739 bool isKnownPredicateViaNoOverflow(ICmpInst::Predicate Pred, const SCEV *LHS,
1740 const SCEV *RHS);
1744 bool isKnownPredicateViaSplitting(ICmpInst::Predicate Pred, const SCEV *LHS,
1745 const SCEV *RHS);
1748 bool splitBinaryAdd(const SCEV *Expr, const SCEV *&L, const SCEV *&R,
1748 bool splitBinaryAdd(const SCEV *Expr, const SCEV *&L, const SCEV *&R,
1748 bool splitBinaryAdd(const SCEV *Expr, const SCEV *&L, const SCEV *&R,
1749 SCEV::NoWrapFlags &Flags);
1758 Optional<APInt> computeConstantDifference(const SCEV *LHS, const SCEV *RHS);
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;
1776 bool proveNoWrapByVaryingStart(const SCEV *Start, const SCEV *Step,
1776 bool proveNoWrapByVaryingStart(const SCEV *Start, const SCEV *Step,
1780 SCEV::NoWrapFlags proveNoWrapViaConstantRanges(const SCEVAddRecExpr *AR);
1788 SCEV::NoWrapFlags getNoWrapFlagsFromUB(const Value *V);
1824 Optional<std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
1829 const SCEV *computeBECount(const SCEV *Delta, const SCEV *Stride,
1829 const SCEV *computeBECount(const SCEV *Delta, const SCEV *Stride,
1829 const SCEV *computeBECount(const SCEV *Delta, const SCEV *Stride,
1838 const SCEV *computeMaxBECountForLT(const SCEV *Start, const SCEV *Stride,
1838 const SCEV *computeMaxBECountForLT(const SCEV *Start, 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,
1845 bool doesIVOverflowOnLT(const SCEV *RHS, const SCEV *Stride, bool IsSigned,
1851 bool doesIVOverflowOnGT(const SCEV *RHS, const SCEV *Stride, bool IsSigned,
1851 bool doesIVOverflowOnGT(const SCEV *RHS, const SCEV *Stride, bool IsSigned,
1855 const SCEV *getOrCreateAddExpr(ArrayRef<const SCEV *> Ops,
1855 const SCEV *getOrCreateAddExpr(ArrayRef<const SCEV *> Ops,
1856 SCEV::NoWrapFlags Flags);
1859 const SCEV *getOrCreateMulExpr(ArrayRef<const SCEV *> Ops,
1859 const SCEV *getOrCreateMulExpr(ArrayRef<const SCEV *> Ops,
1860 SCEV::NoWrapFlags Flags);
1863 const SCEV *getOrCreateAddRecExpr(ArrayRef<const SCEV *> Ops,
1863 const SCEV *getOrCreateAddRecExpr(ArrayRef<const SCEV *> Ops,
1864 const Loop *L, SCEV::NoWrapFlags Flags);
1867 const SCEV *stripInjectiveFunctions(const SCEV *Val) const;
1867 const SCEV *stripInjectiveFunctions(const SCEV *Val) const;
1872 void getUsedLoops(const SCEV *S, SmallPtrSetImpl<const Loop *> &LoopsUsed);
1876 void addToLoopUseLists(const SCEV *S);
1880 bool matchURem(const SCEV *Expr, const SCEV *&LHS, const SCEV *&RHS);
1880 bool matchURem(const SCEV *Expr, const SCEV *&LHS, const SCEV *&RHS);
1880 bool matchURem(const SCEV *Expr, const SCEV *&LHS, const SCEV *&RHS);
1889 std::tuple<const SCEV *, FoldingSetNodeID, void *>
1890 findExistingSCEVInCache(int SCEVType, ArrayRef<const SCEV *> Ops);
1892 FoldingSet<SCEV> UniqueSCEVs;
1898 DenseMap<const Loop *, SmallVector<const SCEV *, 4>> LoopUsers;
1903 std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
1977 const SCEV *getSCEV(Value *V);
1980 const SCEV *getBackedgeTakenCount();
2020 using RewriteEntry = std::pair<unsigned, const SCEV *>;
2027 DenseMap<const SCEV *, RewriteEntry> RewriteMap;
2049 const SCEV *BackedgeCount = nullptr;
include/llvm/Analysis/ScalarEvolutionAliasAnalysis.h 37 Value *GetBaseValue(const SCEV *S);
include/llvm/Analysis/ScalarEvolutionExpander.h 31 bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE);
36 bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint,
53 DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>>
61 DenseMap<const SCEV *, const Loop *> RelevantLoops;
180 bool isHighCostExpansion(const SCEV *Expr, Loop *L,
182 SmallPtrSet<const SCEV *, 8> Processed;
207 Value *expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I);
213 Value *expandCodeFor(const SCEV *SH, Type *Ty = nullptr);
303 Value *getExactExistingExpansion(const SCEV *S, const Instruction *At,
319 getRelatedExistingExpansion(const SCEV *S, const Instruction *At, Loop *L);
325 bool isHighCostExpansionHelper(const SCEV *S, Loop *L,
327 SmallPtrSetImpl<const SCEV *> &Processed);
333 SCEV::NoWrapFlags Flags, bool IsSafeToHoist);
348 Value *expandAddToGEP(const SCEV *const *op_begin,
349 const SCEV *const *op_end,
351 Value *expandAddToGEP(const SCEV *Op, PointerType *PTy, Type *Ty, Value *V);
355 FindValueInExprValueMap(const SCEV *S, const Instruction *InsertPt);
357 Value *expand(const SCEV *S);
360 const Loop *getRelevantLoop(const SCEV *);
include/llvm/Analysis/ScalarEvolutionExpressions.h 47 class SCEVConstant : public SCEV {
62 static bool classof(const SCEV *S) {
67 static unsigned short computeExpressionSize(ArrayRef<const SCEV *> Args) {
75 class SCEVCastExpr : public SCEV {
77 const SCEV *Op;
81 unsigned SCEVTy, const SCEV *op, Type *ty);
84 const SCEV *getOperand() const { return Op; }
88 static bool classof(const SCEV *S) {
101 const SCEV *op, Type *ty);
105 static bool classof(const SCEV *S) {
116 const SCEV *op, Type *ty);
120 static bool classof(const SCEV *S) {
131 const SCEV *op, Type *ty);
135 static bool classof(const SCEV *S) {
142 class SCEVNAryExpr : public SCEV {
148 const SCEV *const *Operands;
152 const SCEV *const *O, size_t N)
159 const SCEV *getOperand(unsigned i) const {
164 using op_iterator = const SCEV *const *;
192 static bool classof(const SCEV *S) {
204 enum SCEVTypes T, const SCEV *const *O, size_t N)
209 static bool classof(const SCEV *S) {
226 const SCEV *const *O, size_t N)
238 static bool classof(const SCEV *S) {
248 const SCEV *const *O, size_t N)
253 static bool classof(const SCEV *S) {
259 class SCEVUDivExpr : public SCEV {
262 const SCEV *LHS;
263 const SCEV *RHS;
265 SCEVUDivExpr(const FoldingSetNodeIDRef ID, const SCEV *lhs, const SCEV *rhs)
265 SCEVUDivExpr(const FoldingSetNodeIDRef ID, const SCEV *lhs, const SCEV *rhs)
270 const SCEV *getLHS() const { return LHS; }
271 const SCEV *getRHS() const { return RHS; }
283 static bool classof(const SCEV *S) {
302 const SCEV *const *O, size_t N, const Loop *l)
306 const SCEV *getStart() const { return Operands[0]; }
313 const SCEV *getStepRecurrence(ScalarEvolution &SE) const {
346 const SCEV *evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const;
346 const SCEV *evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const;
354 const SCEV *getNumIterationsInRange(const ConstantRange &Range,
362 static bool classof(const SCEV *S) {
379 const SCEV *const *O, size_t N)
387 static bool classof(const SCEV *S) {
411 SCEVSMaxExpr(const FoldingSetNodeIDRef ID, const SCEV *const *O, size_t N)
416 static bool classof(const SCEV *S) {
425 SCEVUMaxExpr(const FoldingSetNodeIDRef ID, const SCEV *const *O, size_t N)
430 static bool classof(const SCEV *S) {
439 SCEVSMinExpr(const FoldingSetNodeIDRef ID, const SCEV *const *O, size_t N)
444 static bool classof(const SCEV *S) {
453 SCEVUMinExpr(const FoldingSetNodeIDRef ID, const SCEV *const *O, size_t N)
458 static bool classof(const SCEV *S) {
466 class SCEVUnknown final : public SCEV, private CallbackVH {
504 static bool classof(const SCEV *S) {
513 RetVal visit(const SCEV *S) {
563 SmallVector<const SCEV *, 8> Worklist;
564 SmallPtrSet<const SCEV *, 8> Visited;
566 void push(const SCEV *S) {
574 void visitAll(const SCEV *Root) {
577 const SCEV *S = Worklist.pop_back_val();
595 for (const auto *Op : cast<SCEVNAryExpr>(S)->operands())
615 void visitAll(const SCEV *Root, SV& Visitor) {
622 bool SCEVExprContains(const SCEV *Root, PredTy Pred) {
629 bool follow(const SCEV *S) {
649 class SCEVRewriteVisitor : public SCEVVisitor<SC, const SCEV *> {
657 DenseMap<const SCEV *, const SCEV *> RewriteResults;
657 DenseMap<const SCEV *, const SCEV *> RewriteResults;
662 const SCEV *visit(const SCEV *S) {
662 const SCEV *visit(const SCEV *S) {
666 auto* Visited = SCEVVisitor<SC, const SCEV *>::visit(S);
672 const SCEV *visitConstant(const SCEVConstant *Constant) {
676 const SCEV *visitTruncateExpr(const SCEVTruncateExpr *Expr) {
677 const SCEV *Operand = ((SC*)this)->visit(Expr->getOperand());
683 const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
684 const SCEV *Operand = ((SC*)this)->visit(Expr->getOperand());
690 const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
691 const SCEV *Operand = ((SC*)this)->visit(Expr->getOperand());
697 const SCEV *visitAddExpr(const SCEVAddExpr *Expr) {
698 SmallVector<const SCEV *, 2> Operands;
707 const SCEV *visitMulExpr(const SCEVMulExpr *Expr) {
708 SmallVector<const SCEV *, 2> Operands;
717 const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) {
724 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
725 SmallVector<const SCEV *, 2> Operands;
736 const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) {
737 SmallVector<const SCEV *, 2> Operands;
746 const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) {
747 SmallVector<const SCEV *, 2> Operands;
756 const SCEV *visitSMinExpr(const SCEVSMinExpr *Expr) {
757 SmallVector<const SCEV *, 2> Operands;
766 const SCEV *visitUMinExpr(const SCEVUMinExpr *Expr) {
767 SmallVector<const SCEV *, 2> Operands;
776 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
780 const SCEV *visitCouldNotCompute(const SCEVCouldNotCompute *Expr) {
791 static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
791 static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
801 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
817 using LoopToScevMapT = DenseMap<const Loop *, const SCEV *>;
827 static const SCEV *rewrite(const SCEV *Scev, LoopToScevMapT &Map,
827 static const SCEV *rewrite(const SCEV *Scev, LoopToScevMapT &Map,
833 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
834 SmallVector<const SCEV *, 2> Operands;
835 for (const SCEV *Op : Expr->operands())
839 const SCEV *Res = SE.getAddRecExpr(Operands, L, Expr->getNoWrapFlags());
include/llvm/Analysis/ScalarEvolutionNormalization.h 54 const SCEV *normalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops,
54 const SCEV *normalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops,
59 const SCEV *normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred,
59 const SCEV *normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred,
64 const SCEV *denormalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops,
64 const SCEV *denormalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops,
include/llvm/Analysis/TargetTransformInfo.h 89 const SCEV *ExitCount = nullptr;
1014 const SCEV *Ptr = nullptr) const;
1337 const SCEV *Ptr) = 0;
1762 const SCEV *Ptr) override {
include/llvm/Analysis/TargetTransformInfoImpl.h 492 const SCEV *) {
661 bool isStridedAccess(const SCEV *Ptr) {
666 const SCEV *Ptr) {
673 bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr,
include/llvm/Analysis/VectorUtils.h 614 StrideDescriptor(int64_t Stride, const SCEV *Scev, uint64_t Size,
622 const SCEV *Scev = nullptr;
include/llvm/CodeGen/BasicTTIImpl.h 1556 const SCEV *) {
include/llvm/Support/Casting.h 34 using SimpleType = From; // The real type this represents...
37 static SimpleType &getSimplifiedValue(From &Val) { return Val; }
41 using NonConstSimpleType = typename simplify_type<From>::SimpleType;
47 static RetType getSimplifiedValue(const From& Val) {
57 static inline bool doit(const From &Val) {
76 static inline bool doit(const From &Val) {
77 return isa_impl<To, From>::doit(Val);
104 static inline bool doit(const From *Val) {
106 return isa_impl<To, From>::doit(*Val);
141 template <class X, class Y> LLVM_NODISCARD inline bool isa(const Y &Val) {
142 return isa_impl_wrap<X, const Y,
143 typename simplify_type<const Y>::SimpleType>::doit(Val);
263 inline typename cast_retty<X, Y *>::ret_type cast(Y *Val) {
263 inline typename cast_retty<X, Y *>::ret_type cast(Y *Val) {
265 return cast_convert_val<X, Y*,
266 typename simplify_type<Y*>::SimpleType>::doit(Val);
include/llvm/Support/PointerLikeTypeTraits.h 56 static inline void *getAsVoidPointer(T *P) { return P; }
57 static inline T *getFromVoidPointer(void *P) { return static_cast<T *>(P); }
59 enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
91 typedef PointerLikeTypeTraits<T *> NonConst;
93 static inline const void *getAsVoidPointer(const T *P) {
96 static inline const T *getFromVoidPointer(const void *P) {
include/llvm/Support/type_traits.h 55 struct add_const_past_pointer { using type = const T; };
include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h 38 bool extractAlignmentInfo(CallInst *I, Value *&AAPtr, const SCEV *&AlignSCEV,
39 const SCEV *&OffSCEV);
include/llvm/Transforms/Scalar/NaryReassociate.h 146 Instruction *tryReassociatedBinaryOp(const SCEV *LHS, Value *RHS,
153 const SCEV *getBinarySCEV(BinaryOperator *I, const SCEV *LHS,
153 const SCEV *getBinarySCEV(BinaryOperator *I, const SCEV *LHS,
154 const SCEV *RHS);
158 Instruction *findClosestMatchingDominator(const SCEV *CandidateExpr,
183 DenseMap<const SCEV *, SmallVector<WeakTrackingVH, 2>> SeenExprs;
include/llvm/Transforms/Utils/LoopUtils.h 344 bool isKnownNegativeInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE);
348 bool isKnownNonNegativeInLoop(const SCEV *S, const Loop *L,
352 bool cannotBeMaxInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE,
356 bool cannotBeMinInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE,
lib/Analysis/Delinearization.cpp 85 const SCEV *AccessFn = SE->getSCEVAtScope(getPointerOperand(Inst), L);
99 SmallVector<const SCEV *, 3> Subscripts, Sizes;
lib/Analysis/DependenceAnalysis.cpp 270 const SCEV *FullDependence::getDistance(unsigned Level) const {
313 const SCEV *DependenceInfo::Constraint::getX() const {
321 const SCEV *DependenceInfo::Constraint::getY() const {
329 const SCEV *DependenceInfo::Constraint::getA() const {
338 const SCEV *DependenceInfo::Constraint::getB() const {
347 const SCEV *DependenceInfo::Constraint::getC() const {
356 const SCEV *DependenceInfo::Constraint::getD() const {
369 void DependenceInfo::Constraint::setPoint(const SCEV *X, const SCEV *Y,
369 void DependenceInfo::Constraint::setPoint(const SCEV *X, const SCEV *Y,
377 void DependenceInfo::Constraint::setLine(const SCEV *AA, const SCEV *BB,
377 void DependenceInfo::Constraint::setLine(const SCEV *AA, const SCEV *BB,
378 const SCEV *CC, const Loop *CurLoop) {
386 void DependenceInfo::Constraint::setDistance(const SCEV *D,
478 const SCEV *Prod1 = SE->getMulExpr(X->getA(), Y->getB());
479 const SCEV *Prod2 = SE->getMulExpr(X->getB(), Y->getA());
497 const SCEV *C1B2 = SE->getMulExpr(X->getC(), Y->getB());
498 const SCEV *C1A2 = SE->getMulExpr(X->getC(), Y->getA());
499 const SCEV *C2B1 = SE->getMulExpr(Y->getC(), X->getB());
500 const SCEV *C2A1 = SE->getMulExpr(Y->getC(), X->getA());
501 const SCEV *A1B2 = SE->getMulExpr(X->getA(), Y->getB());
502 const SCEV *A2B1 = SE->getMulExpr(Y->getA(), X->getB());
563 const SCEV *A1X1 = SE->getMulExpr(Y->getA(), X->getX());
564 const SCEV *B1Y1 = SE->getMulExpr(Y->getB(), X->getY());
565 const SCEV *Sum = SE->getAddExpr(A1X1, B1Y1);
607 const SCEV *Distance = getDistance(II);
783 bool DependenceInfo::isLoopInvariant(const SCEV *Expression,
795 void DependenceInfo::collectCommonLoops(const SCEV *Expression,
814 const SCEV *Src = Pair->Src;
815 const SCEV *Dst = Pair->Dst;
839 const SCEV *Src = Pair->Src;
840 const SCEV *Dst = Pair->Dst;
864 const SCEV *Src = Pair->Src;
865 const SCEV *Dst = Pair->Dst;
870 const SCEV *SrcCastOp = SrcCast->getOperand();
871 const SCEV *DstCastOp = DstCast->getOperand();
882 bool DependenceInfo::checkSrcSubscript(const SCEV *Src, const Loop *LoopNest,
887 const SCEV *Start = AddRec->getStart();
888 const SCEV *Step = AddRec->getStepRecurrence(*SE);
889 const SCEV *UB = SE->getBackedgeTakenCount(AddRec->getLoop());
907 bool DependenceInfo::checkDstSubscript(const SCEV *Dst, const Loop *LoopNest,
912 const SCEV *Start = AddRec->getStart();
913 const SCEV *Step = AddRec->getStepRecurrence(*SE);
914 const SCEV *UB = SE->getBackedgeTakenCount(AddRec->getLoop());
933 DependenceInfo::classifyPair(const SCEV *Src, const Loop *SrcLoopNest,
934 const SCEV *Dst, const Loop *DstLoopNest,
967 bool DependenceInfo::isKnownPredicate(ICmpInst::Predicate Pred, const SCEV *X,
968 const SCEV *Y) const {
977 const SCEV *Xop = CX->getOperand();
978 const SCEV *Yop = CY->getOperand();
992 const SCEV *Delta = SE->getMinusSCEV(X, Y);
1014 bool DependenceInfo::isKnownLessThan(const SCEV *S, const SCEV *Size) const {
1014 bool DependenceInfo::isKnownLessThan(const SCEV *S, const SCEV *Size) const {
1026 const SCEV *Bound = SE->getMinusSCEV(S, Size);
1029 const SCEV *BECount = SE->getBackedgeTakenCount(AddRec->getLoop());
1031 const SCEV *Limit = AddRec->evaluateAtIteration(BECount, *SE);
1039 const SCEV *LimitedBound =
1044 bool DependenceInfo::isKnownNonNegative(const SCEV *S, const Value *Ptr) const {
1070 const SCEV *DependenceInfo::collectUpperBound(const Loop *L, Type *T) const {
1072 const SCEV *UB = SE->getBackedgeTakenCount(L);
1083 if (const SCEV *UB = collectUpperBound(L, T))
1099 bool DependenceInfo::testZIV(const SCEV *Src, const SCEV *Dst,
1099 bool DependenceInfo::testZIV(const SCEV *Src, const SCEV *Dst,
1146 bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
1146 bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
1147 const SCEV *DstConst, const Loop *CurLoop,
1161 const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst);
1166 if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) {
1169 const SCEV *AbsDelta =
1171 const SCEV *AbsCoeff =
1173 const SCEV *Product = SE->getMulExpr(UpperBound, AbsCoeff);
1283 const SCEV *Coeff, const SCEV *SrcConst, const SCEV *DstConst,
1283 const SCEV *Coeff, const SCEV *SrcConst, const SCEV *DstConst,
1283 const SCEV *Coeff, const SCEV *SrcConst, const SCEV *DstConst,
1285 Constraint &NewConstraint, const SCEV *&SplitIter) const {
1294 const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
1344 if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) {
1346 const SCEV *ConstantTwo = SE->getConstant(UpperBound->getType(), 2);
1347 const SCEV *ML = SE->getMulExpr(SE->getMulExpr(ConstCoeff, UpperBound),
1493 bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
1493 bool DependenceInfo::exactSIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
1494 const SCEV *SrcConst, const SCEV *DstConst,
1494 const SCEV *SrcConst, const SCEV *DstConst,
1507 const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
1702 bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
1703 const SCEV *SrcConst,
1704 const SCEV *DstConst,
1719 const SCEV *Delta = SE->getMinusSCEV(SrcConst, DstConst);
1734 const SCEV *AbsCoeff =
1737 const SCEV *NewDelta =
1742 if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) {
1744 const SCEV *Product = SE->getMulExpr(AbsCoeff, UpperBound);
1812 bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff,
1813 const SCEV *SrcConst,
1814 const SCEV *DstConst,
1828 const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
1843 const SCEV *AbsCoeff =
1846 const SCEV *NewDelta =
1851 if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) {
1853 const SCEV *Product = SE->getMulExpr(AbsCoeff, UpperBound);
1897 bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
1897 bool DependenceInfo::exactRDIVtest(const SCEV *SrcCoeff, const SCEV *DstCoeff,
1898 const SCEV *SrcConst, const SCEV *DstConst,
1898 const SCEV *SrcConst, const SCEV *DstConst,
1908 const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
2038 bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
2038 bool DependenceInfo::symbolicRDIVtest(const SCEV *A1, const SCEV *A2,
2039 const SCEV *C1, const SCEV *C2,
2039 const SCEV *C1, const SCEV *C2,
2049 const SCEV *N1 = collectUpperBound(Loop1, A1->getType());
2050 const SCEV *N2 = collectUpperBound(Loop2, A1->getType());
2053 const SCEV *C2_C1 = SE->getMinusSCEV(C2, C1);
2054 const SCEV *C1_C2 = SE->getMinusSCEV(C1, C2);
2062 const SCEV *A1N1 = SE->getMulExpr(A1, N1);
2071 const SCEV *A2N2 = SE->getMulExpr(A2, N2);
2083 const SCEV *A1N1 = SE->getMulExpr(A1, N1);
2084 const SCEV *A2N2 = SE->getMulExpr(A2, N2);
2085 const SCEV *A1N1_A2N2 = SE->getMinusSCEV(A1N1, A2N2);
2104 const SCEV *A1N1 = SE->getMulExpr(A1, N1);
2105 const SCEV *A2N2 = SE->getMulExpr(A2, N2);
2106 const SCEV *A1N1_A2N2 = SE->getMinusSCEV(A1N1, A2N2);
2123 const SCEV *A1N1 = SE->getMulExpr(A1, N1);
2132 const SCEV *A2N2 = SE->getMulExpr(A2, N2);
2153 bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level,
2153 bool DependenceInfo::testSIV(const SCEV *Src, const SCEV *Dst, unsigned &Level,
2155 const SCEV *&SplitIter) const {
2161 const SCEV *SrcConst = SrcAddRec->getStart();
2162 const SCEV *DstConst = DstAddRec->getStart();
2163 const SCEV *SrcCoeff = SrcAddRec->getStepRecurrence(*SE);
2164 const SCEV *DstCoeff = DstAddRec->getStepRecurrence(*SE);
2184 const SCEV *SrcConst = SrcAddRec->getStart();
2185 const SCEV *SrcCoeff = SrcAddRec->getStepRecurrence(*SE);
2186 const SCEV *DstConst = Dst;
2194 const SCEV *DstConst = DstAddRec->getStart();
2195 const SCEV *DstCoeff = DstAddRec->getStepRecurrence(*SE);
2196 const SCEV *SrcConst = Src;
2221 bool DependenceInfo::testRDIV(const SCEV *Src, const SCEV *Dst,
2221 bool DependenceInfo::testRDIV(const SCEV *Src, const SCEV *Dst,
2229 const SCEV *SrcConst, *DstConst;
2230 const SCEV *SrcCoeff, *DstCoeff;
2287 bool DependenceInfo::testMIV(const SCEV *Src, const SCEV *Dst,
2287 bool DependenceInfo::testMIV(const SCEV *Src, const SCEV *Dst,
2301 const SCEVConstant *getConstantPart(const SCEV *Expr) {
2329 bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
2329 bool DependenceInfo::gcdMIVtest(const SCEV *Src, const SCEV *Dst,
2340 const SCEV *Coefficients = Src;
2343 const SCEV *Coeff = AddRec->getStepRecurrence(*SE);
2353 const SCEV *SrcConst = Coefficients;
2362 const SCEV *Coeff = AddRec->getStepRecurrence(*SE);
2372 const SCEV *DstConst = Coefficients;
2375 const SCEV *Delta = SE->getMinusSCEV(DstConst, SrcConst);
2381 const SCEV *Operand = Sum->getOperand(Op);
2435 const SCEV *SrcCoeff = AddRec->getStepRecurrence(*SE);
2436 const SCEV *DstCoeff = SE->getMinusSCEV(SrcCoeff, SrcCoeff);
2437 const SCEV *Inner = Src;
2440 const SCEV *Coeff = AddRec->getStepRecurrence(*SE);
2457 const SCEV *Coeff = AddRec->getStepRecurrence(*SE);
2532 bool DependenceInfo::banerjeeMIVtest(const SCEV *Src, const SCEV *Dst,
2532 bool DependenceInfo::banerjeeMIVtest(const SCEV *Src, const SCEV *Dst,
2538 const SCEV *A0;
2541 const SCEV *B0;
2544 const SCEV *Delta = SE->getMinusSCEV(B0, A0);
2616 const SCEV *Delta) const {
2718 BoundInfo *Bound, const SCEV *Delta) const {
2720 if (const SCEV *LowerBound = getLowerBound(Bound))
2723 if (const SCEV *UpperBound = getUpperBound(Bound))
2789 const SCEV *Delta = SE->getMinusSCEV(A[K].Coeff, B[K].Coeff);
2790 const SCEV *NegativePart = getNegativePart(Delta);
2793 const SCEV *PositivePart = getPositivePart(Delta);
2800 const SCEV *Delta = SE->getMinusSCEV(A[K].Coeff, B[K].Coeff);
2801 const SCEV *NegativePart = getNegativePart(Delta);
2804 const SCEV *PositivePart = getPositivePart(Delta);
2829 const SCEV *Iter_1 = SE->getMinusSCEV(
2831 const SCEV *NegPart =
2835 const SCEV *PosPart =
2843 const SCEV *NegPart =
2847 const SCEV *PosPart =
2873 const SCEV *Iter_1 = SE->getMinusSCEV(
2875 const SCEV *NegPart =
2879 const SCEV *PosPart =
2887 const SCEV *NegPart = getNegativePart(SE->getMinusSCEV(A[K].Coeff, B[K].PosPart));
2890 const SCEV *PosPart = getPositivePart(SE->getMinusSCEV(A[K].Coeff, B[K].NegPart));
2898 const SCEV *DependenceInfo::getPositivePart(const SCEV *X) const {
2898 const SCEV *DependenceInfo::getPositivePart(const SCEV *X) const {
2904 const SCEV *DependenceInfo::getNegativePart(const SCEV *X) const {
2904 const SCEV *DependenceInfo::getNegativePart(const SCEV *X) const {
2913 DependenceInfo::collectCoeffInfo(const SCEV *Subscript, bool SrcFlag,
2914 const SCEV *&Constant) const {
2915 const SCEV *Zero = SE->getZero(Subscript->getType());
2958 const SCEV *DependenceInfo::getLowerBound(BoundInfo *Bound) const {
2959 const SCEV *Sum = Bound[1].Lower[Bound[1].Direction];
2974 const SCEV *DependenceInfo::getUpperBound(BoundInfo *Bound) const {
2975 const SCEV *Sum = Bound[1].Upper[Bound[1].Direction];
2995 const SCEV *DependenceInfo::findCoefficient(const SCEV *Expr,
2995 const SCEV *DependenceInfo::findCoefficient(const SCEV *Expr,
3011 const SCEV *DependenceInfo::zeroCoefficient(const SCEV *Expr,
3011 const SCEV *DependenceInfo::zeroCoefficient(const SCEV *Expr,
3030 const SCEV *DependenceInfo::addToCoefficient(const SCEV *Expr,
3030 const SCEV *DependenceInfo::addToCoefficient(const SCEV *Expr,
3032 const SCEV *Value) const {
3038 SCEV::FlagAnyWrap); // Worst case, with no info.
3040 const SCEV *Sum = SE->getAddExpr(AddRec->getStepRecurrence(*SE), Value);
3049 return SE->getAddRecExpr(AddRec, Value, TargetLoop, SCEV::FlagAnyWrap);
3067 bool DependenceInfo::propagate(const SCEV *&Src, const SCEV *&Dst,
3067 bool DependenceInfo::propagate(const SCEV *&Src, const SCEV *&Dst,
3091 bool DependenceInfo::propagateDistance(const SCEV *&Src, const SCEV *&Dst,
3091 bool DependenceInfo::propagateDistance(const SCEV *&Src, const SCEV *&Dst,
3096 const SCEV *A_K = findCoefficient(Src, CurLoop);
3099 const SCEV *DA_K = SE->getMulExpr(A_K, CurConstraint.getD());
3117 bool DependenceInfo::propagateLine(const SCEV *&Src, const SCEV *&Dst,
3117 bool DependenceInfo::propagateLine(const SCEV *&Src, const SCEV *&Dst,
3121 const SCEV *A = CurConstraint.getA();
3122 const SCEV *B = CurConstraint.getB();
3123 const SCEV *C = CurConstraint.getC();
3136 const SCEV *AP_K = findCoefficient(Dst, CurLoop);
3151 const SCEV *A_K = findCoefficient(Src, CurLoop);
3165 const SCEV *A_K = findCoefficient(Src, CurLoop);
3174 const SCEV *A_K = findCoefficient(Src, CurLoop);
3192 bool DependenceInfo::propagatePoint(const SCEV *&Src, const SCEV *&Dst,
3192 bool DependenceInfo::propagatePoint(const SCEV *&Src, const SCEV *&Dst,
3195 const SCEV *A_K = findCoefficient(Src, CurLoop);
3196 const SCEV *AP_K = findCoefficient(Dst, CurLoop);
3197 const SCEV *XA_K = SE->getMulExpr(A_K, CurConstraint.getX());
3198 const SCEV *YAP_K = SE->getMulExpr(AP_K, CurConstraint.getY());
3275 const SCEV *SrcAccessFn =
3277 const SCEV *DstAccessFn =
3288 const SCEV *ElementSize = SE->getElementSize(Src);
3292 const SCEV *SrcSCEV = SE->getMinusSCEV(SrcAccessFn, SrcBase);
3293 const SCEV *DstSCEV = SE->getMinusSCEV(DstAccessFn, DstBase);
3301 SmallVector<const SCEV *, 4> Terms;
3306 SmallVector<const SCEV *, 4> Sizes;
3310 SmallVector<const SCEV *, 4> SrcSubscripts, DstSubscripts;
3452 const SCEV *SrcSCEV = SE->getSCEV(SrcPtr);
3453 const SCEV *DstSCEV = SE->getSCEV(DstPtr);
3607 const SCEV *SplitIter = nullptr;
3658 const SCEV *SplitIter = nullptr;
3832 const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
3855 const SCEV *SrcSCEV = SE->getSCEV(SrcPtr);
3856 const SCEV *DstSCEV = SE->getSCEV(DstPtr);
3928 const SCEV *SplitIter = nullptr;
3967 const SCEV *SplitIter = nullptr;
lib/Analysis/IVDescriptors.cpp 777 const SCEV *Step, BinaryOperator *BOp,
875 const SCEV *Step = SE->getUnknown(Addend);
1001 const SCEV *PhiScev = PSE.getSCEV(Phi);
1031 InductionDescriptor &D, const SCEV *Expr,
1039 const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi);
1064 const SCEV *Step = AR->getStepRecurrence(*SE);
lib/Analysis/IVUsers.cpp 59 static bool isInteresting(const SCEV *S, const Instruction *I, const Loop *L,
79 for (const auto *Op : Add->operands())
198 const SCEV *ISE = SE->getSCEV(I);
253 const SCEV *OriginalISE = ISE;
270 const SCEV *DenormalizedISE =
384 const SCEV *IVUsers::getReplacementExpr(const IVStrideUse &IU) const {
389 const SCEV *IVUsers::getExpr(const IVStrideUse &IU) const {
394 static const SCEVAddRecExpr *findAddRecForLoop(const SCEV *S, const Loop *L) {
402 for (const auto *Op : Add->operands())
411 const SCEV *IVUsers::getStride(const IVStrideUse &IU, const Loop *L) const {
lib/Analysis/LoopAccessAnalysis.cpp 144 const SCEV *llvm::replaceSymbolicStrideSCEV(PredicatedScalarEvolution &PSE,
147 const SCEV *OrigSCEV = PSE.getSCEV(Ptr);
194 const SCEV *Sc = replaceSymbolicStrideSCEV(PSE, Strides, Ptr);
197 const SCEV *ScStart;
198 const SCEV *ScEnd;
205 const SCEV *Ex = PSE.getBackedgeTakenCount();
209 const SCEV *Step = AR->getStepRecurrence(*SE);
226 const SCEV *EltSizeSCEV = SE->getConstant(ScEnd->getType(), EltSize);
267 static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J,
267 static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J,
267 static const SCEV *getMinFromExprs(const SCEV *I, const SCEV *J,
269 const SCEV *Diff = SE->getMinusSCEV(J, I);
280 const SCEV *Start = RtCheck.Pointers[Index].Start;
281 const SCEV *End = RtCheck.Pointers[Index].End;
286 const SCEV *Min0 = getMinFromExprs(Start, Low, RtCheck.SE);
290 const SCEV *Min1 = getMinFromExprs(End, High, RtCheck.SE);
622 const SCEV *PtrScev = replaceSymbolicStrideSCEV(PSE, Strides, Ptr);
642 const SCEV *PtrScev = PSE.getSCEV(Ptr);
946 if (AR->getNoWrapFlags(SCEV::NoWrapMask))
983 return OpAR->getLoop() == L && OpAR->getNoWrapFlags(SCEV::FlagNSW);
1004 const SCEV *PtrScev = replaceSymbolicStrideSCEV(PSE, StridesMap, Ptr);
1053 const SCEV *Step = AR->getStepRecurrence(*PSE.getSE());
1112 const SCEV *Scev0 = SE.getSCEV(Ptr0);
1128 const SCEV *Scev = SE.getSCEV(Ptr);
1212 const SCEV *OffsetSCEVA = SE.getConstant(OffsetA);
1213 const SCEV *OffsetSCEVB = SE.getConstant(OffsetB);
1214 const SCEV *OffsetDeltaSCEV = SE.getMinusSCEV(OffsetSCEVB, OffsetSCEVA);
1225 const SCEV *SizeSCEV = SE.getConstant(Size);
1226 const SCEV *BaseDelta = SE.getMinusSCEV(SizeSCEV, OffsetDeltaSCEV);
1229 const SCEV *PtrSCEVA = SE.getSCEV(PtrA);
1230 const SCEV *PtrSCEVB = SE.getSCEV(PtrB);
1231 const SCEV *X = SE.getAddExpr(PtrSCEVA, BaseDelta);
1351 const SCEV &BackedgeTakenCount,
1352 const SCEV &Dist, uint64_t Stride,
1373 const SCEV *Step = SE.getConstant(BackedgeTakenCount.getType(), ByteStride);
1374 const SCEV *Product = SE.getMulExpr(&BackedgeTakenCount, Step);
1376 const SCEV *CastedDist = &Dist;
1377 const SCEV *CastedProduct = Product;
1391 const SCEV *Minus = SE.getMinusSCEV(CastedDist, CastedProduct);
1397 const SCEV *NegDist = SE.getNegativeSCEV(CastedDist);
1464 const SCEV *Src = PSE.getSCEV(APtr);
1465 const SCEV *Sink = PSE.getSCEV(BPtr);
1477 const SCEV *Dist = PSE.getSE()->getMinusSCEV(Sink, Src);
1778 const SCEV *ExitCount = PSE->getBackedgeTakenCount();
2149 const SCEV *Sc = SE->getSCEV(Ptr);
2167 const SCEV *ScPlusOne = SE->getAddExpr(Sc, SE->getOne(PtrArithTy));
2311 const SCEV *StrideExpr = PSE->getSCEV(Stride);
2312 const SCEV *BETakenCount = PSE->getBackedgeTakenCount();
2320 const SCEV *CastedStride = StrideExpr;
2321 const SCEV *CastedBECount = BETakenCount;
2327 const SCEV *StrideMinusBETaken = SE->getMinusSCEV(CastedStride, CastedBECount);
lib/Analysis/LoopCacheAnalysis.cpp 74 static bool isOneDimensionalArray(const SCEV &AccessFn, const SCEV &ElemSize,
74 static bool isOneDimensionalArray(const SCEV &AccessFn, const SCEV &ElemSize,
83 const SCEV *Start = AR->getStart();
84 const SCEV *Step = AR->getStepRecurrence(SE);
97 static const SCEV *computeTripCount(const Loop &L, ScalarEvolution &SE) {
98 const SCEV *BackedgeTakenCount = SE.getBackedgeTakenCount(&L);
118 for (const SCEV *Subscript : R.Subscripts)
122 for (const SCEV *Size : R.Sizes)
170 const SCEV *LastSubscript = getLastSubscript();
171 const SCEV *OtherLastSubscript = Other.getLastSubscript();
227 const SCEV *Distance = D->getDistance(Level);
268 const SCEV *TripCount = computeTripCount(L, SE);
272 const SCEV *ElemSize = Sizes.back();
279 const SCEV *RefCost = TripCount;
282 const SCEV *Coeff = getLastCoefficient();
283 const SCEV *ElemSize = Sizes.back();
284 const SCEV *Stride = SE.getMulExpr(Coeff, ElemSize);
285 const SCEV *CacheLineSize = SE.getConstant(Stride->getType(), CLS);
286 const SCEV *Numerator = SE.getMulExpr(Stride, TripCount);
313 const SCEV *ElemSize = SE.getElementSize(&StoreOrLoadInst);
317 const SCEV *AccessFn =
348 const SCEV *Div = SE.getUDivExactExpr(AccessFn, ElemSize);
381 const SCEV *LastSubscript = Subscripts.back();
382 for (const SCEV *Subscript : Subscripts) {
390 const SCEV *Coeff = getLastCoefficient();
391 const SCEV *ElemSize = Sizes.back();
392 const SCEV *Stride = SE.getMulExpr(Coeff, ElemSize);
393 const SCEV *CacheLineSize = SE.getConstant(Stride->getType(), CLS);
398 const SCEV *IndexedReference::getLastCoefficient() const {
399 const SCEV *LastSubscript = getLastSubscript();
406 bool IndexedReference::isCoeffForLoopZeroOrInvariant(const SCEV &Subscript,
413 bool IndexedReference::isSimpleAddRecurrence(const SCEV &Subscript,
424 const SCEV *Start = AR->getStart();
425 const SCEV *Step = AR->getStepRecurrence(SE);
lib/Analysis/LoopInfo.cpp 209 const SCEV *Step = IndDesc.getStep();
273 if (const SCEV *StepRecur = StepAddRecExpr->getStepRecurrence(SE)) {
lib/Analysis/LoopUnrollAnalyzer.cpp 31 const SCEV *S = SE.getSCEV(I);
41 const SCEV *ValueAtIteration = AR->evaluateAtIteration(IterationNumber, SE);
lib/Analysis/ScalarEvolution.cpp 245 const SCEV *Op = Trunc->getOperand();
252 const SCEV *Op = ZExt->getOperand();
259 const SCEV *Op = SExt->getOperand();
416 bool SCEVCouldNotCompute::classof(const SCEV *S) {
420 const SCEV *ScalarEvolution::getConstant(ConstantInt *V) {
425 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
426 SCEV *S = new (SCEVAllocator) SCEVConstant(ID.Intern(SCEVAllocator), V);
431 const SCEV *ScalarEvolution::getConstant(const APInt &Val) {
435 const SCEV *
442 unsigned SCEVTy, const SCEV *op, Type *ty)
446 const SCEV *op, Type *ty)
453 const SCEV *op, Type *ty)
460 const SCEV *op, Type *ty)
652 EquivalenceClasses<const SCEV *> &EqCacheSCEV,
654 const LoopInfo *const LI, const SCEV *LHS, const SCEV *RHS,
654 const LoopInfo *const LI, const SCEV *LHS, const SCEV *RHS,
802 static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops,
806 EquivalenceClasses<const SCEV *> EqCacheSCEV;
811 const SCEV *&LHS = Ops[0], *&RHS = Ops[1];
828 const SCEV *S = Ops[i];
845 static inline int sizeOfSCEV(const SCEV *S) {
851 bool follow(const SCEV *S) {
870 static bool isHugeExpression(const SCEV *S) {
875 static bool hasHugeExpression(ArrayRef<const SCEV *> Ops) {
885 static void divide(ScalarEvolution &SE, const SCEV *Numerator,
886 const SCEV *Denominator, const SCEV **Quotient,
886 const SCEV *Denominator, const SCEV **Quotient,
887 const SCEV **Remainder) {
915 const SCEV *Q, *R;
917 for (const SCEV *Op : T->operands()) {
973 const SCEV *StartQ, *StartR, *StepQ, *StepR;
990 SmallVector<const SCEV *, 2> Qs, Rs;
993 for (const SCEV *Op : Numerator->operands()) {
994 const SCEV *Q, *R;
1016 SmallVector<const SCEV *, 2> Qs;
1020 for (const SCEV *Op : Numerator->operands()) {
1031 const SCEV *Q, *R;
1074 const SCEV *Q, *R;
1075 const SCEV *Diff = SE.getMinusSCEV(Numerator, Remainder);
1086 SCEVDivision(ScalarEvolution &S, const SCEV *Numerator,
1087 const SCEV *Denominator)
1100 void cannotDivide(const SCEV *Numerator) {
1106 const SCEV *Denominator, *Quotient, *Remainder, *Zero, *One;
1116 static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,
1116 static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,
1210 const SCEV *Dividend = SE.getTruncateOrZeroExtend(It, CalculationTy);
1212 const SCEV *S = SE.getMinusSCEV(It, SE.getConstant(It->getType(), i));
1218 const SCEV *DivResult = SE.getUDivExpr(Dividend, SE.getConstant(DivFactor));
1234 const SCEV *SCEVAddRecExpr::evaluateAtIteration(const SCEV *It,
1234 const SCEV *SCEVAddRecExpr::evaluateAtIteration(const SCEV *It,
1236 const SCEV *Result = getStart();
1241 const SCEV *Coeff = BinomialCoefficient(It, i, SE, getType());
1254 const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op, Type *Ty,
1254 const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op, Type *Ty,
1267 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
1287 SCEV *S =
1300 SmallVector<const SCEV *, 4> Operands;
1304 const SCEV *S = getTruncateExpr(CommOp->getOperand(i), Ty, Depth + 1);
1320 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP))
1326 SmallVector<const SCEV *, 4> Operands;
1327 for (const SCEV *Op : AddRec->operands())
1329 return getAddRecExpr(Operands, AddRec->getLoop(), SCEV::FlagAnyWrap);
1335 SCEV *S = new (SCEVAllocator) SCEVTruncateExpr(ID.Intern(SCEVAllocator),
1345 static const SCEV *getSignedOverflowLimitForStep(const SCEV *Step,
1345 static const SCEV *getSignedOverflowLimitForStep(const SCEV *Step,
1365 static const SCEV *getUnsignedOverflowLimitForStep(const SCEV *Step,
1365 static const SCEV *getUnsignedOverflowLimitForStep(const SCEV *Step,
1397 static const SCEV::NoWrapFlags WrapType = SCEV::FlagNSW;
1397 static const SCEV::NoWrapFlags WrapType = SCEV::FlagNSW;
1401 static const SCEV *getOverflowLimitForStep(const SCEV *Step,
1401 static const SCEV *getOverflowLimitForStep(const SCEV *Step,
1413 static const SCEV::NoWrapFlags WrapType = SCEV::FlagNUW;
1413 static const SCEV::NoWrapFlags WrapType = SCEV::FlagNUW;
1417 static const SCEV *getOverflowLimitForStep(const SCEV *Step,
1417 static const SCEV *getOverflowLimitForStep(const SCEV *Step,
1437 static const SCEV *getPreStartForExtend(const SCEVAddRecExpr *AR, Type *Ty,
1443 const SCEV *Start = AR->getStart();
1444 const SCEV *Step = AR->getStepRecurrence(*SE);
1454 SmallVector<const SCEV *, 4> DiffOps;
1455 for (const SCEV *Op : SA->operands())
1467 ScalarEvolution::maskFlags(SA->getNoWrapFlags(), SCEV::FlagNUW);
1468 const SCEV *PreStart = SE->getAddExpr(DiffOps, PreStartFlags);
1470 SE->getAddRecExpr(PreStart, Step, L, SCEV::FlagAnyWrap));
1476 const SCEV *BECount = SE->getBackedgeTakenCount(L);
1484 const SCEV *OperandExtendedStart =
1499 const SCEV *OverflowLimit =
1511 static const SCEV *getExtendAddRecStart(const SCEVAddRecExpr *AR, Type *Ty,
1516 const SCEV *PreStart = getPreStartForExtend<ExtendOpTy>(AR, Ty, SE, Depth);
1558 bool ScalarEvolution::proveNoWrapByVaryingStart(const SCEV *Start,
1559 const SCEV *Step,
1574 const SCEV *PreStart = getConstant(StartAI - Delta);
1588 const SCEV *DeltaS = getConstant(StartC->getType(), Delta);
1590 const SCEV *Limit = ExtendOpTraits<ExtendOpTy>::getOverflowLimitForStep(
1628 const SCEV *Step) {
1637 const SCEV *
1638 ScalarEvolution::getZeroExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth) {
1661 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
1663 SCEV *S = new (SCEVAllocator) SCEVZeroExtendExpr(ID.Intern(SCEVAllocator),
1674 const SCEV *X = ST->getOperand();
1689 const SCEV *Start = AR->getStart();
1690 const SCEV *Step = AR->getStepRecurrence(*this);
1714 const SCEV *MaxBECount = getConstantMaxBackedgeTakenCount(L);
1721 const SCEV *CastedMaxBECount =
1723 const SCEV *RecastedMaxBECount = getTruncateOrZeroExtend(
1728 const SCEV *ZMul = getMulExpr(CastedMaxBECount, Step,
1729 SCEV::FlagAnyWrap, Depth + 1);
1730 const SCEV *ZAdd = getZeroExtendExpr(getAddExpr(Start, ZMul,
1731 SCEV::FlagAnyWrap,
1734 const SCEV *WideStart = getZeroExtendExpr(Start, WideTy, Depth + 1);
1735 const SCEV *WideMaxBECount =
1737 const SCEV *OperandExtendedAdd =
1741 SCEV::FlagAnyWrap, Depth + 1),
1742 SCEV::FlagAnyWrap, Depth + 1);
1745 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNUW);
1759 SCEV::FlagAnyWrap, Depth + 1),
1760 SCEV::FlagAnyWrap, Depth + 1);
1764 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNW);
1790 const SCEV *N = getConstant(APInt::getMinValue(BitWidth) -
1796 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNUW);
1805 const SCEV *N = getConstant(APInt::getMaxValue(BitWidth) -
1812 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNW);
1830 const SCEV *SZExtD = getZeroExtendExpr(getConstant(D), Ty, Depth);
1831 const SCEV *SResidual =
1833 const SCEV *SZExtR = getZeroExtendExpr(SResidual, Ty, Depth + 1);
1835 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
1835 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
1841 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNUW);
1850 const SCEV *LHS;
1851 const SCEV *RHS;
1867 SmallVector<const SCEV *, 4> Ops;
1868 for (const auto *Op : SA->operands())
1870 return getAddExpr(Ops, SCEV::FlagNUW, Depth + 1);
1884 const SCEV *SZExtD = getZeroExtendExpr(getConstant(D), Ty, Depth);
1885 const SCEV *SResidual =
1886 getAddExpr(getConstant(-D), SA, SCEV::FlagAnyWrap, Depth);
1887 const SCEV *SZExtR = getZeroExtendExpr(SResidual, Ty, Depth + 1);
1889 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
1889 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
1900 SmallVector<const SCEV *, 4> Ops;
1901 for (const auto *Op : SM->operands())
1903 return getMulExpr(Ops, SCEV::FlagNUW, Depth + 1);
1929 SCEV::FlagNUW, Depth + 1);
1935 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
1936 SCEV *S = new (SCEVAllocator) SCEVZeroExtendExpr(ID.Intern(SCEVAllocator),
1943 const SCEV *
1944 ScalarEvolution::getSignExtendExpr(const SCEV *Op, Type *Ty, unsigned Depth) {
1971 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
1974 SCEV *S = new (SCEVAllocator) SCEVSignExtendExpr(ID.Intern(SCEVAllocator),
1985 const SCEV *X = ST->getOperand();
1999 SmallVector<const SCEV *, 4> Ops;
2000 for (const auto *Op : SA->operands())
2002 return getAddExpr(Ops, SCEV::FlagNSW, Depth + 1);
2017 const SCEV *SSExtD = getSignExtendExpr(getConstant(D), Ty, Depth);
2018 const SCEV *SResidual =
2019 getAddExpr(getConstant(-D), SA, SCEV::FlagAnyWrap, Depth);
2020 const SCEV *SSExtR = getSignExtendExpr(SResidual, Ty, Depth + 1);
2022 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
2022 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
2033 const SCEV *Start = AR->getStart();
2034 const SCEV *Step = AR->getStepRecurrence(*this);
2048 getSignExtendExpr(Step, Ty, Depth + 1), L, SCEV::FlagNSW);
2058 const SCEV *MaxBECount = getConstantMaxBackedgeTakenCount(L);
2065 const SCEV *CastedMaxBECount =
2067 const SCEV *RecastedMaxBECount = getTruncateOrZeroExtend(
2072 const SCEV *SMul = getMulExpr(CastedMaxBECount, Step,
2073 SCEV::FlagAnyWrap, Depth + 1);
2074 const SCEV *SAdd = getSignExtendExpr(getAddExpr(Start, SMul,
2075 SCEV::FlagAnyWrap,
2078 const SCEV *WideStart = getSignExtendExpr(Start, WideTy, Depth + 1);
2079 const SCEV *WideMaxBECount =
2081 const SCEV *OperandExtendedAdd =
2085 SCEV::FlagAnyWrap, Depth + 1),
2086 SCEV::FlagAnyWrap, Depth + 1);
2089 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNSW);
2103 SCEV::FlagAnyWrap, Depth + 1),
2104 SCEV::FlagAnyWrap, Depth + 1);
2114 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNW);
2142 const SCEV *OverflowLimit =
2148 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNSW);
2162 const SCEV *SSExtD = getSignExtendExpr(getConstant(D), Ty, Depth);
2163 const SCEV *SResidual =
2165 const SCEV *SSExtR = getSignExtendExpr(SResidual, Ty, Depth + 1);
2167 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
2167 (SCEV::NoWrapFlags)(SCEV::FlagNSW | SCEV::FlagNUW),
2173 const_cast<SCEVAddRecExpr *>(AR)->setNoWrapFlags(SCEV::FlagNSW);
2187 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
2188 SCEV *S = new (SCEVAllocator) SCEVSignExtendExpr(ID.Intern(SCEVAllocator),
2197 const SCEV *ScalarEvolution::getAnyExtendExpr(const SCEV *Op,
2197 const SCEV *ScalarEvolution::getAnyExtendExpr(const SCEV *Op,
2212 const SCEV *NewOp = T->getOperand();
2219 const SCEV *ZExt = getZeroExtendExpr(Op, Ty);
2224 const SCEV *SExt = getSignExtendExpr(Op, Ty);
2230 SmallVector<const SCEV *, 4> Ops;
2231 for (const SCEV *Op : AR->operands())
2233 return getAddRecExpr(Ops, AR->getLoop(), SCEV::FlagNW);
2268 CollectAddOperandsWithScales(DenseMap<const SCEV *, APInt> &M,
2269 SmallVectorImpl<const SCEV *> &NewOps,
2271 const SCEV *const *Ops, size_t NumOperands,
2303 SmallVector<const SCEV *, 4> MulOps(Mul->op_begin()+1, Mul->op_end());
2304 const SCEV *Key = SE.getMulExpr(MulOps);
2317 std::pair<DenseMap<const SCEV *, APInt>::iterator, bool> Pair =
2336 static SCEV::NoWrapFlags
2338 const ArrayRef<const SCEV *> Ops,
2339 SCEV::NoWrapFlags Flags) {
2349 int SignOrUnsignMask = SCEV::FlagNUW | SCEV::FlagNSW;
2349 int SignOrUnsignMask = SCEV::FlagNUW | SCEV::FlagNSW;
2350 SCEV::NoWrapFlags SignOrUnsignWrap =
2358 if (SignOrUnsignWrap == SCEV::FlagNSW && all_of(Ops, IsKnownNonNegative))
2382 if (!(SignOrUnsignWrap & SCEV::FlagNSW)) {
2386 Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNSW);
2390 if (!(SignOrUnsignWrap & SCEV::FlagNUW)) {
2394 Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNUW);
2401 bool ScalarEvolution::isAvailableAtLoopEntry(const SCEV *S, const Loop *L) {
2406 const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
2406 const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops,
2407 SCEV::NoWrapFlags Flags,
2463 const SCEV *Scale = getConstant(Ty, Count);
2464 const SCEV *Mul = getMulExpr(Scale, Ops[i], SCEV::FlagAnyWrap, Depth + 1);
2464 const SCEV *Mul = getMulExpr(Scale, Ops[i], SCEV::FlagAnyWrap, Depth + 1);
2487 const auto *LastOp = Mul->getOperand(Mul->getNumOperands() - 1);
2494 SmallVector<const SCEV *, 8> LargeOps;
2508 SmallVector<const SCEV *, 8> LargeMulOps;
2525 LargeOps.push_back(getMulExpr(LargeMulOps, SCEV::FlagAnyWrap, Depth + 1));
2533 const SCEV *Fold = getAddExpr(LargeOps, SCEV::FlagAnyWrap, Depth + 1);
2533 const SCEV *Fold = getAddExpr(LargeOps, SCEV::FlagAnyWrap, Depth + 1);
2562 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2573 DenseMap<const SCEV *, APInt> M;
2574 SmallVector<const SCEV *, 8> NewOps;
2588 std::map<APInt, SmallVector<const SCEV *, 4>, APIntCompare> MulOpLists;
2589 for (const SCEV *NewOp : NewOps)
2599 getAddExpr(MulOp.second, SCEV::FlagAnyWrap, Depth + 1),
2600 SCEV::FlagAnyWrap, Depth + 1));
2605 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2615 const SCEV *MulOpSCEV = Mul->getOperand(MulOp);
2621 const SCEV *InnerMul = Mul->getOperand(MulOp == 0);
2625 SmallVector<const SCEV *, 4> MulOps(Mul->op_begin(),
2628 InnerMul = getMulExpr(MulOps, SCEV::FlagAnyWrap, Depth + 1);
2630 SmallVector<const SCEV *, 2> TwoOps = {getOne(Ty), InnerMul};
2631 const SCEV *AddOne = getAddExpr(TwoOps, SCEV::FlagAnyWrap, Depth + 1);
2631 const SCEV *AddOne = getAddExpr(TwoOps, SCEV::FlagAnyWrap, Depth + 1);
2632 const SCEV *OuterMul = getMulExpr(AddOne, MulOpSCEV,
2633 SCEV::FlagAnyWrap, Depth + 1);
2643 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2657 const SCEV *InnerMul1 = Mul->getOperand(MulOp == 0);
2659 SmallVector<const SCEV *, 4> MulOps(Mul->op_begin(),
2662 InnerMul1 = getMulExpr(MulOps, SCEV::FlagAnyWrap, Depth + 1);
2664 const SCEV *InnerMul2 = OtherMul->getOperand(OMulOp == 0);
2666 SmallVector<const SCEV *, 4> MulOps(OtherMul->op_begin(),
2669 InnerMul2 = getMulExpr(MulOps, SCEV::FlagAnyWrap, Depth + 1);
2671 SmallVector<const SCEV *, 2> TwoOps = {InnerMul1, InnerMul2};
2672 const SCEV *InnerMulSum =
2673 getAddExpr(TwoOps, SCEV::FlagAnyWrap, Depth + 1);
2674 const SCEV *OuterMul = getMulExpr(MulOpSCEV, InnerMulSum,
2675 SCEV::FlagAnyWrap, Depth + 1);
2680 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2696 SmallVector<const SCEV *, 8> LIOps;
2711 SmallVector<const SCEV *, 4> AddRecOps(AddRec->op_begin(),
2721 Flags = AddRec->getNoWrapFlags(setFlags(Flags, SCEV::FlagNW));
2722 const SCEV *NewRec = getAddRecExpr(AddRecOps, AddRecLoop, Flags);
2733 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2750 SmallVector<const SCEV *, 4> AddRecOps(AddRec->op_begin(),
2763 SmallVector<const SCEV *, 2> TwoOps = {
2765 AddRecOps[i] = getAddExpr(TwoOps, SCEV::FlagAnyWrap, Depth + 1);
2771 Ops[Idx] = getAddRecExpr(AddRecOps, AddRecLoop, SCEV::FlagAnyWrap);
2772 return getAddExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
2785 const SCEV *
2786 ScalarEvolution::getOrCreateAddExpr(ArrayRef<const SCEV *> Ops,
2787 SCEV::NoWrapFlags Flags) {
2790 for (const SCEV *Op : Ops)
2796 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2796 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2807 const SCEV *
2808 ScalarEvolution::getOrCreateAddRecExpr(ArrayRef<const SCEV *> Ops,
2809 const Loop *L, SCEV::NoWrapFlags Flags) {
2819 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2819 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2830 const SCEV *
2831 ScalarEvolution::getOrCreateMulExpr(ArrayRef<const SCEV *> Ops,
2832 SCEV::NoWrapFlags Flags) {
2841 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2841 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
2886 static bool containsConstantInAddMulChain(const SCEV *StartExpr) {
2890 bool follow(const SCEV *S) {
2907 const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
2907 const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops,
2908 SCEV::NoWrapFlags Flags,
2945 SCEV::FlagAnyWrap, Depth + 1),
2947 SCEV::FlagAnyWrap, Depth + 1),
2948 SCEV::FlagAnyWrap, Depth + 1);
2973 SmallVector<const SCEV *, 4> NewOps;
2975 for (const SCEV *AddOp : Add->operands()) {
2976 const SCEV *Mul = getMulExpr(Ops[0], AddOp, SCEV::FlagAnyWrap,
2976 const SCEV *Mul = getMulExpr(Ops[0], AddOp, SCEV::FlagAnyWrap,
2982 return getAddExpr(NewOps, SCEV::FlagAnyWrap, Depth + 1);
2985 SmallVector<const SCEV *, 4> Operands;
2986 for (const SCEV *AddRecOp : AddRec->operands())
2987 Operands.push_back(getMulExpr(Ops[0], AddRecOp, SCEV::FlagAnyWrap,
2991 AddRec->getNoWrapFlags(SCEV::FlagNW));
3021 return getMulExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
3034 SmallVector<const SCEV *, 8> LIOps;
3047 SmallVector<const SCEV *, 4> NewOps;
3049 const SCEV *Scale = getMulExpr(LIOps, SCEV::FlagAnyWrap, Depth + 1);
3049 const SCEV *Scale = getMulExpr(LIOps, SCEV::FlagAnyWrap, Depth + 1);
3052 SCEV::FlagAnyWrap, Depth + 1));
3059 Flags = AddRec->getNoWrapFlags(clearFlags(Flags, SCEV::FlagNW));
3060 const SCEV *NewRec = getAddRecExpr(NewOps, AddRecLoop, Flags);
3071 return getMulExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
3107 SmallVector<const SCEV*, 7> AddRecOps;
3110 SmallVector <const SCEV *, 7> SumOps;
3122 const SCEV *CoeffTerm = getConstant(Ty, Coeff);
3123 const SCEV *Term1 = AddRec->getOperand(y-z);
3124 const SCEV *Term2 = OtherAddRec->getOperand(z);
3126 SCEV::FlagAnyWrap, Depth + 1));
3131 AddRecOps.push_back(getAddExpr(SumOps, SCEV::FlagAnyWrap, Depth + 1));
3134 const SCEV *NewAddRec = getAddRecExpr(AddRecOps, AddRecLoop,
3135 SCEV::FlagAnyWrap);
3146 return getMulExpr(Ops, SCEV::FlagAnyWrap, Depth + 1);
3158 const SCEV *ScalarEvolution::getURemExpr(const SCEV *LHS,
3158 const SCEV *ScalarEvolution::getURemExpr(const SCEV *LHS,
3159 const SCEV *RHS) {
3180 const SCEV *UDiv = getUDivExpr(LHS, RHS);
3181 const SCEV *Mult = getMulExpr(UDiv, RHS, SCEV::FlagNUW);
3181 const SCEV *Mult = getMulExpr(UDiv, RHS, SCEV::FlagNUW);
3182 return getMinusSCEV(LHS, Mult, SCEV::FlagNUW);
3187 const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
3187 const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
3188 const SCEV *RHS) {
3222 AR->getLoop(), SCEV::FlagAnyWrap)) {
3223 SmallVector<const SCEV *, 4> Operands;
3224 for (const SCEV *Op : AR->operands())
3226 return getAddRecExpr(Operands, AR->getLoop(), SCEV::FlagNW);
3236 AR->getLoop(), SCEV::FlagAnyWrap)) {
3241 AR->getLoop(), SCEV::FlagNW);
3246 SmallVector<const SCEV *, 4> Operands;
3247 for (const SCEV *Op : M->operands())
3252 const SCEV *Op = M->getOperand(i);
3253 const SCEV *Div = getUDivExpr(Op, RHSC);
3279 SmallVector<const SCEV *, 4> Operands;
3280 for (const SCEV *Op : A->operands())
3285 const SCEV *Op = getUDivExpr(A->getOperand(i), RHS);
3311 if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
3312 SCEV *S = new (SCEVAllocator) SCEVUDivExpr(ID.Intern(SCEVAllocator),
3337 const SCEV *ScalarEvolution::getUDivExactExpr(const SCEV *LHS,
3337 const SCEV *ScalarEvolution::getUDivExactExpr(const SCEV *LHS,
3338 const SCEV *RHS) {
3352 SmallVector<const SCEV *, 2> Operands;
3366 SmallVector<const SCEV *, 2> Operands;
3380 SmallVector<const SCEV *, 2> Operands;
3392 const SCEV *ScalarEvolution::getAddRecExpr(const SCEV *Start, const SCEV *Step,
3392 const SCEV *ScalarEvolution::getAddRecExpr(const SCEV *Start, const SCEV *Step,
3392 const SCEV *ScalarEvolution::getAddRecExpr(const SCEV *Start, const SCEV *Step,
3394 SCEV::NoWrapFlags Flags) {
3395 SmallVector<const SCEV *, 4> Operands;
3400 return getAddRecExpr(Operands, L, maskFlags(Flags, SCEV::FlagNW));
3409 const SCEV *
3410 ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
3411 const Loop *L, SCEV::NoWrapFlags Flags) {
3425 return getAddRecExpr(Operands, L, SCEV::FlagAnyWrap); // {X,+,0} --> X
3443 SmallVector<const SCEV *, 4> NestedOperands(NestedAR->op_begin(),
3457 SCEV::NoWrapFlags OuterFlags =
3458 maskFlags(Flags, SCEV::FlagNW | NestedAR->getNoWrapFlags());
3470 SCEV::NoWrapFlags InnerFlags =
3471 maskFlags(NestedAR->getNoWrapFlags(), SCEV::FlagNW | Flags);
3485 const SCEV *
3487 const SmallVectorImpl<const SCEV *> &IndexExprs) {
3488 const SCEV *BaseExpr = getSCEV(GEP->getPointerOperand());
3497 SCEV::NoWrapFlags Wrap = GEP->isInBounds() ? SCEV::FlagNSW
3497 SCEV::NoWrapFlags Wrap = GEP->isInBounds() ? SCEV::FlagNSW
3498 : SCEV::FlagAnyWrap;
3500 const SCEV *TotalOffset = getZero(IntPtrTy);
3504 for (const SCEV *IndexExpr : IndexExprs) {
3510 const SCEV *FieldOffset = getOffsetOfExpr(IntPtrTy, STy, FieldNo);
3521 const SCEV *ElementSize = getSizeOfExpr(IntPtrTy, CurTy);
3526 const SCEV *LocalOffset = getMulExpr(IndexExpr, ElementSize, Wrap);
3537 std::tuple<const SCEV *, FoldingSetNodeID, void *>
3539 ArrayRef<const SCEV *> Ops) {
3549 const SCEV *ScalarEvolution::getMinMaxExpr(unsigned Kind,
3550 SmallVectorImpl<const SCEV *> &Ops) {
3567 if (const SCEV *S = std::get<0>(findExistingSCEVInCache(Kind, Ops))) {
3665 const SCEV *ExistingSCEV;
3671 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
3671 const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
3673 SCEV *S = new (SCEVAllocator) SCEVMinMaxExpr(
3681 const SCEV *ScalarEvolution::getSMaxExpr(const SCEV *LHS, const SCEV *RHS) {
3681 const SCEV *ScalarEvolution::getSMaxExpr(const SCEV *LHS, const SCEV *RHS) {
3681 const SCEV *ScalarEvolution::getSMaxExpr(const SCEV *LHS, const SCEV *RHS) {
3682 SmallVector<const SCEV *, 2> Ops = {LHS, RHS};
3686 const SCEV *ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
3686 const SCEV *ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
3690 const SCEV *ScalarEvolution::getUMaxExpr(const SCEV *LHS, const SCEV *RHS) {
3690 const SCEV *ScalarEvolution::getUMaxExpr(const SCEV *LHS, const SCEV *RHS) {
3690 const SCEV *ScalarEvolution::getUMaxExpr(const SCEV *LHS, const SCEV *RHS) {
3691 SmallVector<const SCEV *, 2> Ops = {LHS, RHS};
3695 const SCEV *ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
3695 const SCEV *ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV *> &Ops) {
3699 const SCEV *ScalarEvolution::getSMinExpr(const SCEV *LHS,
3699 const SCEV *ScalarEvolution::getSMinExpr(const SCEV *LHS,
3700 const SCEV *RHS) {
3701 SmallVector<const SCEV *, 2> Ops = { LHS, RHS };
3705 const SCEV *ScalarEvolution::getSMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
3705 const SCEV *ScalarEvolution::getSMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
3709 const SCEV *ScalarEvolution::getUMinExpr(const SCEV *LHS,
3709 const SCEV *ScalarEvolution::getUMinExpr(const SCEV *LHS,
3710 const SCEV *RHS) {
3711 SmallVector<const SCEV *, 2> Ops = { LHS, RHS };
3715 const SCEV *ScalarEvolution::getUMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
3715 const SCEV *ScalarEvolution::getUMinExpr(SmallVectorImpl<const SCEV *> &Ops) {
3719 const SCEV *ScalarEvolution::getSizeOfExpr(Type *IntTy, Type *AllocTy) {
3726 const SCEV *ScalarEvolution::getOffsetOfExpr(Type *IntTy,
3736 const SCEV *ScalarEvolution::getUnknown(Value *V) {
3746 if (SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) {
3751 SCEV *S = new (SCEVAllocator) SCEVUnknown(ID.Intern(SCEVAllocator), V, this,
3798 const SCEV *ScalarEvolution::getCouldNotCompute() {
3802 bool ScalarEvolution::checkValidity(const SCEV *S) const {
3811 bool ScalarEvolution::containsAddRecurrence(const SCEV *S) {
3816 bool FoundAddRec = SCEVExprContains(S, isa<SCEVAddRecExpr, const SCEV *>);
3824 static std::pair<const SCEV *, ConstantInt *> splitAddExpr(const SCEV *S) {
3824 static std::pair<const SCEV *, ConstantInt *> splitAddExpr(const SCEV *S) {
3842 ScalarEvolution::getSCEVValues(const SCEV *S) {
3862 const SCEV *S = I->second;
3868 const SCEV *Stripped;
3882 static bool SCEVLostPoisonFlags(const SCEV *S, const Value *V) {
3899 const SCEV *ScalarEvolution::getSCEV(Value *V) {
3902 const SCEV *S = getExistingSCEV(V);
3915 const SCEV *Stripped = S;
3931 const SCEV *ScalarEvolution::getExistingSCEV(Value *V) {
3936 const SCEV *S = I->second;
3946 const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V,
3946 const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V,
3947 SCEV::NoWrapFlags Flags) {
3959 static const SCEV *MatchNotExpr(const SCEV *Expr) {
3959 static const SCEV *MatchNotExpr(const SCEV *Expr) {
3974 const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) {
3974 const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) {
3982 SmallVector<const SCEV *, 2> MatchedOperands;
3983 for (const SCEV *Operand : MME->operands()) {
3984 const SCEV *Matched = MatchNotExpr(Operand);
3993 if (const SCEV *Replaced = MatchMinMaxNegation(MME))
3999 const SCEV *AllOnes =
4004 const SCEV *ScalarEvolution::getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
4004 const SCEV *ScalarEvolution::getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
4004 const SCEV *ScalarEvolution::getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
4005 SCEV::NoWrapFlags Flags,
4013 auto AddFlags = SCEV::FlagAnyWrap;
4016 if (maskFlags(Flags, SCEV::FlagNSW) == SCEV::FlagNSW) {
4016 if (maskFlags(Flags, SCEV::FlagNSW) == SCEV::FlagNSW) {
4027 AddFlags = SCEV::FlagNSW;
4038 auto NegFlags = RHSIsNotMinSigned ? SCEV::FlagNSW : SCEV::FlagAnyWrap;
4038 auto NegFlags = RHSIsNotMinSigned ? SCEV::FlagNSW : SCEV::FlagAnyWrap;
4043 const SCEV *ScalarEvolution::getTruncateOrZeroExtend(const SCEV *V, Type *Ty,
4043 const SCEV *ScalarEvolution::getTruncateOrZeroExtend(const SCEV *V, Type *Ty,
4055 const SCEV *ScalarEvolution::getTruncateOrSignExtend(const SCEV *V, Type *Ty,
4055 const SCEV *ScalarEvolution::getTruncateOrSignExtend(const SCEV *V, Type *Ty,
4067 const SCEV *
4068 ScalarEvolution::getNoopOrZeroExtend(const SCEV *V, Type *Ty) {
4079 const SCEV *
4080 ScalarEvolution::getNoopOrSignExtend(const SCEV *V, Type *Ty) {
4091 const SCEV *
4092 ScalarEvolution::getNoopOrAnyExtend(const SCEV *V, Type *Ty) {
4103 const SCEV *
4104 ScalarEvolution::getTruncateOrNoop(const SCEV *V, Type *Ty) {
4115 const SCEV *ScalarEvolution::getUMaxFromMismatchedTypes(const SCEV *LHS,
4115 const SCEV *ScalarEvolution::getUMaxFromMismatchedTypes(const SCEV *LHS,
4116 const SCEV *RHS) {
4117 const SCEV *PromotedLHS = LHS;
4118 const SCEV *PromotedRHS = RHS;
4128 const SCEV *ScalarEvolution::getUMinFromMismatchedTypes(const SCEV *LHS,
4128 const SCEV *ScalarEvolution::getUMinFromMismatchedTypes(const SCEV *LHS,
4129 const SCEV *RHS) {
4130 SmallVector<const SCEV *, 2> Ops = { LHS, RHS };
4134 const SCEV *ScalarEvolution::getUMinFromMismatchedTypes(
4135 SmallVectorImpl<const SCEV *> &Ops) {
4150 SmallVector<const SCEV *, 2> PromotedOps;
4158 const SCEV *ScalarEvolution::getPointerBase(const SCEV *V) {
4158 const SCEV *ScalarEvolution::getPointerBase(const SCEV *V) {
4166 const SCEV *PtrOp = nullptr;
4167 for (const SCEV *NAryOp : NAry->operands()) {
4191 void ScalarEvolution::forgetSymbolicName(Instruction *PN, const SCEV *SymName) {
4204 const SCEV *Old = It->second;
4239 static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE,
4239 static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE,
4242 const SCEV *Result = Rewriter.visit(S);
4250 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
4256 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
4283 static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE) {
4283 static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE) {
4285 const SCEV *Result = Rewriter.visit(S);
4291 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
4297 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
4324 static const SCEV *rewrite(const SCEV *S, const Loop *L,
4324 static const SCEV *rewrite(const SCEV *S, const Loop *L,
4343 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
4344 const SCEV *Result = Expr;
4352 Optional<const SCEV *> Res =
4361 Optional<const SCEV *> Res = compareWithBackedgeCondition(I);
4377 Optional<const SCEV *> compareWithBackedgeCondition(Value *IC);
4386 Optional<const SCEV *>
4400 static const SCEV *rewrite(const SCEV *S, const Loop *L,
4400 static const SCEV *rewrite(const SCEV *S, const Loop *L,
4403 const SCEV *Result = Rewriter.visit(S);
4407 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
4414 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
4433 SCEV::NoWrapFlags
4436 return SCEV::FlagAnyWrap;
4440 SCEV::NoWrapFlags Result = SCEV::FlagAnyWrap;
4440 SCEV::NoWrapFlags Result = SCEV::FlagAnyWrap;
4449 Result = ScalarEvolution::setFlags(Result, SCEV::FlagNSW);
4459 Result = ScalarEvolution::setFlags(Result, SCEV::FlagNUW);
4585 static Type *isSimpleCastedPHI(const SCEV *Op, const SCEVUnknown *SymbolicPHI,
4614 const SCEV *X = Trunc->getOperand();
4683 Optional<std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
4717 const SCEV *BEValue = getSCEV(BEValueV);
4743 SmallVector<const SCEV *, 8> Ops;
4747 const SCEV *Accum = getAddExpr(Ops);
4805 const SCEV *StartVal = getSCEV(StartValueV);
4806 const SCEV *PHISCEV =
4808 getTruncateExpr(Accum, TruncTy), L, SCEV::FlagAnyWrap);
4836 const SCEV *TruncatedExpr = getTruncateExpr(Expr, TruncTy);
4837 const SCEV *ExtendedExpr =
4854 const SCEV *StartExtended = getExtendedExpr(StartVal, Signed);
4862 const SCEV *AccumExtended = getExtendedExpr(Accum, /*CreateSignExtend=*/true);
4885 auto *NewAR = getAddRecExpr(StartVal, Accum, L, SCEV::FlagAnyWrap);
4887 std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>> PredRewrite =
4894 Optional<std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
4904 std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>> Rewrite =
4916 Optional<std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
4959 const SCEV *ScalarEvolution::createSimpleAffineAddRec(PHINode *PN,
4973 const SCEV *Accum = nullptr;
4982 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
4982 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
4984 Flags = setFlags(Flags, SCEV::FlagNUW);
4986 Flags = setFlags(Flags, SCEV::FlagNSW);
4988 const SCEV *StartVal = getSCEV(StartValueV);
4989 const SCEV *PHISCEV = getAddRecExpr(StartVal, Accum, L, Flags);
5003 const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) {
5040 const SCEV *SymbolicName = getUnknown(PN);
5045 const SCEV *BEValue = getSCEV(BEValueV);
5065 SmallVector<const SCEV *, 8> Ops;
5070 const SCEV *Accum = getAddExpr(Ops);
5077 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
5077 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
5082 Flags = setFlags(Flags, SCEV::FlagNUW);
5084 Flags = setFlags(Flags, SCEV::FlagNSW);
5094 Flags = setFlags(Flags, SCEV::FlagNW);
5096 const SCEV *Ptr = getSCEV(GEP->getPointerOperand());
5098 Flags = setFlags(Flags, SCEV::FlagNUW);
5106 const SCEV *StartVal = getSCEV(StartValueV);
5107 const SCEV *PHISCEV = getAddRecExpr(StartVal, Accum, L, Flags);
5135 const SCEV *Shifted = SCEVShiftRewriter::rewrite(BEValue, L, *this);
5136 const SCEV *Start = SCEVInitRewriter::rewrite(Shifted, L, *this, false);
5139 const SCEV *StartVal = getSCEV(StartValueV);
5162 static bool IsAvailableOnEntry(const Loop *L, DominatorTree &DT, const SCEV *S,
5181 bool follow(const SCEV *S) {
5268 const SCEV *ScalarEvolution::createNodeFromSelectLikePHI(PHINode *PN) {
5307 const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
5308 if (const SCEV *S = createAddRecFromPHI(PN))
5311 if (const SCEV *S = createNodeFromSelectLikePHI(PN))
5326 const SCEV *ScalarEvolution::createNodeForSelectOrPHI(Instruction *I,
5353 const SCEV *LS = getNoopOrSignExtend(getSCEV(LHS), I->getType());
5354 const SCEV *RS = getNoopOrSignExtend(getSCEV(RHS), I->getType());
5355 const SCEV *LA = getSCEV(TrueVal);
5356 const SCEV *RA = getSCEV(FalseVal);
5357 const SCEV *LDiff = getMinusSCEV(LA, LS);
5358 const SCEV *RDiff = getMinusSCEV(RA, RS);
5376 const SCEV *LS = getNoopOrZeroExtend(getSCEV(LHS), I->getType());
5377 const SCEV *RS = getNoopOrZeroExtend(getSCEV(RHS), I->getType());
5378 const SCEV *LA = getSCEV(TrueVal);
5379 const SCEV *RA = getSCEV(FalseVal);
5380 const SCEV *LDiff = getMinusSCEV(LA, LS);
5381 const SCEV *RDiff = getMinusSCEV(RA, RS);
5394 const SCEV *One = getOne(I->getType());
5395 const SCEV *LS = getNoopOrZeroExtend(getSCEV(LHS), I->getType());
5396 const SCEV *LA = getSCEV(TrueVal);
5397 const SCEV *RA = getSCEV(FalseVal);
5398 const SCEV *LDiff = getMinusSCEV(LA, LS);
5399 const SCEV *RDiff = getMinusSCEV(RA, One);
5408 const SCEV *One = getOne(I->getType());
5409 const SCEV *LS = getNoopOrZeroExtend(getSCEV(LHS), I->getType());
5410 const SCEV *LA = getSCEV(TrueVal);
5411 const SCEV *RA = getSCEV(FalseVal);
5412 const SCEV *LDiff = getMinusSCEV(LA, One);
5413 const SCEV *RDiff = getMinusSCEV(RA, LS);
5427 const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
5432 SmallVector<const SCEV *, 4> IndexExprs;
5438 uint32_t ScalarEvolution::GetMinTrailingZerosImpl(const SCEV *S) {
5513 uint32_t ScalarEvolution::GetMinTrailingZeros(const SCEV *S) {
5537 ScalarEvolution::getRangeRef(const SCEV *S,
5539 DenseMap<const SCEV *, ConstantRange> &Cache =
5547 DenseMap<const SCEV *, ConstantRange>::iterator I = Cache.find(S);
5677 const SCEV *MaxBECount = getConstantMaxBackedgeTakenCount(AddRec->getLoop());
5818 ConstantRange ScalarEvolution::getRangeForAffineAR(const SCEV *Start,
5819 const SCEV *Step,
5820 const SCEV *MaxBECount,
5851 ConstantRange ScalarEvolution::getRangeViaFactoring(const SCEV *Start,
5852 const SCEV *Step,
5853 const SCEV *MaxBECount,
5864 const SCEV *S) {
5953 const SCEV *TrueStart = this->getConstant(StartPattern.TrueValue);
5954 const SCEV *TrueStep = this->getConstant(StepPattern.TrueValue);
5955 const SCEV *FalseStart = this->getConstant(StartPattern.FalseValue);
5956 const SCEV *FalseStep = this->getConstant(StepPattern.FalseValue);
5966 SCEV::NoWrapFlags ScalarEvolution::getNoWrapFlagsFromUB(const Value *V) {
5967 if (isa<ConstantExpr>(V)) return SCEV::FlagAnyWrap;
5971 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
5971 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
5973 Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNUW);
5975 Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNSW);
5976 if (Flags == SCEV::FlagAnyWrap)
5977 return SCEV::FlagAnyWrap;
5979 return isSCEVExprNeverPoison(BinOp) ? Flags : SCEV::FlagAnyWrap;
6017 const SCEV *Op = getSCEV(I->getOperand(OpIndex));
6023 const SCEV *OtherOp = getSCEV(I->getOperand(OtherOpIndex));
6134 const SCEV *ScalarEvolution::createSCEV(Value *V) {
6164 SmallVector<const SCEV *, 4> AddOps;
6179 const SCEV *RHS = getSCEV(BO->RHS);
6180 SCEV::NoWrapFlags Flags = getNoWrapFlagsFromUB(BO->Op);
6181 if (Flags != SCEV::FlagAnyWrap) {
6182 const SCEV *LHS = getSCEV(BO->LHS);
6209 SmallVector<const SCEV *, 4> MulOps;
6217 SCEV::NoWrapFlags Flags = getNoWrapFlagsFromUB(BO->Op);
6218 if (Flags != SCEV::FlagAnyWrap) {
6241 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
6241 SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap;
6270 const SCEV *MulCount = getConstant(APInt::getOneBitSet(BitWidth, TZ));
6271 const SCEV *LHS = getSCEV(BO->LHS);
6272 const SCEV *ShiftedLHS = nullptr;
6279 SmallVector<const SCEV*, 4> MulOps;
6306 const SCEV *LHS = getSCEV(BO->LHS);
6311 const SCEV *S = getAddExpr(LHS, getSCEV(CI));
6341 const SCEV *Z0 = Z->getOperand();
6381 auto Flags = SCEV::FlagAnyWrap;
6418 const SCEV *ShlOp0SCEV = getSCEV(L->getOperand(0));
6466 return getMinusSCEV(V1, V2, SCEV::FlagNSW);
6576 const SCEV *ExitCount = getExitCount(L, ExitingBlock);
6581 const SCEV *TCExpr = getAddExpr(ExitCount, getOne(ExitCount->getType()));
6602 const SCEV *ScalarEvolution::getExitCount(const Loop *L,
6614 const SCEV *
6620 const SCEV *ScalarEvolution::getBackedgeTakenCount(const Loop *L,
6683 const SCEV *BEExact = Result.getExact(L, this);
6713 const SCEV *Old = It->second;
6812 std::pair<const SCEV *, const Loop *> Entry = I->first;
6892 const SCEV *
6906 SmallVector<const SCEV *, 2> Ops;
6908 const SCEV *BECount = ENT.ExactNotTaken;
6927 const SCEV *
6937 const SCEV *
6948 const SCEV *
6969 bool ScalarEvolution::BackedgeTakenInfo::hasOperand(const SCEV *S,
6983 ScalarEvolution::ExitLimit::ExitLimit(const SCEV *E)
6991 const SCEV *E, const SCEV *M, bool MaxOrZero,
6991 const SCEV *E, const SCEV *M, bool MaxOrZero,
7006 const SCEV *E, const SCEV *M, bool MaxOrZero,
7006 const SCEV *E, const SCEV *M, bool MaxOrZero,
7014 ScalarEvolution::ExitLimit::ExitLimit(const SCEV *E, const SCEV *M,
7014 ScalarEvolution::ExitLimit::ExitLimit(const SCEV *E, const SCEV *M,
7027 bool Complete, const SCEV *MaxCount, bool MaxOrZero)
7069 const SCEV *MustExitMaxBECount = nullptr;
7070 const SCEV *MayExitMaxBECount = nullptr;
7120 const SCEV *MaxBECount = MustExitMaxBECount ? MustExitMaxBECount :
7237 const SCEV *BECount = getCouldNotCompute();
7238 const SCEV *MaxBECount = getCouldNotCompute();
7285 const SCEV *BECount = getCouldNotCompute();
7286 const SCEV *MaxBECount = getCouldNotCompute();
7378 const SCEV *LHS = getSCEV(ExitCond->getOperand(0));
7379 const SCEV *RHS = getSCEV(ExitCond->getOperand(1));
7405 const SCEV *Ret = AddRec->getNumIterationsInRange(CompRange, *this);
7467 const SCEV *LHS = getSCEVAtScope(Switch->getCondition(), L);
7468 const SCEV *RHS = getConstant(Switch->findCaseDest(ExitingBlock));
7481 const SCEV *InVal = SE.getConstant(C);
7482 const SCEV *Val = AddRec->evaluateAtIteration(InVal, SE);
7531 const SCEV *Idx = getSCEV(VarIdx);
7701 const SCEV *UpperBound =
7957 const SCEV *ScalarEvolution::computeExitCountExhaustively(const Loop *L,
8024 const SCEV *ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
8024 const SCEV *ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
8025 SmallVector<std::pair<const Loop *, const SCEV *>, 2> &Values =
8035 const SCEV *C = computeSCEVAtScope(V, L);
8048 static Constant *BuildConstantFromSCEV(const SCEV *V) {
8145 const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
8145 const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
8161 const SCEV *BackedgeTakenCount = getBackedgeTakenCount(LI);
8186 const SCEV *OnBackedge = getSCEV(PN->getIncomingValue(InLoopPred));
8203 const SCEV *Input = getSCEV(PN->getOperand(0));
8204 const SCEV *InputAtScope = getSCEVAtScope(Input, L);
8230 const SCEV *OrigV = getSCEV(Op);
8231 const SCEV *OpV = getSCEVAtScope(OrigV, L);
8270 const SCEV *OpAtScope = getSCEVAtScope(Comm->getOperand(i), L);
8274 SmallVector<const SCEV *, 8> NewOps(Comm->op_begin(),
8296 const SCEV *LHS = getSCEVAtScope(Div->getLHS(), L);
8297 const SCEV *RHS = getSCEVAtScope(Div->getRHS(), L);
8310 const SCEV *OpAtScope = getSCEVAtScope(AddRec->getOperand(i), L);
8316 SmallVector<const SCEV *, 8> NewOps(AddRec->op_begin(),
8322 const SCEV *FoldedRec =
8324 AddRec->getNoWrapFlags(SCEV::FlagNW));
8339 const SCEV *BackedgeTakenCount = getBackedgeTakenCount(AddRec->getLoop());
8350 const SCEV *Op = getSCEVAtScope(Cast->getOperand(), L);
8357 const SCEV *Op = getSCEVAtScope(Cast->getOperand(), L);
8364 const SCEV *Op = getSCEVAtScope(Cast->getOperand(), L);
8373 const SCEV *ScalarEvolution::getSCEVAtScope(Value *V, const Loop *L) {
8377 const SCEV *ScalarEvolution::stripInjectiveFunctions(const SCEV *S) const {
8377 const SCEV *ScalarEvolution::stripInjectiveFunctions(const SCEV *S) const {
8393 static const SCEV *SolveLinEquationWithOverflow(const APInt &A, const SCEV *B,
8393 static const SCEV *SolveLinEquationWithOverflow(const APInt &A, const SCEV *B,
8428 const SCEV *D = SE.getConstant(APInt::getOneBitSet(BW, Mult2));
8702 ScalarEvolution::howFarToZero(const SCEV *V, const Loop *L, bool ControlsExit,
8759 const SCEV *Start = getSCEVAtScope(AddRec->getStart(), L->getParentLoop());
8760 const SCEV *Step = getSCEVAtScope(AddRec->getOperand(1), L->getParentLoop());
8778 const SCEV *Distance = CountDown ? Start : getNegativeSCEV(Start);
8793 const SCEV *Zero = getZero(Distance->getType());
8794 const SCEV *One = getOne(Distance->getType());
8795 const SCEV *DistancePlusOne = getAddExpr(Distance, One);
8812 const SCEV *Exact =
8814 const SCEV *Max =
8822 const SCEV *E = SolveLinEquationWithOverflow(StepC->getAPInt(),
8824 const SCEV *M = E == getCouldNotCompute()
8831 ScalarEvolution::howFarToNonZero(const SCEV *V, const Loop *L) {
8870 static bool HasSameValue(const SCEV *A, const SCEV *B) {
8870 static bool HasSameValue(const SCEV *A, const SCEV *B) {
8895 const SCEV *&LHS, const SCEV *&RHS,
8895 const SCEV *&LHS, const SCEV *&RHS,
9030 SCEV::FlagNSW);
9035 SCEV::FlagNSW);
9043 SCEV::FlagNSW);
9048 SCEV::FlagNSW);
9056 SCEV::FlagNUW);
9072 SCEV::FlagNUW);
9091 bool ScalarEvolution::isKnownNegative(const SCEV *S) {
9095 bool ScalarEvolution::isKnownPositive(const SCEV *S) {
9099 bool ScalarEvolution::isKnownNonNegative(const SCEV *S) {
9103 bool ScalarEvolution::isKnownNonPositive(const SCEV *S) {
9107 bool ScalarEvolution::isKnownNonZero(const SCEV *S) {
9111 std::pair<const SCEV *, const SCEV *>
9111 std::pair<const SCEV *, const SCEV *>
9112 ScalarEvolution::SplitIntoInitAndPostInc(const Loop *L, const SCEV *S) {
9114 const SCEV *Start = SCEVInitRewriter::rewrite(S, L, *this);
9118 const SCEV *PostInc = SCEVPostIncRewriter::rewrite(S, L, *this);
9124 const SCEV *LHS, const SCEV *RHS) {
9124 const SCEV *LHS, const SCEV *RHS) {
9173 const SCEV *LHS, const SCEV *RHS) {
9173 const SCEV *LHS, const SCEV *RHS) {
9189 const SCEV *RHS) {
9251 const SCEV *Step = LHS->getStepRecurrence(*this);
9272 ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L,
9272 ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L,
9273 ICmpInst::Predicate &InvariantPred, const SCEV *&InvariantLHS,
9274 const SCEV *&InvariantRHS) {
9323 ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) {
9323 ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS) {
9353 const SCEV *LHS,
9354 const SCEV *RHS) {
9360 const SCEV *NonConstOp, *ConstOp;
9361 SCEV::NoWrapFlags FlagsPresent;
9382 if (MatchBinaryAddToConst(RHS, LHS, C, SCEV::FlagNSW) && C.isNonNegative())
9386 if (MatchBinaryAddToConst(LHS, RHS, C, SCEV::FlagNSW) &&
9396 if (MatchBinaryAddToConst(RHS, LHS, C, SCEV::FlagNSW) &&
9401 if (MatchBinaryAddToConst(LHS, RHS, C, SCEV::FlagNSW) && C.isNegative())
9410 const SCEV *LHS,
9411 const SCEV *RHS) {
9433 const SCEV *LHS, const SCEV *RHS) {
9433 const SCEV *LHS, const SCEV *RHS) {
9454 const SCEV *LHS, const SCEV *RHS) {
9454 const SCEV *LHS, const SCEV *RHS) {
9488 const SCEV *LatchBECount = BETakenInfo.getExact(Latch, this);
9494 auto NoWrapFlags = SCEV::NoWrapFlags(SCEV::FlagNUW | SCEV::FlagNW);
9494 auto NoWrapFlags = SCEV::NoWrapFlags(SCEV::FlagNUW | SCEV::FlagNW);
9495 const SCEV *LoopCounter =
9564 const SCEV *LHS, const SCEV *RHS) {
9564 const SCEV *LHS, const SCEV *RHS) {
9673 const SCEV *LHS, const SCEV *RHS,
9673 const SCEV *LHS, const SCEV *RHS,
9706 const SCEV *FoundLHS = getSCEV(ICI->getOperand(0));
9707 const SCEV *FoundRHS = getSCEV(ICI->getOperand(1));
9712 bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS,
9713 const SCEV *RHS,
9715 const SCEV *FoundLHS,
9716 const SCEV *FoundRHS) {
9784 const SCEV *V = nullptr;
9855 bool ScalarEvolution::splitBinaryAdd(const SCEV *Expr,
9856 const SCEV *&L, const SCEV *&R,
9856 const SCEV *&L, const SCEV *&R,
9857 SCEV::NoWrapFlags &Flags) {
9868 Optional<APInt> ScalarEvolution::computeConstantDifference(const SCEV *More,
9869 const SCEV *Less) {
9904 SCEV::NoWrapFlags Flags;
9905 const SCEV *LLess = nullptr, *RLess = nullptr;
9906 const SCEV *LMore = nullptr, *RMore = nullptr;
9928 ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
9928 ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
9929 const SCEV *FoundLHS, const SCEV *FoundRHS) {
9929 const SCEV *FoundLHS, const SCEV *FoundRHS) {
10005 const SCEV *LHS, const SCEV *RHS,
10005 const SCEV *LHS, const SCEV *RHS,
10006 const SCEV *FoundLHS,
10007 const SCEV *FoundRHS, unsigned Depth) {
10073 const SCEV *L = getSCEV(LPhi->getIncomingValueForBlock(IncBB));
10074 const SCEV *R = getSCEV(RPhi->getIncomingValueForBlock(IncBB));
10089 const SCEV *L1 = getSCEV(LPhi->getIncomingValueForBlock(Predecessor));
10094 const SCEV *L2 = getSCEV(LPhi->getIncomingValueForBlock(Latch));
10106 const SCEV *L = getSCEV(LPhi->getIncomingValueForBlock(IncBB));
10115 const SCEV *LHS, const SCEV *RHS,
10115 const SCEV *LHS, const SCEV *RHS,
10116 const SCEV *FoundLHS,
10117 const SCEV *FoundRHS) {
10134 static bool IsMinMaxConsistingOf(const SCEV *MaybeMinMaxExpr,
10135 const SCEV *Candidate) {
10145 const SCEV *LHS, const SCEV *RHS) {
10145 const SCEV *LHS, const SCEV *RHS) {
10167 SCEV::NoWrapFlags NW = ICmpInst::isSigned(Pred) ?
10168 SCEV::FlagNSW : SCEV::FlagNUW;
10168 SCEV::FlagNSW : SCEV::FlagNUW;
10179 const SCEV *LHS, const SCEV *RHS) {
10179 const SCEV *LHS, const SCEV *RHS) {
10209 const SCEV *LHS, const SCEV *RHS,
10209 const SCEV *LHS, const SCEV *RHS,
10210 const SCEV *FoundLHS,
10211 const SCEV *FoundRHS,
10359 const SCEV *LHS, const SCEV *RHS) {
10359 const SCEV *LHS, const SCEV *RHS) {
10392 const SCEV *LHS, const SCEV *RHS) {
10392 const SCEV *LHS, const SCEV *RHS) {
10402 const SCEV *LHS, const SCEV *RHS,
10402 const SCEV *LHS, const SCEV *RHS,
10403 const SCEV *FoundLHS,
10404 const SCEV *FoundRHS) {
10446 const SCEV *LHS,
10447 const SCEV *RHS,
10448 const SCEV *FoundLHS,
10449 const SCEV *FoundRHS) {
10480 bool ScalarEvolution::doesIVOverflowOnLT(const SCEV *RHS, const SCEV *Stride,
10480 bool ScalarEvolution::doesIVOverflowOnLT(const SCEV *RHS, const SCEV *Stride,
10487 const SCEV *One = getOne(Stride->getType());
10506 bool ScalarEvolution::doesIVOverflowOnGT(const SCEV *RHS, const SCEV *Stride,
10506 bool ScalarEvolution::doesIVOverflowOnGT(const SCEV *RHS, const SCEV *Stride,
10511 const SCEV *One = getOne(Stride->getType());
10530 const SCEV *ScalarEvolution::computeBECount(const SCEV *Delta, const SCEV *Step,
10530 const SCEV *ScalarEvolution::computeBECount(const SCEV *Delta, const SCEV *Step,
10530 const SCEV *ScalarEvolution::computeBECount(const SCEV *Delta, const SCEV *Step,
10532 const SCEV *One = getOne(Step->getType());
10538 const SCEV *ScalarEvolution::computeMaxBECountForLT(const SCEV *Start,
10538 const SCEV *ScalarEvolution::computeMaxBECountForLT(const SCEV *Start,
10539 const SCEV *Stride,
10540 const SCEV *End,
10548 const SCEV *MaxBECount;
10582 ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
10582 ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
10603 IV->getNoWrapFlags(IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW);
10603 IV->getNoWrapFlags(IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW);
10605 const SCEV *Stride = IV->getStepRecurrence(*this);
10666 const SCEV *Start = IV->getStart();
10667 const SCEV *End = RHS;
10674 const SCEV *MaxBECount = computeMaxBECountForLT(
10683 const SCEV *BECountIfBackedgeTaken =
10692 const SCEV *BECount;
10700 const SCEV *MaxBECount;
10723 ScalarEvolution::howManyGreaterThans(const SCEV *LHS, const SCEV *RHS,
10723 ScalarEvolution::howManyGreaterThans(const SCEV *LHS, const SCEV *RHS,
10743 IV->getNoWrapFlags(IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW);
10743 IV->getNoWrapFlags(IsSigned ? SCEV::FlagNSW : SCEV::FlagNUW);
10745 const SCEV *Stride = getNegativeSCEV(IV->getStepRecurrence(*this));
10761 const SCEV *Start = IV->getStart();
10762 const SCEV *End = RHS;
10766 const SCEV *BECount = computeBECount(getMinusSCEV(Start, End), Stride, false);
10785 const SCEV *MaxBECount = isa<SCEVConstant>(BECount)
10796 const SCEV *SCEVAddRecExpr::getNumIterationsInRange(const ConstantRange &Range,
10804 SmallVector<const SCEV *, 4> Operands(op_begin(), op_end());
10806 const SCEV *Shifted = SE.getAddRecExpr(Operands, getLoop(),
10876 SmallVector<const SCEV *, 3> Ops;
10885 const SCEV *Last = getOperand(getNumOperands() - 1);
10889 SCEV::FlagAnyWrap));
10893 static inline bool containsUndefs(const SCEV *S) {
10906 SmallVectorImpl<const SCEV *> &Strides;
10908 SCEVCollectStrides(ScalarEvolution &SE, SmallVectorImpl<const SCEV *> &S)
10911 bool follow(const SCEV *S) {
10922 SmallVectorImpl<const SCEV *> &Terms;
10924 SCEVCollectTerms(SmallVectorImpl<const SCEV *> &T) : Terms(T) {}
10926 bool follow(const SCEV *S) {
10951 bool follow(const SCEV *S) {
10979 SmallVectorImpl<const SCEV *> &Terms;
10982 SCEVCollectAddRecMultiplies(SmallVectorImpl<const SCEV *> &T, ScalarEvolution &SE)
10985 bool follow(const SCEV *S) {
10988 SmallVector<const SCEV *, 0> Operands;
11026 void ScalarEvolution::collectParametricTerms(const SCEV *Expr,
11027 SmallVectorImpl<const SCEV *> &Terms) {
11028 SmallVector<const SCEV *, 4> Strides;
11038 for (const SCEV *S : Strides) {
11054 SmallVectorImpl<const SCEV *> &Terms,
11055 SmallVectorImpl<const SCEV *> &Sizes) {
11057 const SCEV *Step = Terms[Last];
11062 SmallVector<const SCEV *, 2> Qs;
11063 for (const SCEV *Op : M->operands())
11074 for (const SCEV *&Term : Terms) {
11076 const SCEV *Q, *R;
11100 static inline bool containsParameters(SmallVectorImpl<const SCEV *> &Terms) {
11101 for (const SCEV *T : Terms)
11102 if (SCEVExprContains(T, isa<SCEVUnknown, const SCEV *>))
11108 static inline int numberOfTerms(const SCEV *S) {
11114 static const SCEV *removeConstantFactors(ScalarEvolution &SE, const SCEV *T) {
11114 static const SCEV *removeConstantFactors(ScalarEvolution &SE, const SCEV *T) {
11122 SmallVector<const SCEV *, 2> Factors;
11123 for (const SCEV *Op : M->operands())
11134 const SCEV *ScalarEvolution::getElementSize(Instruction *Inst) {
11147 void ScalarEvolution::findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
11148 SmallVectorImpl<const SCEV *> &Sizes,
11149 const SCEV *ElementSize) {
11175 for (const SCEV *&Term : Terms) {
11176 const SCEV *Q, *R;
11182 SmallVector<const SCEV *, 4> NewTerms;
11185 for (const SCEV *T : Terms)
11186 if (const SCEV *NewT = removeConstantFactors(*this, T))
11211 const SCEV *Expr, SmallVectorImpl<const SCEV *> &Subscripts,
11211 const SCEV *Expr, SmallVectorImpl<const SCEV *> &Subscripts,
11212 SmallVectorImpl<const SCEV *> &Sizes) {
11221 const SCEV *Res = Expr;
11224 const SCEV *Q, *R;
11316 void ScalarEvolution::delinearize(const SCEV *Expr,
11317 SmallVectorImpl<const SCEV *> &Subscripts,
11318 SmallVectorImpl<const SCEV *> &Sizes,
11319 const SCEV *ElementSize) {
11321 SmallVector<const SCEV *, 4> Terms;
11571 const SCEV *SV = SE.getSCEV(&I);
11582 const SCEV *AtUse = SE.getSCEVAtScope(SV, L);
11596 const SCEV *ExitValue = SE.getSCEVAtScope(SV, L->getParentLoop());
11644 ScalarEvolution::getLoopDisposition(const SCEV *S, const Loop *L) {
11663 ScalarEvolution::computeLoopDisposition(const SCEV *S, const Loop *L) {
11742 bool ScalarEvolution::isLoopInvariant(const SCEV *S, const Loop *L) {
11746 bool ScalarEvolution::hasComputableLoopEvolution(const SCEV *S, const Loop *L) {
11751 ScalarEvolution::getBlockDisposition(const SCEV *S, const BasicBlock *BB) {
11770 ScalarEvolution::computeBlockDisposition(const SCEV *S, const BasicBlock *BB) {
11798 for (const SCEV *NAryOp : NAry->operands()) {
11809 const SCEV *LHS = UDiv->getLHS(), *RHS = UDiv->getRHS();
11835 bool ScalarEvolution::dominates(const SCEV *S, const BasicBlock *BB) {
11839 bool ScalarEvolution::properlyDominates(const SCEV *S, const BasicBlock *BB) {
11843 bool ScalarEvolution::hasOperand(const SCEV *S, const SCEV *Op) const {
11843 bool ScalarEvolution::hasOperand(const SCEV *S, const SCEV *Op) const {
11847 bool ScalarEvolution::ExitLimit::hasOperand(const SCEV *S) const {
11856 ScalarEvolution::forgetMemoizedResults(const SCEV *S) {
11868 std::pair<const SCEV *, const Loop *> Entry = I->first;
11892 ScalarEvolution::getUsedLoops(const SCEV *S,
11898 bool follow(const SCEV *S) {
11911 void ScalarEvolution::addToLoopUseLists(const SCEV *S) {
11928 const SCEV *visitConstant(const SCEVConstant *Constant) {
11932 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
11936 const SCEV *visitCouldNotCompute(const SCEVCouldNotCompute *Expr) {
11978 const SCEV *Delta = SE2.getMinusSCEV(CurBECount, NewBECount);
12064 const SCEVPredicate *ScalarEvolution::getEqualPredicate(const SCEV *LHS,
12065 const SCEV *RHS) {
12112 static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE,
12112 static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE,
12119 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
12130 const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
12131 const SCEV *Operand = visit(Expr->getOperand());
12136 const SCEV *Step = AR->getStepRecurrence(SE);
12146 const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
12147 const SCEV *Operand = visit(Expr->getOperand());
12152 const SCEV *Step = AR->getStepRecurrence(SE);
12189 const SCEV *convertToAddRecWithPreds(const SCEVUnknown *Expr) {
12192 Optional<std::pair<const SCEV *, SmallVector<const SCEVPredicate *, 3>>>
12216 const SCEV *ScalarEvolution::rewriteUsingPredicate(const SCEV *S, const Loop *L,
12216 const SCEV *ScalarEvolution::rewriteUsingPredicate(const SCEV *S, const Loop *L,
12222 const SCEV *S, const Loop *L,
12245 const SCEV *LHS, const SCEV *RHS)
12245 const SCEV *LHS, const SCEV *RHS)
12262 const SCEV *SCEVEqualPredicate::getExpr() const { return LHS; }
12273 const SCEV *SCEVWrapPredicate::getExpr() const { return AR; }
12282 SCEV::NoWrapFlags ScevFlags = AR->getNoWrapFlags();
12285 if (ScalarEvolution::setFlags(ScevFlags, SCEV::FlagNSW) == ScevFlags)
12304 SCEV::NoWrapFlags StaticFlags = AR->getNoWrapFlags();
12307 if (ScalarEvolution::setFlags(StaticFlags, SCEV::FlagNSW) == StaticFlags)
12310 if (ScalarEvolution::setFlags(StaticFlags, SCEV::FlagNUW) == StaticFlags) {
12331 SCEVUnionPredicate::getPredicatesForExpr(const SCEV *Expr) {
12352 const SCEV *SCEVUnionPredicate::getExpr() const { return nullptr; }
12369 const SCEV *Key = N->getExpr();
12381 const SCEV *PredicatedScalarEvolution::getSCEV(Value *V) {
12382 const SCEV *Expr = SE.getSCEV(V);
12394 const SCEV *NewSCEV = SE.rewriteUsingPredicate(Expr, &L, Preds);
12400 const SCEV *PredicatedScalarEvolution::getBackedgeTakenCount() {
12424 const SCEV *Rewritten = II.second.second;
12432 const SCEV *Expr = getSCEV(V);
12448 const SCEV *Expr = getSCEV(V);
12463 const SCEV *Expr = this->getSCEV(V);
12513 bool ScalarEvolution::matchURem(const SCEV *Expr, const SCEV *&LHS,
12513 bool ScalarEvolution::matchURem(const SCEV *Expr, const SCEV *&LHS,
12514 const SCEV *&RHS) {
12519 const SCEV *A = Add->getOperand(1);
lib/Analysis/ScalarEvolutionAliasAnalysis.cpp 33 const SCEV *AS = SE.getSCEV(const_cast<Value *>(LocA.Ptr));
34 const SCEV *BS = SE.getSCEV(const_cast<Value *>(LocB.Ptr));
53 const SCEV *BA = SE.getMinusSCEV(BS, AS);
67 const SCEV *AB = SE.getMinusSCEV(AS, BS);
99 Value *SCEVAAResult::GetBaseValue(const SCEV *S) {
106 const SCEV *Last = A->getOperand(A->getNumOperands() - 1);
lib/Analysis/ScalarEvolutionExpander.cpp 171 SCEV::NoWrapFlags Flags, bool IsSafeToHoist) {
193 if (I->hasNoSignedWrap() != (Flags & SCEV::FlagNSW))
195 if (I->hasNoUnsignedWrap() != (Flags & SCEV::FlagNUW))
230 if (Flags & SCEV::FlagNUW)
232 if (Flags & SCEV::FlagNSW)
243 static bool FactorOutConstant(const SCEV *&S, const SCEV *&Remainder,
243 static bool FactorOutConstant(const SCEV *&S, const SCEV *&Remainder,
244 const SCEV *Factor, ScalarEvolution &SE,
269 const SCEV *Div = SE.getConstant(CI);
286 SmallVector<const SCEV *, 4> NewMulOps(M->op_begin(), M->op_end());
295 const SCEV *Step = A->getStepRecurrence(SE);
296 const SCEV *StepRem = SE.getConstant(Step->getType(), 0);
301 const SCEV *Start = A->getStart();
305 A->getNoWrapFlags(SCEV::FlagNW));
316 static void SimplifyAddOperands(SmallVectorImpl<const SCEV *> &Ops,
323 SmallVector<const SCEV *, 8> NoAddRecs(Ops.begin(), Ops.end() - NumAddRecs);
324 SmallVector<const SCEV *, 8> AddRecs(Ops.end() - NumAddRecs, Ops.end());
326 const SCEV *Sum = NoAddRecs.empty() ?
345 static void SplitAddRecs(SmallVectorImpl<const SCEV *> &Ops,
349 SmallVector<const SCEV *, 8> AddRecs;
352 const SCEV *Start = A->getStart();
354 const SCEV *Zero = SE.getConstant(Ty, 0);
358 A->getNoWrapFlags(SCEV::FlagNW)));
402 Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin,
403 const SCEV *const *op_end,
410 SmallVector<const SCEV *, 8> Ops(op_begin, op_end);
427 SmallVector<const SCEV *, 8> ScaledOps;
429 const SCEV *ElSize = SE.getSizeOfExpr(IntPtrTy, ElTy);
431 SmallVector<const SCEV *, 8> NewOps;
432 for (const SCEV *Op : Ops) {
433 const SCEV *Remainder = SE.getConstant(Ty, 0);
596 Value *SCEVExpander::expandAddToGEP(const SCEV *Op, PointerType *PTy, Type *Ty,
598 const SCEV *const Ops[1] = {Op};
618 const Loop *SCEVExpander::getRelevantLoop(const SCEV *S) {
637 for (const SCEV *Op : N->operands())
661 bool operator()(std::pair<const Loop *, const SCEV *> LHS,
662 std::pair<const Loop *, const SCEV *> RHS) const {
695 SmallVector<std::pair<const Loop *, const SCEV *>, 8> OpsAndLoops;
709 const SCEV *Op = I->second;
717 SmallVector<const SCEV *, 4> NewOps;
721 const SCEV *X = I->second;
732 SmallVector<const SCEV *, 4> NewOps;
742 Sum = InsertBinop(Instruction::Sub, Sum, W, SCEV::FlagAnyWrap,
765 SmallVector<std::pair<const Loop *, const SCEV *>, 8> OpsAndLoops;
804 P = InsertBinop(Instruction::Mul, P, P, SCEV::FlagAnyWrap,
808 SCEV::FlagAnyWrap,
826 SCEV::FlagAnyWrap, /*IsSafeToHoist*/ true);
841 NWFlags = ScalarEvolution::clearFlags(NWFlags, SCEV::FlagNSW);
864 SCEV::FlagAnyWrap, /*IsSafeToHoist*/ true);
868 return InsertBinop(Instruction::UDiv, LHS, RHS, SCEV::FlagAnyWrap,
875 static void ExposePointerBase(const SCEV *&Base, const SCEV *&Rest,
875 static void ExposePointerBase(const SCEV *&Base, const SCEV *&Rest,
883 A->getNoWrapFlags(SCEV::FlagNW)));
887 SmallVector<const SCEV *, 8> NewAddOps(A->op_begin(), A->op_end());
1133 const SCEV *Step = AR->getStepRecurrence(SE);
1134 const SCEV *OpAfterExtend = SE.getAddExpr(SE.getSignExtendExpr(Step, WideTy),
1136 const SCEV *ExtendAfterOp =
1147 const SCEV *Step = AR->getStepRecurrence(SE);
1148 const SCEV *OpAfterExtend = SE.getAddExpr(SE.getZeroExtendExpr(Step, WideTy),
1150 const SCEV *ExtendAfterOp =
1276 const SCEV *Step = Normalized->getStepRecurrence(SE);
1352 const SCEV *Start = Normalized->getStart();
1353 const SCEV *PostLoopOffset = nullptr;
1360 Normalized->getNoWrapFlags(SCEV::FlagNW)));
1364 const SCEV *Step = Normalized->getStepRecurrence(SE);
1365 const SCEV *PostLoopScale = nullptr;
1379 Normalized->getNoWrapFlags(SCEV::FlagNW)));
1513 SmallVector<const SCEV *, 4> NewOps(S->getNumOperands());
1517 S->getNoWrapFlags(SCEV::FlagNW)));
1527 SmallVector<const SCEV *, 4> NewOps(S->op_begin(), S->op_end());
1529 const SCEV *Rest = SE.getAddRecExpr(NewOps, L,
1530 S->getNoWrapFlags(SCEV::FlagNW));
1534 const SCEV *Base = S->getStart();
1536 const SCEV *ExposedRest = Rest;
1554 const SCEV *AddExprLHS = SE.getUnknown(expand(S->getStart()));
1555 const SCEV *AddExprRHS = SE.getUnknown(expand(Rest));
1618 const SCEV *IH = SE.getUnknown(CanonicalIV); // Get I as a "symbolic" SCEV.
1621 const SCEV *NewS = S;
1622 const SCEV *Ext = SE.getNoopOrAnyExtend(S, CanonicalIV->getType());
1626 const SCEV *V = cast<SCEVAddRecExpr>(NewS)->evaluateAtIteration(IH, SE);
1630 const SCEV *T = SE.getTruncateOrNoop(V, Ty);
1761 Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty,
1767 Value *SCEVExpander::expandCodeFor(const SCEV *SH, Type *Ty) {
1779 SCEVExpander::FindValueInExprValueMap(const SCEV *S,
1813 Value *SCEVExpander::expand(const SCEV *S) {
1931 const SCEV *H = SE.getAddRecExpr(SE.getConstant(Ty, 0),
1932 SE.getConstant(Ty, 1), L, SCEV::FlagAnyWrap);
1967 DenseMap<const SCEV *, PHINode *> ExprToIVMap;
2005 const SCEV *TruncExpr =
2042 const SCEV *TruncExpr =
2084 Value *SCEVExpander::getExactExistingExpansion(const SCEV *S,
2094 SCEVExpander::getRelatedExistingExpansion(const SCEV *S, const Instruction *At,
2132 const SCEV *S, Loop *L, const Instruction *At,
2133 SmallPtrSetImpl<const SCEV *> &Processed) {
2244 const SCEV *ExitCount =
2249 const SCEV *Step = AR->getStepRecurrence(SE);
2250 const SCEV *Start = AR->getStart();
2296 const SCEV *MulS = SE.getSCEV(MulV);
2297 const SCEV *NegMulS = SE.getNegativeSCEV(MulS);
2402 bool follow(const SCEV *S) {
2411 const SCEV *Step = AR->getStepRecurrence(SE);
2424 bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE) {
2430 bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint,
lib/Analysis/ScalarEvolutionNormalization.cpp 42 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr);
46 const SCEV *
48 SmallVector<const SCEV *, 8> Operands;
54 return SE.getAddRecExpr(Operands, AR->getLoop(), SCEV::FlagAnyWrap);
93 return SE.getAddRecExpr(Operands, AR->getLoop(), SCEV::FlagAnyWrap);
96 const SCEV *llvm::normalizeForPostIncUse(const SCEV *S,
96 const SCEV *llvm::normalizeForPostIncUse(const SCEV *S,
105 const SCEV *llvm::normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred,
105 const SCEV *llvm::normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred,
110 const SCEV *llvm::denormalizeForPostIncUse(const SCEV *S,
110 const SCEV *llvm::denormalizeForPostIncUse(const SCEV *S,
lib/Analysis/StackSafetyAnalysis.cpp 36 const SCEV *visit(const SCEV *Expr) {
36 const SCEV *visit(const SCEV *Expr) {
46 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
239 const SCEV *Expr = Rewriter.visit(SE.getSCEV(Addr));
252 const SCEV *Expr = Rewriter.visit(SE.getSCEV(Addr));
lib/Analysis/TargetTransformInfo.cpp 71 const SCEV *EC = SE.getExitCount(L, BB);
711 const SCEV *Ptr) const {
lib/Analysis/VectorUtils.cpp 199 const SCEV *V = SE->getSCEV(Ptr);
834 const SCEV *Scev = replaceSymbolicStrideSCEV(PSE, Strides, Ptr);
lib/CodeGen/HardwareLoops.cpp 162 const SCEV *ExitCount = nullptr;
lib/CodeGen/SafeStack.cpp 112 const SCEV *visitUnknown(const SCEVUnknown *Expr) {
233 const SCEV *Expr = Rewriter.visit(SE.getSCEV(Addr));
lib/Target/AArch64/AArch64FalkorHWPFFix.cpp 163 const SCEV *LSCEV = SE.getSCEV(PtrValue);
lib/Target/AArch64/AArch64TargetTransformInfo.cpp 573 const SCEV *Ptr) {
738 const SCEV *LSCEV = SE.getSCEV(PtrValue);
lib/Target/AArch64/AArch64TargetTransformInfo.h 129 int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr);
lib/Target/ARM/ARMTargetTransformInfo.cpp 474 const SCEV *Ptr) {
860 const SCEV *BackedgeTakenCount = SE.getBackedgeTakenCount(L);
864 const SCEV *TripCountSCEV =
lib/Target/ARM/ARMTargetTransformInfo.h 182 const SCEV *Ptr);
lib/Target/ARM/MVETailPredication.cpp 319 const SCEV *TripCountSE = SE->getSCEV(TripCount);
372 const SCEV *Elems = nullptr;
lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp 147 bool processCopyingStore(Loop *CurLoop, StoreInst *SI, const SCEV *BECount);
149 bool runOnLoopBlock(Loop *CurLoop, BasicBlock *BB, const SCEV *BECount,
1782 const SCEV *CT = SE.getBackedgeTakenCount(CurLoop);
1968 const SCEV *BECount, unsigned StoreSize,
2008 StoreInst *SI, const SCEV *BECount) {
2147 const SCEV *NumBytesS =
2148 SE->getAddExpr(BECount, SE->getOne(IntPtrTy), SCEV::FlagNUW);
2151 SCEV::FlagNUW);
2259 const SCEV *OneS = SE->getConstant(Int32Ty, 1);
2260 const SCEV *BECount32 = SE->getTruncateOrZeroExtend(BECount, Int32Ty);
2261 const SCEV *NumWordsS = SE->getAddExpr(BECount32, OneS, SCEV::FlagNUW);
2261 const SCEV *NumWordsS = SE->getAddExpr(BECount32, OneS, SCEV::FlagNUW);
2356 const SCEV *BECount, SmallVectorImpl<BasicBlock*> &ExitBlocks) {
2386 const SCEV *BECount = SE->getBackedgeTakenCount(L);
lib/Target/Hexagon/HexagonTargetTransformInfo.cpp 150 ScalarEvolution *SE, const SCEV *S) {
lib/Target/Hexagon/HexagonTargetTransformInfo.h 114 const SCEV *S);
lib/Target/PowerPC/PPCLoopPreIncPrep.cpp 78 Bucket(const SCEV *B, Instruction *I) : BaseSCEV(B),
81 const SCEV *BaseSCEV;
118 const SCEV *BasePtrStartSCEV,
130 void addOneCandidate(Instruction *MemI, const SCEV *LSCEV,
216 void PPCLoopPreIncPrep::addOneCandidate(Instruction *MemI, const SCEV *LSCEV,
224 const SCEV *Diff = SE->getMinusSCEV(LSCEV, B.BaseSCEV);
269 const SCEV *LSCEV = SE->getSCEVAtScope(PtrValue, L);
311 const SCEV *Offset = BucketChain.Elements[j].Offset;
348 const SCEV *BasePtrStartSCEV = BasePtrSCEV->getStart();
491 const SCEV *BasePtrStartSCEV,
513 const SCEV *PHISCEV = SE->getSCEVAtScope(CurrentPHINode, L);
581 const SCEV *LSCEV = SE->getSCEVAtScope(const_cast<Value *>(PtrValue), L);
lib/Target/X86/X86TargetTransformInfo.cpp 2508 const SCEV *Ptr) {
lib/Target/X86/X86TargetTransformInfo.h 144 const SCEV *Ptr);
lib/Transforms/Scalar/AlignmentFromAssumptions.cpp 92 static unsigned getNewAlignmentDiff(const SCEV *DiffSCEV,
93 const SCEV *AlignSCEV,
96 const SCEV *DiffUnitsSCEV = SE->getURemExpr(DiffSCEV, AlignSCEV);
125 static unsigned getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV,
125 static unsigned getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV,
126 const SCEV *OffSCEV, Value *Ptr,
128 const SCEV *PtrSCEV = SE->getSCEV(Ptr);
129 const SCEV *DiffSCEV = SE->getMinusSCEV(PtrSCEV, AASCEV);
157 const SCEV *DiffStartSCEV = DiffARSCEV->getStart();
158 const SCEV *DiffIncSCEV = DiffARSCEV->getStepRecurrence(*SE);
199 const SCEV *&AlignSCEV,
200 const SCEV *&OffSCEV) {
214 const SCEV *CmpLHSSCEV = SE->getSCEV(CmpLHS);
215 const SCEV *CmpRHSSCEV = SE->getSCEV(CmpRHS);
229 const SCEV *AndLHSSCEV = SE->getSCEV(AndLHS);
230 const SCEV *AndRHSSCEV = SE->getSCEV(AndRHS);
293 const SCEV *AlignSCEV, *OffSCEV;
302 const SCEV *AASCEV = SE->getSCEV(AAPtr);
lib/Transforms/Scalar/IndVarSimplify.cpp 163 const SCEV *ExitCount,
218 const SCEV *FromBase = SE->getPointerBase(SE->getSCEV(FromPtr));
219 const SCEV *ToBase = SE->getPointerBase(SE->getSCEV(ToPtr));
643 const SCEV *ExitValue = SE->getSCEVAtScope(Inst, L->getParentLoop());
651 const SCEV *ExitCount = SE->getExitCount(L, PN->getIncomingBlock(i));
983 const SCEV *WideIncExpr = nullptr;
1056 const SCEV *getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
1056 const SCEV *getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
1056 const SCEV *getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
1159 const SCEV *WideLHS;
1160 const SCEV *WideRHS;
1170 const SCEV *NarrowRHS = SE->getSCEV(NarrowUse->getOperand(1));
1173 const SCEV *NarrowLHS = SE->getSCEV(NarrowUse->getOperand(0));
1179 const SCEV *WideUse = nullptr;
1237 const SCEV *WidenIV::getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
1237 const SCEV *WidenIV::getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
1237 const SCEV *WidenIV::getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
1268 const SCEV *ExtendOperExpr = nullptr;
1286 const SCEV *lhs = SE->getSCEV(DU.WideDef);
1287 const SCEV *rhs = ExtendOperExpr;
1311 const SCEV *NarrowExpr = SE->getSCEV(DU.NarrowUse);
1319 const SCEV *WideExpr;
1432 const SCEV *ExtendOperExpr = nullptr;
1452 const SCEV *Op1 = SE->getSCEV(WideDef);
1694 const SCEV *NarrowSCEV = SE->getSCEV(NarrowDef);
1732 const SCEV *WideIVExpr = getExtendKind(OrigPhi) == SignExtended
2231 const SCEV *Step = dyn_cast<SCEVConstant>(AR->getStepRecurrence(*SE));
2248 const SCEV *BECount,
2256 const SCEV *BestInit = nullptr;
2303 const SCEV *Init = AR->getStart();
2332 const SCEV *ExitCount, bool UsePostInc, Loop *L,
2336 const SCEV *IVInit = AR->getStart();
2351 const SCEV *IVOffset = SE->getTruncateOrZeroExtend(ExitCount, OfsTy);
2366 const SCEV *IVLimit = SE->getAddExpr(IVInit, IVOffset);
2398 const SCEV *IVLimit = SE->getAddExpr(IVInit, ExitCount);
2423 const SCEV *ExitCount,
2510 const SCEV *IV = SE->getSCEV(CmpIndVar);
2511 const SCEV *TruncatedIV = SE->getTruncateExpr(SE->getSCEV(CmpIndVar),
2513 const SCEV *ZExtTrunc =
2521 const SCEV *SExtTrunc =
2656 static const SCEV* getMaxBackedgeTakenCount(ScalarEvolution &SE,
2664 SmallVector<const SCEV*, 4> ExitCounts;
2666 const SCEV *ExitCount = SE.getExitCount(L, ExitingBB);
2704 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
2715 const SCEV *MaxExitCount = getMaxBackedgeTakenCount(*SE, *DT, L);
2749 SmallSet<const SCEV*, 8> DominatingExitCounts;
2751 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
2831 const SCEV *ExactBTC = SE->getBackedgeTakenCount(L);
2861 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
2940 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
2999 const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L);
3053 const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
3124 const SCEV *NewBECount = SE->getBackedgeTakenCount(L);
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp 141 const SCEV *Begin = nullptr;
142 const SCEV *Step = nullptr;
143 const SCEV *End = nullptr;
157 const SCEV *getBegin() const { return Begin; }
158 const SCEV *getStep() const { return Step; }
159 const SCEV *getEnd() const { return End; }
186 const SCEV *Begin;
187 const SCEV *End;
190 Range(const SCEV *Begin, const SCEV *End) : Begin(Begin), End(End) {
190 Range(const SCEV *Begin, const SCEV *End) : Begin(Begin), End(End) {
195 const SCEV *getBegin() const { return Begin; }
196 const SCEV *getEnd() const { return End; }
368 const SCEV *End = nullptr;
378 const SCEV *SIntMax = SE.getConstant(APInt::getSignedMaxValue(BitWidth));
535 Optional<const SCEV *> LowLimit;
536 Optional<const SCEV *> HighLimit;
611 const SCEV *LatchTakenCount = nullptr;
642 static bool isSafeDecreasingBound(const SCEV *Start,
643 const SCEV *BoundSCEV, const SCEV *Step,
643 const SCEV *BoundSCEV, const SCEV *Step,
676 const SCEV *StepPlusOne = SE.getAddExpr(Step, SE.getOne(Step->getType()));
680 const SCEV *Limit = SE.getMinusSCEV(SE.getConstant(Min), StepPlusOne);
682 const SCEV *MinusOne =
692 static bool isSafeIncreasingBound(const SCEV *Start,
693 const SCEV *BoundSCEV, const SCEV *Step,
693 const SCEV *BoundSCEV, const SCEV *Step,
723 const SCEV *StepMinusOne =
728 const SCEV *Limit = SE.getMinusSCEV(SE.getConstant(Max), StepMinusOne);
788 const SCEV *LatchCount = SE.getExitCount(&L, Latch);
796 const SCEV *LeftSCEV = SE.getSCEV(LeftValue);
800 const SCEV *RightSCEV = SE.getSCEV(RightValue);
815 if (AR->getNoWrapFlags(SCEV::FlagNSW))
825 const SCEV *ExtendedStart = SE.getSignExtendExpr(AR->getStart(), WideTy);
826 const SCEV *ExtendedStep =
837 return AR->getNoWrapFlags(SCEV::FlagNSW) != SCEV::FlagAnyWrap;
837 return AR->getNoWrapFlags(SCEV::FlagNSW) != SCEV::FlagAnyWrap;
848 const SCEV* StepRec = IndVarBase->getStepRecurrence(SE);
863 const SCEV *StartNext = IndVarBase->getStart();
864 const SCEV *Addend = SE.getNegativeSCEV(IndVarBase->getStepRecurrence(SE));
865 const SCEV *IndVarStart = SE.getAddExpr(StartNext, Addend);
866 const SCEV *Step = SE.getSCEV(StepCI);
891 if (IndVarBase->getNoWrapFlags(SCEV::FlagNUW) &&
956 if (IndVarBase->getNoWrapFlags(SCEV::FlagNUW) &&
1041 static const SCEV *NoopOrExtend(const SCEV *S, Type *Ty, ScalarEvolution &SE,
1041 static const SCEV *NoopOrExtend(const SCEV *S, Type *Ty, ScalarEvolution &SE,
1063 const SCEV *Start = NoopOrExtend(SE.getSCEV(MainLoopStructure.IndVarStart),
1065 const SCEV *End = NoopOrExtend(SE.getSCEV(MainLoopStructure.LoopExitAt), RTy,
1074 const SCEV *Smallest = nullptr, *Greatest = nullptr, *GreatestSeen = nullptr;
1076 const SCEV *One = SE.getOne(RTy);
1426 const SCEV *ExitPreLoopAtSCEV = nullptr;
1453 const SCEV *ExitMainLoopAtSCEV = nullptr;
1598 const SCEV *A = NoopOrExtend(IndVar->getStart(), RCType, SE, IsLatchSigned);
1605 const SCEV *C = getBegin();
1612 const SCEV *SIntMax = SE.getConstant(APInt::getSignedMaxValue(BitWidth));
1642 const SCEV *XMinusSIntMax = SE.getMinusSCEV(X, SIntMax);
1644 SCEV::FlagNSW);
1656 return SE.getMinusSCEV(X, SE.getSMinExpr(X, Y), SCEV::FlagNUW);
1658 const SCEV *M = SE.getMinusSCEV(C, A);
1659 const SCEV *Zero = SE.getZero(M->getType());
1664 const SCEV *One = SE.getOne(X->getType());
1672 const SCEV *NegOne = SE.getNegativeSCEV(One);
1683 const SCEV *REnd = getEnd();
1684 const SCEV *EndIsNonNegative = SCEVCheckNonNegative(REnd);
1686 const SCEV *Begin = SE.getMulExpr(ClampedSubtract(Zero, M), EndIsNonNegative);
1687 const SCEV *End = SE.getMulExpr(ClampedSubtract(REnd, M), EndIsNonNegative);
1710 const SCEV *NewBegin = SE.getSMaxExpr(R1Value.getBegin(), R2.getBegin());
1711 const SCEV *NewEnd = SE.getSMinExpr(R1Value.getEnd(), R2.getEnd());
1739 const SCEV *NewBegin = SE.getUMaxExpr(R1Value.getBegin(), R2.getBegin());
1740 const SCEV *NewEnd = SE.getUMinExpr(R1Value.getEnd(), R2.getEnd());
lib/Transforms/Scalar/LoopDataPrefetch.cpp 272 const SCEV *LSCEV = SE->getSCEV(PtrValue);
287 const SCEV *PtrDiff = SE->getMinusSCEV(LSCEVAddRec, PrefLoad.second);
300 const SCEV *NextLSCEV = SE->getAddExpr(LSCEVAddRec, SE->getMulExpr(
lib/Transforms/Scalar/LoopDeletion.cpp 194 const SCEV *S = SE.getConstantMaxBackedgeTakenCount(L);
lib/Transforms/Scalar/LoopFuse.cpp 669 const SCEV *TripCount0 = SE.getBackedgeTakenCount(FC0.L);
676 const SCEV *TripCount1 = SE.getBackedgeTakenCount(FC1.L);
846 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) {
848 SmallVector<const SCEV *, 2> Operands;
863 for (const SCEV *Op : Expr->operands())
884 const SCEV *SCEVPtr0 = SE.getSCEVAtScope(Ptr0, &L0);
885 const SCEV *SCEVPtr1 = SE.getSCEVAtScope(Ptr1, &L1);
lib/Transforms/Scalar/LoopIdiomRecognize.cpp 193 bool runOnLoopBlock(BasicBlock *BB, const SCEV *BECount,
199 bool processLoopStores(SmallVectorImpl<StoreInst *> &SL, const SCEV *BECount,
201 bool processLoopMemSet(MemSetInst *MSI, const SCEV *BECount);
207 const SCEVAddRecExpr *Ev, const SCEV *BECount,
209 bool processLoopStoreOfLoopLoad(StoreInst *SI, const SCEV *BECount);
234 const SCEV *&SrcA, const SCEV *&SrcB,
234 const SCEV *&SrcA, const SCEV *&SrcB,
235 const SCEV *&Iterations) const;
237 LoadInst *&LoadA, LoadInst *&LoadB, const SCEV *&SrcA,
238 const SCEV *&SrcB, const SCEV *&NBytes) const;
238 const SCEV *&SrcB, const SCEV *&NBytes) const;
241 LoadInst *LoadA, LoadInst *LoadB, const SCEV *SrcA,
242 const SCEV *SrcB, const SCEV *NBytes);
242 const SCEV *SrcB, const SCEV *NBytes);
383 const SCEV *BECount = SE->getBackedgeTakenCount(CurLoop);
616 BasicBlock *BB, const SCEV *BECount,
664 const SCEV *BECount, ForMemset For) {
807 const SCEV *BECount) {
859 const SCEV *BECount, unsigned StoreSize,
893 static const SCEV *getStartForNegStride(const SCEV *Start, const SCEV *BECount,
893 static const SCEV *getStartForNegStride(const SCEV *Start, const SCEV *BECount,
893 static const SCEV *getStartForNegStride(const SCEV *Start, const SCEV *BECount,
896 const SCEV *Index = SE->getTruncateOrZeroExtend(BECount, IntPtr);
899 SCEV::FlagNUW);
907 static const SCEV *getNumBytes(const SCEV *BECount, Type *IntPtr,
907 static const SCEV *getNumBytes(const SCEV *BECount, Type *IntPtr,
910 const SCEV *NumBytesS;
923 SE->getAddExpr(BECount, SE->getOne(BECount->getType()), SCEV::FlagNUW),
927 SE->getOne(IntPtr), SCEV::FlagNUW);
933 SCEV::FlagNUW);
944 const SCEV *BECount, bool NegStride, bool IsLoopMemset) {
965 const SCEV *Start = Ev->getStart();
995 const SCEV *NumBytesS =
1056 const SCEV *BECount) {
1082 const SCEV *StrStart = StoreEv->getStart();
1109 const SCEV *LdStart = LoadEv->getStart();
1135 const SCEV *NumBytesS =
2035 const SCEV *&SrcA,
2036 const SCEV *&SrcB,
2037 const SCEV *&Iterations) const {
2052 const SCEV *RecStepForA = ScevForSrcA->getStepRecurrence(*SE);
2053 const SCEV *RecStepForB = ScevForSrcB->getStepRecurrence(*SE);
2090 const SCEV *LoopExitCount =
2107 LoopExitCount, SE->getOne(LoopExitCount->getType()), SCEV::FlagNUW);
2128 const SCEV *&SrcA, const SCEV *&SrcB,
2128 const SCEV *&SrcA, const SCEV *&SrcB,
2129 const SCEV *&NBytes) const {
2177 const SCEV *Iterations;
2194 Iterations, SE->getConstant(CmpFuncSizeTy, BCmpTyBytes), SCEV::FlagNUW);
2594 const SCEV *SrcA, const SCEV *SrcB,
2594 const SCEV *SrcA, const SCEV *SrcB,
2595 const SCEV *NBytes) {
2686 const SCEV *SrcA, *SrcB, *NBytes;
lib/Transforms/Scalar/LoopInterchange.cpp 135 const SCEV *Distance = D->getDistance(II);
311 const SCEV *Step = AddRec->getStepRecurrence(*SE);
467 const SCEV *ExitCountOuter = SE->getBackedgeTakenCount(L);
1039 const SCEV *OperandVal = SE->getSCEV(GEP->getOperand(i));
lib/Transforms/Scalar/LoopPredication.cpp 238 const SCEV *Limit;
240 const SCEV *Limit)
259 bool isSupportedStep(const SCEV* Step);
272 Instruction *findInsertPt(Instruction *User, ArrayRef<const SCEV*> Ops);
277 bool isLoopInvariantValue(const SCEV* S);
280 ICmpInst::Predicate Pred, const SCEV *LHS,
281 const SCEV *RHS);
368 const SCEV *LHSS = SE->getSCEV(LHS);
371 const SCEV *RHSS = SE->getSCEV(RHS);
391 ICmpInst::Predicate Pred, const SCEV *LHS,
392 const SCEV *RHS) {
490 bool LoopPredication::isSupportedStep(const SCEV* Step) {
503 ArrayRef<const SCEV*> Ops) {
507 for (const SCEV *Op : Ops)
514 bool LoopPredication::isLoopInvariantValue(const SCEV* S) {
561 const SCEV *GuardStart = RangeCheck.IV->getStart();
562 const SCEV *GuardLimit = RangeCheck.Limit;
563 const SCEV *LatchStart = LatchCheck.IV->getStart();
564 const SCEV *LatchLimit = LatchCheck.Limit;
582 const SCEV *RHS =
604 const SCEV *GuardStart = RangeCheck.IV->getStart();
605 const SCEV *GuardLimit = RangeCheck.Limit;
606 const SCEV *LatchStart = LatchCheck.IV->getStart();
607 const SCEV *LatchLimit = LatchCheck.Limit;
lib/Transforms/Scalar/LoopRerollPass.cpp 397 void replace(const SCEV *BackedgeTakenCount);
427 void replaceIV(DAGRootSet &DRS, const SCEV *Start, const SCEV *IncrExpr);
427 void replaceIV(DAGRootSet &DRS, const SCEV *Start, const SCEV *IncrExpr);
481 const SCEV *BackedgeTakenCount, ReductionTracker &Reductions);
897 const SCEV *StepSCEV = SE->getMinusSCEV(SE->getSCEV(DRS.Roots[0]), ADR);
898 const SCEV *ScaleSCEV = SE->getConstant(StepSCEV->getType(), N);
904 const SCEV *NewStepSCEV = SE->getMinusSCEV(SE->getSCEV(DRS.Roots[i]),
1420 void LoopReroll::DAGRootTracker::replace(const SCEV *BackedgeTakenCount) {
1425 SmallVector<const SCEV *, 8> StartExprs;
1426 SmallVector<const SCEV *, 8> IncrExprs;
1458 auto NewIVSCEV = SE->getAddRecExpr(Zero, One, L, SCEV::FlagAnyWrap);
1483 const SCEV *Start,
1484 const SCEV *IncrExpr) {
1488 const SCEV *NewIVSCEV =
1489 SE->getAddRecExpr(Start, IncrExpr, L, SCEV::FlagAnyWrap);
1616 const SCEV *BackedgeTakenCount,
1664 const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L);
lib/Transforms/Scalar/LoopStrengthReduce.cpp 234 using RegUsesTy = DenseMap<const SCEV *, RegSortData>;
237 SmallVector<const SCEV *, 16> RegSequence;
240 void countRegister(const SCEV *Reg, size_t LUIdx);
241 void dropRegister(const SCEV *Reg, size_t LUIdx);
244 bool isRegUsedByUsesOtherThan(const SCEV *Reg, size_t LUIdx) const;
246 const SmallBitVector &getUsedByIndices(const SCEV *Reg) const;
250 using iterator = SmallVectorImpl<const SCEV *>::iterator;
251 using const_iterator = SmallVectorImpl<const SCEV *>::const_iterator;
262 RegUseTracker::countRegister(const SCEV *Reg, size_t LUIdx) {
273 RegUseTracker::dropRegister(const SCEV *Reg, size_t LUIdx) {
297 RegUseTracker::isRegUsedByUsesOtherThan(const SCEV *Reg, size_t LUIdx) const {
308 const SmallBitVector &RegUseTracker::getUsedByIndices(const SCEV *Reg) const {
350 SmallVector<const SCEV *, 4> BaseRegs;
354 const SCEV *ScaledReg = nullptr;
363 void initialMatch(const SCEV *S, Loop *L, ScalarEvolution &SE);
376 void deleteBaseReg(const SCEV *&S);
378 bool referencesReg(const SCEV *S) const;
389 static void DoInitialMatch(const SCEV *S, Loop *L,
390 SmallVectorImpl<const SCEV *> &Good,
391 SmallVectorImpl<const SCEV *> &Bad,
401 for (const SCEV *S : Add->operands())
413 AR->getLoop(), SCEV::FlagAnyWrap),
421 SmallVector<const SCEV *, 4> Ops(Mul->op_begin()+1, Mul->op_end());
422 const SCEV *NewMul = SE.getMulExpr(Ops);
424 SmallVector<const SCEV *, 4> MyGood;
425 SmallVector<const SCEV *, 4> MyBad;
427 const SCEV *NegOne = SE.getSCEV(ConstantInt::getAllOnesValue(
429 for (const SCEV *S : MyGood)
431 for (const SCEV *S : MyBad)
443 void Formula::initialMatch(const SCEV *S, Loop *L, ScalarEvolution &SE) {
444 SmallVector<const SCEV *, 4> Good;
445 SmallVector<const SCEV *, 4> Bad;
448 const SCEV *Sum = SE.getAddExpr(Good);
454 const SCEV *Sum = SE.getAddExpr(Bad);
562 void Formula::deleteBaseReg(const SCEV *&S) {
569 bool Formula::referencesReg(const SCEV *S) const {
580 for (const SCEV *BaseReg : BaseRegs)
597 for (const SCEV *BaseReg : BaseRegs) {
658 static const SCEV *getExactSDiv(const SCEV *LHS, const SCEV *RHS,
658 static const SCEV *getExactSDiv(const SCEV *LHS, const SCEV *RHS,
658 static const SCEV *getExactSDiv(const SCEV *LHS, const SCEV *RHS,
692 const SCEV *Step = getExactSDiv(AR->getStepRecurrence(SE), RHS, SE,
695 const SCEV *Start = getExactSDiv(AR->getStart(), RHS, SE,
701 return SE.getAddRecExpr(Start, Step, AR->getLoop(), SCEV::FlagAnyWrap);
709 SmallVector<const SCEV *, 8> Ops;
710 for (const SCEV *S : Add->operands()) {
711 const SCEV *Op = getExactSDiv(S, RHS, SE, IgnoreSignificantBits);
723 SmallVector<const SCEV *, 4> Ops;
725 for (const SCEV *S : Mul->operands()) {
727 if (const SCEV *Q = getExactSDiv(S, RHS, SE,
745 static int64_t ExtractImmediate(const SCEV *&S, ScalarEvolution &SE) {
752 SmallVector<const SCEV *, 8> NewOps(Add->op_begin(), Add->op_end());
758 SmallVector<const SCEV *, 8> NewOps(AR->op_begin(), AR->op_end());
763 SCEV::FlagAnyWrap);
771 static GlobalValue *ExtractSymbol(const SCEV *&S, ScalarEvolution &SE) {
778 SmallVector<const SCEV *, 8> NewOps(Add->op_begin(), Add->op_end());
784 SmallVector<const SCEV *, 8> NewOps(AR->op_begin(), AR->op_end());
789 SCEV::FlagAnyWrap);
903 static bool isHighCostExpansion(const SCEV *S,
904 SmallPtrSetImpl<const SCEV*> &Processed,
926 for (const SCEV *S : Add->operands()) {
1057 SmallPtrSetImpl<const SCEV *> &Regs,
1058 const DenseSet<const SCEV *> &VisitedRegs,
1060 SmallPtrSetImpl<const SCEV *> *LoserRegs = nullptr);
1066 void RateRegister(const Formula &F, const SCEV *Reg,
1067 SmallPtrSetImpl<const SCEV *> &Regs);
1068 void RatePrimaryRegister(const Formula &F, const SCEV *Reg,
1069 SmallPtrSetImpl<const SCEV *> &Regs,
1070 SmallPtrSetImpl<const SCEV *> *LoserRegs);
1104 static SmallVector<const SCEV *, 4> getEmptyKey() {
1105 SmallVector<const SCEV *, 4> V;
1110 static SmallVector<const SCEV *, 4> getTombstoneKey() {
1111 SmallVector<const SCEV *, 4> V;
1116 static unsigned getHashValue(const SmallVector<const SCEV *, 4> &V) {
1120 static bool isEqual(const SmallVector<const SCEV *, 4> &LHS,
1132 DenseSet<SmallVector<const SCEV *, 4>, UniquifierDenseMapInfo> Uniquifier;
1145 using SCEVUseKindPair = PointerIntPair<const SCEV *, 2, KindType>;
1180 SmallPtrSet<const SCEV *, 4> Regs;
1198 float getNotSelectedProbability(const SCEV *Reg) const;
1215 static unsigned getSetupCost(const SCEV *Reg, unsigned Depth) {
1236 void Cost::RateRegister(const Formula &F, const SCEV *Reg,
1237 SmallPtrSetImpl<const SCEV *> &Regs) {
1272 const SCEV *LoopStep = AR->getStepRecurrence(*SE);
1274 const SCEV *LoopStart = AR->getStart();
1308 void Cost::RatePrimaryRegister(const Formula &F, const SCEV *Reg,
1309 SmallPtrSetImpl<const SCEV *> &Regs,
1310 SmallPtrSetImpl<const SCEV *> *LoserRegs) {
1323 SmallPtrSetImpl<const SCEV *> &Regs,
1324 const DenseSet<const SCEV *> &VisitedRegs,
1326 SmallPtrSetImpl<const SCEV *> *LoserRegs) {
1332 if (const SCEV *ScaledReg = F.ScaledReg) {
1341 for (const SCEV *BaseReg : F.BaseRegs) {
1515 SmallVector<const SCEV *, 4> Key = F.BaseRegs;
1523 float LSRUse::getNotSelectedProbability(const SCEV *Reg) const {
1539 SmallVector<const SCEV *, 4> Key = F.BaseRegs;
1551 for (const SCEV *BaseReg : F.BaseRegs)
1576 SmallPtrSet<const SCEV *, 4> OldRegs = std::move(Regs);
1584 for (const SCEV *S : OldRegs)
1820 MemAccessTy AccessTy, const SCEV *S,
1858 const SCEV *IncExpr;
1860 IVInc(Instruction *U, Value *O, const SCEV *E)
1868 const SCEV *ExprBase = nullptr;
1871 IVChain(const IVInc &Head, const SCEV *Base)
1895 bool isProfitableIncrement(const SCEV *OperExpr,
1896 const SCEV *IncExpr,
1977 std::pair<size_t, int64_t> getUse(const SCEV *&Expr, LSRUse::KindType Kind,
1984 void InsertInitialFormula(const SCEV *S, LSRUse &LU, size_t LUIdx);
1985 void InsertSupplementalFormula(const SCEV *S, LSRUse &LU, size_t LUIdx);
2028 const SmallPtrSet<const SCEV *, 16> &CurRegs,
2071 const SCEV *BackedgeTakenCount = SE.getBackedgeTakenCount(L);
2256 const SCEV *BackedgeTakenCount = SE.getBackedgeTakenCount(L);
2259 const SCEV *One = SE.getConstant(BackedgeTakenCount->getType(), 1);
2262 const SCEV *IterationCount = SE.getAddExpr(One, BackedgeTakenCount);
2289 const SCEV *MaxLHS = Max->getOperand(0);
2290 const SCEV *MaxRHS = Max->getOperand(1);
2300 const SCEV *IV = SE.getSCEV(Cond->getOperand(0));
2428 const SCEV *A = IU.getStride(*CondUse, L);
2429 const SCEV *B = IU.getStride(*UI, L);
2564 std::pair<size_t, int64_t> LSRInstance::getUse(const SCEV *&Expr,
2567 const SCEV *Copy = Expr;
2652 SmallSetVector<const SCEV *, 4> Strides;
2655 SmallVector<const SCEV *, 4> Worklist;
2657 const SCEV *Expr = IU.getExpr(U);
2665 const SCEV *S = Worklist.pop_back_val();
2677 for (SmallSetVector<const SCEV *, 4>::const_iterator
2679 for (SmallSetVector<const SCEV *, 4>::const_iterator NewStrideIter =
2681 const SCEV *OldStride = *I;
2682 const SCEV *NewStride = *NewStrideIter;
2765 static const SCEV *getExprBase(const SCEV *S) {
2765 static const SCEV *getExprBase(const SCEV *S) {
2784 const SCEV *SubExpr = *I;
2803 bool IVChain::isProfitableIncrement(const SCEV *OperExpr,
2804 const SCEV *IncExpr,
2813 const SCEV *HeadExpr = SE.getSCEV(getWideOperand(Incs[0].IVOperand));
2818 SmallPtrSet<const SCEV*, 8> Processed;
2859 const SCEV *LastIncExpr = nullptr;
2909 const SCEV *const OperExpr = SE.getSCEV(NextIV);
2910 const SCEV *const OperExprBase = getExprBase(OperExpr);
2915 const SCEV *LastIncExpr = nullptr;
2935 const SCEV *PrevExpr = SE.getSCEV(PrevIV);
2936 const SCEV *IncExpr = SE.getMinusSCEV(OperExpr, PrevExpr);
3118 static bool canFoldIVIncExpr(const SCEV *IncExpr, Instruction *UserInst,
3175 const SCEV *LeftOverExpr = nullptr;
3187 const SCEV *IncExpr = SE.getNoopOrSignExtend(Inc.IncExpr, IntTy);
3195 const SCEV *IVOperExpr = SE.getAddExpr(SE.getUnknown(IVSrc),
3262 const SCEV *S = IU.getExpr(U);
3288 const SCEV *N = SE.getSCEV(NV);
3338 LSRInstance::InsertInitialFormula(const SCEV *S, LSRUse &LU, size_t LUIdx) {
3352 LSRInstance::InsertSupplementalFormula(const SCEV *S,
3365 for (const SCEV *BaseReg : F.BaseRegs)
3390 SmallVector<const SCEV *, 8> Worklist(RegUses.begin(), RegUses.end());
3391 SmallPtrSet<const SCEV *, 32> Visited;
3394 const SCEV *S = Worklist.pop_back_val();
3440 const SCEV *UserS = SE.getSCEV(const_cast<Instruction *>(UserInst));
3485 static const SCEV *CollectSubexprs(const SCEV *S, const SCEVConstant *C,
3485 static const SCEV *CollectSubexprs(const SCEV *S, const SCEVConstant *C,
3486 SmallVectorImpl<const SCEV *> &Ops,
3496 for (const SCEV *S : Add->operands()) {
3497 const SCEV *Remainder = CollectSubexprs(S, C, Ops, L, SE, Depth+1);
3507 const SCEV *Remainder = CollectSubexprs(AR->getStart(),
3522 SCEV::FlagAnyWrap);
3531 const SCEV *Remainder =
3544 LSRUse &LU, const SCEV *S, const Loop *L,
3552 const SCEV *LoopStep = AR->getStepRecurrence(SE);
3561 const SCEV *LoopStart = AR->getStart();
3573 const SCEV *BaseReg = IsScaledReg ? Base.ScaledReg : Base.BaseRegs[Idx];
3580 SmallVector<const SCEV *, 8> AddOps;
3581 const SCEV *Remainder = CollectSubexprs(BaseReg, nullptr, AddOps, L, SE);
3588 for (SmallVectorImpl<const SCEV *>::const_iterator J = AddOps.begin(),
3603 SmallVector<const SCEV *, 8> InnerAddOps(
3615 const SCEV *InnerSum = SE.getAddExpr(InnerAddOps);
3689 SmallVector<const SCEV *, 4> Ops;
3693 for (const SCEV *BaseReg : Base.BaseRegs) {
3726 SmallVector<const SCEV *, 4> OpsCopy(Ops); // Don't let SE modify Ops.
3745 const SCEV *G = IsScaledReg ? Base.ScaledReg : Base.BaseRegs[Idx];
3785 const SCEV *NewG = SE.getAddExpr(SE.getConstant(G->getType(), Offset), G);
3803 const SCEV *G = IsScaledReg ? Base.ScaledReg : Base.BaseRegs[Idx];
3879 for (const SCEV *BaseReg : Base.BaseRegs)
3919 const SCEV *FactorS = SE.getConstant(IntTy, Factor);
3995 const SCEV *FactorS = SE.getConstant(IntTy, Factor);
4000 if (const SCEV *Quotient = getExactSDiv(AR, FactorS, SE, true)) {
4041 const SCEV *NewScaledReg = SE.getAnyExtendExpr(F.ScaledReg, SrcTy);
4047 for (const SCEV *&BaseReg : F.BaseRegs) {
4048 const SCEV *NewBaseReg = SE.getAnyExtendExpr(BaseReg, SrcTy);
4077 const SCEV *OrigReg;
4079 WorkItem(size_t LI, int64_t I, const SCEV *R)
4103 using ImmMapTy = std::map<int64_t, const SCEV *>;
4105 DenseMap<const SCEV *, ImmMapTy> Map;
4106 DenseMap<const SCEV *, SmallBitVector> UsedByIndicesMap;
4107 SmallVector<const SCEV *, 8> Sequence;
4108 for (const SCEV *Use : RegUses) {
4109 const SCEV *Reg = Use; // Make a copy for ExtractImmediate to modify.
4123 for (const SCEV *Reg : Sequence) {
4139 const SCEV *OrigReg = J->second;
4188 const SCEV *OrigReg = WI.OrigReg;
4191 const SCEV *NegImmS = SE.getSCEV(ConstantInt::get(IntTy, -(uint64_t)Imm));
4231 const SCEV *BaseReg = F.BaseRegs[N];
4251 for (const SCEV *NewReg : NewF.BaseRegs)
4310 DenseSet<const SCEV *> VisitedRegs;
4311 SmallPtrSet<const SCEV *, 16> Regs;
4312 SmallPtrSet<const SCEV *, 16> LoserRegs;
4320 DenseMap<SmallVector<const SCEV *, 4>, size_t, UniquifierDenseMapInfo>;
4355 SmallVector<const SCEV *, 4> Key;
4356 for (const SCEV *Reg : F.BaseRegs) {
4445 for (SmallVectorImpl<const SCEV *>::const_iterator
4592 using BestFormulaeTy = DenseMap<std::pair<const SCEV *, int64_t>, size_t>;
4598 DenseSet<const SCEV *> VisitedRegs;
4599 SmallPtrSet<const SCEV *, 16> Regs;
4613 for (const SCEV *Reg : FA.BaseRegs) {
4618 for (const SCEV *Reg : FB.BaseRegs) {
4726 SmallPtrSet<const SCEV *, 4> UniqRegs;
4730 DenseMap <const SCEV *, float> RegNumMap;
4731 for (const SCEV *Reg : RegUses) {
4766 for (const SCEV *BaseReg : F.BaseRegs) {
4774 if (const SCEV *ScaledReg = F.ScaledReg) {
4817 SmallPtrSet<const SCEV *, 4> Taken;
4825 const SCEV *Best = nullptr;
4827 for (const SCEV *Reg : RegUses) {
4896 const SmallPtrSet<const SCEV *, 16> &CurRegs,
4914 SmallSetVector<const SCEV *, 4> ReqRegs;
4915 for (const SCEV *S : CurRegs)
4919 SmallPtrSet<const SCEV *, 16> NewRegs;
4926 for (const SCEV *Reg : ReqRegs) {
4974 SmallPtrSet<const SCEV *, 16> CurRegs;
4975 DenseSet<const SCEV *> VisitedRegs;
5157 SmallVector<const SCEV *, 8> Ops;
5160 for (const SCEV *Reg : F.BaseRegs) {
5171 const SCEV *ScaledS = F.ScaledReg;
5257 const SCEV *FullS = Ops.empty() ?
lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp 261 const SCEV *LSCEV = SE.getSCEVAtScope(V, L);
lib/Transforms/Scalar/LoopVersioningLICM.cpp 255 const SCEV *ExitCount = SE->getBackedgeTakenCount(CurLoop);
lib/Transforms/Scalar/NaryReassociate.cpp 237 const SCEV *OldSCEV = SE->getSCEV(&*I);
257 const SCEV *NewSCEV = SE->getSCEV(&*I);
371 SmallVector<const SCEV *, 4> IndexExprs;
386 const SCEV *CandidateExpr = SE->getGEPExpr(cast<GEPOperator>(GEP),
456 const SCEV *AExpr = SE->getSCEV(A), *BExpr = SE->getSCEV(B);
457 const SCEV *RHSExpr = SE->getSCEV(RHS);
472 Instruction *NaryReassociatePass::tryReassociatedBinaryOp(const SCEV *LHSExpr,
509 const SCEV *NaryReassociatePass::getBinarySCEV(BinaryOperator *I,
510 const SCEV *LHS,
511 const SCEV *RHS) {
524 NaryReassociatePass::findClosestMatchingDominator(const SCEV *CandidateExpr,
lib/Transforms/Scalar/PlaceSafepoints.cpp 243 const SCEV *MaxTrips = SE->getConstantMaxBackedgeTakenCount(L);
255 const SCEV *MaxExec = SE->getExitCount(L, Pred);
lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp 433 Instruction *findClosestMatchingDominator(const SCEV *Key,
458 DenseMap<const SCEV *, SmallVector<Instruction *, 2>> DominatingExprs;
1143 const SCEV *Key, Instruction *Dominatee) {
1174 const SCEV *Key =
1190 const SCEV *Key =
lib/Transforms/Scalar/StraightLineStrengthReduce.cpp 110 Candidate(Kind CT, const SCEV *B, ConstantInt *Idx, Value *S,
116 const SCEV *Base = nullptr;
204 void allocateCandidatesAndFindBasisForGEP(const SCEV *B, ConstantInt *Idx,
210 void allocateCandidatesAndFindBasis(Candidate::Kind CT, const SCEV *B,
220 void factorArrayIndex(Value *ArrayIdx, const SCEV *Base, uint64_t ElementSize,
282 static bool isAddFoldable(const SCEV *Base, ConstantInt *Index, Value *Stride,
336 Candidate::Kind CT, const SCEV *B, ConstantInt *Idx, Value *S,
470 const SCEV *B, ConstantInt *Idx, Value *S, uint64_t ElementSize,
483 const SCEV *Base,
523 SmallVector<const SCEV *, 4> IndexExprs;
532 const SCEV *OrigIndexExpr = IndexExprs[I - 1];
537 const SCEV *BaseExpr = SE->getGEPExpr(cast<GEPOperator>(GEP), IndexExprs);
lib/Transforms/Utils/LoopUnrollPeel.cpp 192 const SCEV *LeftSCEV = SE.getSCEV(LeftVal);
193 const SCEV *RightSCEV = SE.getSCEV(RightVal);
231 const SCEV *IterVal = LeftAR->evaluateAtIteration(
240 const SCEV *Step = LeftAR->getStepRecurrence(SE);
lib/Transforms/Utils/LoopUnrollRuntime.cpp 617 const SCEV *BECountSC = SE->getExitCount(L, Latch);
627 const SCEV *TripCountSC =
lib/Transforms/Utils/LoopUtils.cpp 728 const SCEV *InnerLoopBECountSC = SE.getExitCount(InnerLoop, InnerLoopLatch);
998 bool llvm::isKnownNegativeInLoop(const SCEV *S, const Loop *L,
1000 const SCEV *Zero = SE.getZero(S->getType());
1005 bool llvm::isKnownNonNegativeInLoop(const SCEV *S, const Loop *L,
1007 const SCEV *Zero = SE.getZero(S->getType());
1012 bool llvm::cannotBeMinInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE,
1023 bool llvm::cannotBeMaxInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE,
lib/Transforms/Utils/SimplifyIndVar.cpp 111 const SCEV *FoldedExpr = nullptr;
189 const SCEV *S = SE->getSCEVAtScope(ICmp->getOperand(IVOperIdx), ICmpLoop);
190 const SCEV *X = SE->getSCEVAtScope(ICmp->getOperand(1 - IVOperIdx), ICmpLoop);
193 const SCEV *InvariantLHS, *InvariantRHS;
206 SmallDenseMap<const SCEV*, Value*> CheapExpansions;
216 const SCEV *IncomingS = SE->getSCEV(Incoming);
259 const SCEV *S = SE->getSCEVAtScope(ICmp->getOperand(IVOperIdx), ICmpLoop);
260 const SCEV *X = SE->getSCEVAtScope(ICmp->getOperand(1 - IVOperIdx), ICmpLoop);
367 const SCEV *N = SE->getSCEV(NValue);
379 const SCEV *D = SE->getSCEV(DValue);
390 const auto *NLessOne = SE->getMinusSCEV(N, SE->getOne(T));
406 bool Signed, const SCEV *LHS, const SCEV *RHS) {
406 bool Signed, const SCEV *LHS, const SCEV *RHS) {
432 const SCEV *A =
433 (SE->*Extension)((SE->*Operation)(LHS, RHS, SCEV::FlagAnyWrap, 0),
435 const SCEV *B =
437 (SE->*Extension)(RHS, WideTy, 0), SCEV::FlagAnyWrap, 0);
442 const SCEV *LHS = SE->getSCEV(WO->getLHS());
443 const SCEV *RHS = SE->getSCEV(WO->getRHS());
482 const SCEV *LHS = SE->getSCEV(SI->getLHS());
483 const SCEV *RHS = SE->getSCEV(SI->getRHS());
519 const SCEV *IVSCEV = SE->getSCEV(IV);
520 const SCEV *TISCEV = SE->getSCEV(TI);
573 const SCEV *SCEVOP1 = SE->getSCEV(ICI->getOperand(0));
574 const SCEV *SCEVOP2 = SE->getSCEV(ICI->getOperand(1));
664 const SCEV *S = SE->getSCEV(I);
740 const SCEV *LHS = SE->getSCEV(BO->getOperand(0));
741 const SCEV *RHS = SE->getSCEV(BO->getOperand(1));
830 const SCEV *S = SE->getSCEV(I);
lib/Transforms/Vectorize/LoadStoreVectorizer.cpp 374 const SCEV *PtrSCEVA = SE.getSCEV(PtrA);
375 const SCEV *PtrSCEVB = SE.getSCEV(PtrB);
376 const SCEV *C = SE.getConstant(BaseDelta);
377 const SCEV *X = SE.getAddExpr(PtrSCEVA, C);
385 const SCEV *Dist = SE.getMinusSCEV(PtrSCEVB, PtrSCEVA);
479 const SCEV *OffsetSCEVA = SE.getSCEV(ValA);
480 const SCEV *OffsetSCEVB = SE.getSCEV(OpB);
481 const SCEV *C = SE.getConstant(IdxDiff.trunc(BitWidth));
482 const SCEV *X = SE.getAddExpr(OffsetSCEVA, C);
lib/Transforms/Vectorize/LoopVectorize.cpp 2562 const SCEV *BackedgeTakenCount = PSE.getBackedgeTakenCount();
2580 const SCEV *ExitCount = SE->getAddExpr(
5698 static const SCEV *getAddressAccessSCEV(
5740 const SCEV *PtrSCEV = getAddressAccessSCEV(Ptr, Legal, PSE, TheLoop);
6228 const SCEV *CondSCEV = SE->getSCEV(SI->getCondition());
lib/Transforms/Vectorize/SLPVectorizer.cpp 2445 const SCEV *Scev0 = SE->getSCEV(Ptr0);
2446 const SCEV *ScevN = SE->getSCEV(PtrN);
tools/polly/include/polly/CodeGen/IRBuilder.h 117 llvm::DenseMap<const llvm::SCEV *, llvm::MDNode *> SecondLevelAliasScopeMap;
120 llvm::DenseMap<const llvm::SCEV *, llvm::MDNode *>
tools/polly/include/polly/CodeGen/IslNodeBuilder.h 40 SetVector<const SCEV *> &SCEVs;
163 MapVector<const Loop *, const SCEV *> OutsideLoopIterations;
180 Value *generateSCEV(const SCEV *Expr);
291 SmallSet<std::pair<const SCEV *, Type *>, 16> PreloadedPtrs;
tools/polly/include/polly/ScopBuilder.h 197 const SCEV *SCEV_TestVal, const SCEV *SCEV_UpperBound,
197 const SCEV *SCEV_TestVal, const SCEV *SCEV_UpperBound,
290 const SCEV *E, bool NonNegative = false);
547 ArrayRef<const SCEV *> Subscripts,
548 ArrayRef<const SCEV *> Sizes, MemoryKind Kind);
567 ArrayRef<const SCEV *> Subscripts,
568 ArrayRef<const SCEV *> Sizes, Value *AccessValue);
tools/polly/include/polly/ScopDetection.h 66 using ParamSetType = std::set<const SCEV *>;
74 SmallVector<const SCEV *, 4> DelinearizedSizes;
86 SmallVector<const SCEV *, 4> DelinearizedSubscripts;
93 using PairInstSCEV = std::pair<const Instruction *, const SCEV *>;
96 using BaseToElSize = std::map<const SCEVUnknown *, const SCEV *>;
218 bool involvesMultiplePtrs(const SCEV *S0, const SCEV *S1, Loop *Scope) const;
218 bool involvesMultiplePtrs(const SCEV *S0, const SCEV *S1, Loop *Scope) const;
234 SmallVector<const SCEV *, 4>
247 SmallVectorImpl<const SCEV *> &Sizes,
381 bool isValidAccess(Instruction *Inst, const SCEV *AF, const SCEVUnknown *BP,
443 bool isAffine(const SCEV *S, Loop *Scope, DetectionContext &Context) const;
tools/polly/include/polly/ScopDetectionDiagnostic.h 373 const SCEV *LHS;
374 const SCEV *RHS;
378 ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS,
378 ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS,
383 const SCEV *lhs() { return LHS; }
384 const SCEV *rhs() { return RHS; }
468 const SCEV *AccessFunction;
474 ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst,
479 const SCEV *get() { return AccessFunction; }
527 const SCEV *LoopCount;
533 ReportLoopBound(Loop *L, const SCEV *LoopCount);
535 const SCEV *loopCount() { return LoopCount; }
tools/polly/include/polly/ScopInfo.h 203 using LoopBoundMapType = std::map<const Loop *, const SCEV *>;
225 ArrayRef<const SCEV *> DimensionSizes, MemoryKind Kind,
253 bool updateSizes(ArrayRef<const SCEV *> Sizes, bool CheckConsistency = true);
295 const SCEV *getDimensionSize(unsigned Dim) const {
416 SmallVector<const SCEV *, 4> DimensionSizes;
551 SmallVector<const SCEV *, 4> Sizes;
593 SmallVector<const SCEV *, 4> Subscripts;
722 ArrayRef<const SCEV *> Subscripts, ArrayRef<const SCEV *> Sizes,
722 ArrayRef<const SCEV *> Subscripts, ArrayRef<const SCEV *> Sizes,
901 const SCEV *getSubscript(unsigned Dim) const { return Subscripts[Dim]; }
906 isl::pw_aff getPwAff(const SCEV *E);
1121 const SCEV *IdentifyingPointer;
1668 __isl_keep isl_set *Domain, const SCEV *SCEV_TestVal,
1669 const SCEV *SCEV_UpperBound,
1777 DenseMap<const SCEV *, isl::id> ParameterIds;
1962 void createParameterId(const SCEV *Param);
2116 bool isParam(const SCEV *Param) const { return Parameters.count(Param); }
2184 isl::id getIdForParam(const SCEV *Parameter) const;
2487 ArrayRef<const SCEV *> Sizes,
2591 PWACtx getPwAff(const SCEV *E, BasicBlock *BB = nullptr,
2598 isl::pw_aff getPwAffOnly(const SCEV *E, BasicBlock *BB = nullptr);
2715 const SCEV *getRepresentingInvariantLoadSCEV(const SCEV *S) const;
2715 const SCEV *getRepresentingInvariantLoadSCEV(const SCEV *S) const;
tools/polly/include/polly/Support/SCEVAffinator.h 39 PWACtx getPwAff(const llvm::SCEV *E, llvm::BasicBlock *BB = nullptr);
55 using CacheKey = std::pair<const llvm::SCEV *, llvm::BasicBlock *>;
90 PWACtx checkForWrapping(const llvm::SCEV *Expr, PWACtx PWAC) const;
94 bool computeModuloForExpr(const llvm::SCEV *Expr);
96 PWACtx visit(const llvm::SCEV *E);
tools/polly/include/polly/Support/SCEVValidator.h 38 bool hasIVParams(const llvm::SCEV *Expr);
44 void findLoops(const llvm::SCEV *Expr,
53 void findValues(const llvm::SCEV *Expr, llvm::ScalarEvolution &SE,
64 bool hasScalarDepsInsideRegion(const llvm::SCEV *Expr, const llvm::Region *R,
68 const llvm::SCEV *Expression, llvm::ScalarEvolution &SE,
77 const llvm::SCEV *Expression,
86 std::pair<const llvm::SCEVConstant *, const llvm::SCEV *>
87 extractConstantFactor(const llvm::SCEV *M, llvm::ScalarEvolution &SE);
95 const llvm::SCEV *tryForwardThroughPHI(const llvm::SCEV *Expr, llvm::Region &R,
95 const llvm::SCEV *tryForwardThroughPHI(const llvm::SCEV *Expr, llvm::Region &R,
tools/polly/include/polly/Support/ScopHelper.h 45 using ParameterSetTy = llvm::SetVector<const llvm::SCEV *>;
349 const llvm::SCEV *E, llvm::Type *Ty,
459 std::tuple<std::vector<const llvm::SCEV *>, std::vector<int>>
tools/polly/include/polly/Support/VirtualInstruction.h 76 const SCEV *ScevExpr;
84 VirtualUse(ScopStmt *User, Value *Val, UseKind Kind, const SCEV *ScevExpr,
146 const SCEV *getScevExpr() const { return ScevExpr; }
tools/polly/lib/Analysis/ScopBuilder.cpp 346 const SCEV *E, bool NonNegative) {
362 const SCEV *SCEV_TestVal, const SCEV *SCEV_UpperBound,
362 const SCEV *SCEV_TestVal, const SCEV *SCEV_UpperBound,
435 const SCEV *LHSSCEV = SE.getSCEVAtScope(Load, L);
436 const SCEV *RHSSCEV = SE.getZero(LHSSCEV->getType());
491 const SCEV *LeftOperand = SE.getSCEVAtScope(ICond->getOperand(0), L),
806 DenseMap<std::pair<const SCEV *, Type *>, LoadInst *> EquivClasses;
810 const SCEV *PointerSCEV = SE.getSCEV(LInst->getPointerOperand());
1604 const SCEV *AccessFunction =
1630 std::vector<const SCEV *> Subscripts;
1643 std::vector<const SCEV *> SizesSCEV;
1684 const SCEV *AccessFunction =
1696 std::vector<const SCEV *> Sizes = {nullptr};
1849 const SCEV *AccessFunction =
2265 ArrayRef<const SCEV *> Subscripts, ArrayRef<const SCEV *> Sizes,
2265 ArrayRef<const SCEV *> Subscripts, ArrayRef<const SCEV *> Sizes,
2304 ArrayRef<const SCEV *> Subscripts,
2305 ArrayRef<const SCEV *> Sizes,
2322 static bool isDivisible(const SCEV *Expr, unsigned Size, ScalarEvolution &SE) {
2435 std::vector<const SCEV *> Sizes;
2486 const SCEV *Subscript = Access->getSubscript(0);
2997 for (const SCEV *Parameter : scop->parameters()) {
3021 const SCEV *PointerSCEV = SE.getSCEV(LInst->getPointerOperand());
tools/polly/lib/Analysis/ScopDetection.cpp 486 bool ScopDetection::involvesMultiplePtrs(const SCEV *S0, const SCEV *S1,
486 bool ScopDetection::involvesMultiplePtrs(const SCEV *S0, const SCEV *S1,
520 bool ScopDetection::isAffine(const SCEV *S, Loop *Scope,
536 const SCEV *ConditionSCEV = SE.getSCEVAtScope(Condition, L);
602 const SCEV *LHS = SE.getSCEVAtScope(ICmp->getOperand(0), L);
603 const SCEV *RHS = SE.getSCEVAtScope(ICmp->getOperand(1), L);
749 const SCEV *AF;
826 SCEVRemoveMax(ScalarEvolution &SE, std::vector<const SCEV *> *Terms)
829 static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
829 static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
830 std::vector<const SCEV *> *Terms = nullptr) {
835 const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) {
847 std::vector<const SCEV *> *Terms;
851 SmallVector<const SCEV *, 4>
854 SmallVector<const SCEV *, 4> Terms;
856 std::vector<const SCEV *> MaxTerms;
875 SmallVector<const SCEV *, 0> Operands;
902 SmallVectorImpl<const SCEV *> &Sizes,
916 for (const SCEV *DelinearizedSize : Sizes) {
946 const SCEV *AF = Pair.second;
995 for (const SCEV *S : Acc->DelinearizedSubscripts)
1054 bool ScopDetection::isValidAccess(Instruction *Inst, const SCEV *AF,
1076 const SCEV *Size;
1184 const SCEV *AccessFunction = SE.getSCEVAtScope(Ptr, L);
1331 const SCEV *LoopCount = SE.getBackedgeTakenCount(L);
tools/polly/lib/Analysis/ScopDetectionDiagnostic.cpp 87 template <typename T> std::string operator+(Twine LHS, const T &RHS) {
448 ReportLoopBound::ReportLoopBound(Loop *L, const SCEV *LoopCount)
tools/polly/lib/Analysis/ScopInfo.cpp 224 ArrayRef<const SCEV *> Sizes, MemoryKind Kind,
321 bool ScopArrayInfo::updateSizes(ArrayRef<const SCEV *> NewSizes,
343 for (const SCEV *Expr : DimensionSizes) {
888 ArrayRef<const SCEV *> Subscripts,
889 ArrayRef<const SCEV *> Sizes, Value *AccessValue,
977 isl::pw_aff MemoryAccess::getPwAff(const SCEV *E) {
1396 static const SCEV *rewrite(const SCEV *E, ScalarEvolution &SE,
1396 static const SCEV *rewrite(const SCEV *E, ScalarEvolution &SE,
1402 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *E) {
1406 E->getLoop(), SCEV::FlagAnyWrap);
1410 const SCEV *visitUnknown(const SCEVUnknown *E) {
1428 static bool hasVariant(const SCEV *E, ScalarEvolution &SE,
1435 bool follow(const SCEV *E) {
1449 const SCEV *Scop::getRepresentingInvariantLoadSCEV(const SCEV *E) const {
1449 const SCEV *Scop::getRepresentingInvariantLoadSCEV(const SCEV *E) const {
1491 void Scop::createParameterId(const SCEV *Parameter) {
1528 for (const SCEV *Parameter : NewParameters) {
1538 isl::id Scop::getIdForParam(const SCEV *Parameter) const {
1803 const SCEV *PointerSCEV = SE->getSCEV(LInst->getPointerOperand());
1818 ArrayRef<const SCEV *> Sizes,
1845 std::vector<const SCEV *> SCEVSizes;
1916 for (const SCEV *Parameter : Parameters) {
2144 for (const SCEV *Parameter : Parameters)
2242 __isl_give PWACtx Scop::getPwAff(const SCEV *E, BasicBlock *BB,
2276 isl::pw_aff Scop::getPwAffOnly(const SCEV *E, BasicBlock *BB) {
tools/polly/lib/CodeGen/BlockGenerators.cpp 71 const SCEV *Scev = SE.getSCEVAtScope(Old, L);
78 const SCEV *NewScev = SCEVLoopAddRecRewriter::rewrite(Scev, LTS, SE);
tools/polly/lib/CodeGen/IslExprBuilder.cpp 314 const SCEV *DimSCEV = SAI->getDimensionSize(u);
tools/polly/lib/CodeGen/IslNodeBuilder.cpp 311 SetVector<const SCEV *> SCEVs;
326 for (const SCEV *Expr : SCEVs) {
962 const SCEV *OuterLIV = SE.getAddRecExpr(SE.getUnknown(Builder.getInt64(0)),
964 SCEV::FlagAnyWrap);
1111 for (const SCEV *Param : S.parameters()) {
1361 const SCEV *Dim = SAI->getDimensionSize(i);
1553 Value *IslNodeBuilder::generateSCEV(const SCEV *Expr) {
tools/polly/lib/Support/SCEVAffinator.cpp 61 static SCEV::NoWrapFlags getNoWrapFlags(const SCEV *Expr) {
61 static SCEV::NoWrapFlags getNoWrapFlags(const SCEV *Expr) {
64 return SCEV::NoWrapMask;
113 PWACtx SCEVAffinator::getPwAff(const SCEV *Expr, BasicBlock *BB) {
126 PWACtx SCEVAffinator::checkForWrapping(const SCEV *Expr, PWACtx PWAC) const {
134 if (IgnoreIntegerWrapping || (getNoWrapFlags(Expr) & SCEV::FlagNSW))
174 if (AddRec->getNoWrapFlags() & SCEV::FlagNSW)
181 bool SCEVAffinator::computeModuloForExpr(const SCEV *Expr) {
185 if (NAry->getNoWrapFlags() & SCEV::FlagNSW)
190 PWACtx SCEVAffinator::visit(const SCEV *Expr) {
416 const SCEV *ZeroStartExpr =
tools/polly/lib/Support/SCEVValidator.cpp 58 ValidatorResult(SCEVType::TYPE Type, const SCEV *Expr) : Type(Type) {
149 class ValidatorResult visitZeroExtendOrTruncateExpr(const SCEV *Expr,
150 const SCEV *Operand) {
271 const SCEV *ZeroStartExpr = SE.getAddRecExpr(
342 ValidatorResult visitGenericInst(Instruction *I, const SCEV *S) {
352 ValidatorResult visitCallInstruction(Instruction *I, const SCEV *S) {
364 ValidatorResult visitLoadInstruction(Instruction *I, const SCEV *S) {
373 ValidatorResult visitDivision(const SCEV *Dividend, const SCEV *Divisor,
373 ValidatorResult visitDivision(const SCEV *Dividend, const SCEV *Divisor,
374 const SCEV *DivExpr,
407 ValidatorResult visitSDivInstruction(Instruction *SDiv, const SCEV *Expr) {
416 ValidatorResult visitSRemInstruction(Instruction *SRem, const SCEV *S) {
472 bool follow(const SCEV *S) {
507 bool follow(const SCEV *S) {
563 bool follow(const SCEV *S) {
571 void findLoops(const SCEV *Expr, SetVector<const Loop *> &Loops) {
586 bool follow(const SCEV *S) {
612 void findValues(const SCEV *Expr, ScalarEvolution &SE,
619 bool hasIVParams(const SCEV *Expr) {
626 bool hasScalarDepsInsideRegion(const SCEV *Expr, const Region *R,
635 bool isAffineExpr(const Region *R, llvm::Loop *Scope, const SCEV *Expr,
700 const SCEV *Expr, ScalarEvolution &SE) {
712 std::pair<const SCEVConstant *, const SCEV *>
713 extractConstantFactor(const SCEV *S, ScalarEvolution &SE) {
733 SmallVector<const SCEV *, 4> LeftOvers;
762 SmallVector<const SCEV *, 4> LeftOvers;
772 const SCEV *tryForwardThroughPHI(const SCEV *Expr, Region &R,
772 const SCEV *tryForwardThroughPHI(const SCEV *Expr, Region &R,
tools/polly/lib/Support/ScopHelper.cpp 230 struct ScopExpander : SCEVVisitor<ScopExpander, const SCEV *> {
239 Value *expandCodeFor(const SCEV *E, Type *Ty, Instruction *I) {
248 const SCEV *visit(const SCEV *E) {
248 const SCEV *visit(const SCEV *E) {
254 const SCEV *Result = SCEVVisitor::visit(E);
266 DenseMap<const SCEV *, const SCEV *> SCEVCache;
266 DenseMap<const SCEV *, const SCEV *> SCEVCache;
268 const SCEV *visitGenericInst(const SCEVUnknown *E, Instruction *Inst,
289 const SCEV *visitUnknown(const SCEVUnknown *E) {
315 const SCEV *LHSScev = SE.getSCEV(Inst->getOperand(0));
316 const SCEV *RHSScev = SE.getSCEV(Inst->getOperand(1));
333 const SCEV *visitConstant(const SCEVConstant *E) { return E; }
334 const SCEV *visitTruncateExpr(const SCEVTruncateExpr *E) {
337 const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *E) {
340 const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *E) {
343 const SCEV *visitUDivExpr(const SCEVUDivExpr *E) {
349 const SCEV *visitAddExpr(const SCEVAddExpr *E) {
350 SmallVector<const SCEV *, 4> NewOps;
351 for (const SCEV *Op : E->operands())
355 const SCEV *visitMulExpr(const SCEVMulExpr *E) {
356 SmallVector<const SCEV *, 4> NewOps;
357 for (const SCEV *Op : E->operands())
361 const SCEV *visitUMaxExpr(const SCEVUMaxExpr *E) {
362 SmallVector<const SCEV *, 4> NewOps;
363 for (const SCEV *Op : E->operands())
367 const SCEV *visitSMaxExpr(const SCEVSMaxExpr *E) {
368 SmallVector<const SCEV *, 4> NewOps;
369 for (const SCEV *Op : E->operands())
373 const SCEV *visitUMinExpr(const SCEVUMinExpr *E) {
374 SmallVector<const SCEV *, 4> NewOps;
375 for (const SCEV *Op : E->operands())
379 const SCEV *visitSMinExpr(const SCEVSMinExpr *E) {
380 SmallVector<const SCEV *, 4> NewOps;
381 for (const SCEV *Op : E->operands())
385 const SCEV *visitAddRecExpr(const SCEVAddRecExpr *E) {
386 SmallVector<const SCEV *, 4> NewOps;
387 for (const SCEV *Op : E->operands())
395 const char *Name, const SCEV *E, Type *Ty,
541 const SCEV *PtrSCEV = SE.getSCEVAtScope(Val, L);
572 const SCEV *PtrSCEV = SE.getSCEVAtScope(Ptr, L);
642 if (const SCEV *Scev = SE->getSCEVAtScope(const_cast<Value *>(V), Scope))
661 std::tuple<std::vector<const SCEV *>, std::vector<int>>
663 std::vector<const SCEV *> Subscripts;
672 const SCEV *Expr = SE.getSCEV(GEP->getOperand(i));
tools/polly/lib/Transform/ForwardOpTree.cpp 352 SmallVector<const SCEV *, 4> Sizes;
354 SmallVector<const SCEV *, 4> Subscripts;
unittests/Analysis/ScalarEvolutionTest.cpp 62 const SCEV *LHS,
63 const SCEV *RHS) {
83 const SCEV *S0 = SE.getSCEV(V0);
84 const SCEV *S1 = SE.getSCEV(V1);
85 const SCEV *S2 = SE.getSCEV(V2);
87 const SCEV *P0 = SE.getAddExpr(S0, S0);
88 const SCEV *P1 = SE.getAddExpr(S1, S1);
89 const SCEV *P2 = SE.getAddExpr(S2, S2);
304 SmallVector<const SCEV *, 3> Ops0 = {A, B, C};
305 SmallVector<const SCEV *, 3> Ops1 = {A, C, B};
306 SmallVector<const SCEV *, 3> Ops2 = {B, A, C};
307 SmallVector<const SCEV *, 3> Ops3 = {B, C, A};
308 SmallVector<const SCEV *, 3> Ops4 = {C, B, A};
309 SmallVector<const SCEV *, 3> Ops5 = {C, A, B};
558 SmallVector<const SCEV *, 4> OpsCopy(Ops);
559 return SE.getAddRecExpr(OpsCopy, L, SCEV::FlagAnyWrap);
563 SmallVector<const SCEV *, 4> OpsCopy(Ops);
564 return SE.getAddExpr(OpsCopy, SCEV::FlagAnyWrap);
571 std::vector<const SCEV *> Exprs;
573 const SCEV *V0 = SE.getSCEV(&*F.arg_begin());
574 const SCEV *V1 = SE.getSCEV(&*std::next(F.arg_begin(), 1));
575 const SCEV *V2 = SE.getSCEV(&*std::next(F.arg_begin(), 2));
576 const SCEV *V3 = SE.getSCEV(&*std::next(F.arg_begin(), 3));
717 const SCEV *S = SE.getSCEV(Accum);
788 LI->getLoopFor(L), SCEV::FlagNUW);
861 const SCEV *EC = SE.getBackedgeTakenCount(Loop);
870 SE.getAddRecExpr(Five, SE.getOne(T_int64), Loop, SCEV::FlagAnyWrap);
871 const SCEV *ARAtLoopExit = SE.getSCEVAtScope(AR, nullptr);
885 const SCEV *NewEC = SE.getBackedgeTakenCount(Loop);
889 const SCEV *NewARAtLoopExit = SE.getSCEVAtScope(AR, nullptr);
961 const SCEV *EC = SE.getBackedgeTakenCount(Loop);
974 const SCEV *NewEC = SE.getBackedgeTakenCount(Loop);
1030 const SCEV *Expr = SE.getSCEV(Phi);
1088 const SCEV *Expr = SE.getSCEV(Phi);
1109 const auto *ArgSCEV = SE.getSCEV(Arg);
1112 const auto *A0 = SE.getNegativeSCEV(ArgSCEV);
1113 const auto *A1 = SE.getTruncateExpr(A0, Int32Ty);
1114 const auto *A = SE.getNegativeSCEV(A1);
1116 const auto *B0 = SE.getTruncateExpr(ArgSCEV, Int32Ty);
1117 const auto *B = SE.getNegativeSCEV(B0);
1119 const auto *Expr = SE.getAddExpr(A, B);
1121 const auto *ZeroConst = SE.getConstant(Int32Ty, 0);
1186 const SCEV *S = SE.getSCEV(Phi);
1241 const SCEV *S = SE.getSCEV(S1);
1293 const SCEV *S = SE.getSCEV(S1);
1339 const SCEV *SC2 = SE.getSCEV(S2);
1342 const SCEV *SC1 = SE.getSCEV(S1);
1390 const SCEV *SC2 = SE.getSCEV(S2);
1393 const SCEV *SC1 = SE.getSCEV(S1);
1440 const SCEV *AS = SE.getSCEV(A);
1441 const SCEV *BS = SE.getSCEV(B);
1442 const SCEV *CS = SE.getSCEV(C);
1443 const SCEV *S1S = SE.getSCEV(S1);
1444 const SCEV *S2S = SE.getSCEV(S2);
1638 SE.getOne(ARType), L, SCEV::FlagAnyWrap);
1663 const SCEV *AndSCEV = SE.getSCEV(And);
1899 SmallVector<const SCEV *, 3> Ops = {SE.getConstant(APInt(ARBitWidth, 5)),
1901 return cast<SCEVAddRecExpr>(SE.getAddRecExpr(Ops, L, SCEV::FlagAnyWrap));
1909 SmallVector<const SCEV *, 4> Ops = {SE.getConstant(APInt(ARBitWidth, 5)),
1912 return cast<SCEVAddRecExpr>(SE.getAddRecExpr(Ops, L, SCEV::FlagAnyWrap));
1920 SmallVector<const SCEV *, 5> Ops = {SE.getConstant(APInt(ARBitWidth, 5)),
1923 return cast<SCEVAddRecExpr>(SE.getAddRecExpr(Ops, L, SCEV::FlagAnyWrap));
usr/include/c++/7.4.0/type_traits 381 : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
1554 { typedef _Tp type; };
1558 { typedef _Tp type; };
1563 { typedef _Tp type; };
1574 remove_const<typename remove_volatile<_Tp>::type>::type type;
1983 { typedef _Up type; };
utils/unittest/googletest/include/gtest/gtest-message.h 116 inline Message& operator <<(const T& val) {
utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h 35 auto printable(const T &V) -> decltype(StreamSwitch<T>::printable(V)) {
35 auto printable(const T &V) -> decltype(StreamSwitch<T>::printable(V)) {
37 return StreamSwitch<T>::printable(V);
54 const T& V;
55 friend std::ostream &operator<<(std::ostream &S, const RawStreamProxy<T> &V) {
69 static const RawStreamProxy<T> printable(const T &V) { return {V}; }
69 static const RawStreamProxy<T> printable(const T &V) { return {V}; }