## A Simple, Fast Dominance Algorithm

### Cached

### Download Links

Citations: | 31 - 0 self |

### BibTeX

@MISC{Cooper_asimple,,

author = {Keith D. Cooper and Timothy J. Harvey and Ken Kennedy},

title = {A Simple, Fast Dominance Algorithm},

year = {}

}

### OpenURL

### Abstract

The problem of finding the dominators in a control-flow graph has a long history in the literature. The original algorithms su#ered from a large asymptotic complexity but were easy to understand. Subsequent work improved the time bound, but generally sacrificed both simplicity and ease of implementation. This paper returns to a simple formulation of dominance as a global data-flow problem. Some insights into the natureofdominance lead to an implementation of an O(N )algorithm that runs faster, in practice, than the classic Lengauer-Tarjan algorithm, which has a timebound of O(E log(N)). We compare the algorithm to Lengauer-Tarjan because it is the best known and most widely used of the fast algorithms for dominance. Working from the same implementationinsights,wealso rederive (from earlier work on control dependence by Ferrante, et al.)amethodforcalculating dominance frontiers that we show is faster than the original algorithm by Cytron, et al. The aim of this paper is not to present a new algorithm, but, rather, to make an argument based on empirical evidence that algorithms with discouraging asymptotic complexities can be faster in practice than those more commonly employed. We show that, in some cases, careful engineering of simple algorithms can overcome theoretical advantages, even when problems grow beyond realistic sizes. Further, we argue that the algorithms presented herein are intuitive and easily implemented, making them excellent teaching tools.

### Citations

842 | Efficiently computing static single assignment form and the control dependence graph
- Cytron, Ferrante, et al.
- 1991
(Show Context)
Citation Context ...making them excellent teaching tools. Keywords: Dominators, Dominance Frontiers Introduction The advent of static single assignment form (ssa) has rekindled interest in dominance and related concepts =-=[13]-=-. New algorithms for several problems in optimization and code generation have built on dominance [8, 12, 25, 27]. In this paper, we re-examine the formulation of dominance as a forward data-flow prob... |

826 | The program dependence graph and its use in optimization
- Ferrante, Ottenstein, et al.
- 1987
(Show Context)
Citation Context ...cribed by Cytron et al. [13]. The timing results for our algorithm include the cost of computing the 4 This algorithm first appeared in a paper by Ferrante et al. in the context of control dependence =-=[14]-=-. We believe that its value as a method of computing dominance frontiers has not been studied prior to this work. 9reverse postorder numbers, although in neither case do we include the cost of buildi... |

148 | A linear-time algorithm for a special case of disjoint set union - Gabow, Tarjan - 1985 |

142 | A fast algorithm for finding dominators in a flowgraph - Lengauer, Tarjan - 1979 |

135 | Empirical Study of FORTRAN Programs - Knuth - 1971 |

128 |
Principles of Compiler Designer
- Aho, Uliman
- 1977
(Show Context)
Citation Context ...hm (but not the time bound) to handle irreducible graphs. Both Hecht’s book and Aho and Ullman’s “dragon” book present the iterative algorithm for dominance without restricting it to reducible graphs =-=[18, 3]-=-. Unfortunately, Aho and Ullman mistakenly credit the algorithm to Purdom and Moore [24], rather than to Allen and Cocke. Aho and Ullman approached the problem from another direction [2]. Their algori... |

124 | Global data flow analysis and iterative algorithms
- Kam, Ullman
- 1976
(Show Context)
Citation Context ...Graph Properties of the Iterative Framework This algorithm produces correct results because the equations for Dom, as shown above, form a distributive data-flow framework as defined by Kam and Ullman =-=[20]-=-. Thus, we know that the iterative algorithm will discover the maximal fixed-point solution and halt. Since the framework is distributive, we know that the maximal fixed-point solution is identical to... |

118 | The Theory - Aho, Ullman - 1972 |

109 |
Cornputer Methods for Mathematical Computations
- Forsythe, Malcolm, et al.
- 1977
(Show Context)
Citation Context ...granularity of only one hundredth of a second. 5 Our standard test suite contains 169 Fortran routines taken from the SPEC benchmarks and from Forsythe, Malcolm, and Moler’s book on numerical methods =-=[15]-=-. The largest cfg in the suite is from field, with 744 basic blocks. 6 On this file, the timer only measures one hundredth of a second of cpu time to compute dominators using the iterative algorithm. ... |

85 | Control flow analysis - Allen - 1970 |

80 | Testing flow graph reducibility - Tarjan - 1973 |

50 | Finding dominators in directed graphs - TARJAN - 1972 |

45 |
A Simple Algorithm for Global Data Flow Analysis Problems
- Hecht, Ullman
- 1975
(Show Context)
Citation Context ...w algorithms for several problems in optimization and code generation have built on dominance [8, 12, 25, 27]. In this paper, we re-examine the formulation of dominance as a forward data-flow problem =-=[4, 5, 19]-=-. We present several insights that lead to a simple, general, and efficient implementation in an iterative data-flow framework. The resulting algorithm, an iterative solver that uses our representatio... |

38 |
A linear time algorithm for finding dominators in flow graphs and related problems
- Harel
- 1985
(Show Context)
Citation Context ...cellent example of the need to balance theory with practice. Ever since Lowry and Medlock’s O(N 4 ) algorithm appeared in 1969 [23], researchers have steadily improved the time bound for this problem =-=[7, 10, 17, 19, 22, 26, 29]-=-. However, our results suggest that these improvements in asymptotic complexity may not help on realistically-sized examples, and that careful engineering makes the iterative scheme the clear method o... |

37 |
Object code optimization
- Lorry, Medlock
- 1969
(Show Context)
Citation Context ...f choice for computing dominators on cfgs. The dominance problem is an excellent example of the need to balance theory with practice. Ever since Lowry and Medlock’s O(N 4 ) algorithm appeared in 1969 =-=[23]-=-, researchers have steadily improved the time bound for this problem [7, 10, 17, 19, 22, 26, 29]. However, our results suggest that these improvements in asymptotic complexity may not help on realisti... |

30 | An efficient representation for sparse sets
- Briggs, Torczon
- 1993
(Show Context)
Citation Context ...rsections on sparsely populated sets and copying these sets from one node to another. When we tried to reduce the time necessary to do the intersections by substituting SparseSets for the bit vectors =-=[9]-=-, the increased memory requirements again made the algorithm impractical. To improve the iterative algorithm’s performance, we need a memory-efficient data structure that supports 3Two studies suggest... |

27 | Linear-Time Pointer-Machine Algorithms for Least Common Ancestors
- Buchsbaum, Kaplan, et al.
- 1998
(Show Context)
Citation Context ...cellent example of the need to balance theory with practice. Ever since Lowry and Medlock’s O(N 4 ) algorithm appeared in 1969 [23], researchers have steadily improved the time bound for this problem =-=[7, 10, 17, 19, 22, 26, 29]-=-. However, our results suggest that these improvements in asymptotic complexity may not help on realistically-sized examples, and that careful engineering makes the iterative scheme the clear method o... |

25 | Dominators in linear time
- Alstrup, Harel, et al.
- 1999
(Show Context)
Citation Context ...cellent example of the need to balance theory with practice. Ever since Lowry and Medlock’s O(N 4 ) algorithm appeared in 1969 [23], researchers have steadily improved the time bound for this problem =-=[7, 10, 17, 19, 22, 26, 29]-=-. However, our results suggest that these improvements in asymptotic complexity may not help on realistically-sized examples, and that careful engineering makes the iterative scheme the clear method o... |

24 |
On finding lowest common ancestors in trees
- Aho, Hopcroft, et al.
- 1973
(Show Context)
Citation Context ...mber of nodes. With Hopcroft, they improved this time bound to O(E log E) for reducible graphs, where E is the number of edges in the graph, by using an efficient method of finding ancestors in trees =-=[1]-=-. Purdom and Moore, in the same year, proposed a similar algorithm, which first builds a tree from the graph. Dominators are then found by successively removing each node from the graph and noting whi... |

18 |
Immediate predominators in a directed graph [h
- Purdom, Moore
- 1972
(Show Context)
Citation Context ...man’s “dragon” book present the iterative algorithm for dominance without restricting it to reducible graphs [18, 3]. Unfortunately, Aho and Ullman mistakenly credit the algorithm to Purdom and Moore =-=[24]-=-, rather than to Allen and Cocke. Aho and Ullman approached the problem from another direction [2]. Their algorithm takes the graph and successively removes nodes. Any nodes in the entire graph (rathe... |

17 |
Applications of boolean matrices to the analysis of flow diagrams
- Prosser
- 1959
(Show Context)
Citation Context |

16 |
Flow Analysis of Computer Programs. Programming Languages series
- Hecht
- 1977
(Show Context)
Citation Context ...hm (but not the time bound) to handle irreducible graphs. Both Hecht’s book and Aho and Ullman’s “dragon” book present the iterative algorithm for dominance without restricting it to reducible graphs =-=[18, 3]-=-. Unfortunately, Aho and Ullman mistakenly credit the algorithm to Purdom and Moore [24], rather than to Allen and Cocke. Aho and Ullman approached the problem from another direction [2]. Their algori... |

16 | Optimal control dependence computation and the Roman Chariots problem - Pingali, Bilardi - 1997 |

12 |
An incremental algorithm for software analysis
- Carroll, Ryder
- 1987
(Show Context)
Citation Context ...t of static single assignment form (ssa) has rekindled interest in dominance and related concepts [13]. New algorithms for several problems in optimization and code generation have built on dominance =-=[8, 12, 25, 27]-=-. In this paper, we re-examine the formulation of dominance as a forward data-flow problem [4, 5, 19]. We present several insights that lead to a simple, general, and efficient implementation in an it... |

12 |
An empirical study of FORTRAN programs. Software Practice and Experience
- Knuth
- 1974
(Show Context)
Citation Context ...ry-efficient data structure that supports 3Two studies suggest that, even before the advent of “structured programming,” most procedures had reducible cfgs [5] and that d(G) is typically ≤ 3 for cfgs =-=[21]-=-. 5a fast intersection. Keeping the Dom sets in a consistent order is one way to speed up intersection. If we think of the set as a list, and require that the union always add to the end of the list,... |

11 |
Gabow and Robert Endre Tarjan. A linear-time algorithm for a special case of disjoint set union
- Harold
- 1983
(Show Context)
Citation Context ...uilt on Lengauer-Tarjan that computes immediate dominators in linear time. He improved the time bound by speeding up the union-find operations with a technique from Gabow and Tarjan in that same year =-=[16]-=-. Harel’s explanation, however, was subsequently found to be incomplete. In 1999, Alstrup et al. published a simpler method based on Harel’s initial work that achieves a theoretical linear-time comple... |

9 |
Advanced Compilation for Vector and Parallel Computers
- Allen, Kennedy
- 2001
(Show Context)
Citation Context ...lications to algorithms other than ssa, as well. For example, finding postdominance frontiers is an efficient method of computing control dependence, a critical analysis for automatic parallelization =-=[6]-=-. Cytron et al. propose finding the dominance frontier set for each node in a two step manner. They begin by walking over the dominator tree in a bottom-up traversal. At each node, b, they add to b’s ... |

7 |
Endre Tarjan. Testing flow graph reducibility
- Robert
- 1974
(Show Context)
Citation Context |

5 |
Graph-theoretic constructs for program flow analysis
- Allen, Cocke
- 1972
(Show Context)
Citation Context ...w algorithms for several problems in optimization and code generation have built on dominance [8, 12, 25, 27]. In this paper, we re-examine the formulation of dominance as a forward data-flow problem =-=[4, 5, 19]-=-. We present several insights that lead to a simple, general, and efficient implementation in an iterative data-flow framework. The resulting algorithm, an iterative solver that uses our representatio... |

4 |
Value numbering. Software–Practice and Experience
- Briggs, Cooper, et al.
- 1997
(Show Context)
Citation Context ...t of static single assignment form (ssa) has rekindled interest in dominance and related concepts [13]. New algorithms for several problems in optimization and code generation have built on dominance =-=[8, 12, 25, 27]-=-. In this paper, we re-examine the formulation of dominance as a forward data-flow problem [4, 5, 19]. We present several insights that lead to a simple, general, and efficient implementation in an it... |

4 |
Endre Tarjan. Finding dominators in directed graphs
- Robert
- 1974
(Show Context)
Citation Context ...onnects those edges to blocks that already exist. Creating back edges is problematic. The classic method used to identify a back edge has an implicit assumption that the entire graph has been defined =-=[28]-=-. Since the random graph builder does not have access to the entire graph, it cannot tell, for certain, whether an edge will be a back edge in the completed graph. Thus, it cannot add the back edges a... |

3 |
Dominator-path scheduling—a global scheduling method
- Sweany, Beaty
- 1992
(Show Context)
Citation Context ...t of static single assignment form (ssa) has rekindled interest in dominance and related concepts [13]. New algorithms for several problems in optimization and code generation have built on dominance =-=[8, 12, 25, 27]-=-. In this paper, we re-examine the formulation of dominance as a forward data-flow problem [4, 5, 19]. We present several insights that lead to a simple, general, and efficient implementation in an it... |

1 | AhoandJ.D.Ullman.Principles of Compiler Design - V - 1977 |

1 | An efficient representationfor sparse sets - Briggs, Torczon - 1993 |