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

GHC ghc-devs at haskell.org
Tue Mar 29 08:02:20 UTC 2016


#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):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > I suppose that would work, although I don’t like solving such issues by
 slamming just another pass to the end of the pipeline, instead of making
 sure the passes work well together (which is indeed tricky here).

 I agree with the principle here.  But it does seem hard.  The float-out
 pass assumes, crudely, that it's good to float out a redex of any called-
 many lambda.  But, as we see here, that's wrong for case branches that are
 only evaluated on one of those calls (the final one in this case).  Not
 only is that info hard to record in the syntax tree, but it's also
 potentially quite fragile to program transformation, like other sorts of
 cardinality information.

 So refraining from let-floating after the final call-arity/simplifier pass
 does seem plausible.

 Annoyingly, it's just possible that inlining `(foo ys` into that `[]`
 branch might then put it in a context when `foo` inlines, leading to a
 cascade of further transformations.  So it's not necessarily just a little
 delta.

 It'd be good to understand the paraffins thing.

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


More information about the ghc-tickets mailing list