<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.8">
<title>Shrink</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css"/>
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20130715</a>
</div>
</div>
<div id="header">
<h1>Shrink</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p><a href="Shrink">Shrink</a> is a rewrite pass for the <a href="SSA">SSA</a> and <a href="SSA2">SSA2</a>
<a href="IntermediateLanguage">IntermediateLanguage</a>s, invoked from every optimization pass (see
<a href="SSASimplify">SSASimplify</a> and <a href="SSA2Simplify">SSA2Simplify</a>).</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_description">Description</h2>
<div class="sectionbody">
<div class="paragraph"><p>This pass implements a whole family of compile-time reductions, like:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">#1(a, b)</span> &#8658; <span class="monospaced">a</span>
</p>
</li>
<li>
<p>
<span class="monospaced">case C x of C y =&gt; e</span> &#8658; <span class="monospaced">let y = x in e</span>
</p>
</li>
<li>
<p>
constant folding, copy propagation
</p>
</li>
<li>
<p>
eta blocks
</p>
</li>
<li>
<p>
tuple reconstruction elimination
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
<h2 id="_implementation">Implementation</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink.sig"><span class="monospaced">shrink.sig</span></a>
</p>
</li>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink.fun"><span class="monospaced">shrink.fun</span></a>
</p>
</li>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink2.sig"><span class="monospaced">shrink2.sig</span></a>
</p>
</li>
<li>
<p>
<a href="https://github.com/MLton/mlton/blob/master/mlton/ssa/shrink2.fun"><span class="monospaced">shrink2.fun</span></a>
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
<h2 id="_details_and_notes">Details and Notes</h2>
<div class="sectionbody">
<div class="paragraph"><p>The <a href="Shrink">Shrink</a> pass is run after every <a href="SSA">SSA</a> and <a href="SSA2">SSA2</a>
optimization pass.</p></div>
<div class="paragraph"><p>The <a href="Shrink">Shrink</a> implementation also includes functions to eliminate
unreachable blocks from a <a href="SSA">SSA</a> or <a href="SSA2">SSA2</a> program or function.
The <a href="Shrink">Shrink</a> pass does not guarantee to eliminate all unreachable
blocks.  Doing so would unduly complicate the implementation, and it
is almost always the case that all unreachable blocks are eliminated.
However, a small number of optimization passes require that the input
have no unreachable blocks (essentially, when the analysis works on
the control flow graph and the rewrite iterates on the vector of
blocks).  These passes explicitly call <span class="monospaced">eliminateDeadBlocks</span>.</p></div>
<div class="paragraph"><p>The <a href="Shrink">Shrink</a> pass has a special case to turn a non-tail call where
the continuation and handler only do <span class="monospaced">Profile</span> statements into a tail
call where the <span class="monospaced">Profile</span> statements precede the tail call.</p></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
