[PATCH] D103584: [LoopUnroll] Eliminate PreserveOnlyFirst parameter [nfc]
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 3 10:33:26 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44d70d298acc: [LoopUnroll] Eliminate PreserveOnlyFirst parameter [nfc] (authored by reames).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103584/new/
https://reviews.llvm.org/D103584
Files:
llvm/include/llvm/Transforms/Utils/UnrollLoop.h
llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
llvm/lib/Transforms/Utils/LoopUnroll.cpp
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
Index: llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -987,7 +987,7 @@
{/*Count*/ Count - 1, /*TripCount*/ Count - 1,
/*Force*/ false, /*AllowRuntime*/ false,
/*AllowExpensiveTripCount*/ false, /*PreserveCondBr*/ true,
- /*PreserveOnlyFirst*/ false, /*TripMultiple*/ 1,
+ /*TripMultiple*/ 1,
/*PeelCount*/ 0, /*UnrollRemainder*/ false, ForgetAllSCEV},
LI, SE, DT, AC, TTI, /*ORE*/ nullptr, PreserveLCSSA);
}
Index: llvm/lib/Transforms/Utils/LoopUnroll.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -256,8 +256,7 @@
///
/// PreserveCondBr indicates whether the conditional branch of the LatchBlock
/// needs to be preserved. It is needed when we use trip count upper bound to
-/// fully unroll the loop. If PreserveOnlyFirst is also set then only the first
-/// conditional branch needs to be preserved.
+/// fully unroll the loop.
///
/// Similarly, TripMultiple divides the number of times that the LatchBlock may
/// execute without exiting the loop.
@@ -381,6 +380,11 @@
any_of(ExitBlocks,
[](const BasicBlock *BB) { return isa<PHINode>(BB->begin()); });
+ const unsigned MaxTripCount = SE->getSmallConstantMaxTripCount(L);
+ const bool MaxOrZero = SE->isBackedgeTakenCountMaxOrZero(L);
+
+ const bool PreserveOnlyFirst = ULO.Count == MaxTripCount && MaxOrZero;
+
// The current loop unroll pass can unroll loops that have
// (1) single latch; and
// (2a) latch is unconditional; or
@@ -755,7 +759,7 @@
auto WillExit = [&](unsigned i, unsigned j) -> Optional<bool> {
if (CompletelyUnroll) {
- if (ULO.PreserveCondBr && j && !(ULO.PreserveOnlyFirst && i != 0))
+ if (ULO.PreserveCondBr && j && !(PreserveOnlyFirst && i != 0))
return None;
return j == 0;
}
Index: llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -1166,7 +1166,7 @@
LoopUnrollResult UnrollResult = UnrollLoop(
L,
{UP.Count, TripCount, UP.Force, UP.Runtime, UP.AllowExpensiveTripCount,
- UseUpperBound, MaxOrZero, TripMultiple, PP.PeelCount, UP.UnrollRemainder,
+ UseUpperBound, TripMultiple, PP.PeelCount, UP.UnrollRemainder,
ForgetAllSCEV},
LI, &SE, &DT, &AC, &TTI, &ORE, PreserveLCSSA, &RemainderLoop);
if (UnrollResult == LoopUnrollResult::Unmodified)
Index: llvm/include/llvm/Transforms/Utils/UnrollLoop.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/UnrollLoop.h
+++ llvm/include/llvm/Transforms/Utils/UnrollLoop.h
@@ -71,7 +71,6 @@
bool AllowRuntime;
bool AllowExpensiveTripCount;
bool PreserveCondBr;
- bool PreserveOnlyFirst;
unsigned TripMultiple;
unsigned PeelCount;
bool UnrollRemainder;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103584.349603.patch
Type: text/x-patch
Size: 3298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/153741a0/attachment.bin>
More information about the llvm-commits
mailing list