Skip to content

Duplicate join points redux

Join points sometimes duplicate alpha-equivalent (up to permutation of arguments) tail calls with identical continuations.

Attaching a self-contained, if not entirely small example.Test.hs

Also attaching the Core output hscore (GHC 9.2), which shows the redundant join points exit2 and exit3 (lines 286–301). The much smaller exit and exit1 just above are likewise redundant (lines 278–285).

The entire loop is inlined twice, unless I create NOINLINE variants of True and False that avoid generating separate code paths for the code with a leading digit (True) vs. the calls with a leading sign (False) one which starts having already consumed the first digit, so we're sure to find a number, but the code to parse the rest is identical...

The goal of all this inlining is to do all the work with unboxed data, but moving everything into the I/O loop. It isn't that the loop is cheap, but rather that doing all the work inside IO, and boxing only the final result is cheap...

Edited by vdukhovni
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information