[PATCH] D104590: [LoopUnroll] Don't modify TripCount/TripMultiple in computeUnrollCount()
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 19 12:31:14 PDT 2021
nikic updated this revision to Diff 353207.
nikic added a comment.
Remove outdated comment.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104590/new/
https://reviews.llvm.org/D104590
Files:
llvm/include/llvm/Transforms/Utils/UnrollLoop.h
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
Index: llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -764,8 +764,8 @@
bool llvm::computeUnrollCount(
Loop *L, const TargetTransformInfo &TTI, DominatorTree &DT, LoopInfo *LI,
ScalarEvolution &SE, const SmallPtrSetImpl<const Value *> &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 @@
// 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 @@
// 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 @@
getFullUnrollBoostingFactor(*Cost, UP.MaxPercentThresholdBoost);
if (Cost->UnrolledCost < UP.Threshold * Boost / 100) {
UseUpperBound = (FullUnrollMaxTripCount == FullUnrollTripCount);
- TripCount = FullUnrollTripCount;
- TripMultiple = UP.UpperBound ? 1 : TripMultiple;
return ExplicitUnroll;
}
}
@@ -1166,9 +1160,6 @@
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");
Index: llvm/include/llvm/Transforms/Utils/UnrollLoop.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/UnrollLoop.h
+++ llvm/include/llvm/Transforms/Utils/UnrollLoop.h
@@ -101,9 +101,9 @@
bool computeUnrollCount(Loop *L, const TargetTransformInfo &TTI,
DominatorTree &DT, LoopInfo *LI, ScalarEvolution &SE,
const SmallPtrSetImpl<const Value *> &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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104590.353207.patch
Type: text/x-patch
Size: 3497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210619/771cf4e6/attachment.bin>
More information about the llvm-commits
mailing list