Skip to content

Commit 862313c

Browse files
committed
[LoopUnroll] Don't modify TripCount/TripMultiple in computeUnrollCount() (NFCI)
As these are no longer passed to UnrollLoop(), there is no need to modify them in computeUnrollCount(). Make them non-reference parameters. Differential Revision: https://reviews.llvm.org/D104590
1 parent 908b753 commit 862313c

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

llvm/include/llvm/Transforms/Utils/UnrollLoop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ bool isSafeToUnrollAndJam(Loop *L, ScalarEvolution &SE, DominatorTree &DT,
101101
bool computeUnrollCount(Loop *L, const TargetTransformInfo &TTI,
102102
DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE,
103103
const SmallPtrSetImpl<const Value *> &EphValues,
104-
OptimizationRemarkEmitter *ORE, unsigned &TripCount,
104+
OptimizationRemarkEmitter *ORE, unsigned TripCount,
105105
unsigned MaxTripCount, bool MaxOrZero,
106-
unsigned &TripMultiple, unsigned LoopSize,
106+
unsigned TripMultiple, unsigned LoopSize,
107107
TargetTransformInfo::UnrollingPreferences &UP,
108108
TargetTransformInfo::PeelingPreferences &PP,
109109
bool &UseUpperBound);

llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ class UnrollCostEstimator {
764764
bool llvm::computeUnrollCount(
765765
Loop *L, const TargetTransformInfo &TTI, DominatorTree &DT, LoopInfo *LI,
766766
ScalarEvolution &SE, const SmallPtrSetImpl<const Value *> &EphValues,
767-
OptimizationRemarkEmitter *ORE, unsigned &TripCount, unsigned MaxTripCount,
768-
bool MaxOrZero, unsigned &TripMultiple, unsigned LoopSize,
767+
OptimizationRemarkEmitter *ORE, unsigned TripCount, unsigned MaxTripCount,
768+
bool MaxOrZero, unsigned TripMultiple, unsigned LoopSize,
769769
TargetTransformInfo::UnrollingPreferences &UP,
770770
TargetTransformInfo::PeelingPreferences &PP, bool &UseUpperBound) {
771771

@@ -829,8 +829,6 @@ bool llvm::computeUnrollCount(
829829
// Full unroll makes sense only when TripCount or its upper bound could be
830830
// statically calculated.
831831
// Also we need to check if we exceed FullUnrollMaxCount.
832-
// If using the upper bound to unroll, TripMultiple should be set to 1 because
833-
// we do not know when loop may exit.
834832

835833
// We can unroll by the upper bound amount if it's generally allowed or if
836834
// we know that the loop is executed either the upper bound or zero times.
@@ -859,8 +857,6 @@ bool llvm::computeUnrollCount(
859857
// like the rest of the loop body.
860858
if (UCE.getUnrolledLoopSize(UP) < UP.Threshold) {
861859
UseUpperBound = (FullUnrollMaxTripCount == FullUnrollTripCount);
862-
TripCount = FullUnrollTripCount;
863-
TripMultiple = UP.UpperBound ? 1 : TripMultiple;
864860
return ExplicitUnroll;
865861
} else {
866862
// The loop isn't that small, but we still can fully unroll it if that
@@ -874,8 +870,6 @@ bool llvm::computeUnrollCount(
874870
getFullUnrollBoostingFactor(*Cost, UP.MaxPercentThresholdBoost);
875871
if (Cost->UnrolledCost < UP.Threshold * Boost / 100) {
876872
UseUpperBound = (FullUnrollMaxTripCount == FullUnrollTripCount);
877-
TripCount = FullUnrollTripCount;
878-
TripMultiple = UP.UpperBound ? 1 : TripMultiple;
879873
return ExplicitUnroll;
880874
}
881875
}
@@ -1177,9 +1171,6 @@ static LoopUnrollResult tryToUnrollLoop(
11771171
TripMultiple, LoopSize, UP, PP, UseUpperBound);
11781172
if (!UP.Count)
11791173
return LoopUnrollResult::Unmodified;
1180-
// Unroll factor (Count) must be less or equal to TripCount.
1181-
if (TripCount && UP.Count > TripCount)
1182-
UP.Count = TripCount;
11831174

11841175
if (PP.PeelCount) {
11851176
assert(UP.Count == 1 && "Cannot perform peel and unroll in the same step");

0 commit comments

Comments
 (0)