summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
diff options
context:
space:
mode:
authorSerguei Katkov <serguei.katkov@azul.com>2019-07-15 05:51:10 +0000
committerSerguei Katkov <serguei.katkov@azul.com>2019-07-15 05:51:10 +0000
commitf1ee04c42a431d88cd66b884570ca7928cffd0cd (patch)
treeb03a56ba843ebe73213bfb0964f69d3d65039934 /llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
parent335f955dc4942d6956e759b8c2686c52914c36b6 (diff)
downloadbcm5719-llvm-f1ee04c42a431d88cd66b884570ca7928cffd0cd.tar.gz
bcm5719-llvm-f1ee04c42a431d88cd66b884570ca7928cffd0cd.zip
[LoopInfo] Introduce getUniqueNonLatchExitBlocks utility function
Extract the code from LoopUnrollRuntime into utility function to re-use it in D63923. Reviewers: reames, mkuper Reviewed By: reames Subscribers: fhahn, hiraditya, zzheng, dmgreen, llvm-commits Differential Revision: https://reviews.llvm.org/D64548 llvm-svn: 366040
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index b39d78dde00..d22fdb4d52d 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -424,10 +424,9 @@ CloneLoopBlocks(Loop *L, Value *NewIter, const bool CreateRemainderLoop,
/// Returns true if we can safely unroll a multi-exit/exiting loop. OtherExits
/// is populated with all the loop exit blocks other than the LatchExit block.
-static bool
-canSafelyUnrollMultiExitLoop(Loop *L, SmallVectorImpl<BasicBlock *> &OtherExits,
- BasicBlock *LatchExit, bool PreserveLCSSA,
- bool UseEpilogRemainder) {
+static bool canSafelyUnrollMultiExitLoop(Loop *L, BasicBlock *LatchExit,
+ bool PreserveLCSSA,
+ bool UseEpilogRemainder) {
// We currently have some correctness constrains in unrolling a multi-exit
// loop. Check for these below.
@@ -435,11 +434,6 @@ canSafelyUnrollMultiExitLoop(Loop *L, SmallVectorImpl<BasicBlock *> &OtherExits,
// We rely on LCSSA form being preserved when the exit blocks are transformed.
if (!PreserveLCSSA)
return false;
- SmallVector<BasicBlock *, 4> Exits;
- L->getUniqueExitBlocks(Exits);
- for (auto *BB : Exits)
- if (BB != LatchExit)
- OtherExits.push_back(BB);
// TODO: Support multiple exiting blocks jumping to the `LatchExit` when
// UnrollRuntimeMultiExit is true. This will need updating the logic in
@@ -469,9 +463,8 @@ static bool canProfitablyUnrollMultiExitLoop(
bool PreserveLCSSA, bool UseEpilogRemainder) {
#if !defined(NDEBUG)
- SmallVector<BasicBlock *, 8> OtherExitsDummyCheck;
- assert(canSafelyUnrollMultiExitLoop(L, OtherExitsDummyCheck, LatchExit,
- PreserveLCSSA, UseEpilogRemainder) &&
+ assert(canSafelyUnrollMultiExitLoop(L, LatchExit, PreserveLCSSA,
+ UseEpilogRemainder) &&
"Should be safe to unroll before checking profitability!");
#endif
@@ -595,8 +588,9 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
// These are exit blocks other than the target of the latch exiting block.
SmallVector<BasicBlock *, 4> OtherExits;
+ L->getUniqueNonLatchExitBlocks(OtherExits);
bool isMultiExitUnrollingEnabled =
- canSafelyUnrollMultiExitLoop(L, OtherExits, LatchExit, PreserveLCSSA,
+ canSafelyUnrollMultiExitLoop(L, LatchExit, PreserveLCSSA,
UseEpilogRemainder) &&
canProfitablyUnrollMultiExitLoop(L, OtherExits, LatchExit, PreserveLCSSA,
UseEpilogRemainder);
OpenPOWER on IntegriCloud