diff options
author | Sidharth Baveja <sidharth.baveja@ibm.com> | 2021-02-05 16:10:53 +0000 |
---|---|---|
committer | Sidharth Baveja <sidharth.baveja@ibm.com> | 2021-02-05 16:10:53 +0000 |
commit | 22ebbc47655737eb543c8641b2e8491846b3aefb (patch) | |
tree | 7531d22b46c6ddcc4cd62bbe16a4b4c197541a37 /llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp | |
parent | d88c55ab95c9985e366b62569f2a50cf8ce5c469 (diff) | |
download | llvm-22ebbc47655737eb543c8641b2e8491846b3aefb.zip llvm-22ebbc47655737eb543c8641b2e8491846b3aefb.tar.gz llvm-22ebbc47655737eb543c8641b2e8491846b3aefb.tar.bz2 |
LoopUnrollAndJam] Only allow loops with single exit(ing) blocks
Summary:
This resolves an issue posted on Bugzilla. https://bugs.llvm.org/show_bug.cgi?id=48764
In this issue, the loop had multiple exit blocks, which resulted in the
function getExitBlock to return a nullptr, which resulted in hitting the assert.
This patch ensures that loops which only have one exit block as allowed to be
unrolled and jammed.
Reviewed By: Whitney, Meinersbur, dmgreen
Differential Revision: https://reviews.llvm.org/D95806
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp index 6e32a2b..c62049c 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp @@ -831,6 +831,23 @@ static bool isEligibleLoopForm(const Loop &Root) { if (SubLoopsSize != 1) return false; + // Only loops with a single exit block can be unrolled and jammed. + // The function getExitBlock() is used for this check, rather than + // getUniqueExitBlock() to ensure loops with mulitple exit edges are + // disallowed. + if (!L->getExitBlock()) { + LLVM_DEBUG(dbgs() << "Won't unroll-and-jam; only loops with single exit " + "blocks can be unrolled and jammed.\n"); + return false; + } + + // Only loops with a single exiting block can be unrolled and jammed. + if (!L->getExitingBlock()) { + LLVM_DEBUG(dbgs() << "Won't unroll-and-jam; only loops with single " + "exiting blocks can be unrolled and jammed.\n"); + return false; + } + L = L->getSubLoops()[0]; } while (L); |