[GHC] #14816: Missed Called Arity opportunity?
GHC
ghc-devs at haskell.org
Tue Feb 20 04:57:46 UTC 2018
#14816: Missed Called Arity opportunity?
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.2.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
It works if you don't export `insertModifyingArr`. Then it gets inlined
into `test`, and CallArity, when looking at the binding of `g_s9E` in your
original snippet, sees all the uses, sees that they are called at most
once, and is happy to eta-expand it!
But without inlining `insertModifyingArr`, this is beyond the reach of
Call Arity, because it is not a higher-order analysis.
Now, why does the demand analyser (which is higher-order, i.e. knows how
functions call their arguments) not fix this? Because the demand analyser
does not see that `insertModifyingArr` calls its argument only once,
because the call is in a recursive loop.
Sebastian Graf (@sgraf812) has thoughts on combining the analyses to give
us the best of both worlds, maybe he can comment.
For now, does
{{{
import GHC.Magic
blink :: (a -> b) -> a -> (# b #)
blink g = oneShot $ \a -> (# g a #)
}}}
do what you want?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14816#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list