[PATCH] D38541: [Dominators] Take fast path when applying <=1 updates
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 4 10:34:41 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314917: [Dominators] Take fast path when applying <=1 updates (authored by kuhar).
Changed prior to commit:
https://reviews.llvm.org/D38541?vs=117670&id=117696#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38541
Files:
llvm/trunk/include/llvm/Support/GenericDomTree.h
llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
Index: llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
===================================================================
--- llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
@@ -1122,6 +1122,22 @@
//~~
static void ApplyUpdates(DomTreeT &DT, ArrayRef<UpdateT> Updates) {
+ const size_t NumUpdates = Updates.size();
+ if (NumUpdates == 0)
+ return;
+
+ // Take the fast path for a single update and avoid running the batch update
+ // machinery.
+ if (NumUpdates == 1) {
+ const auto &Update = Updates.front();
+ if (Update.getKind() == UpdateKind::Insert)
+ DT.insertEdge(Update.getFrom(), Update.getTo());
+ else
+ DT.deleteEdge(Update.getFrom(), Update.getTo());
+
+ return;
+ }
+
BatchUpdateInfo BUI;
LegalizeUpdates(Updates, BUI.Updates);
Index: llvm/trunk/include/llvm/Support/GenericDomTree.h
===================================================================
--- llvm/trunk/include/llvm/Support/GenericDomTree.h
+++ llvm/trunk/include/llvm/Support/GenericDomTree.h
@@ -522,7 +522,9 @@
///
/// Batch updates should be generally faster when performing longer sequences
/// of updates than calling insertEdge/deleteEdge manually multiple times, as
- /// they can reorder the updates and remove redundant ones internally.
+ /// it can reorder the updates and remove redundant ones internally.
+ /// The batch updater is also able to detect sequences of zero and exactly one
+ /// update -- it's optimized to do less work in these cases.
///
/// Note that for postdominators it automatically takes care of applying
/// updates on reverse edges internally (so there's no need to swap the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38541.117696.patch
Type: text/x-patch
Size: 1780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/8d447a17/attachment.bin>
More information about the llvm-commits
mailing list