[PATCH] D28511: Skip loop header when we can computing loop safety info

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 21:44:29 PST 2017


trentxintong created this revision.
trentxintong added a reviewer: hfinkel.
trentxintong added a subscriber: llvm-commits.

Skip loop header when we can computing loop safety info


https://reviews.llvm.org/D28511

Files:
  lib/Transforms/Scalar/LICM.cpp


Index: lib/Transforms/Scalar/LICM.cpp
===================================================================
--- lib/Transforms/Scalar/LICM.cpp
+++ lib/Transforms/Scalar/LICM.cpp
@@ -447,8 +447,10 @@
 
   SafetyInfo->MayThrow = SafetyInfo->HeaderMayThrow;
   // Iterate over loop instructions and compute safety info.
-  for (Loop::block_iterator BB = CurLoop->block_begin(),
-                            BBE = CurLoop->block_end();
+  // The first block in loopinfo.Blocks is guaranteed to be the header.
+  assert(Header == *CurLoop->getBlocks().begin() && "First block must be header");
+  Loop::block_iterator BB = std::next(CurLoop->block_begin());
+  for (Loop::block_iterator BBE = CurLoop->block_end();
        (BB != BBE) && !SafetyInfo->MayThrow; ++BB)
     for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end();
          (I != E) && !SafetyInfo->MayThrow; ++I)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28511.83776.patch
Type: text/x-patch
Size: 879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170110/aef38a23/attachment.bin>


More information about the llvm-commits mailing list