[llvm] r292310 - Skip loop header while we can when computing loop safety info

Xin Tong via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 16:15:11 PST 2017


Author: trentxintong
Date: Tue Jan 17 18:15:11 2017
New Revision: 292310

URL: http://llvm.org/viewvc/llvm-project?rev=292310&view=rev
Log:
Skip loop header while we can when computing loop safety info

Modified:
    llvm/trunk/lib/Transforms/Scalar/LICM.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=292310&r1=292309&r2=292310&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Jan 17 18:15:11 2017
@@ -461,7 +461,10 @@ void llvm::computeLoopSafetyInfo(LoopSaf
 
   SafetyInfo->MayThrow = SafetyInfo->HeaderMayThrow;
   // Iterate over loop instructions and compute safety info.
-  for (Loop::block_iterator BB = CurLoop->block_begin(),
+  // Skip header as it has been computed and stored in HeaderMayThrow.
+  // The first block in loopinfo.Blocks is guaranteed to be the header.
+  assert(Header == *CurLoop->getBlocks().begin() && "First block must be header");
+  for (Loop::block_iterator BB = std::next(CurLoop->block_begin()),
                             BBE = CurLoop->block_end();
        (BB != BBE) && !SafetyInfo->MayThrow; ++BB)
     for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end();




More information about the llvm-commits mailing list