[GHC] #13316: Bad inlining cascade leads to slow optimisation

GHC ghc-devs at haskell.org
Mon Apr 24 13:58:23 UTC 2017


#13316: Bad inlining cascade leads to slow optimisation
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 I've just discovered that this inline cascade happens in a module of GHC
 itself: `StgCmmBind`.  Here's the output if you compile with `-fmax-
 simplifier-iterations=8`:
 {{{
 WARNING: file compiler/simplCore/SimplCore.hs, line 700
   Simplifier bailing out after 8 iterations [2478, 266, 16, 1, 1, 1, 2, 1]
     Size = {terms: 2,793, types: 8,470, coercions: 529, joins: 4/77}
 WARNING: file compiler/simplCore/SimplCore.hs, line 700
   Simplifier bailing out after 8 iterations [990, 166, 9, 4, 2, 4, 2, 3]
     Size = {terms: 4,605, types: 13,273, coercions: 302, joins: 21/138}
 }}}
 The cascade of iterations with only one or two ticks each time comes from
 exactly the kind of nested data constructor applications in the
 description.

 To be specific, in `closureCodeBody`, at some point we see code like this,
 and those `wild` variables get inlined one by one:
 {{{
             let {
               wild1_so1n :: CLabel
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False,
                        ConLike=False, WorkFree=False,
                        Expandable=False, Guidance=IF_ARGS [] 30 0}]
               wild1_so1n
                 = closureLocalEntryLabel ipv_anWK cl_info_aegJ } in
             let {
               wild1_so1m :: CmmLit
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True,
                        ConLike=True, WorkFree=True, Expandable=True,
                        Guidance=IF_ARGS [] 10 20}]
               wild1_so1m = CmmExpr.CmmLabel wild1_so1n } in
             let {
               wild1_so1l :: CmmExpr
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True,
                        ConLike=True, WorkFree=True, Expandable=True,
                        Guidance=IF_ARGS [] 10 20}]
               wild1_so1l = CmmExpr.CmmLit wild1_so1m } in
             let {
               wild1_so1k
                 :: CmmNode
                      hoopl-3.10.2.2:Compiler.Hoopl.Block.O
                      hoopl-3.10.2.2:Compiler.Hoopl.Block.C
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True,
                        ConLike=True, WorkFree=True, Expandable=True,
                        Guidance=IF_ARGS [] 10 70}]
               wild1_so1k
                 = CmmNode.CmmCall
                     @ hoopl-3.10.2.2:Compiler.Hoopl.Block.O
                     @ hoopl-3.10.2.2:Compiler.Hoopl.Block.C
                     @~ (<hoopl-3.10.2.2:Compiler.Hoopl.Block.O>_N
                         :: (hoopl-3.10.2.2:Compiler.Hoopl.Block.O :: *)
                            ghc-prim-0.5.0.0:GHC.Prim.~#
                            (hoopl-3.10.2.2:Compiler.Hoopl.Block.O :: *))
                     @~ (<hoopl-3.10.2.2:Compiler.Hoopl.Block.C>_N
                         :: (hoopl-3.10.2.2:Compiler.Hoopl.Block.C :: *)
                            ghc-prim-0.5.0.0:GHC.Prim.~#
                            (hoopl-3.10.2.2:Compiler.Hoopl.Block.C :: *))
                     wild1_so1l
                     (GHC.Base.Nothing @ BlockId)
                     ww2_ao10
                     ww1_ao0Z
                     MkGraph.mkFinalCall1
                     updfr_off_alrO } in
             case wild_ao13 of wild2_ao15 {
               __DEFAULT ->
                 OrdList.Snoc
                   @ CgStmt wild2_ao15 (MkGraph.CgLast wild1_so1k);
               OrdList.One a1_ao1b ->
                 OrdList.Cons
                   @ CgStmt
                   a1_ao1b
                   (OrdList.One @ CgStmt (MkGraph.CgLast wild1_so1k))
             };
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13316#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list