Skip to content

Commit 1a00ffd

Browse files
committedSep 6, 2018
[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. llvm-svn: 341545
1 parent afbf318 commit 1a00ffd

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed
 

‎llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

+16-12
Original file line numberDiff line numberDiff line change
@@ -1260,8 +1260,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
12601260
break;
12611261
}
12621262
case Instruction::Select: {
1263-
APInt LeftDemanded(DemandedElts), RightDemanded(DemandedElts);
1264-
if (ConstantVector* CV = dyn_cast<ConstantVector>(I->getOperand(0))) {
1263+
APInt DemandedLHS(DemandedElts), DemandedRHS(DemandedElts);
1264+
if (auto *CV = dyn_cast<ConstantVector>(I->getOperand(0))) {
12651265
for (unsigned i = 0; i < VWidth; i++) {
12661266
Constant *CElt = CV->getAggregateElement(i);
12671267
// Method isNullValue always returns false when called on a
@@ -1270,22 +1270,26 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
12701270
if (isa<ConstantExpr>(CElt))
12711271
continue;
12721272
if (CElt->isNullValue())
1273-
LeftDemanded.clearBit(i);
1273+
DemandedLHS.clearBit(i);
12741274
else
1275-
RightDemanded.clearBit(i);
1275+
DemandedRHS.clearBit(i);
12761276
}
12771277
}
12781278

1279-
TmpV = SimplifyDemandedVectorElts(I->getOperand(1), LeftDemanded, UndefElts,
1280-
Depth + 1);
1281-
if (TmpV) { I->setOperand(1, TmpV); MadeChange = true; }
1279+
if (Value *V = SimplifyDemandedVectorElts(I->getOperand(1), DemandedLHS,
1280+
UndefElts2, Depth + 1)) {
1281+
I->setOperand(1, V);
1282+
MadeChange = true;
1283+
}
12821284

1283-
TmpV = SimplifyDemandedVectorElts(I->getOperand(2), RightDemanded,
1284-
UndefElts2, Depth + 1);
1285-
if (TmpV) { I->setOperand(2, TmpV); MadeChange = true; }
1285+
if (Value *V = SimplifyDemandedVectorElts(I->getOperand(2), DemandedRHS,
1286+
UndefElts3, Depth + 1)) {
1287+
I->setOperand(2, V);
1288+
MadeChange = true;
1289+
}
12861290

1287-
// Output elements are undefined if both are undefined.
1288-
UndefElts &= UndefElts2;
1291+
// Output elements are undefined if the element from each arm is undefined.
1292+
UndefElts = UndefElts2 & UndefElts3;
12891293
break;
12901294
}
12911295
case Instruction::BitCast: {

0 commit comments

Comments
 (0)
Please sign in to comment.