[llvm] r334865 - [BPI] Remove unnecessary std::list

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 15 14:06:44 PDT 2018


Author: d0k
Date: Fri Jun 15 14:06:43 2018
New Revision: 334865

URL: http://llvm.org/viewvc/llvm-project?rev=334865&view=rev
Log:
[BPI] Remove unnecessary std::list

vector is sufficient here. No functionality change intended.

Modified:
    llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp

Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=334865&r1=334864&r2=334865&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Fri Jun 15 14:06:43 2018
@@ -500,13 +500,13 @@ computeUnlikelySuccessors(const BasicBlo
   PHINode *CmpPHI = dyn_cast<PHINode>(CmpLHS);
   Constant *CmpConst = dyn_cast<Constant>(CI->getOperand(1));
   // Collect the instructions until we hit a PHI
-  std::list<BinaryOperator*> InstChain;
+  SmallVector<BinaryOperator *, 1> InstChain;
   while (!CmpPHI && CmpLHS && isa<BinaryOperator>(CmpLHS) &&
          isa<Constant>(CmpLHS->getOperand(1))) {
     // Stop if the chain extends outside of the loop
     if (!L->contains(CmpLHS))
       return;
-    InstChain.push_front(dyn_cast<BinaryOperator>(CmpLHS));
+    InstChain.push_back(cast<BinaryOperator>(CmpLHS));
     CmpLHS = dyn_cast<Instruction>(CmpLHS->getOperand(0));
     if (CmpLHS)
       CmpPHI = dyn_cast<PHINode>(CmpLHS);
@@ -542,10 +542,9 @@ computeUnlikelySuccessors(const BasicBlo
           std::find(succ_begin(BB), succ_end(BB), B) == succ_end(BB))
         continue;
       // First collapse InstChain
-      for (Instruction *I : InstChain) {
+      for (Instruction *I : llvm::reverse(InstChain)) {
         CmpLHSConst = ConstantExpr::get(I->getOpcode(), CmpLHSConst,
-                                        dyn_cast<Constant>(I->getOperand(1)),
-                                        true);
+                                        cast<Constant>(I->getOperand(1)), true);
         if (!CmpLHSConst)
           break;
       }




More information about the llvm-commits mailing list