From 7971de4178d3be9b31ac03c20e2b50c3e7f4641c Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Thu, 26 Jul 2012 23:10:24 +0000 Subject: Simplify demanded bits of select sources where the condition is a constant vector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160835 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineSelect.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/Transforms/InstCombine/InstCombineSelect.cpp') diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index eb9945b681..bdd97a862b 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -899,5 +899,16 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { return &SI; } + if (VectorType* VecTy = dyn_cast(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; } -- cgit v1.2.3-18-g5258