new CPS simplification pass - remove-unused

Stephen Weeks MLton@sourcelight.com
Mon, 2 Oct 2000 14:18:44 -0700 (PDT)


> Now, for the benchmarks.  For a loop that counts the number of newlines in a
> file, the imperative IO runs at 7M/s on my machine and the functional IO runs at
> 3M/s.  Unfortunately this change has cost a factor of 2 slowdown in the
> imperative IO (it was up to 15M/s a few days ago).  This is due to a weakness in
> MLton's elimination of useless constructors that causes it to not eliminate the
> Stream constructor.  The problem comes from code like the following:
...
> In this code, MLton will not eliminate the B constructor, because it sees the
> explicit construction of a B object.  It does not notice that this construction
> could only happen if there was already another B object, which there isn't.
> Anyways, it should be easy to catch this case -- it's on my todo list.

I implemented a new CPS simplification pass that combines
remove-unused-constructors, remove-unused-functions, and remove-unused-globals.
It runs to fixed-point and produces results at least as good as running the
previous three in (any) sequence.  It catches the above case.  Here are the new
rates for the 'wc -l' IO benchmark on my 400MhZ pentium.

scanStream	 3.7 M/s
input1		20.4 M/s