[PATCH] D68107: [LoopInfo] Remove duplicates in ExitBlocks to reduce the compile time of hasDedicatedExits
Wei Mi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 15:09:40 PDT 2019
wmi created this revision.
wmi added reviewers: reames, skatkov, qcolombet.
Herald added a project: LLVM.
For the 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 lead me to find the root cause.
But how to properly add a compile time test is still a question for me.
Repository:
rL LLVM
https://reviews.llvm.org/D68107
Files:
include/llvm/Analysis/LoopInfoImpl.h
Index: include/llvm/Analysis/LoopInfoImpl.h
===================================================================
--- include/llvm/Analysis/LoopInfoImpl.h
+++ include/llvm/Analysis/LoopInfoImpl.h
@@ -87,7 +87,9 @@
// within the loop.
SmallVector<BlockT *, 4> ExitBlocks;
getExitBlocks(ExitBlocks);
- for (BlockT *EB : ExitBlocks)
+ SmallPtrSet<BlockT *, 4> UniqExitBlocks;
+ UniqExitBlocks.insert(ExitBlocks.begin(), ExitBlocks.end());
+ for (BlockT *EB : UniqExitBlocks)
for (BlockT *Predecessor : children<Inverse<BlockT *>>(EB))
if (!contains(Predecessor))
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68107.222034.patch
Type: text/x-patch
Size: 606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190926/f22c11b5/attachment.bin>
More information about the llvm-commits
mailing list