aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2017-04-17 05:38:28 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2017-04-17 05:38:28 +0000
commit8ed6b66d853cbdb13ab838bcb47ea6feb94c09f3 (patch)
tree5ad4218fb70a7501a7c0986bf8484c0b448ba3fd /llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
parent2616bbb16d8a2ba0817b846fb3fc354f6f511260 (diff)
downloadllvm-8ed6b66d853cbdb13ab838bcb47ea6feb94c09f3.zip
llvm-8ed6b66d853cbdb13ab838bcb47ea6feb94c09f3.tar.gz
llvm-8ed6b66d853cbdb13ab838bcb47ea6feb94c09f3.tar.bz2
[LoopPeeling] Fix condition for phi-eliminating peeling
When peeling loops basing on phis becoming invariants, we make a wrong loop size check. UP.Threshold should be compared against the total numbers of instructions after the transformation, which is equal to 2 * LoopSize in case of peeling one iteration. We should also check that the maximum allowed number of peeled iterations is not zero. Reviewers: sanjoy, anna, reames, mkuper Reviewed By: mkuper Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31753 llvm-svn: 300441
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
index 73c14f5..a5f2765 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
@@ -82,7 +82,8 @@ 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 (LoopSize <= UP.Threshold) {
+ // First, check that we can peel at least one iteration.
+ if (2 * LoopSize <= UP.Threshold && UnrollPeelMaxCount > 0) {
BasicBlock *BackEdge = L->getLoopLatch();
assert(BackEdge && "Loop is not in simplified form?");
BasicBlock *Header = L->getHeader();