[PATCH] D67359: [IVUser] Limit the iterations to check whether a loop has dedicated exits for extreme large case
Wei Mi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 09:39:45 PDT 2019
wmi created this revision.
wmi added reviewers: qcolombet, skatkov.
Herald added a project: LLVM.
We had a case that a single loop which has 4000 exits and the average number of predecessors of each exit is > 1000. It increased the compilation time of IVUser analysis significantly. This patch adds a limit for the iterations to check whether a loop has only dedicated exits. With the patch, the time to compile our testcase reduced from 1000s to 200s (clang release build).
Repository:
rL LLVM
https://reviews.llvm.org/D67359
Files:
include/llvm/Analysis/LoopInfoImpl.h
lib/Analysis/LoopInfo.cpp
Index: lib/Analysis/LoopInfo.cpp
===================================================================
--- lib/Analysis/LoopInfo.cpp
+++ lib/Analysis/LoopInfo.cpp
@@ -54,6 +54,13 @@
VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo),
cl::Hidden, cl::desc("Verify loop info (time consuming)"));
+namespace llvm {
+cl::opt<uint64_t> MaxDedicateExitIterations(
+ "max-dedicate-exit-iterations", cl::Hidden, cl::init(100000),
+ cl::desc("Max number of loop iterations to check whether a loop is a "
+ "dedicated exit loop. "));
+}
+
//===----------------------------------------------------------------------===//
// Loop implementation
//
Index: include/llvm/Analysis/LoopInfoImpl.h
===================================================================
--- include/llvm/Analysis/LoopInfoImpl.h
+++ include/llvm/Analysis/LoopInfoImpl.h
@@ -23,6 +23,10 @@
namespace llvm {
+// Max number of loop iterations to check whether a loop is a dedicated
+// exit loop.
+extern cl::opt<uint64_t> MaxDedicateExitIterations;
+
//===----------------------------------------------------------------------===//
// APIs for simple analysis of the loop. See header notes.
@@ -87,10 +91,16 @@
// within the loop.
SmallVector<BlockT *, 4> ExitBlocks;
getExitBlocks(ExitBlocks);
- for (BlockT *EB : ExitBlocks)
- for (BlockT *Predecessor : children<Inverse<BlockT *>>(EB))
+ uint64_t Iterations = 0;
+ for (BlockT *EB : ExitBlocks) {
+ for (BlockT *Predecessor : children<Inverse<BlockT *>>(EB)) {
if (!contains(Predecessor))
return false;
+ Iterations++;
+ }
+ if (Iterations > MaxDedicateExitIterations)
+ return false;
+ }
// All the requirements are met.
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67359.219371.patch
Type: text/x-patch
Size: 1776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190909/0c5ae2f6/attachment.bin>
More information about the llvm-commits
mailing list