#1643: Unnecessary dictionaries
-------------------------+--------------------------------------------------
    Reporter:  guest     |        Owner:         
        Type:  bug       |       Status:  new    
    Priority:  normal    |    Milestone:         
   Component:  Compiler  |      Version:  6.7    
    Severity:  normal    |   Resolution:         
    Keywords:            |   Difficulty:  Unknown
          Os:  MacOS X   |     Testcase:         
Architecture:  x86       |  
-------------------------+--------------------------------------------------
Comment (by [EMAIL PROTECTED]):

 If you look at the Core, you can see that the definition of the $dMonad
 inside qsort looks like this:
 {{{
 $dMonad_s5Hx :: forall s_a5pv.
                 GHC.Base.Monad (CTBase.E' CTBase.RValue (GHC.ST.ST
 s_a5pv))
 []
 $dMonad_s5Hx =
   \ (@ s_a5pv) ->
     case CT.$wic
            @ (GHC.ST.ST s_a5pv)
            @ (GHC.STRef.STRef s_a5pv)
            @ GHC.Base.Int
            (MonadRef.$f1 @ s_a5pv)
     of ww_s3pb [Dead Nothing] { (# ww1_s3pd, ww2_s3pe, ww3_s3pf, ww4_s3pg
 #) ->
     GHC.Base.:DMonad
       @ (CTBase.E' CTBase.RValue (GHC.ST.ST s_a5pv))
       ww1_s3pd
       ww2_s3pe
       ww3_s3pf
       ww4_s3pg
     }
 }}}

 Because the rhs of {{{$dMonad_s5Hx}}} isn't cheap, it doesn't get inlined
 inside a lambda (e.g., in the body of {{{qsort}}}. If the call to
 {{{CT.$wic}}} inside {{{$dMonad_s5Hx}}} were inlined, then
 {{{$dMonad_s5Hx}}} would be inlined as well. But by default, GHC thinks
 {{{CT.$wic}}} is too big to inline. If you pass in the flag
 {{{-funfolding-use-threshold36}}} to increase the threshold for the
 allowable size of an unfolding, then you get the results you want, but I
 haven't measured whether that actually increases performance here.

 -Tim

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