#7360: Case-of-identical-alts optimisation fails abjectly
    Reporter:  simonpj           |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.6.1           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  

Comment(by simonpj):

 I'm afraid I don't but let me try here to explain the issues, and you can
 have a go yourself.

 To implement my comment above, here are the changes I have in mind:

  * Remove the 'scrut' arg to `simplAlt` and `addBinderUnfolding`; simplify
 the latter by eliminating the `(Just v)` alternative.

  * Remove the call to `(isNothing scrut`) around line 2072 of

 Then you want to check that things are better. In particular I'd like
 to be confident that we have not thereby increased the number of
 simplifier iterations, or (worse still) claiming that something is
 dead when it isn't.

 So it would be good to run a nofib performance test before and after,
 with -dcore-lint.  That mainly checks runtime performance and
 allocation.  Adding `-ddump-simpl-stats` and looking for the
 `SimplifierDone` figure tells you the number of simplifier iterations,
 which should not increase.  We don't have an automated way to check that.

 Even this isn't ideal.  If we have
 case x of y {
    [] -> length y
    (_:_) -> length y }
 we won't combine the alteratives because `y` is alive in the alternatives.
 (See teh (necessary) call to `(isDeadBinder case_bndr')` online 2072 of
 `Simplify.lhs`.  This is silly.

 So the next thing I'd try is moving the `Merge Identical ALternatives`
 code from `mkCase1` to `prepareAlts`.  The latter happens ''before''
 the alternatives are simplified, so it'd be fine to simply combine the
 alternatives without messing with the occurrence info on the
 alternative binders at all.

 Again easy to try, but we'd want the same performance testing as
 before.  Would you like to try?


Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7360#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

Glasgow-haskell-bugs mailing list

Reply via email to