summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2017-03-07 06:03:15 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2017-03-07 06:03:15 +0000
commit30c3538e2e88858c34611c5ba554658ede11691d (patch)
tree9df4742856e87a5dca1777784b0d2a134b1b74e7 /llvm/lib/Transforms/Utils
parentb60a46fea1a920445f3de6d91be7496cd6e68466 (diff)
downloadbcm5719-llvm-30c3538e2e88858c34611c5ba554658ede11691d.tar.gz
bcm5719-llvm-30c3538e2e88858c34611c5ba554658ede11691d.zip
[LoopUnrolling] Fix loop size check for peeling
Summary: We should check if loop size allows us to peel at least one iteration before we do so. Patch by Max Kazantsev! Reviewers: sanjoy, mkuper, efriedma Reviewed By: mkuper Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30632 llvm-svn: 297122
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
index 55bfc25a086..b8147fcb697 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
@@ -75,7 +75,9 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize,
// its only back edge. If there is such Phi, peeling 1 iteration from the
// loop is profitable, because starting from 2nd iteration we will have an
// invariant instead of this Phi.
- if (auto *BackEdge = L->getLoopLatch()) {
+ if (LoopSize <= UP.Threshold) {
+ BasicBlock *BackEdge = L->getLoopLatch();
+ assert(BackEdge && "Loop is not in simplified form?");
BasicBlock *Header = L->getHeader();
// Iterate over Phis to find one with invariant input on back edge.
bool FoundCandidate = false;
OpenPOWER on IntegriCloud