[GHC] #13523: Be more explicit in generated case alternatives

GHC ghc-devs at haskell.org
Tue Apr 4 15:38:59 UTC 2017


#13523: Be more explicit in generated case alternatives
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:  (none)
            Type:  feature request   |               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:                    |
-------------------------------------+-------------------------------------
Description changed by bgamari:

Old description:

> This came up during the GHC call while discussing #13397 and I thought it
> would be good to record.
>
> Often in the compiler we end up with a case analysis with a number of
> alternatives and a `DEFAULT` case in place of the remaining alternative,
> {{{!#hs
> case x of
>   True -> a
>   DEFAULT -> b
> }}}
> Arguably we should instead generate,
> {{{
> case x of
>   True -> a
>   False -> b
> }}}
> instead as this may allow the code generator may be able to emit better
> code when it knows the finite bounds of the switch (e.g. using a jump
> table).

New description:

 This came up during the GHC call while discussing #13397 and I thought it
 would be good to record.

 Often in the compiler we end up with a case analysis with a number of
 alternatives and a `DEFAULT` case in place of the remaining alternative,

 {{{#!hs
 case x of
   True -> a
   DEFAULT -> b
 }}}

 Arguably we should instead generate,

 {{{#!hs
 case x of
   True -> a
   False -> b
 }}}
 instead as this may allow the code generator may be able to emit better
 code when it knows the finite bounds of the switch (e.g. using a jump
 table).

--

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


More information about the ghc-tickets mailing list