[llvm-commits] [llvm] r92734 - in /llvm/trunk/lib/Transforms: InstCombine/InstructionCombining.cpp Scalar/ADCE.cpp Scalar/DeadStoreElimination.cpp Scalar/GVN.cpp Scalar/LoopIndexSplit.cpp Scalar/MemCpyOptimizer.cpp Scalar/SCCVN.cpp Scalar/ScalarReplAggregates.cpp Scalar/SimplifyCFGPass.cpp Utils/CloneLoop.cpp Utils/Local.cpp Utils/PromoteMemoryToRegister.cpp
Dan Gohman
gohman at apple.com
Tue Jan 5 08:27:26 PST 2010
Author: djg
Date: Tue Jan 5 10:27:25 2010
New Revision: 92734
URL: http://llvm.org/viewvc/llvm-project?rev=92734&view=rev
Log:
Use do+while instead of while for loops which obviously have a
non-zero trip count. Use SmallVector's pop_back_val().
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp
llvm/trunk/lib/Transforms/Utils/CloneLoop.cpp
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Tue Jan 5 10:27:25 2010
@@ -1000,9 +1000,8 @@
SmallPtrSet<ConstantExpr*, 64> FoldedConstants;
- while (!Worklist.empty()) {
- BB = Worklist.back();
- Worklist.pop_back();
+ do {
+ BB = Worklist.pop_back_val();
// We have now visited this block! If we've already been here, ignore it.
if (!Visited.insert(BB)) continue;
@@ -1082,7 +1081,7 @@
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
Worklist.push_back(TI->getSuccessor(i));
- }
+ } while (!Worklist.empty());
// Once we've found all of the instructions to add to instcombine's worklist,
// add them in reverse order. This way instcombine will visit from the top
Modified: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ADCE.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp Tue Jan 5 10:27:25 2010
@@ -62,8 +62,7 @@
// Propagate liveness backwards to operands.
while (!worklist.empty()) {
- Instruction* curr = worklist.back();
- worklist.pop_back();
+ Instruction* curr = worklist.pop_back_val();
for (Instruction::op_iterator OI = curr->op_begin(), OE = curr->op_end();
OI != OE; ++OI)
Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Tue Jan 5 10:27:25 2010
@@ -523,9 +523,8 @@
// Before we touch this instruction, remove it from memdep!
MemoryDependenceAnalysis &MDA = getAnalysis<MemoryDependenceAnalysis>();
- while (!NowDeadInsts.empty()) {
- Instruction *DeadInst = NowDeadInsts.back();
- NowDeadInsts.pop_back();
+ do {
+ Instruction *DeadInst = NowDeadInsts.pop_back_val();
++NumFastOther;
@@ -549,7 +548,7 @@
DeadInst->eraseFromParent();
if (ValueSet) ValueSet->erase(DeadInst);
- }
+ } while (!NowDeadInsts.empty());
}
unsigned DSE::getPointerSize(Value *V) const {
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Jan 5 10:27:25 2010
@@ -829,7 +829,7 @@
SmallVector<BasicBlock*, 32> BBWorklist;
BBWorklist.push_back(BB);
- while (!BBWorklist.empty()) {
+ do {
BasicBlock *Entry = BBWorklist.pop_back_val();
// Note that this sets blocks to 0 (unavailable) if they happen to not
// already be in FullyAvailableBlocks. This is safe.
@@ -841,7 +841,7 @@
for (succ_iterator I = succ_begin(Entry), E = succ_end(Entry); I != E; ++I)
BBWorklist.push_back(*I);
- }
+ } while (!BBWorklist.empty());
return false;
}
Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Tue Jan 5 10:27:25 2010
@@ -708,7 +708,7 @@
}
while (!WorkList.empty()) {
- BasicBlock *BB = WorkList.back(); WorkList.pop_back();
+ BasicBlock *BB = WorkList.pop_back_val();
LPM->deleteSimpleAnalysisValue(BB, LP);
for(BasicBlock::iterator BBI = BB->begin(), BBE = BB->end();
BBI != BBE; ) {
@@ -726,7 +726,7 @@
// Update Frontier BBs' dominator info.
while (!FrontierBBs.empty()) {
- BasicBlock *FBB = FrontierBBs.back(); FrontierBBs.pop_back();
+ BasicBlock *FBB = FrontierBBs.pop_back_val();
BasicBlock *NewDominator = FBB->getSinglePredecessor();
if (!NewDominator) {
pred_iterator PI = pred_begin(FBB), PE = pred_end(FBB);
Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Jan 5 10:27:25 2010
@@ -562,8 +562,7 @@
SmallVector<User*, 8> srcUseList(srcAlloca->use_begin(),
srcAlloca->use_end());
while (!srcUseList.empty()) {
- User *UI = srcUseList.back();
- srcUseList.pop_back();
+ User *UI = srcUseList.pop_back_val();
if (isa<BitCastInst>(UI)) {
for (User::use_iterator I = UI->use_begin(), E = UI->use_end();
Modified: llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCVN.cpp Tue Jan 5 10:27:25 2010
@@ -678,8 +678,7 @@
stack.push_back(*PI);
while (!stack.empty()) {
- BasicBlock* CurrBB = stack.back();
- stack.pop_back();
+ BasicBlock* CurrBB = stack.pop_back_val();
visited.insert(CurrBB);
ValueNumberScope* S = BBMap[CurrBB];
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Jan 5 10:27:25 2010
@@ -1181,7 +1181,7 @@
if (!isa<StoreInst>(I) && OnlyUsedByDbgInfoIntrinsics(I, &DbgInUses)) {
// Safe to remove debug info uses.
while (!DbgInUses.empty()) {
- DbgInfoIntrinsic *DI = DbgInUses.back(); DbgInUses.pop_back();
+ DbgInfoIntrinsic *DI = DbgInUses.pop_back_val();
DI->eraseFromParent();
}
I->eraseFromParent();
Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp Tue Jan 5 10:27:25 2010
@@ -99,9 +99,8 @@
SmallVector<BasicBlock*, 128> Worklist;
Worklist.push_back(BB);
bool Changed = false;
- while (!Worklist.empty()) {
- BB = Worklist.back();
- Worklist.pop_back();
+ do {
+ BB = Worklist.pop_back_val();
if (!Reachable.insert(BB))
continue;
@@ -150,7 +149,7 @@
Changed |= ConstantFoldTerminator(BB);
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI)
Worklist.push_back(*SI);
- }
+ } while (!Worklist.empty());
return Changed;
}
Modified: llvm/trunk/lib/Transforms/Utils/CloneLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneLoop.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneLoop.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneLoop.cpp Tue Jan 5 10:27:25 2010
@@ -91,7 +91,7 @@
Loop *NewParentLoop = NULL;
- while (!LoopNest.empty()) {
+ do {
Loop *L = LoopNest.pop_back_val();
Loop *NewLoop = new Loop();
@@ -123,7 +123,7 @@
// Process sub loops
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
LoopNest.push_back(*I);
- }
+ } while (!LoopNest.empty());
// Remap instructions to reference operands from ValueMap.
for(SmallVector<BasicBlock *, 16>::iterator NBItr = NewBlocks.begin(),
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Jan 5 10:27:25 2010
@@ -278,7 +278,7 @@
SmallVector<Instruction*, 16> DeadInsts;
DeadInsts.push_back(I);
- while (!DeadInsts.empty()) {
+ do {
I = DeadInsts.pop_back_val();
// Null out all of the instruction's operands to see if any operand becomes
@@ -298,7 +298,7 @@
}
I->eraseFromParent();
- }
+ } while (!DeadInsts.empty());
return true;
}
Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=92734&r1=92733&r2=92734&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Tue Jan 5 10:27:25 2010
@@ -448,13 +448,13 @@
//
std::vector<RenamePassData> RenamePassWorkList;
RenamePassWorkList.push_back(RenamePassData(F.begin(), 0, Values));
- while (!RenamePassWorkList.empty()) {
+ do {
RenamePassData RPD;
RPD.swap(RenamePassWorkList.back());
RenamePassWorkList.pop_back();
// RenamePass may add new worklist entries.
RenamePass(RPD.BB, RPD.Pred, RPD.Values, RenamePassWorkList);
- }
+ } while (!RenamePassWorkList.empty());
// The renamer uses the Visited set to avoid infinite loops. Clear it now.
Visited.clear();
More information about the llvm-commits
mailing list