[GHC] #15578: Honour INLINE pragmas on 0-arity bindings
GHC
ghc-devs at haskell.org
Thu Aug 30 08:18:41 UTC 2018
#15578: Honour INLINE pragmas on 0-arity bindings
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Looking at `CoreUnfold.mkInlineUnfolding`, a function with an INLINE
pragma has its unfolding built with `mkInlineUnfoldingWithArity` (the
arity being the syntactic arity in the source code). This function gives
the unfolding an `UnfoldingGuidance` of
{{{
guide = UnfWhen { ug_arity = arity
, ug_unsat_ok = needSaturated
, ug_boring_ok = boring_ok }
boring_ok = inlineBoringOk expr'
}}}
And in fact, in `callSiteInline`, you can see that if `ug_arity = 0` then
`x` will inline if `boring_ok` is True.
What is `boring_ok`? It says whether to inline in an utterly boring
context. In
{{{
\ y x -> Just (f x y)
}}}
we don't inline `f` ''even if `f` has an INLINE pragma'' because the
context of the call us utterly boring: nothing is known about `x` or `y`
or the calling context. So there is really no point in inlining.
I don't think this applies to 0-ary INLINE pragmas, as Trac #15519 shows.
So I think it may be enough to say, in `mkInlineUnfoldingWithArity`,
{{{
boring_ok | arity == 0 = True
| otherwise = inlineBoringOk expr'
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15578#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list