#1547: Arity can decrease with -prof
---------------------------------------+------------------------------------
 Reporter:  igloo                      |          Owner:             
     Type:  bug                        |         Status:  new        
 Priority:  high                       |      Milestone:  6.10 branch
Component:  Profiling                  |        Version:  6.6.1      
 Severity:  normal                     |     Resolution:             
 Keywords:                             |     Difficulty:  Unknown    
 Testcase:  stm package/tests/conc052  |   Architecture:  Unknown    
       Os:  Unknown                    |  
---------------------------------------+------------------------------------
Comment (by simonpj):

 I had a half-done change in `SimplUtils` which I'm just going to dump here
 for now.  The actual code change (which I am not sure is right) is this:
 {{{
 hunk ./compiler/simplCore/SimplUtils.lhs 827
 -       any isRuntimeVar bndrs
 +       any isRuntimeVar bndrs || not (exprIsTrivial body)
 +               -- Note [RHS eta expansion]
 }}}
 and the note is this:
 {{{
 Note [RHS eta expansion]
 ~~~~~~~~~~~~~~~~~~~~~~~~
 The basic idea is to transform
    f = \x1..xn -> N  ==>   f = \x1..xn y1..ym -> N y1..ym
                                  (n >= 0)
 where (in both cases)

         * The xi can include type variables

         * The yi are all value variables

         * N is a NORMAL FORM (i.e. no redexes anywhere)
           wanting a suitable number of extra args.

 This is OK even if n=0; for example:
         let g=\xs. x:xs in (\ys. map g ys)
 Here we can eta expand to
         \ys. let g=\xs. x:xs in map g ys
 You might think the f-binding woudl have floated, but it may not when
 we are profiling:
         f = scc "foo" (let g=\xs. x:xs in (\xs. map g ys))
 Furthermore, f's arity might have been 1 before, if it originally looked
 like
         h g ys = map g ys
         f = scc "foo" (h (\xs. x:xs))
 and we do not expect like the arity to decrease so that it now looks
 like zero (to the cheap-and-cheerful exprArity).

 However, we must be careful not to undo the effect of eta-reduction, hence
 the check for `(not (exprIsTrivial body))`.
 }}}
 I just want to capture the state of play because I can't finish this
 today.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1547#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to