[llvm] r241739 - [LoopVectorizer] Move some code around to ease further refactoring. NFCI.

Michael Zolotukhin mzolotukhin at apple.com
Wed Jul 8 14:47:54 PDT 2015


Author: mzolotukhin
Date: Wed Jul  8 16:47:53 2015
New Revision: 241739

URL: http://llvm.org/viewvc/llvm-project?rev=241739&view=rev
Log:
[LoopVectorizer] Move some code around to ease further refactoring. NFCI.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=241739&r1=241738&r2=241739&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Wed Jul  8 16:47:53 2015
@@ -2615,6 +2615,19 @@ void InnerLoopVectorizer::createEmptyLoo
   // times the unroll factor (num of SIMD instructions).
   Constant *Step = ConstantInt::get(IdxTy, VF * UF);
 
+  // Generate code to check that the loop's trip count that we computed by
+  // adding one to the backedge-taken count will not overflow.
+  auto PastOverflowCheck = std::next(BasicBlock::iterator(OverflowCheckAnchor));
+  BasicBlock *CheckBlock =
+      BypassBlock->splitBasicBlock(PastOverflowCheck, "overflow.checked");
+  if (ParentLoop)
+    ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
+  LoopBypassBlocks.push_back(CheckBlock);
+  ReplaceInstWithInst(
+      BypassBlock->getTerminator(),
+      BranchInst::Create(ScalarPH, CheckBlock, CheckBCOverflow));
+  BypassBlock = CheckBlock;
+
   // This is the IR builder that we use to add all of the logic for bypassing
   // the new vector loop.
   IRBuilder<> BypassBuilder(BypassBlock->getTerminator());
@@ -2647,22 +2660,6 @@ void InnerLoopVectorizer::createEmptyLoo
   Value *Cmp =
       BypassBuilder.CreateICmpEQ(IdxEndRoundDown, StartIdx, "cmp.zero");
 
-  // Generate code to check that the loops trip count that we computed by adding
-  // one to the backedge-taken count will not overflow.
-  {
-    auto PastOverflowCheck =
-        std::next(BasicBlock::iterator(OverflowCheckAnchor));
-    BasicBlock *CheckBlock =
-      BypassBlock->splitBasicBlock(PastOverflowCheck, "overflow.checked");
-    if (ParentLoop)
-      ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
-    LoopBypassBlocks.push_back(CheckBlock);
-    ReplaceInstWithInst(
-        BypassBlock->getTerminator(),
-        BranchInst::Create(ScalarPH, CheckBlock, CheckBCOverflow));
-    BypassBlock = CheckBlock;
-  }
-
   // Generate the code to check that the strides we assumed to be one are really
   // one. We want the new basic block to start at the first instruction in a
   // sequence of instructions that form a check.





More information about the llvm-commits mailing list