From 48afe9e63601238d166624ff964cedbe743dd003 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 6 Sep 2018 13:19:22 +0000 Subject: [PATCH] [InstCombine] fix formatting in SimplifyDemandedVectorElts->Select; NFCI I'm preparing to add the same functionality both here and to the DAG version of this code in D51696 / D51433, so try to make those cases as similar as possible to avoid bugs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341545 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/InstCombineSimplifyDemanded.cpp | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 425f5ce384b..c5fe5561c0b 100644 --- a/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -1260,8 +1260,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, break; } case Instruction::Select: { - APInt LeftDemanded(DemandedElts), RightDemanded(DemandedElts); - if (ConstantVector* CV = dyn_cast(I->getOperand(0))) { + APInt DemandedLHS(DemandedElts), DemandedRHS(DemandedElts); + if (auto *CV = dyn_cast(I->getOperand(0))) { for (unsigned i = 0; i < VWidth; i++) { Constant *CElt = CV->getAggregateElement(i); // Method isNullValue always returns false when called on a @@ -1270,22 +1270,26 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (isa(CElt)) continue; if (CElt->isNullValue()) - LeftDemanded.clearBit(i); + DemandedLHS.clearBit(i); else - RightDemanded.clearBit(i); + DemandedRHS.clearBit(i); } } - TmpV = SimplifyDemandedVectorElts(I->getOperand(1), LeftDemanded, UndefElts, - Depth + 1); - if (TmpV) { I->setOperand(1, TmpV); MadeChange = true; } + if (Value *V = SimplifyDemandedVectorElts(I->getOperand(1), DemandedLHS, + UndefElts2, Depth + 1)) { + I->setOperand(1, V); + MadeChange = true; + } - TmpV = SimplifyDemandedVectorElts(I->getOperand(2), RightDemanded, - UndefElts2, Depth + 1); - if (TmpV) { I->setOperand(2, TmpV); MadeChange = true; } + if (Value *V = SimplifyDemandedVectorElts(I->getOperand(2), DemandedRHS, + UndefElts3, Depth + 1)) { + I->setOperand(2, V); + MadeChange = true; + } - // Output elements are undefined if both are undefined. - UndefElts &= UndefElts2; + // Output elements are undefined if the element from each arm is undefined. + UndefElts = UndefElts2 & UndefElts3; break; } case Instruction::BitCast: { -- 2.11.0