[commit: ghc] master: Re-engineer caseRules to add tagToEnum/dataToTag (193664d)
git at git.haskell.org
git at git.haskell.org
Fri Apr 28 22:07:55 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/193664d42dbceadaa1e4689dfa17ff1cf5a405a0/ghc
>---------------------------------------------------------------
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
>---------------------------------------------------------------
193664d42dbceadaa1e4689dfa17ff1cf5a405a0
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 193664d42dbceadaa1e4689dfa17ff1cf5a405a0
More information about the ghc-commits
mailing list