[GHC] #10137: Rewrite switch code generation

GHC ghc-devs at haskell.org
Sun Mar 8 16:14:59 UTC 2015


#10137: Rewrite switch code generation
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                   Owner:
            Type:  task              |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.9
  (CodeGen)                          |                Keywords:
      Resolution:                    |            Architecture:
Operating System:  Unknown/Multiple  |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:  #9157, #8326,     |  Differential Revisions:
  #8317, #9159                       |
-------------------------------------+-------------------------------------

Comment (by nomeata):

 > Note that when matching on an enumeration type, we can assume that the
 constructor tag is within the range of possible tag values. We cannot make
 any such assumption for matches on ints. So, we should remember the extra
 information that we have about the range when doing this reduction.

 Right. The datatype is currently
 {{{
 data SwitchTargets =
     SwitchTargets (Maybe (Integer, Integer)) (Maybe Label) (M.Map Integer
 Label)
 }}}
 so there optionally is a definite range (absent when matching literal).
 The function `addRange` in the new `CmmSwitch` module (currently in branch
 `wip/T10137`) takes care of that case, before the general layout algorithm
 runs on the remaining range.

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


More information about the ghc-tickets mailing list