diff options
author | Pete Cooper <peter_cooper@apple.com> | 2012-07-26 23:10:24 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2012-07-26 23:10:24 +0000 |
commit | abc13af9c6ccbaf730f3f6e719dee37374a22017 (patch) | |
tree | 0b1ab0744fa2b0b653dde30631cca3eb014e7bf3 /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | 7cd08536c21d8ad7d814c109ff2f255174be4fed (diff) | |
download | bcm5719-llvm-abc13af9c6ccbaf730f3f6e719dee37374a22017.tar.gz bcm5719-llvm-abc13af9c6ccbaf730f3f6e719dee37374a22017.zip |
Simplify demanded bits of select sources where the condition is a constant vector
llvm-svn: 160835
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index eb9945b6817..bdd97a862b7 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -899,5 +899,16 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { return &SI; } + if (VectorType* VecTy = dyn_cast<VectorType>(SI.getType())) { + unsigned VWidth = VecTy->getNumElements(); + APInt UndefElts(VWidth, 0); + APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); + if (Value *V = SimplifyDemandedVectorElts(&SI, AllOnesEltMask, UndefElts)) { + if (V != &SI) + return ReplaceInstUsesWith(SI, V); + return &SI; + } + } + return 0; } |