[GHC] #15019: Fix performance regressions from #14737

GHC ghc-devs at haskell.org
Wed Apr 25 13:42:12 UTC 2018


#15019: Fix performance regressions from #14737
-------------------------------------+-------------------------------------
        Reporter:  tdammers          |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14737            |  Differential Rev(s):  phab:D4568
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Replying to [comment:9 simonpj]:
 > OK, got it.  The culprit is this:
 > {{{
 >         addCoerce co1 (CastIt co2 cont)
 >           = addCoerce (mkTransCo co1 co2) cont
 > }}}
 > It's really very common for `co1` and `co2` to cancel each other out,
 but `mkTransCo` doesn't spot that.  Next thing to try:
 >
 > {{{
 >         addCoerce co cont
 >           | isReflCo co = return cont
 >
 >         addCoerce co1 (CastIt co2 cont)
 >           | isReflexiveCo co' = return cont
 >           | otherwise         = {-#SCC "addCoerce-simple-recursion" #-}
 >                                 addCoerce co' cont
 >           where
 >             co' = mkTransCo co1 co2
 > }}}
 > And get rid of the `isReflexiveCo` at the end altogether.
 >
 > The initial `isReflCo` is optional -- just to catch the case where the
 `simplCorecion` returns Refl.

 Yes, this does seem to work. Running some tests to verify.

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


More information about the ghc-tickets mailing list