From 862313cf59eef22023cc8c5d93bd368e661791d1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 19 Jun 2021 10:09:12 +0200 Subject: [PATCH] [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 --- llvm/include/llvm/Transforms/Utils/UnrollLoop.h | 4 ++-- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Transforms/Utils/UnrollLoop.h b/llvm/include/llvm/Transforms/Utils/UnrollLoop.h index 4a22b57..d95ead2 100644 --- a/llvm/include/llvm/Transforms/Utils/UnrollLoop.h +++ b/llvm/include/llvm/Transforms/Utils/UnrollLoop.h @@ -101,9 +101,9 @@ bool isSafeToUnrollAndJam(Loop *L, ScalarEvolution &SE, DominatorTree &DT, bool computeUnrollCount(Loop *L, const TargetTransformInfo &TTI, DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE, const SmallPtrSetImpl &EphValues, - OptimizationRemarkEmitter *ORE, unsigned &TripCount, + OptimizationRemarkEmitter *ORE, unsigned TripCount, unsigned MaxTripCount, bool MaxOrZero, - unsigned &TripMultiple, unsigned LoopSize, + unsigned TripMultiple, unsigned LoopSize, TargetTransformInfo::UnrollingPreferences &UP, TargetTransformInfo::PeelingPreferences &PP, bool &UseUpperBound); diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index ce1b1d7..49501f3 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -764,8 +764,8 @@ public: bool llvm::computeUnrollCount( Loop *L, const TargetTransformInfo &TTI, DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE, const SmallPtrSetImpl &EphValues, - OptimizationRemarkEmitter *ORE, unsigned &TripCount, unsigned MaxTripCount, - bool MaxOrZero, unsigned &TripMultiple, unsigned LoopSize, + OptimizationRemarkEmitter *ORE, unsigned TripCount, unsigned MaxTripCount, + bool MaxOrZero, unsigned TripMultiple, unsigned LoopSize, TargetTransformInfo::UnrollingPreferences &UP, TargetTransformInfo::PeelingPreferences &PP, bool &UseUpperBound) { @@ -829,8 +829,6 @@ bool llvm::computeUnrollCount( // Full unroll makes sense only when TripCount or its upper bound could be // statically calculated. // Also we need to check if we exceed FullUnrollMaxCount. - // If using the upper bound to unroll, TripMultiple should be set to 1 because - // we do not know when loop may exit. // We can unroll by the upper bound amount if it's generally allowed or if // we know that the loop is executed either the upper bound or zero times. @@ -859,8 +857,6 @@ bool llvm::computeUnrollCount( // like the rest of the loop body. if (UCE.getUnrolledLoopSize(UP) < UP.Threshold) { UseUpperBound = (FullUnrollMaxTripCount == FullUnrollTripCount); - TripCount = FullUnrollTripCount; - TripMultiple = UP.UpperBound ? 1 : TripMultiple; return ExplicitUnroll; } else { // The loop isn't that small, but we still can fully unroll it if that @@ -874,8 +870,6 @@ bool llvm::computeUnrollCount( getFullUnrollBoostingFactor(*Cost, UP.MaxPercentThresholdBoost); if (Cost->UnrolledCost < UP.Threshold * Boost / 100) { UseUpperBound = (FullUnrollMaxTripCount == FullUnrollTripCount); - TripCount = FullUnrollTripCount; - TripMultiple = UP.UpperBound ? 1 : TripMultiple; return ExplicitUnroll; } } @@ -1177,9 +1171,6 @@ static LoopUnrollResult tryToUnrollLoop( TripMultiple, LoopSize, UP, PP, UseUpperBound); if (!UP.Count) return LoopUnrollResult::Unmodified; - // Unroll factor (Count) must be less or equal to TripCount. - if (TripCount && UP.Count > TripCount) - UP.Count = TripCount; if (PP.PeelCount) { assert(UP.Count == 1 && "Cannot perform peel and unroll in the same step"); -- 2.7.4