]> granicus.if.org Git - llvm/commitdiff
[LoopInfo] Remove duplicates in ExitBlocks to reduce the compile time of
authorWei Mi <wmi@google.com>
Fri, 27 Sep 2019 05:43:31 +0000 (05:43 +0000)
committerWei Mi <wmi@google.com>
Fri, 27 Sep 2019 05:43:31 +0000 (05:43 +0000)
hasDedicatedExits.

For the compile time problem described in https://reviews.llvm.org/D67359,
turns out the root cause is there are many duplicates in ExitBlocks so
the algorithm complexity of hasDedicatedExits gets very high. If we remove
the duplicates, the compile time issue is gone.

Thanks to Philip Reames for raising a good question and it leads me to
find the root cause.

Differential Revision: https://reviews.llvm.org/D68107

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

include/llvm/Analysis/LoopInfoImpl.h

index 2f38dde7b3af32ce1d8bfd29d1e216a5776f01a0..8b11e848a195b26a57ab13720bb379c665cb1501 100644 (file)
@@ -85,9 +85,9 @@ template <class BlockT, class LoopT>
 bool LoopBase<BlockT, LoopT>::hasDedicatedExits() const {
   // Each predecessor of each exit block of a normal loop is contained
   // within the loop.
-  SmallVector<BlockT *, 4> ExitBlocks;
-  getExitBlocks(ExitBlocks);
-  for (BlockT *EB : ExitBlocks)
+  SmallVector<BlockT *, 4> UniqueExitBlocks;
+  getUniqueExitBlocks(UniqueExitBlocks);
+  for (BlockT *EB : UniqueExitBlocks)
     for (BlockT *Predecessor : children<Inverse<BlockT *>>(EB))
       if (!contains(Predecessor))
         return false;