[PATCH] D49955: [Dominators] Make slow walks shorter

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 31 08:53:51 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL338396: [Dominators] Make slow walks shorter (authored by kuhar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49955?vs=157839&id=158294#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49955

Files:
  llvm/trunk/include/llvm/Support/GenericDomTree.h


Index: llvm/trunk/include/llvm/Support/GenericDomTree.h
===================================================================
--- llvm/trunk/include/llvm/Support/GenericDomTree.h
+++ llvm/trunk/include/llvm/Support/GenericDomTree.h
@@ -853,10 +853,15 @@
     assert(isReachableFromEntry(B));
     assert(isReachableFromEntry(A));
 
+    const unsigned ALevel = A->getLevel();
     const DomTreeNodeBase<NodeT> *IDom;
-    while ((IDom = B->getIDom()) != nullptr && IDom != A && IDom != B)
+
+    // Don't walk nodes above A's subtree. When we reach A's level, we must
+    // either find A or be in some other subtree not dominated by A.
+    while ((IDom = B->getIDom()) != nullptr && IDom->getLevel() >= ALevel)
       B = IDom;  // Walk up the tree
-    return IDom != nullptr;
+
+    return B == A;
   }
 
   /// Wipe this tree's state without releasing any resources.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49955.158294.patch
Type: text/x-patch
Size: 871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180731/ad269905/attachment.bin>


More information about the llvm-commits mailing list