Speed up dominator computation some more by optimizing bucket processing. When
authorCameron Zwarich <zwarich@apple.com>
Sun, 2 Jan 2011 07:03:00 +0000 (07:03 +0000)
committerCameron Zwarich <zwarich@apple.com>
Sun, 2 Jan 2011 07:03:00 +0000 (07:03 +0000)
commit8252ad1351594039fa5d6633ff3eef1bafb7fdf9
tree5381ccfb7b0747b75fd55df1baaa81dad13e5184
parente2c43920919c6fe376613d1d8331897dc1ba3d57
Speed up dominator computation some more by optimizing bucket processing. When
naively implemented, the Lengauer-Tarjan algorithm requires a separate bucket
for each vertex. However, this is unnecessary, because each vertex is only
placed into a single bucket (that of its semidominator), and each vertex's
bucket is processed before it is added to any bucket itself.

Instead of using a bucket per vertex, we use a single array Buckets that has two
purposes. Before the vertex V with DFS number i is processed, Buckets[i] stores
the index of the first element in V's bucket. After V's bucket is processed,
Buckets[i] stores the index of the next element in the bucket to which V now
belongs, if any.

Reading from the buckets can also be optimized. Instead of processing the bucket
of V's parent at the end of processing V, we process the bucket of V itself at
the beginning of processing V. This means that the case of the root vertex can
be simplified somewhat. It also means that we don't need to look up the DFS
number of the semidominator of every node in the bucket we are processing,
since we know it is the current index being processed.

This is a 6.5% speedup running -domtree on test-suite + SPEC2000/2006, with
larger speedups of around 12% on the larger benchmarks like GCC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122680 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/DominatorInternals.h
include/llvm/Analysis/Dominators.h