common-subexpression elimination (cse)

Henry Cejtin henry@sourcelight.com
Tue, 24 Jul 2001 17:15:32 -0500


But  that  (just replacing latter occurances with the name bound to the first
result) isn't always correct.  There is, of course, side effect things  which
have  to  be duplicated, but the more serious example I was talking about was
the delay due to lambda.

Consider something like

    let val magic: (unit -> int) option ref = ref NONE
        fun f x =
               (magic := SOME (fn () => 1 div x);
                1 div x)
    in f 0
          handle _ => 0;
       valOf (! magic) ()
    end

You have to raise the exception twice.