shrinker

Stephen Weeks MLton@sourcelight.com
Tue, 20 Nov 2001 15:14:31 -0800


> It's easier to see in a dot file, but each of those L_??? (global_3)
> basically pass "true" onto an if branch.  Looking at the same functions in
> cps, I don't see things like this, so maybe there was something in the
> CPS shrinker that got them.

The SSA shrinker is supposed to get goto's to cases with a known
constructor, provided that the only occurrence of the bound variable
is in the case test (this so that we don't violate the SSA
condition).  For example, the following should be simplified, even if
there are other references to L2.

  L1 () =
    ...
    L2 (C)
  L2 (x)
    case x of
       C => L3
     | ...

So, if the code in your example isn't gone after another round of
shrinking, there is definitely a problem.

> No big deal, though.  Something like this should be subsumed by a
> known-case analysis/transformation, which should work on all datatypes,
> not just bools.  

Right, but as you note, the known-case stuff will do more because it
may violate SSA.

> Also, does/will/should the shrinker restore the SSA condition if a
> transformation breaks it?  My guess is not, since so far no transformation
> has needed it.

Right.  We will write another pass that restores SSA that will be run
only after passes that break it.