diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/EarlyCSE.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/EarlyCSE.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp index 80739a02e9f..565745d12e9 100644 --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -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) |