Content deleted Content added
→Expression in terms of dataflow equations: corrected a typo Tags: Reverted Mobile edit Mobile web edit |
improve typesetting of constants and variables |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 10:
The set of live variables between lines 2 and 3 is {<code>b</code>, <code>c</code>} because both are used in the multiplication on line 3. But the set of live variables after line 1 is only {<code>b</code>}, since variable <code>c</code> is updated later, on line 2. The value of variable <code>a</code> is not used in this code.
Note that the assignment to <code>a</code> may be eliminated as <code>a</code> is not used later, but there is insufficient information to justify removing all of line 3 as <code>f</code> may have [[Side effect (computer science)|side effects]] (printing <code>b * c</code>, perhaps).
== Expression in terms of dataflow equations ==
Liveness analysis is a "backwards
The dataflow equations used for a given basic block
:<math>
{\mbox{GEN}}[s] </math>: The set of variables that are used in s before any assignment in the same basic block.
:<math>
{\mbox{KILL}}[s] </math>: The set of variables that are assigned a value in s (in many books
:<math>
{\mbox{LIVE}}_{\mathrm{in}}[s] = {\mbox{GEN}}[s] \cup ({\mbox{LIVE}}_{\mathrm{out}}[s] - {\mbox{KILL}}[s])
</math>
:<math>
{\mbox{LIVE}}_{\mathrm{out}}[\mathit{final}] = {\emptyset}
</math>
:<math>
{\mbox{LIVE}}_{\mathrm{out}}[s] = \bigcup_{p \in \mathrm{succ}[s]} {\mbox{LIVE}}_{\mathrm{in}}[p]
</math>
Line 47:
{|
|
// in: {}; predecessor blocks: none
b1: a = 3;
b = 5;
Line 55:
// out: {a,b,d} //union of all (in) successors of b1 => b2: {a,b}, and b3:{b,d}
// in: {a,b}; predecessor blocks: b1
b2: c = a + b;
d = 2;
// out: {b,d}
// in: {b,d}; predecessor blocks: b1 and b2
b3: endif
c = 4;
Line 110:
==References==
{{reflist|30em}}
{{cite book|last1=Aho|first1=Alfred|last2=Lam|first2=Monica|last3=Sethi|first3=Ravi|last4=Ullman|first4=Jeffrey|year=2007|edition=2|title=Compilers: Principles, Techniques, and Tools|page=608}}
{{Compiler optimizations}}
[[Category:Compiler optimizations]]
|