[EarlyCSE] Fix MSVC build. NFCI.

MSVC doesn't let you assign different lambdas through a ternary operator.

llvm-svn: 334715
This commit is contained in:
Simon Pilgrim 2018-06-14 14:22:03 +00:00
parent 607a1e2196
commit dee9c67f24
1 changed files with 5 additions and 9 deletions

View File

@ -719,20 +719,16 @@ bool EarlyCSE::handleBranchCondition(Instruction *CondInst,
auto *TorF = (BI->getSuccessor(0) == BB)
? ConstantInt::getTrue(BB->getContext())
: ConstantInt::getFalse(BB->getContext());
auto IsAnd = [](Instruction *I) {
auto MatchBinOp = [](Instruction *I, unsigned Opcode) {
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(I))
return BOp->getOpcode() == Instruction::And;
return false;
};
auto IsOr = [](Instruction *I) {
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(I))
return BOp->getOpcode() == Instruction::Or;
return BOp->getOpcode() == Opcode;
return false;
};
// If the condition is AND operation, we can propagate its operands into the
// true branch. If it is OR operation, we can propagate them into the false
// branch.
auto CanPropagateOperands = (BI->getSuccessor(0) == BB) ? IsAnd : IsOr;
unsigned PropagateOpcode =
(BI->getSuccessor(0) == BB) ? Instruction::And : Instruction::Or;
bool MadeChanges = false;
SmallVector<Instruction *, 4> WorkList;
@ -756,7 +752,7 @@ bool EarlyCSE::handleBranchCondition(Instruction *CondInst,
}
}
if (CanPropagateOperands(Curr))
if (MatchBinOp(Curr, PropagateOpcode))
for (auto &Op : cast<BinaryOperator>(Curr)->operands())
if (Instruction *OPI = dyn_cast<Instruction>(Op))
if (SimpleValue::canHandle(OPI) && Visited.insert(OPI).second)