Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / Redundant.adoc
CommitLineData
7f918cf1
CE
1Redundant
2=========
3
4<:Redundant:> is an optimization pass for the <:SSA:>
5<:IntermediateLanguage:>, invoked from <:SSASimplify:>.
6
7== Description ==
8
9The redundant SSA optimization eliminates redundant function and label
10arguments; an argument of a function or label is redundant if it is
11always the same as another argument of the same function or label.
12The analysis finds an equivalence relation on the arguments of a
13function or label, such that all arguments in an equivalence class are
14redundant with respect to the other arguments in the equivalence
15class; the transformation selects one representative of each
16equivalence class and drops the binding occurrence of
17non-representative variables and renames use occurrences of the
18non-representative variables to the representative variable. The
19analysis finds the equivalence classes via a fixed-point analysis.
20Each vector of arguments to a function or label is initialized to
21equivalence classes that equate all arguments of the same type; one
22could start with an equivalence class that equates all arguments, but
23arguments of different type cannot be redundant. Variables bound in
24statements are initialized to singleton equivalence classes. The
25fixed-point analysis repeatedly refines these equivalence classes on
26the formals by the equivalence classes of the actuals.
27
28== Implementation ==
29
30* <!ViewGitFile(mlton,master,mlton/ssa/redundant.fun)>
31
32== Details and Notes ==
33
34The reason <:Redundant:> got put in was due to some output of the
35<:ClosureConvert:> pass converter where the environment record, or
36components of it, were passed around in several places. That may have
37been more relevant with polyvariant analyses (which are long gone).
38But it still seems possibly relevant, especially with more aggressive
39flattening, which should reveal some fields in nested closure records
40that are redundant.