4 <:KnownCase:> is an optimization pass for the <:SSA:>
5 <:IntermediateLanguage:>, invoked from <:SSASimplify:>.
9 This pass duplicates and simplifies `Case` transfers when the
10 constructor of the scrutinee is known.
14 For example, the program
22 val _ = 1 + last [2, 3, 4, 5, 6, 7]
25 gives rise to the <:SSA:> function
28 fun last_0 (x_142) = loopS_1 ()
33 nil_1 => L_73 | ::_0 => L_74
38 nil_1 => L_75 | _ => L_76
45 which is simplified to
48 fun last_0 (x_142) = loopS_1 ()
51 nil_1 => L_73 | ::_0 => L_118
55 L_74 (x_230, x_229, x_142)
56 L_74 (x_145, x_144, x_232)
58 nil_1 => L_75 | ::_0 => L_114
62 L_74 (x_227, x_226, x_145)
67 * <!ViewGitFile(mlton,master,mlton/ssa/known-case.fun)>
69 == Details and Notes ==
71 One interesting aspect of <:KnownCase:>, is that it often has the
72 effect of unrolling list traversals by one iteration, moving the
73 `nil`/`::` check to the end of the loop, rather than the beginning.