From 7f68a309ac68d43752ffe5e543fe03c4d4e2a989 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 15 Jun 2018 21:06:43 +0000 Subject: [PATCH] [BPI] Remove unnecessary std::list vector is sufficient here. No functionality change intended. llvm-svn: 334865 --- llvm/lib/Analysis/BranchProbabilityInfo.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 1a4fc04..54a6570 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -500,13 +500,13 @@ computeUnlikelySuccessors(const BasicBlock *BB, Loop *L, PHINode *CmpPHI = dyn_cast(CmpLHS); Constant *CmpConst = dyn_cast(CI->getOperand(1)); // Collect the instructions until we hit a PHI - std::list InstChain; + SmallVector InstChain; while (!CmpPHI && CmpLHS && isa(CmpLHS) && isa(CmpLHS->getOperand(1))) { // Stop if the chain extends outside of the loop if (!L->contains(CmpLHS)) return; - InstChain.push_front(dyn_cast(CmpLHS)); + InstChain.push_back(cast(CmpLHS)); CmpLHS = dyn_cast(CmpLHS->getOperand(0)); if (CmpLHS) CmpPHI = dyn_cast(CmpLHS); @@ -542,10 +542,9 @@ computeUnlikelySuccessors(const BasicBlock *BB, Loop *L, 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(I->getOperand(1)), - true); + cast(I->getOperand(1)), true); if (!CmpLHSConst) break; } -- 2.7.4