llvm.org GIT mirror llvm / dad3898
[SCEV] Rename getMaxBackedgeTakenCount to getConstantMaxBackedgeTakenCount [NFC] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368930 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames a month ago
5 changed file(s) with 15 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
778778 /// to (i.e. a "conservative over-approximation") of the value returend by
779779 /// getBackedgeTakenCount. If such a value cannot be computed, it returns the
780780 /// SCEVCouldNotCompute object.
781 const SCEV *getMaxBackedgeTakenCount(const Loop *L);
781 const SCEV *getConstantMaxBackedgeTakenCount(const Loop *L);
782782
783783 /// Return true if the backedge taken count is either the value returned by
784 /// getMaxBackedgeTakenCount or zero.
784 /// getConstantMaxBackedgeTakenCount or zero.
785785 bool isBackedgeTakenCountMaxOrZero(const Loop *L);
786786
787787 /// Return true if the specified loop has an analyzable loop-invariant
17061706 // in infinite recursion. In the later case, the analysis code will
17071707 // cope with a conservative value, and it will take care to purge
17081708 // that value once it has finished.
1709 const SCEV *MaxBECount = getMaxBackedgeTakenCount(L);
1709 const SCEV *MaxBECount = getConstantMaxBackedgeTakenCount(L);
17101710 if (!isa(MaxBECount)) {
17111711 // Manually compute the final value for AR, checking for
17121712 // overflow.
20502050 // in infinite recursion. In the later case, the analysis code will
20512051 // cope with a conservative value, and it will take care to purge
20522052 // that value once it has finished.
2053 const SCEV *MaxBECount = getMaxBackedgeTakenCount(L);
2053 const SCEV *MaxBECount = getConstantMaxBackedgeTakenCount(L);
20542054 if (!isa(MaxBECount)) {
20552055 // Manually compute the final value for AR, checking for
20562056 // overflow.
34203420 return getAddRecExpr(Operands, L, SCEV::FlagAnyWrap); // {X,+,0} --> X
34213421 }
34223422
3423 // It's tempting to want to call getMaxBackedgeTakenCount count here and
3423 // It's tempting to want to call getConstantMaxBackedgeTakenCount count here and
34243424 // use that information to infer NUW and NSW flags. However, computing a
34253425 // BE count requires calling getAddRecExpr, so we may not yet have a
34263426 // meaningful BE count at this point (and if we don't, we'd be stuck
56535653
56545654 // TODO: non-affine addrec
56555655 if (AddRec->isAffine()) {
5656 const SCEV *MaxBECount = getMaxBackedgeTakenCount(AddRec->getLoop());
5656 const SCEV *MaxBECount = getConstantMaxBackedgeTakenCount(AddRec->getLoop());
56575657 if (!isa(MaxBECount) &&
56585658 getTypeSizeInBits(MaxBECount->getType()) <= BitWidth) {
56595659 auto RangeFromAffine = getRangeForAffineAR(
65226522
65236523 unsigned ScalarEvolution::getSmallConstantMaxTripCount(const Loop *L) {
65246524 const auto *MaxExitCount =
6525 dyn_cast(getMaxBackedgeTakenCount(L));
6525 dyn_cast(getConstantMaxBackedgeTakenCount(L));
65266526 return getConstantTripCount(MaxExitCount);
65276527 }
65286528
65986598
65996599 /// Similar to getBackedgeTakenCount, except return the least SCEV value that is
66006600 /// known never to be less than the actual backedge taken count.
6601 const SCEV *ScalarEvolution::getMaxBackedgeTakenCount(const Loop *L) {
6601 const SCEV *ScalarEvolution::getConstantMaxBackedgeTakenCount(const Loop *L) {
66026602 return getBackedgeTakenInfo(L).getMax(this);
66036603 }
66046604
1143711437 L->getHeader()->printAsOperand(OS, /*PrintType=*/false);
1143811438 OS << ": ";
1143911439
11440 if (!isa(SE->getMaxBackedgeTakenCount(L))) {
11441 OS << "max backedge-taken count is " << *SE->getMaxBackedgeTakenCount(L);
11440 if (!isa(SE->getConstantMaxBackedgeTakenCount(L))) {
11441 OS << "max backedge-taken count is " << *SE->getConstantMaxBackedgeTakenCount(L);
1144211442 if (SE->isBackedgeTakenCountMaxOrZero(L))
1144311443 OS << ", actual taken count either this or zero.";
1144411444 } else {
26462646
26472647 // Form an expression for the maximum exit count possible for this loop. We
26482648 // merge the max and exact information to approximate a version of
2649 // getMaxBackedgeTakenInfo which isn't restricted to just constants.
2650 // TODO: factor this out as a version of getMaxBackedgeTakenCount which
2649 // getConstantMaxBackedgeTakenCount which isn't restricted to just constants.
2650 // TODO: factor this out as a version of getConstantMaxBackedgeTakenCount which
26512651 // isn't guaranteed to return a constant.
26522652 SmallVector ExitCounts;
2653 const SCEV *MaxConstEC = SE->getMaxBackedgeTakenCount(L);
2653 const SCEV *MaxConstEC = SE->getConstantMaxBackedgeTakenCount(L);
26542654 if (!isa(MaxConstEC))
26552655 ExitCounts.push_back(MaxConstEC);
26562656 for (BasicBlock *ExitingBB : ExitingBlocks) {
190190
191191 // Don't remove loops for which we can't solve the trip count.
192192 // They could be infinite, in which case we'd be changing program behavior.
193 const SCEV *S = SE.getMaxBackedgeTakenCount(L);
193 const SCEV *S = SE.getConstantMaxBackedgeTakenCount(L);
194194 if (isa(S)) {
195195 LLVM_DEBUG(dbgs() << "Could not compute SCEV MaxBackedgeTakenCount.\n");
196196 return Changed ? LoopDeletionResult::Modified
239239 static bool mustBeFiniteCountedLoop(Loop *L, ScalarEvolution *SE,
240240 BasicBlock *Pred) {
241241 // A conservative bound on the loop as a whole.
242 const SCEV *MaxTrips = SE->getMaxBackedgeTakenCount(L);
242 const SCEV *MaxTrips = SE->getConstantMaxBackedgeTakenCount(L);
243243 if (MaxTrips != SE->getCouldNotCompute() &&
244244 SE->getUnsignedRange(MaxTrips).getUnsignedMax().isIntN(
245245 CountedLoopTripWidth))