[EXTERNAL] Unexpected duplicate join points in "Core" output?
Viktor Dukhovni
ietf-dane at dukhovni.org
Wed Nov 24 21:27:05 UTC 2021
On Sun, Nov 21, 2021 at 06:53:53AM -0500, Carter Schonwald wrote:
> On Sat, Nov 20, 2021 at 4:17 PM Simon Peyton Jones via ghc-devs <
> ghc-devs at haskell.org> wrote:
>
> > There is absolutely no reason not to common-up those to join points. But
> > we can't common up some join points when we could if they were let's.
> > Consider
> >
> > join j1 x = x+1
> > in case v of
> > A -> f (join j2 x = x+1 in ...j2...)
> > B -> ....j1...
> > C -> ....j1...
> >
> > Even though j2 is identical to j1's, we can't eliminate j2 in favour of j1
> > because then j1 wouldn't be a join point any more.
>
> In this example: why would it stop being a join point ?
>
> Admittedly, my intuition might be skewed by my own ideas about how
> join points are sortah a semantic special case of other constructs.
I think the point is that join points are tail calls that don't return
to the caller. But here even though `j1` and `j2` have the same body
j1's continuation is not the same as j2's continuation.
Rather the result of `j2` is the input to `f`, but the result of j1 is a
possible output of the whole `case` block in the B and C branches. For
two join points to be duplicates they need to not only be alpha
equivalent but to also have the same continuation. Something like
join j1 x = x + 1 in
join j2 y = y + 1 in
... j1 ...
... j2 ...
where eliminating j2 in favour of j1 should be correct.
--
VIktor.
More information about the ghc-devs
mailing list