
#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,
{{{#!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).
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 data T = Con1 | Con2 | Con3 ... case x of Con1 -> a Con2 -> b DEFAULT -> c }}} Arguably we should instead generate, {{{#!hs case x of Con1 -> a Con2 -> b Con3 -> c }}} 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:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler