[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 22:36:25 PDT 2019
wmi updated this revision to Diff 221464.
wmi added a comment.
Address Serguei's comment.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67359/new/
https://reviews.llvm.org/D67359
Files:
include/llvm/Analysis/LoopInfo.h
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;
}
Index: include/llvm/Analysis/LoopInfo.h
===================================================================
--- include/llvm/Analysis/LoopInfo.h
+++ include/llvm/Analysis/LoopInfo.h
@@ -269,6 +269,9 @@
/// Return true if no exit block for the loop has a predecessor that is
/// outside the loop.
+ /// Return false if a non-dedicated successor is found or it cannot finish
+ /// the check within MaxDedicateExitIterations iterations so return false
+ /// conservatively.
bool hasDedicatedExits() const;
/// Return all unique successor blocks of this loop.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67359.221464.patch
Type: text/x-patch
Size: 2351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190924/2396a43a/attachment.bin>
More information about the llvm-commits
mailing list