[GHC] #10788: performance regression involving minimum (and maybe Vector)

GHC ghc-devs at haskell.org
Sun Aug 23 19:28:55 UTC 2015


#10788: performance regression involving minimum (and maybe Vector)
-------------------------------------+-------------------------------------
        Reporter:  rwbarton          |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by nomeata):

 GHC 7.8 will actually inline `minimum` (and hence `foldl1` and `foldl`),
 allowing the compiler to specialize it for the type at hand:
 {{{#!hs
 Rec {
 $wlgo_r6X4 :: GHC.Prim.Int# -> [GHC.Types.Int] -> GHC.Prim.Int#
 [GblId, Arity=2, Caf=NoCafRefs, Str=DmdType <L,U><S,1*U>]
 $wlgo_r6X4 =
   \ (ww_s6TV :: GHC.Prim.Int#) (w_s6TS :: [GHC.Types.Int]) ->
     case w_s6TS of _ [Occ=Dead] {
       [] -> ww_s6TV;
       : x_a52E xs_a52F ->
         case x_a52E of _ [Occ=Dead] { GHC.Types.I# y1_a52Q ->
         case GHC.Prim.tagToEnum#
                @ GHC.Types.Bool (GHC.Prim.<=# ww_s6TV y1_a52Q)
         of _ [Occ=Dead] {
           GHC.Types.False -> $wlgo_r6X4 y1_a52Q xs_a52F;
           GHC.Types.True -> $wlgo_r6X4 ww_s6TV xs_a52F
         }
         }
     }
 end Rec }
 }}}

 GHC-7.10 will ''not'' inline `minimum`, but only replace it by
 `minimumStrict` via a rule, and the latter then called polymorphically:

 {{{#!hs
 ...
             case strictMinimum @ Int GHC.Classes.$fOrdInt (go_a6gJ
 cs_r9bl)
             of _ [Occ=Dead] { I# y_a6hm ->
 }}}

 GHC-7.8’s inlining seems to be a little excessive, but in 7.10 there is
 certainly a lack of specialization. Maybe some `INLINEABLE` pragma would
 help? Not sure...

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


More information about the ghc-tickets mailing list