From 767a389fa55b2d200a9ce4b6f155bc82e164c80a Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Tue, 23 Nov 2010 06:32:37 +0000 Subject: [PATCH] Optimize a common case in the Lengauer-Tarjan dominators algorithm. This gives a 9.7% speedup running domtree on test-suite. Reviewed by Chris Lattner. llvm-svn: 120003 --- llvm/include/llvm/Analysis/DominatorInternals.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Analysis/DominatorInternals.h b/llvm/include/llvm/Analysis/DominatorInternals.h index 654289e6305c..54993e29cd31 100644 --- a/llvm/include/llvm/Analysis/DominatorInternals.h +++ b/llvm/include/llvm/Analysis/DominatorInternals.h @@ -278,9 +278,16 @@ void Calculate(DominatorTreeBase::NodeType>& DT, } } - DT.Info[DT.Vertex[WInfo.Semi]].Bucket.push_back(W); - typename GraphT::NodeType* WParent = DT.Vertex[WInfo.Parent]; + + // If V is a non-root vertex and sdom(V) = parent(V), then idom(V) is + // necessarily parent(V). In this case, set idom(V) here and avoid placing + // V into a bucket. + if (WInfo.Semi == WInfo.Parent) + DT.IDoms[W] = WParent; + else + DT.Info[DT.Vertex[WInfo.Semi]].Bucket.push_back(W); + Link(DT, WInfo.Parent, W, WInfo); // Step #3: Implicitly define the immediate dominator of vertices