@@ -797,7 +797,7 @@ static unsigned getFullUnrollBoostingFactor(const EstimatedUnrollCost &Cost,
797
797
static std::optional<unsigned >
798
798
shouldPragmaUnroll (Loop *L, const PragmaInfo &PInfo,
799
799
const unsigned TripMultiple, const unsigned TripCount,
800
- const UnrollCostEstimator UCE,
800
+ unsigned MaxTripCount, const UnrollCostEstimator UCE,
801
801
const TargetTransformInfo::UnrollingPreferences &UP) {
802
802
803
803
// Using unroll pragma
@@ -827,6 +827,10 @@ shouldPragmaUnroll(Loop *L, const PragmaInfo &PInfo,
827
827
return TripCount;
828
828
}
829
829
830
+ if (PInfo.PragmaEnableUnroll && !TripCount && MaxTripCount &&
831
+ MaxTripCount <= UnrollMaxUpperBound)
832
+ return MaxTripCount;
833
+
830
834
// if didn't return until here, should continue to other priorties
831
835
return std::nullopt;
832
836
}
@@ -953,7 +957,7 @@ bool llvm::computeUnrollCount(
953
957
// 1st priority is unroll count set by "unroll-count" option.
954
958
// 2nd priority is unroll count set by pragma.
955
959
if (auto UnrollFactor = shouldPragmaUnroll (L, PInfo, TripMultiple, TripCount,
956
- UCE, UP)) {
960
+ MaxTripCount, UCE, UP)) {
957
961
UP.Count = *UnrollFactor;
958
962
959
963
if (UserUnrollCount || (PragmaCount > 0 )) {
0 commit comments