4 <:CommonSubexp:> is an optimization pass for the <:SSA:>
5 <:IntermediateLanguage:>, invoked from <:SSASimplify:>.
9 It eliminates instances of common subexpressions.
13 * <!ViewGitFile(mlton,master,mlton/ssa/common-subexp.fun)>
15 == Details and Notes ==
17 In addition to getting the usual sorts of things like
22 (w + 0wx1) + (w + 0wx1)
28 let val w' = w + 0wx1 in w' + w' end
31 it also gets things like
36 val a = Array_uninit n
37 val b = Array_length a
43 val a = Array_uninit n
47 `Arith` transfers are handled specially. The _result_ of an `Arith`
48 transfer can be used in _common_ `Arith` transfers that it dominates:
53 val l = (n + m) + (n + m)
55 val k = (l + n) + ((l + m) handle Overflow => ((l + m)
56 handle Overflow => l + n))
59 is rewritten so that `(n + m)` is computed exactly once, as are
60 `(l + n)` and `(l + m)`.