@@ -9317,8 +9317,8 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeExitLimitFromICmp(
93179317 case ICmpInst::ICMP_SLT:
93189318 case ICmpInst::ICMP_ULT: { // while (X < Y)
93199319 bool IsSigned = ICmpInst::isSigned(Pred);
9320- ExitLimit EL = howManyLessThans(LHS, RHS, L, IsSigned, ControlsOnlyExit ,
9321- AllowPredicates);
9320+ ExitLimit EL = howManyLessThans(LHS, RHS, L, IsSigned, GetLoopGuards ,
9321+ ControlsOnlyExit, AllowPredicates);
93229322 if (EL.hasAnyInfo())
93239323 return EL;
93249324 break;
@@ -10569,7 +10569,7 @@ ScalarEvolution::howFarToZero(const SCEV *V, const Loop *L,
1056910569 if (!isLoopInvariant(Step, L))
1057010570 return getCouldNotCompute();
1057110571
10572- LoopGuards Guards = GetLoopGuards();
10572+ const LoopGuards & Guards = GetLoopGuards();
1057310573 // Specialize step for this loop so we get context sensitive facts below.
1057410574 const SCEV *StepWLG = applyLoopGuards(Step, Guards);
1057510575
@@ -12928,10 +12928,10 @@ const SCEV *ScalarEvolution::computeMaxBECountForLT(const SCEV *Start,
1292812928 getConstant(StrideForMaxBECount) /* Step */);
1292912929}
1293012930
12931- ScalarEvolution::ExitLimit
12932- ScalarEvolution::howManyLessThans( const SCEV *LHS, const SCEV *RHS,
12933- const Loop *L , bool IsSigned ,
12934- bool ControlsOnlyExit, bool AllowPredicates) {
12931+ ScalarEvolution::ExitLimit ScalarEvolution::howManyLessThans(
12932+ const SCEV *LHS, const SCEV *RHS, const Loop *L, bool IsSigned ,
12933+ function_ref< const LoopGuards &()> GetLoopGuards , bool ControlsOnlyExit ,
12934+ bool AllowPredicates) {
1293512935 SmallVector<const SCEVPredicate *> Predicates;
1293612936
1293712937 const SCEVAddRecExpr *IV = dyn_cast<SCEVAddRecExpr>(LHS);
@@ -12965,7 +12965,8 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
1296512965 APInt StrideMax = getUnsignedRangeMax(AR->getStepRecurrence(*this));
1296612966 APInt Limit = APInt::getMaxValue(InnerBitWidth) - (StrideMax - 1);
1296712967 Limit = Limit.zext(OuterBitWidth);
12968- return getUnsignedRangeMax(applyLoopGuards(RHS, L)).ule(Limit);
12968+ return getUnsignedRangeMax(applyLoopGuards(RHS, GetLoopGuards()))
12969+ .ule(Limit);
1296912970 };
1297012971 auto Flags = AR->getNoWrapFlags();
1297112972 if (!hasFlags(Flags, SCEV::FlagNUW) && canProveNUW())
@@ -13216,8 +13217,8 @@ ScalarEvolution::howManyLessThans(const SCEV *LHS, const SCEV *RHS,
1321613217 if (!BECount) {
1321713218 auto canProveRHSGreaterThanEqualStart = [&]() {
1321813219 auto CondGE = IsSigned ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE;
13219- const SCEV *GuardedRHS = applyLoopGuards(OrigRHS, L );
13220- const SCEV *GuardedStart = applyLoopGuards(OrigStart, L );
13220+ const SCEV *GuardedRHS = applyLoopGuards(OrigRHS, GetLoopGuards() );
13221+ const SCEV *GuardedStart = applyLoopGuards(OrigStart, GetLoopGuards() );
1322113222
1322213223 if (isLoopEntryGuardedByCond(L, CondGE, OrigRHS, OrigStart) ||
1322313224 isKnownPredicate(CondGE, GuardedRHS, GuardedStart))
0 commit comments