summaryrefslogtreecommitdiff
path: root/lib/Transforms/Vectorize/LoopVectorize.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-01-27 08:17:58 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-01-27 08:17:58 +0000
commit0afd0bc5facb63a96c706dc8a2468327ee3161da (patch)
treeef09547c51a9ed0e8df1c83bc96770af02518018 /lib/Transforms/Vectorize/LoopVectorize.cpp
parent7018cd5af77e88924bc0658c49a27637019a1927 (diff)
downloadllvm-0afd0bc5facb63a96c706dc8a2468327ee3161da.tar.gz
llvm-0afd0bc5facb63a96c706dc8a2468327ee3161da.tar.bz2
llvm-0afd0bc5facb63a96c706dc8a2468327ee3161da.tar.xz
[vectorizer] Clean up the handling of unvectorized loop unrolling in the
LoopVectorize pass. The logic here doesn't make much sense. We *only* unrolled if the unvectorized loop was a reduction loop with a single basic block *and* small loop body. The reduction part in particular doesn't make much sense. Instead, if we just fall through to the vectorized unroll logic it makes more sense of unrolling if there is a vectorized reduction that could be hacked on by the SLP vectorizer *or* if the loop is small. This is mostly a cleanup and nothing in the test suite really exercises this, but I did run benchmarks across this change and saw no really significant changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9db66e7e69..66134bd95d 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4995,19 +4995,9 @@ LoopVectorizationCostModel::selectUnrollFactor(bool OptForSize,
else if (UF < 1)
UF = 1;
- bool HasReductions = Legal->getReductionVars()->size();
-
- // Decide if we want to unroll if we decided that it is legal to vectorize
- // but not profitable.
- if (VF == 1) {
- if (TheLoop->getNumBlocks() > 1 || !HasReductions ||
- LoopCost > SmallLoopCost)
- return 1;
-
- return UF;
- }
-
- if (HasReductions) {
+ // Unroll if we vectorized this loop and there is a reduction that could
+ // benefit from unrolling.
+ if (VF > 1 && Legal->getReductionVars()->size()) {
DEBUG(dbgs() << "LV: Unrolling because of reductions.\n");
return UF;
}