CallArity: Use exprIsCheap to detect thunks
authorJoachim Breitner <mail@joachim-breitner.de>
Mon, 26 Dec 2016 09:16:55 +0000 (10:16 +0100)
committerJoachim Breitner <mail@joachim-breitner.de>
Mon, 26 Dec 2016 20:33:46 +0000 (21:33 +0100)
commit815099cce8f183d49305c9d40c8ed699c178108c
tree244d0e304edce32814ab796065d80ad013484254
parent3c9fbbac3a34700565b1d51df67444fda149952f
CallArity: Use exprIsCheap to detect thunks

Originally, everything that is not in WHNF (`exprIsWHNF`) is considered
a thunk, not eta-expanded, to avoid losing any sharing. This is also how
the published papers on Call Arity describe it.

In practice, there are thunks that do a just little work, such as
pattern-matching on a variable, and the benefits of eta-expansion likely
oughtweigh the cost of doing that repeatedly. Therefore, this
implementation of Call Arity considers everything that is not cheap
(`exprIsCheap`) as a thunk.

Nofib reports -2.58% allocations for scs and -40.93% allocation for
wheel-sieve1; the latter has - 2.92% runtime.
compiler/simplCore/CallArity.hs
testsuite/tests/callarity/unittest/CallArity1.hs