Lines Matching refs:SE

148   static bool parseRangeCheckICmp(Loop *L, ICmpInst *ICI, ScalarEvolution &SE,
153 extractRangeChecksFromCond(Loop *L, ScalarEvolution &SE, Use &ConditionUse,
198 bool isEmpty(ScalarEvolution &SE, bool IsSigned) const {
202 return SE.isKnownPredicate(ICmpInst::ICMP_SGE, Begin, End);
204 return SE.isKnownPredicate(ICmpInst::ICMP_UGE, Begin, End);
215 Optional<Range> computeSafeIterationSpace(ScalarEvolution &SE,
225 extractRangeChecksFromBranch(BranchInst *BI, Loop *L, ScalarEvolution &SE,
231 ScalarEvolution &SE;
237 InductiveRangeCheckElimination(ScalarEvolution &SE,
240 : SE(SE), BPI(BPI), DT(DT), LI(LI) {}
278 ScalarEvolution &SE, Value *&Index,
280 auto IsLoopInvariant = [&SE, L](Value *V) {
281 return SE.isLoopInvariant(SE.getSCEV(V), L);
337 Loop *L, ScalarEvolution &SE, Use &ConditionUse,
346 extractRangeChecksFromCond(L, SE, cast<User>(Condition)->getOperandUse(0),
348 extractRangeChecksFromCond(L, SE, cast<User>(Condition)->getOperandUse(1),
359 if (!parseRangeCheckICmp(L, ICI, SE, Index, Length, IsSigned))
362 const auto *IndexAddRec = dyn_cast<SCEVAddRecExpr>(SE.getSCEV(Index));
373 End = SE.getSCEV(Length);
379 const SCEV *SIntMax = SE.getConstant(APInt::getSignedMaxValue(BitWidth));
386 IRC.Step = IndexAddRec->getStepRecurrence(SE);
393 BranchInst *BI, Loop *L, ScalarEvolution &SE, BranchProbabilityInfo *BPI,
405 InductiveRangeCheck::extractRangeChecksFromCond(L, SE, BI->getOperandUse(0),
604 ScalarEvolution &SE;
629 const LoopStructure &LS, ScalarEvolution &SE,
632 SE(SE), DT(DT), LI(LI), LPMAddNewLoop(LPMAddNewLoop), OriginalLoop(L),
647 Loop *L, ScalarEvolution &SE) {
652 if (!SE.isAvailableAtLoopEntry(BoundSCEV, L))
655 assert(SE.isKnownNegative(Step) && "expecting negative step");
672 return SE.isLoopEntryGuardedByCond(L, BoundPred, Start, BoundSCEV);
677 const SCEV *StepPlusOne = SE.getAddExpr(Step, SE.getOne(Step->getType()));
681 const SCEV *Limit = SE.getMinusSCEV(SE.getConstant(Min), StepPlusOne);
684 SE.getMinusSCEV(BoundSCEV, SE.getOne(BoundSCEV->getType()));
686 return SE.isLoopEntryGuardedByCond(L, BoundPred, Start, MinusOne) &&
687 SE.isLoopEntryGuardedByCond(L, BoundPred, BoundSCEV, Limit);
697 Loop *L, ScalarEvolution &SE) {
702 if (!SE.isAvailableAtLoopEntry(BoundSCEV, L))
720 return SE.isLoopEntryGuardedByCond(L, BoundPred, Start, BoundSCEV);
725 SE.getMinusSCEV(Step, SE.getOne(Step->getType()));
729 const SCEV *Limit = SE.getMinusSCEV(SE.getConstant(Max), StepMinusOne);
731 return (SE.isLoopEntryGuardedByCond(L, BoundPred, Start,
732 SE.getAddExpr(BoundSCEV, Step)) &&
733 SE.isLoopEntryGuardedByCond(L, BoundPred, BoundSCEV, Limit));
737 LoopStructure::parseLoopStructure(ScalarEvolution &SE,
789 const SCEV *LatchCount = SE.getExitCount(&L, Latch);
797 const SCEV *LeftSCEV = SE.getSCEV(LeftValue);
801 const SCEV *RightSCEV = SE.getSCEV(RightValue);
824 dyn_cast<SCEVAddRecExpr>(SE.getSignExtendExpr(AR, WideTy));
826 const SCEV *ExtendedStart = SE.getSignExtendExpr(AR->getStart(), WideTy);
828 SE.getSignExtendExpr(AR->getStepRecurrence(SE), WideTy);
831 ExtendAfterOp->getStepRecurrence(SE) == ExtendedStep;
849 const SCEV* StepRec = IndVarBase->getStepRecurrence(SE);
865 const SCEV *Addend = SE.getNegativeSCEV(IndVarBase->getStepRecurrence(SE));
866 const SCEV *IndVarStart = SE.getAddExpr(StartNext, Addend);
867 const SCEV *Step = SE.getSCEV(StepCI);
881 if (isKnownNonNegativeInLoop(IndVarStart, &L, SE) &&
882 isKnownNonNegativeInLoop(RightSCEV, &L, SE))
893 cannotBeMinInLoop(RightSCEV, &L, SE, /*Signed*/false)) {
895 RightSCEV = SE.getMinusSCEV(RightSCEV,
896 SE.getOne(RightSCEV->getType()));
898 } else if (cannotBeMinInLoop(RightSCEV, &L, SE, /*Signed*/true)) {
900 RightSCEV = SE.getMinusSCEV(RightSCEV,
901 SE.getOne(RightSCEV->getType()));
924 LatchBrExitIdx, &L, SE)) {
958 cannotBeMaxInLoop(RightSCEV, &L, SE, /* Signed */ false)) {
960 RightSCEV = SE.getAddExpr(RightSCEV, SE.getOne(RightSCEV->getType()));
962 } else if (cannotBeMaxInLoop(RightSCEV, &L, SE, /* Signed */ true)) {
964 RightSCEV = SE.getAddExpr(RightSCEV, SE.getOne(RightSCEV->getType()));
990 LatchBrExitIdx, &L, SE)) {
1009 assert(SE.getLoopDisposition(LatchCount, &L) ==
1016 SCEVExpander(SE, DL, "irce")
1042 static const SCEV *NoopOrExtend(const SCEV *S, Type *Ty, ScalarEvolution &SE,
1044 return Signed ? SE.getNoopOrSignExtend(S, Ty) : SE.getNoopOrZeroExtend(S, Ty);
1064 const SCEV *Start = NoopOrExtend(SE.getSCEV(MainLoopStructure.IndVarStart),
1065 RTy, SE, IsSignedPredicate);
1066 const SCEV *End = NoopOrExtend(SE.getSCEV(MainLoopStructure.LoopExitAt), RTy,
1067 SE, IsSignedPredicate);
1077 const SCEV *One = SE.getOne(RTy);
1082 GreatestSeen = SE.getMinusSCEV(End, One);
1099 Smallest = SE.getAddExpr(End, One);
1100 Greatest = SE.getAddExpr(Start, One);
1106 ? SE.getSMaxExpr(Smallest, SE.getSMinExpr(Greatest, S))
1107 : SE.getUMaxExpr(Smallest, SE.getUMinExpr(Greatest, S));
1117 SE.isKnownPredicate(PredLE, Range.getBegin(), Smallest);
1122 SE.isKnownPredicate(PredLT, GreatestSeen, Range.getEnd());
1389 LatchTakenCount = SE.getExitCount(&OriginalLoop, MainLoopStructure.Latch);
1409 SCEVExpander Expander(SE, F.getParent()->getDataLayout(), "irce");
1424 cast<SCEVConstant>(SE.getConstant(IVTy, -1, true /* isSigned */));
1431 else if (cannotBeMinInLoop(*SR.HighLimit, &OriginalLoop, SE,
1433 ExitPreLoopAtSCEV = SE.getAddExpr(*SR.HighLimit, MinusOneS);
1441 if (!isSafeToExpandAt(ExitPreLoopAtSCEV, InsertPt, SE)) {
1458 else if (cannotBeMinInLoop(*SR.LowLimit, &OriginalLoop, SE,
1460 ExitMainLoopAtSCEV = SE.getAddExpr(*SR.LowLimit, MinusOneS);
1468 if (!isSafeToExpandAt(ExitMainLoopAtSCEV, InsertPt, SE)) {
1547 formLCSSARecursively(*L, DT, &LI, &SE);
1548 simplifyLoop(L, &DT, &LI, &SE, nullptr, nullptr, true);
1568 ScalarEvolution &SE, const SCEVAddRecExpr *IndVar,
1599 const SCEV *A = NoopOrExtend(IndVar->getStart(), RCType, SE, IsLatchSigned);
1601 NoopOrExtend(IndVar->getStepRecurrence(SE), RCType, SE, IsLatchSigned));
1613 const SCEV *SIntMax = SE.getConstant(APInt::getSignedMaxValue(BitWidth));
1643 const SCEV *XMinusSIntMax = SE.getMinusSCEV(X, SIntMax);
1644 return SE.getMinusSCEV(X, SE.getSMaxExpr(Y, XMinusSIntMax),
1657 return SE.getMinusSCEV(X, SE.getSMinExpr(X, Y), SCEV::FlagNUW);
1659 const SCEV *M = SE.getMinusSCEV(C, A);
1660 const SCEV *Zero = SE.getZero(M->getType());
1665 const SCEV *One = SE.getOne(X->getType());
1667 if (isKnownNonNegativeInLoop(X, L, SE))
1669 else if (isKnownNegativeInLoop(X, L, SE))
1673 const SCEV *NegOne = SE.getNegativeSCEV(One);
1674 return SE.getAddExpr(SE.getSMaxExpr(SE.getSMinExpr(X, Zero), NegOne), One);
1687 const SCEV *Begin = SE.getMulExpr(ClampedSubtract(Zero, M), EndIsNonNegative);
1688 const SCEV *End = SE.getMulExpr(ClampedSubtract(REnd, M), EndIsNonNegative);
1693 IntersectSignedRange(ScalarEvolution &SE,
1696 if (R2.isEmpty(SE, /* IsSigned */ true))
1703 assert(!R1Value.isEmpty(SE, /* IsSigned */ true) &&
1711 const SCEV *NewBegin = SE.getSMaxExpr(R1Value.getBegin(), R2.getBegin());
1712 const SCEV *NewEnd = SE.getSMinExpr(R1Value.getEnd(), R2.getEnd());
1716 if (Ret.isEmpty(SE, /* IsSigned */ true))
1722 IntersectUnsignedRange(ScalarEvolution &SE,
1725 if (R2.isEmpty(SE, /* IsSigned */ false))
1732 assert(!R1Value.isEmpty(SE, /* IsSigned */ false) &&
1740 const SCEV *NewBegin = SE.getUMaxExpr(R1Value.getBegin(), R2.getBegin());
1741 const SCEV *NewEnd = SE.getUMinExpr(R1Value.getEnd(), R2.getEnd());
1745 if (Ret.isEmpty(SE, /* IsSigned */ false))
1757 InductiveRangeCheckElimination IRCE(AR.SE, BPI, AR.DT, AR.LI);
1773 ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
1778 InductiveRangeCheckElimination IRCE(SE, &BPI, DT, LI);
1803 InductiveRangeCheck::extractRangeChecksFromBranch(TBI, L, SE, BPI,
1824 LoopStructure::parseLoopStructure(SE, BPI, *L, FailureReason);
1832 cast<SCEVAddRecExpr>(SE.getMinusSCEV(SE.getSCEV(LS.IndVarBase), SE.getSCEV(LS.IndVarStep)));
1847 auto Result = IRC.computeSafeIterationSpace(SE, IndVar,
1851 IntersectRange(SE, SafeIterRange, Result.getValue());
1854 !MaybeSafeIterRange.getValue().isEmpty(SE, LS.IsSignedPredicate) &&
1865 LoopConstrainer LC(*L, LI, LPMAddNewLoop, LS, SE, DT,