[llvm] r341850 - [InstCombine] use SelectInst operand names to make code clearer; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 10 11:37:59 PDT 2018
Author: spatel
Date: Mon Sep 10 11:37:59 2018
New Revision: 341850
URL: http://llvm.org/viewvc/llvm-project?rev=341850&view=rev
Log:
[InstCombine] use SelectInst operand names to make code clearer; NFC
Cleanup step for D51433.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=341850&r1=341849&r2=341850&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Mon Sep 10 11:37:59 2018
@@ -1260,13 +1260,15 @@ Value *InstCombiner::SimplifyDemandedVec
break;
}
case Instruction::Select: {
+ SelectInst *Sel = cast<SelectInst>(I);
+ Value *Cond = Sel->getCondition();
+
APInt DemandedLHS(DemandedElts), DemandedRHS(DemandedElts);
- if (auto *CV = dyn_cast<ConstantVector>(I->getOperand(0))) {
+ if (auto *CV = dyn_cast<ConstantVector>(Cond)) {
for (unsigned i = 0; i < VWidth; i++) {
+ // isNullValue() always returns false when called on a ConstantExpr.
+ // Skip constant expressions to avoid propagating incorrect information.
Constant *CElt = CV->getAggregateElement(i);
- // Method isNullValue always returns false when called on a
- // ConstantExpr. If CElt is a ConstantExpr then skip it in order to
- // to avoid propagating incorrect information.
if (isa<ConstantExpr>(CElt))
continue;
if (CElt->isNullValue())
@@ -1276,15 +1278,15 @@ Value *InstCombiner::SimplifyDemandedVec
}
}
- if (Value *V = SimplifyDemandedVectorElts(I->getOperand(1), DemandedLHS,
+ if (Value *V = SimplifyDemandedVectorElts(Sel->getTrueValue(), DemandedLHS,
UndefElts2, Depth + 1)) {
- I->setOperand(1, V);
+ Sel->setTrueValue(V);
MadeChange = true;
}
- if (Value *V = SimplifyDemandedVectorElts(I->getOperand(2), DemandedRHS,
+ if (Value *V = SimplifyDemandedVectorElts(Sel->getFalseValue(), DemandedRHS,
UndefElts3, Depth + 1)) {
- I->setOperand(2, V);
+ Sel->setFalseValue(V);
MadeChange = true;
}
More information about the llvm-commits
mailing list