Definitioncore
Distributive dataflow framework
Also called distributive framework.
A monotone framework whose transfer functions distribute over the meet, f(x meet y) = f(x) meet f(y), as gen-kill problems do.
A distributive dataflow framework is a monotone dataflow framework in which every transfer function distributes over the meet: . This was Kildall's original condition in 1973. It is the condition under which merging facts early loses nothing, so the maximal fixed-point solution that an iterative solver computes equals the ideal meet-over-all-paths solution. Every gen-kill problem is distributive, which covers reaching definitions, live variables, available expressions and very busy expressions. Constant propagation is the standard monotone framework that is not distributive.
Definition
The dataflow pages use the meet convention: is a meet semilattice, means , is the identity of meet, and the height of is the largest number of strict steps in a chain . A function is monotone if implies .
Definition. A monotone framework is distributive if every satisfies
A monotone function always satisfies (proved on the monotone dataflow framework page). Distributivity asks for equality: applying after a meet loses nothing compared with applying it before.
Distributive implies monotone. Let , so . Then , which says .
Closed under composition. If and distribute, then . The identity distributes too. So the functions of all paths of a distributive instance are distributive.
Finite meets. By induction on , for every . The case fails in general: the empty meet is , and need not be . For example in a may problem maps to .
Infinite meets reduce to finite ones. In a semilattice of finite height with a top, every nonempty set has a greatest lower bound, and it is the meet of at most members of . Proof. Pick and set . While some has , replace with . Each replacement makes strictly smaller, so there are at most of them. At the end for all , and any lower bound of is below each of the chosen members and hence below . So for every nonempty , even when is the infinite set of paths through a loop.
The main consequence: MFP = MOP. Take a forward instance on a CFG in which every block is reachable from the entry, with boundary value . Then the maximal fixed-point solution equals the meet-over-all-paths solution at every block.
Proof. In every monotone framework MFP MOP, as proved on the maximal fixed-point solution page. For the other direction it is enough to show that MOP satisfies the equations, because MFP is the greatest solution. The paths from the entry to the start of are the empty path if is the entry, together with, for each predecessor , every path to the start of followed by . Write for the paths to the start of . Each is nonempty, since is reachable. Then
The middle step uses distributivity over the nonempty set . So MOP is a solution, MOP MFP, and with MFP MOP they are equal. For a backward instance, use the reverse CFG and require every block to reach a ret block.
The MOP-MFP coincidence theorem states this result on its own page. Kam and Ullman (1977) proved that without distributivity no algorithm computes MOP for every monotone framework, which is why the distinction matters.
The reachability condition is needed. If is unreachable, is empty, MOP[P] is , and can be below : an unreachable block in a may problem still sends its set to its successors in every solution of the equations, while no path from the entry carries it. Then MFP is strictly below MOP even in a distributive framework.
Soundness and precision. Distributivity does not change soundness, which every monotone framework has. It removes the loss of precision at joins: the computed answer is as precise as any answer that treats all CFG paths as possible. What it cannot remove is the loss from CFG paths that no run takes.
Cost. The same as for any monotone framework of height : a worklist solver applies transfer functions and meets on a CFG with blocks and edges. Distributivity buys exactness, not speed. Speed comes from the stronger rapid property of the Kam-Ullman iteration bound, which all gen-kill problems have.
Examples and non-examples
Gen-kill functions. On the subsets of a finite set , distributes over both and , so the four bit-vector problems are distributive. The proof is on the gen-kill problem page.
Strongly live variables. In this variant of live variable analysis, the instruction x = y + z makes y and z live only if x is live after it: . With union as the meet, contains exactly when or , so . The function is distributive, but it is not of gen-kill form, because whether it adds depends on the input.
Distributive functions on sets. With union as the meet on the subsets of a finite set , a function is distributive if and only if for every . Proof. If distributes, write and apply the finite-meet rule. Conversely, a function of this form clearly satisfies . So a distributive function on is fully described by sets. The IFDS framework uses exactly this to turn interprocedural distributive problems into graph reachability, and the IDE framework extends the idea to environments.
Copy-constant propagation. Constant propagation restricted to x = c and x = y is distributive. With one flat lattice per variable and the pointwise meet, the function of x = y maps an environment to , and , so the two sides agree in every variable.
Non-example: full constant propagation. Let one branch set , the other , and let them join before z = x + y. Call the two facts and , and let be the function of z = x + y.
| fact | after | ||
|---|---|---|---|
| 2 | 3 | 5 | |
| 3 | 2 | 5 | |
| not a constant | not a constant | 5 | |
| not a constant | not a constant | not a constant |
So , and on this program MFP says z is not a constant while MOP says z = 5. The function combines two variables, and the meet has already forgotten that they move together.
Non-example: a constant that is lost at a join. Even one variable can break distributivity if the function is not one to one. For x = y * 0, the function sends and to , but it sends their meet, "not a constant", to "not a constant" unless the folding rule knows that anything times 0 is 0.
Related definitions
- Monotone dataflow framework: the general class, where MFP MOP and equality can fail.
- Gen-kill problem: the distributive problems on sets with functions .
- Meet-over-all-paths solution and maximal fixed-point solution: the two answers that distributivity makes equal; the MOP-MFP coincidence theorem is the theorem above.
- Kam-Ullman iteration bound: the rapid frameworks, where round-robin iteration in reverse postorder ends after a number of passes set by the loop structure. Rapid and distributive are different conditions.
- IFDS framework and IDE framework: interprocedural analysis that is exact over valid paths for distributive problems.
References
- Gary A. Kildall, A unified approach to global program optimization, Proceedings of the 1st ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 1973), 194-206, the whole paper (the distributive optimizing functions on a meet semilattice, and the result that the iterative algorithm then finds the meet over all paths)
- John B. Kam and Jeffrey D. Ullman, Monotone data flow analysis frameworks, Acta Informatica 7(3), 1977, 305-317, the whole paper (monotone frameworks that are not distributive, such as constant propagation, where the maximal fixed point can be strictly below the meet over all paths)
- Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman, Compilers, Principles, Techniques, and Tools, second edition, Pearson Addison-Wesley, 2007, Section 9.3.2 (Transfer Functions, monotone and distributive frameworks), Section 9.3.4 (Meaning of a Data-Flow Solution, MFP and MOP) and Section 9.4.5 (nondistributivity of the constant-propagation framework)
- Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Section 2.3 (Monotone Frameworks, including distributive frameworks) and Section 2.4 (Equation Solving, the MFP and MOP solutions and when they agree), in the join convention
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag HTP3TD Edit this page History Report an error Markdown