@@ -755,7 +755,7 @@ static unsigned getFullUnrollBoostingFactor(const EstimatedUnrollCost &Cost,
755
755
static std::optional<unsigned >
756
756
shouldPragmaUnroll (Loop *L, const PragmaInfo &PInfo,
757
757
const unsigned TripMultiple, const unsigned TripCount,
758
- const UnrollCostEstimator UCE,
758
+ unsigned MaxTripCount, const UnrollCostEstimator UCE,
759
759
const TargetTransformInfo::UnrollingPreferences &UP) {
760
760
761
761
// Using unroll pragma
@@ -776,6 +776,10 @@ shouldPragmaUnroll(Loop *L, const PragmaInfo &PInfo,
776
776
if (PInfo.PragmaFullUnroll && TripCount != 0 )
777
777
return TripCount;
778
778
779
+ if (PInfo.PragmaEnableUnroll && !TripCount && MaxTripCount &&
780
+ MaxTripCount <= UnrollMaxUpperBound)
781
+ return MaxTripCount;
782
+
779
783
// if didn't return until here, should continue to other priorties
780
784
return std::nullopt;
781
785
}
@@ -902,7 +906,7 @@ bool llvm::computeUnrollCount(
902
906
// 1st priority is unroll count set by "unroll-count" option.
903
907
// 2nd priority is unroll count set by pragma.
904
908
if (auto UnrollFactor = shouldPragmaUnroll (L, PInfo, TripMultiple, TripCount,
905
- UCE, UP)) {
909
+ MaxTripCount, UCE, UP)) {
906
910
UP.Count = *UnrollFactor;
907
911
908
912
if (UserUnrollCount || (PragmaCount > 0 )) {
0 commit comments