Make sure forM_ and related functions fuse cleanly
authorSebastian Graf <sebastian.graf@kit.edu>
Mon, 17 Sep 2018 19:11:09 +0000 (21:11 +0200)
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>
Mon, 17 Sep 2018 19:11:10 +0000 (21:11 +0200)
commite655aac18c5b240f27fcaf26317ad87be5ce8b96
treee496319636b98443874749e07791028e671ddd87
parent43967c0c7d2d0110cfc5f9d64a7dab3a3dda8953
Make sure forM_ and related functions fuse cleanly

Summary:
It was revealed in #8763 that it's hard to come up with a list fusion
helper for `efdtIntFB` that doesn't duplicated occurrences of `c`,
which is crucial in guaranteeing that it is inlined.

Not inlining `c` led to spoiled join points, in turn leading to unnecessary
heap allocation. This patch tackles the problem from a different angle:
Fixing all consumers instead of the less often used producer
`efdtIntFB` by inserting an INLINE pragma in the appropriate places.
See https://ghc.haskell.org/trac/ghc/ticket/8763#comment:76 and the new
Note [List fusion and continuations in 'c'].

A quick run of NoFib revealed no regression or improvements whatsoever.

Reviewers: hvr, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #8763

Differential Revision: https://phabricator.haskell.org/D5131
libraries/base/Data/Foldable.hs
testsuite/tests/perf/compiler/T4007.stdout
testsuite/tests/perf/should_run/T8763.hs [new file with mode: 0644]
testsuite/tests/perf/should_run/all.T