summaryrefslogtreecommitdiff
path: root/lib/Transforms/Vectorize/BBVectorize.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2012-11-13 03:12:40 +0000
committerHal Finkel <hfinkel@anl.gov>2012-11-13 03:12:40 +0000
commit4387b8c95971a512e07bfda30dea6459e8419e8f (patch)
tree856f3aca8f216e27a9753901c637a80ff02f4e30 /lib/Transforms/Vectorize/BBVectorize.cpp
parent310fa65ab9acb96319d0fcb779cdd35350f5d00f (diff)
downloadllvm-4387b8c95971a512e07bfda30dea6459e8419e8f.tar.gz
llvm-4387b8c95971a512e07bfda30dea6459e8419e8f.tar.bz2
llvm-4387b8c95971a512e07bfda30dea6459e8419e8f.tar.xz
BBVectorize: Don't vectorize vector-manipulation chains
Don't choose a vectorization plan containing only shuffles and vector inserts/extracts. Due to inperfections in the cost model, these can lead to infinite recusion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167811 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Vectorize/BBVectorize.cpp')
-rw-r--r--lib/Transforms/Vectorize/BBVectorize.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Transforms/Vectorize/BBVectorize.cpp b/lib/Transforms/Vectorize/BBVectorize.cpp
index 32a37bad7f..a2c3ad7d46 100644
--- a/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -1703,10 +1703,20 @@ assert(n < 10 && "hrmm, really?");
// The set of pairs that have already contributed to the total cost.
DenseSet<ValuePair> IncomingPairs;
+ // If the cost model were perfect, this might not be necessary; but we
+ // need to make sure that we don't get stuck vectorizing our own
+ // shuffle chains.
+ bool HasNontrivialInsts = false;
+
// The node weights represent the cost savings associated with
// fusing the pair of instructions.
for (DenseSet<ValuePair>::iterator S = PrunedTree.begin(),
E = PrunedTree.end(); S != E; ++S) {
+ if (!isa<ShuffleVectorInst>(S->first) &&
+ !isa<InsertElementInst>(S->first) &&
+ !isa<ExtractElementInst>(S->first))
+ HasNontrivialInsts = true;
+
bool FlipOrder = false;
if (getDepthFactor(S->first)) {
@@ -1943,6 +1953,13 @@ assert(n < 10 && "hrmm, really?");
}
}
}
+
+ if (!HasNontrivialInsts) {
+ DEBUG(if (DebugPairSelection) dbgs() <<
+ "\tNo non-trivial instructions in tree;"
+ " override to zero effective size\n");
+ EffSize = 0;
+ }
} else {
for (DenseSet<ValuePair>::iterator S = PrunedTree.begin(),
E = PrunedTree.end(); S != E; ++S)