[GHC] #13157: Opportunity to improve case-of-case

GHC ghc-devs at haskell.org
Fri Jan 20 11:53:42 UTC 2017


#13157: Opportunity to improve case-of-case
-------------------------------------+-------------------------------------
           Reporter:  simonpj        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider this code
 {{{
 f g x = (case g x of True  -> not
                      False -> id) `seq` True
 }}}
 With GHC 8 (and -O) we get this Core
 {{{
 f =
   \ (@ t_a1rk) (g_aqD :: t -> Bool) (x_aqE :: t) ->
     case case g_aqD x_aqE of {
            False -> id @ Bool;
            True -> not
          }
     of
     { __DEFAULT ->
     GHC.Types.True
     }
 }}}
 This is obviously bad.

 The reasoning is in the long, complicated `Note [Single-alternative
 cases]` in `Simplify.hs`.

 Happily with join points the entire Note becomes unnecessary; we can
 delete the special case that this Note describes, and the Note itself.
 Result: simpler compiler, and more optimal code.

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


More information about the ghc-tickets mailing list