break;
}
case Instruction::Select: {
- APInt LeftDemanded(DemandedElts), RightDemanded(DemandedElts);
- if (ConstantVector* CV = dyn_cast<ConstantVector>(I->getOperand(0))) {
+ APInt DemandedLHS(DemandedElts), DemandedRHS(DemandedElts);
+ if (auto *CV = dyn_cast<ConstantVector>(I->getOperand(0))) {
for (unsigned i = 0; i < VWidth; i++) {
Constant *CElt = CV->getAggregateElement(i);
// Method isNullValue always returns false when called on a
if (isa<ConstantExpr>(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: {