Revert "Revert "Add Constant Hoisting Pass" (r200034)"
[oota-llvm.git] / lib / Transforms / Scalar / CodeGenPrepare.cpp
index 38f587b2cc8fd677fe0dfd78fcacf778249489b9..6acbd5eaa146829c778a819b945145a68c66ff83 100644 (file)
@@ -240,7 +240,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
 bool CodeGenPrepare::EliminateFallThrough(Function &F) {
   bool Changed = false;
   // Scan all of the blocks in the function, except for the entry block.
-  for (Function::iterator I = ++F.begin(), E = F.end(); I != E; ) {
+  for (Function::iterator I = llvm::next(F.begin()), E = F.end(); I != E; ) {
     BasicBlock *BB = I++;
     // If the destination block has a single pred, then this is a trivial
     // edge, just collapse it.
@@ -276,7 +276,7 @@ bool CodeGenPrepare::EliminateFallThrough(Function &F) {
 bool CodeGenPrepare::EliminateMostlyEmptyBlocks(Function &F) {
   bool MadeChange = false;
   // Note that this intentionally skips the entry block.
-  for (Function::iterator I = ++F.begin(), E = F.end(); I != E; ) {
+  for (Function::iterator I = llvm::next(F.begin()), E = F.end(); I != E; ) {
     BasicBlock *BB = I++;
 
     // If this block doesn't end with an uncond branch, ignore it.