[GHC] #9509: No automatic specialization of inlinable imports in 7.8

GHC ghc-devs at haskell.org
Sat Dec 3 00:34:56 UTC 2016


#9509: No automatic specialization of inlinable imports in 7.8
-------------------------------------+-------------------------------------
        Reporter:  dolio             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.8.3
      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 nfrisby):

 With no pragma, {{{foo}}} has the following unfolding and gets inlined.

 {{{
  Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
          WorkFree=True, Expandable=True,
          Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)
 }}}

 With the {{{INLINABLE}}} pragma, {{{foo}}} has the following unfolding and
 does not get inlined.

 {{{
  Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
          WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 210 60
 }}}

 In both cases, its RHS is just a cast.

 I think the inferred {{{IF_ARGS}}} guidance is the cause of this
 unexpected behavior, because it violates the {{{"Mind you, then 'choose'
 will be inlined (since RHS is trivial)"}}} assumption in {{{Note
 [Specialisation shape]}}}, which
 otherwise anticipated this consequence of the ({{{IO}}}) newtype.

 https://github.com/ghc/ghc/blob/c36904d66f30d4386a231ce365a056962a881767/compiler/specialise/Specialise.hs#L1607

 I did not investigate where the {{{IF_ARGS}}} guidance is coming from for
 such a trivial declaration. Seems like a leftover from the "actual" RHS
 (at the newtype's representative type), in this specific example and
 context.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9509#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list