[GHC] #14211: Compiler is unable to INLINE as well as the programmer can manually

GHC ghc-devs at haskell.org
Sun Sep 10 10:25:33 UTC 2017


#14211: Compiler is unable to INLINE as well as the programmer can manually
-------------------------------------+-------------------------------------
        Reporter:  harendra          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:
                                     |  StaticArgumentTransformation,
                                     |  Inlining
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:                    |
-------------------------------------+-------------------------------------
Changes (by mpickering):

 * keywords:   => StaticArgumentTransformation, Inlining


Comment:

 `bindWith` is a self-recursive function so GHC won't inline it by itself.

 If you rewrite `bindWith` to

 {{{
 bindWith
     :: (forall c. AsyncT m c -> AsyncT m c -> AsyncT m c)
     -> AsyncT m a
     -> (a -> AsyncT m b)
     -> AsyncT m b
 bindWith k m f = go m
     where go (AsyncT m) =
             AsyncT $ \_ stp yld ->
             let run x = (runAsyncT x) Nothing stp yld
                 yield a _ Nothing  = run $ f a
                 yield a _ (Just r) = run $ f a `k` (go r)
             in m Nothing stp yield
 }}}

 so it delegates the recursion to the `go` function then it seems like the
 performance is the same.

 This is the transformation the static argument transformation is meant to
 achieve (turned on by `-fstatic-argument-transformation`). It didn't seem
 to work just by turning on this flag but I don't have time to investigate
 more now.

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


More information about the ghc-tickets mailing list