#5715: Inliner fails to inline a function, causing 20x slowdown
---------------------------------+------------------------------------------
    Reporter:  bos               |       Owner:                         
        Type:  bug               |      Status:  new                    
    Priority:  normal            |   Milestone:                         
   Component:  Compiler          |     Version:  7.2.1                  
    Keywords:                    |          Os:  Unknown/Multiple       
Architecture:  Unknown/Multiple  |     Failure:  Runtime performance bug
  Difficulty:  Unknown           |    Testcase:                         
   Blockedby:                    |    Blocking:                         
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonpj):

  * difficulty:  => Unknown


Comment:

 The behaviour of INLINE should be simple and predictable.  If you write
 {{{
 f x y = <rhs>
 {-# INLINE f #-}
 }}}
 then `f` will be inlined into any application `(f e1 e2)`.  But not into
 partial applications.

 Consider the example you give:
 {{{
 instance Variate Int8 where
     uniform  = uniform1 fromIntegral
     uniformR = uniformRange
     {-# INLINE uniform  #-}
     {-# INLINE uniformR #-}
 }}}
  * `uniformRange will not be inlined here.  (Doing so would do no good.)
  * Every use of `uniformR` (at type `Int8`) should replaced by
 `uniformRange` (since `uniformR` has an INLINE pragma and has no args).
  * If that call to `uniformR` had two arguments, then `uniformRange`
 should in turn inline.

 I see no reason to write
 {{{
 instance Variate Int8 where
     uniform  = uniform1 fromIntegral
     uniformR inliner sacrifice = uniformRange inliner sacrifice
     {-# INLINE uniform  #-}
     {-# INLINE uniformR #-}
 }}}
 Maybe that is a bug.


 If you believe that HEAD (or even 7.2) is showing odd behaviour, could you
 make a standalone test case?  Then I will certainly look at it.

 Thanks

 Simon

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