diff options
author | Florian Hahn <florian.hahn@arm.com> | 2018-09-07 14:40:06 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2018-09-07 14:40:06 +0000 |
commit | e32ff4b28af4860505e06344383768ce832f615d (patch) | |
tree | aff29cf90589751e032f3fdfcf402c37217e17be /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | 832c4afe00916c11c84130cd39b29e330a5e4d70 (diff) | |
download | bcm5719-llvm-e32ff4b28af4860505e06344383768ce832f615d.tar.gz bcm5719-llvm-e32ff4b28af4860505e06344383768ce832f615d.zip |
[InstCombine] Do not fold scalar ops over select with vector condition.
If OtherOpT or OtherOpF have scalar types and the condition is a vector,
we would create an invalid select.
Reviewers: spatel, john.brawn, mssimpso, craig.topper
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D51781
llvm-svn: 341666
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 3b79ea55a21..622b6eace5d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -362,6 +362,14 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI, return nullptr; } + // If the select condition is a vector, the operands of the original select's + // operands also must be vectors. This may not be the case for getelementptr + // for example. + if (SI.getCondition()->getType()->isVectorTy() && + (!OtherOpT->getType()->isVectorTy() || + !OtherOpF->getType()->isVectorTy())) + return nullptr; + // If we reach here, they do have operations in common. Value *NewSI = Builder.CreateSelect(SI.getCondition(), OtherOpT, OtherOpF, SI.getName() + ".v", &SI); |