@@ -410,10 +410,10 @@ static bool hasIrregularType(Type *Ty, const DataLayout &DL) {
410410// / 2) Returns expected trip count according to profile data if any.
411411// / 3) Returns upper bound estimate if it is known.
412412// / 4) Returns std::nullopt if all of the above failed.
413- static std::optional<unsigned > getSmallBestKnownTC (ScalarEvolution &SE,
414- Loop *L) {
413+ static std::optional<unsigned >
414+ getSmallBestKnownTC (PredicatedScalarEvolution &PSE, Loop *L) {
415415 // Check if exact trip count is known.
416- if (unsigned ExpectedTC = SE. getSmallConstantTripCount (L))
416+ if (unsigned ExpectedTC = PSE. getSE ()-> getSmallConstantTripCount (L))
417417 return ExpectedTC;
418418
419419 // Check if there is an expected trip count available from profile data.
@@ -422,8 +422,7 @@ static std::optional<unsigned> getSmallBestKnownTC(ScalarEvolution &SE,
422422 return *EstimatedTC;
423423
424424 // Check if upper bound estimate is known.
425- SmallVector<const SCEVPredicate *, 2 > Predicates;
426- if (unsigned ExpectedTC = SE.getSmallConstantMaxTripCount (L, &Predicates))
425+ if (unsigned ExpectedTC = PSE.getSmallConstantMaxTripCount ())
427426 return ExpectedTC;
428427
429428 return std::nullopt ;
@@ -2292,9 +2291,7 @@ static bool isIndvarOverflowCheckKnownFalse(
22922291 // We know the runtime overflow check is known false iff the (max) trip-count
22932292 // is known and (max) trip-count + (VF * UF) does not overflow in the type of
22942293 // the vector loop induction variable.
2295- SmallVector<const SCEVPredicate *, 2 > Predicates;
2296- if (unsigned TC = Cost->PSE .getSE ()->getSmallConstantMaxTripCount (
2297- Cost->TheLoop , &Predicates)) {
2294+ if (unsigned TC = Cost->PSE .getSmallConstantMaxTripCount ()) {
22982295 uint64_t MaxVF = VF.getKnownMinValue ();
22992296 if (VF.isScalable ()) {
23002297 std::optional<unsigned > MaxVScale =
@@ -3989,10 +3986,7 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
39893986 }
39903987
39913988 unsigned TC = PSE.getSE ()->getSmallConstantTripCount (TheLoop);
3992-
3993- SmallVector<const SCEVPredicate *, 2 > Predicates;
3994- unsigned MaxTC =
3995- PSE.getSE ()->getSmallConstantMaxTripCount (TheLoop, &Predicates);
3989+ unsigned MaxTC = PSE.getSmallConstantMaxTripCount ();
39963990 LLVM_DEBUG (dbgs () << " LV: Found trip count: " << TC << ' \n ' );
39973991 if (TC != MaxTC)
39983992 LLVM_DEBUG (dbgs () << " LV: Found maximum trip count: " << MaxTC << ' \n ' );
@@ -4283,9 +4277,7 @@ bool LoopVectorizationPlanner::isMoreProfitable(
42834277 InstructionCost CostA = A.Cost ;
42844278 InstructionCost CostB = B.Cost ;
42854279
4286- SmallVector<const SCEVPredicate *, 2 > Predicates;
4287- unsigned MaxTripCount =
4288- PSE.getSE ()->getSmallConstantMaxTripCount (OrigLoop, &Predicates);
4280+ unsigned MaxTripCount = PSE.getSmallConstantMaxTripCount ();
42894281
42904282 // Improve estimate for the vector width if it is scalable.
42914283 unsigned EstimatedWidthA = A.Width .getKnownMinValue ();
@@ -4873,7 +4865,7 @@ LoopVectorizationCostModel::selectInterleaveCount(ElementCount VF,
48734865 if (!Legal->isSafeForAnyVectorWidth ())
48744866 return 1 ;
48754867
4876- auto BestKnownTC = getSmallBestKnownTC (* PSE. getSE () , TheLoop);
4868+ auto BestKnownTC = getSmallBestKnownTC (PSE, TheLoop);
48774869 const bool HasReductions = !Legal->getReductionVars ().empty ();
48784870
48794871 // If we did not calculate the cost for VF (because the user selected the VF)
@@ -9643,7 +9635,7 @@ static void checkMixedPrecision(Loop *L, OptimizationRemarkEmitter *ORE) {
96439635static bool areRuntimeChecksProfitable (GeneratedRTChecks &Checks,
96449636 VectorizationFactor &VF,
96459637 std::optional<unsigned > VScale, Loop *L,
9646- ScalarEvolution &SE ,
9638+ PredicatedScalarEvolution &PSE ,
96479639 ScalarEpilogueLowering SEL) {
96489640 InstructionCost CheckCost = Checks.getCost ();
96499641 if (!CheckCost.isValid ())
@@ -9728,7 +9720,7 @@ static bool areRuntimeChecksProfitable(GeneratedRTChecks &Checks,
97289720
97299721 // Skip vectorization if the expected trip count is less than the minimum
97309722 // required trip count.
9731- if (auto ExpectedTC = getSmallBestKnownTC (SE , L)) {
9723+ if (auto ExpectedTC = getSmallBestKnownTC (PSE , L)) {
97329724 if (ElementCount::isKnownLT (ElementCount::getFixed (*ExpectedTC),
97339725 VF.MinProfitableTripCount )) {
97349726 LLVM_DEBUG (dbgs () << " LV: Vectorization is not beneficial: expected "
@@ -9835,7 +9827,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
98359827
98369828 // Check the loop for a trip count threshold: vectorize loops with a tiny trip
98379829 // count by optimizing for size, to minimize overheads.
9838- auto ExpectedTC = getSmallBestKnownTC (*SE , L);
9830+ auto ExpectedTC = getSmallBestKnownTC (PSE , L);
98399831 if (ExpectedTC && *ExpectedTC < TinyTripCountVectorThreshold) {
98409832 LLVM_DEBUG (dbgs () << " LV: Found a loop with a very small trip count. "
98419833 << " This loop is worth vectorizing only if no scalar "
@@ -9950,7 +9942,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
99509942 Hints.getForce () == LoopVectorizeHints::FK_Enabled;
99519943 if (!ForceVectorization &&
99529944 !areRuntimeChecksProfitable (Checks, VF, getVScaleForTuning (L, *TTI), L,
9953- * PSE. getSE () , SEL)) {
9945+ PSE, SEL)) {
99549946 ORE->emit ([&]() {
99559947 return OptimizationRemarkAnalysisAliasing (
99569948 DEBUG_TYPE, " CantReorderMemOps" , L->getStartLoc (),
0 commit comments