[GHC] #10319: Eta expand PAPs
GHC
ghc-devs at haskell.org
Fri Apr 17 10:39:07 UTC 2015
#10319: Eta expand PAPs
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner:
Type: task | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple | Blocked By:
Test Case: | Related Tickets:
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
SPJ writes in ticket:10260#comment:11:
But see this note in SimplUtils:
{{{
Note [Do not eta-expand PAPs]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We used to have old_arity = manifestArity rhs, which meant that we
would eta-expand even PAPs. But this gives no particular advantage,
and can lead to a massive blow-up in code size, exhibited by Trac #9020.
Suppose we have a PAP
foo :: IO ()
foo = returnIO ()
Then we can eta-expand do
foo = (\eta. (returnIO () |> sym g) eta) |> g
where
g :: IO () ~ State# RealWorld -> (# State# RealWorld, () #)
But there is really no point in doing this, and it generates masses of
coercions and whatnot that eventually disappear again. For T9020, GHC
allocated 6.6G beore, and 0.8G afterwards; and residency dropped from
1.8G to 45M.
But note that this won't eta-expand, say
f = \g -> map g
Does it matter not eta-expanding such functions? I'm not sure. Perhaps
strictness analysis will have less to bite on?
}}}
The worse code for the un-eta-expanded code for last is perhaps an example
of the last paragraph!
And yet the comment is reasonably convincing. I'm not sure what to do
here.
One thing that might be worth trying is to eta-expand as far as poss
without bumping into a coercion. That would expand last but not foo. Want
to try that? We may fix last but there are sure to be other cases, and the
more robust the optimisations the better.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10319>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list