summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2016-05-26 18:43:57 +0000
committerMichael Kuperstein <mkuper@google.com>2016-05-26 18:43:57 +0000
commit9a81b62a0143da6a057084638adc0658c59a77ba (patch)
treee8ed27e78f6b71cd5fc99d38ea6d8ff0ea1c20b2 /llvm/lib/Transforms/Vectorize/BBVectorize.cpp
parent729e7ad31fa4c44025c58131b05fdfba0fca578a (diff)
downloadbcm5719-llvm-9a81b62a0143da6a057084638adc0658c59a77ba.tar.gz
bcm5719-llvm-9a81b62a0143da6a057084638adc0658c59a77ba.zip
[BBVectorize] Don't vectorize selects with a scalar condition and vector operands.
This fixes PR27879. Differential Revision: http://reviews.llvm.org/D20659 llvm-svn: 270888
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/BBVectorize.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/BBVectorize.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
index 72ac7a5ba2b..af594cb751a 100644
--- a/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -886,9 +886,16 @@ namespace {
Type *DestTy = C->getDestTy();
if (!DestTy->isSingleValueType())
return false;
- } else if (isa<SelectInst>(I)) {
+ } else if (SelectInst *SI = dyn_cast<SelectInst>(I)) {
if (!Config.VectorizeSelect)
return false;
+ // We can vectorize a select if either all operands are scalars,
+ // or all operands are vectors. Trying to "widen" a select between
+ // vectors that has a scalar condition results in a malformed select.
+ // FIXME: We could probably be smarter about this by rewriting the select
+ // with different types instead.
+ return (SI->getCondition()->getType()->isVectorTy() ==
+ SI->getTrueValue()->getType()->isVectorTy());
} else if (isa<CmpInst>(I)) {
if (!Config.VectorizeCmp)
return false;
OpenPOWER on IntegriCloud