[commit: ghc] wip/spj-T13397: Re-engineer caseRules to add tagToEnum/dataToTag (e49f315)

git at git.haskell.org git at git.haskell.org
Wed Mar 8 11:08:38 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/spj-T13397
Link       : http://ghc.haskell.org/trac/ghc/changeset/e49f3154a5ceb1894414f4635579aeb3aa84054f/ghc

>---------------------------------------------------------------

commit e49f3154a5ceb1894414f4635579aeb3aa84054f
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


>---------------------------------------------------------------

e49f3154a5ceb1894414f4635579aeb3aa84054f
 compiler/basicTypes/Literal.hs                     |  21 ++
 compiler/coreSyn/CoreSyn.hs                        |   2 +
 compiler/prelude/PrelRules.hs                      | 231 +++++++++++++--------
 compiler/simplCore/SimplUtils.hs                   | 177 +++++++++++-----
 .../tests/simplCore/should_compile/T3772.stdout    |  10 +-
 .../tests/simplCore/should_compile/T4930.stderr    |  30 +--
 .../simplCore/should_compile/spec-inline.stderr    | 152 +++++++-------
 7 files changed, 391 insertions(+), 232 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e49f3154a5ceb1894414f4635579aeb3aa84054f


More information about the ghc-commits mailing list