[GHC] #13397: Optimise calls to tagToEnum#

GHC ghc-devs at haskell.org
Tue Sep 5 04:06:53 UTC 2017


#13397: Optimise calls to tagToEnum#
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  datacon-tags
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 Simon's `caseRules` re-engineering was merged in
 193664d42dbceadaa1e4689dfa17ff1cf5a405a0

 {{{
 commit 193664d42dbceadaa1e4689dfa17ff1cf5a405a0
 Author: Simon Peyton Jones <simonpj at microsoft.com>
 Date:   Wed Mar 8 10:26:47 2017 +0000

     Re-engineer caseRules to add tagToEnum/dataToTag

     See Note [Scrutinee Constant Folding] in SimplUtils

     * Add cases for tagToEnum and dataToTag. This is the main new
       bit.  It allows the simplifier to remove the pervasive uses
       of     case tagToEnum (a > b) of
                 False -> e1
                 True  -> e2
       and replace it by the simpler
              case a > b of
                 DEFAULT -> e1
                 1#      -> e2
       See Note [caseRules for tagToEnum]
       and Note [caseRules for dataToTag] in PrelRules.

     * This required some changes to the API of caseRules, and hence
       to code in SimplUtils.  See Note [Scrutinee Constant Folding]
       in SimplUtils.

     * Avoid duplication of work in the (unusual) case of
          case BIG + 3# of b
            DEFAULT -> e1
            6#      -> e2

       Previously we got
          case BIG of
            DEFAULT -> let b = BIG + 3# in e1
            3#      -> let b = 6#       in e2

       Now we get
          case BIG of b#
            DEFAULT -> let b = b' + 3# in e1
            3#      -> let b = 6#      in e2

     * Avoid duplicated code in caseRules

     A knock-on refactoring:

     * Move Note [Word/Int underflow/overflow] to Literal, as
       documentation to accompany mkMachIntWrap etc; and get
       rid of PrelRuls.intResult' in favour of mkMachIntWrap
 }}}

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


More information about the ghc-tickets mailing list