[llvm] r334715 - [EarlyCSE] Fix MSVC build. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 07:22:03 PDT 2018


Author: rksimon
Date: Thu Jun 14 07:22:03 2018
New Revision: 334715

URL: http://llvm.org/viewvc/llvm-project?rev=334715&view=rev
Log:
[EarlyCSE] Fix MSVC build. NFCI.

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

Modified:
    llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=334715&r1=334714&r2=334715&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Thu Jun 14 07:22:03 2018
@@ -719,20 +719,16 @@ bool EarlyCSE::handleBranchCondition(Ins
   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(Ins
       }
     }
 
-    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)




More information about the llvm-commits mailing list