[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 23 16:52:25 PDT 2019
wmi updated this revision to Diff 221437.
wmi added a comment.
Address Serguei's comment: update function description.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67359/new/
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.
@@ -81,16 +85,26 @@
return nullptr;
}
+/// hasDedicatedExits - Return false if a non-dedicated successor is
+/// found or it cannot finish the check within MaxDedicateExitIterations
+/// iterations so return false conservatively. Return true if the check
+/// is done and all exits are dedicated.
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)
- 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.221437.patch
Type: text/x-patch
Size: 2228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190923/4dba8de4/attachment.bin>
More information about the llvm-commits
mailing list