Aggressively prune the DFS when inserting phi-defs.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 18 Aug 2010 19:00:11 +0000 (19:00 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 18 Aug 2010 19:00:11 +0000 (19:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111394 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/DepthFirstIterator.h
lib/CodeGen/SplitKit.cpp

index b9e5cbdf8c6b622100b9ac29930e8a47e7dbc615..3edb5550788d8351c71ab94cc124daa0d6571780 100644 (file)
@@ -193,6 +193,15 @@ public:
   NodeType *getPath(unsigned n) const {
     return VisitStack[n].first.getPointer();
   }
+
+  /// skipChildren - Skip all children of Node, assuming that Node is on the
+  /// current path. This allows more aggressive pruning than just skipping
+  /// children of the current node.
+  _Self& skipChildren(NodeType *Node) {
+    while (!VisitStack.empty() && **this != Node)
+      VisitStack.pop_back();
+    return skipChildren();
+  }
 };
 
 
index b081bf37337cb66e24df56bdf73b4ec05dc2c416..dae282dfce670ed02981b8c7b80d2c3081b95c41 100644 (file)
@@ -446,9 +446,9 @@ VNInfo *LiveIntervalMap::mapValue(const VNInfo *ParentVNI, SlotIndex Idx) {
     }
 
     // No need to search the children, we found a dominating value.
-    // FIXME: We could prune up to the last phi-def we inserted, need df_iterator
-    // for that.
-    IDFI.skipChildren();
+    // MBB is either the found dominating value, or the last phi-def we created.
+    // Either way, the children of MBB would be shadowed, so don't search them.
+    IDFI.skipChildren(MBB);
   }
 
   // The search should at least find a dominating value for IdxMBB.