LoopUnroll: Change code order of changes to new basic blocks
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 6 Oct 2014 22:05:02 +0000 (22:05 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 6 Oct 2014 22:05:02 +0000 (22:05 +0000)
Add new basic blocks to `LoopInfo` earlier.  No functionality change
intended (simplifies upcoming bugfix patch).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219150 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LoopUnroll.cpp

index fd46a4b8e5491f505b9e2f5ab88469941712d240..fbfebc3a8dc97e49e6958f4994d2c37905ec2b2f 100644 (file)
@@ -308,6 +308,8 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
       BasicBlock *New = CloneBasicBlock(*BB, VMap, "." + Twine(It));
       Header->getParent()->getBasicBlockList().push_back(New);
 
+      L->addBasicBlockToLoop(New, LI->getBase());
+
       if (*BB == Header)
         // Loop over all of the PHI nodes in the block, changing them to use
         // the incoming values from the previous block.
@@ -327,8 +329,6 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
            VI != VE; ++VI)
         LastValueMap[VI->first] = VI->second;
 
-      L->addBasicBlockToLoop(New, LI->getBase());
-
       // Add phi entries for newly created values to all exit blocks.
       for (succ_iterator SI = succ_begin(*BB), SE = succ_end(*BB);
            SI != SE; ++SI) {