#3772: Methods not inlined
---------------------------------+------------------------------------------
    Reporter:  rl                |       Owner:                         
        Type:  bug               |      Status:  new                    
    Priority:  normal            |   Component:  Compiler               
     Version:  6.12.1            |    Keywords:                         
          Os:  Unknown/Multiple  |    Testcase:                         
Architecture:  Unknown/Multiple  |     Failure:  Runtime performance bug
---------------------------------+------------------------------------------
 This affects both 6.12 and the HEAD (albeit differently) but works fine
 with 6.10. It also works if everything is in one module. We are interested
 in the function `U.foo`; in particular, we want the call to `deepSeq`
 (resulting from inlining `T.apply`) to be inlined. This is what we get
 with 6.10 (compiling with `-O2`):
 {{{
 go_riA :: [GHC.Types.Double] -> ()
 go_riA =
   \ (ds_agP :: [GHC.Types.Double]) ->
     case ds_agP of wild_agQ {
       [] -> GHC.Unit.();
       : y_agU ys_agV ->
         case y_agU of tpl2_ah1 { GHC.Types.D# ipv_ah3 -> go_riA ys_agV }
     }

 U.foo :: GHC.Types.Int -> ()
 U.foo =
   \ (n_afR :: GHC.Types.Int) ->
     case n_afR of w_Xhn { GHC.Types.I# ww_ahi ->
     go_riA (T.$wgen @ GHC.Types.Double T.$f2 ww_ahi)
     }
 }}}
 Everything has been nicely inlined. With 6.12, we get this:
 {{{
 U.foo [NEVER Nothing] :: GHC.Types.Int -> ()
 U.foo =
   \ (n_adD :: GHC.Types.Int) ->
     case n_adD of _ { GHC.Types.I# ww_afv ->
     let {
       eta_sgc :: [GHC.Types.Double]
       eta_sgc = T.$wgen @ GHC.Types.Double T.$fCDouble ww_afv } in
     __inline_me (GHC.Base.foldr
                    @ GHC.Types.Double @ () (T.$fCDouble1 @ ()) GHC.Unit.()
 eta_sgc)
     }
 }}}
 The `deepSeq` call has been inlined but hasn't been optimised, I guess
 because GHC retained the `__inline_me` for some reason. Things are even
 worse with the HEAD:
 {{{
 U.foo :: GHC.Types.Int -> ()
 U.foo =
   \ (n_aaO :: GHC.Types.Int) ->
     case n_aaO of _ { GHC.Types.I# ww_abR ->
     T.$fC[]1
       @ GHC.Types.Double
       T.$fCDouble
       @ ()
       (T.$w$cgen @ GHC.Types.Double T.$fCDouble ww_abR)
       GHC.Unit.()
     }
 }}}
 Here, `deepSeq` hasn't even been inlined. But let's add a dummy method to
 `DeepSeq`:
 {{{
 class DeepSeq a where
   deepSeq :: a -> b -> b

   dummy :: a
   dummy = undefined
 }}}
 Now, the HEAD actually inlines the call:
 {{{
 go_rcM :: [GHC.Types.Double] -> ()
 go_rcM =
   \ (ds_acl :: [GHC.Types.Double]) ->
     case ds_acl of _ {
       [] -> GHC.Unit.();
       : y_acq ys_acr ->
         case y_acq of _ { GHC.Types.D# _ -> go_rcM ys_acr }
     }

 U.foo :: GHC.Types.Int -> ()
 U.foo =
   \ (n_aaQ :: GHC.Types.Int) ->
     case n_aaQ of _ { GHC.Types.I# ww_abI ->
     go_rcM (T.$w$cgen @ GHC.Types.Double T.$fCDouble ww_abI)
     }
 }}}
 Unfortunately, 6.12 still doesn't.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3772>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to