#2289: Needless reboxing of values when returning from a tight loop
----------------------------------------+-----------------------------------
 Reporter:  dons                        |          Owner:         
     Type:  run-time performance bug    |         Status:  new    
 Priority:  normal                      |      Milestone:         
Component:  Compiler                    |        Version:  6.8.2  
 Severity:  normal                      |     Resolution:         
 Keywords:  boxing, loops, performance  |     Difficulty:  Unknown
 Testcase:                              |   Architecture:  Unknown
       Os:  Unknown                     |  
----------------------------------------+-----------------------------------
Comment (by simonpj):

 Rats.  I'd forgotten about the strictness question:
 {{{
 f :: Int -> (Int,Int)
 f x = (g x, h x)
 }}
 Suppose `g` and `h` have the CPR property -- that is, they explicitly
 return a boxed value.  Then it's a mistake to transform to
 {{{
 f x = case (g x, h x) of { (I# r1, I# r2) ->
       (I# r1 ,I# r2) }
 }}}
 because that'd make f too strict.  But in your example, `g` and `h` are
 themselves constructors.

 My conclusion: for the ''nested'' part of CPR analysis we do not want to
 "look through" function calls, but rather look only for literal
 constructor applications.  I have not thought about how much this'd affect
 the analysis.

 Provided the analysis was modified in this way, it shouldn't be too hard
 to modify the worker/wrapper part to take account of it.

 But NB that CprAnalyse is dead code; the current analysis is done as part
 of strictness analysis in DmdAnal.  And the strictness analyser itself
 needs love and attention. So much to do, so little time.


 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2289#comment:5>
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