[GHC] #10918: Float once-used let binding into a recursive function

GHC ghc-devs at haskell.org
Wed Sep 30 16:40:32 UTC 2015


#10918: Float once-used let binding into a recursive function
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Oh, you are right!  The inliner is a much better place to do this,
 specifically, the code in `preInlineUnconditionally`.

 It deals with the case where we have
 {{{
 let x = <expression> in ....x.....
 }}}
 where there is a single syntactic occurrence of x, not inside a lambda
 (unless it's a one-shot lambda).  The occurrence analyser marks `x` with
 an `OccInfo` of `OneOcc`.

 So you want to teach the occurrence analyser how to make `x` as "occurs
 once" even though it occurs inside a lambda which is called more than once
 (the one for `go`).  Or perhaps, when the occurrence analyser is about to
 mark it it as `OneOcc True ...`, where the `True` is the `InsideLam` info,
 we can switch the `InsideLam` info to `False` if `x` is marked "demanded
 once"

 In haste

 Simon

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


More information about the ghc-tickets mailing list