diff options
author | Reid Barton <rwbarton@gmail.com> | 2017-03-03 15:49:51 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-03 15:49:51 -0500 |
commit | 5ed56fc8163690c209f594dbfe9dd49b7053739b (patch) | |
tree | a12cd79ac243edd86776a772731682f6d36c0463 | |
parent | 644625449a9b6fbeb9a81f1a7d0e7d18424fb707 (diff) | |
download | haskell-5ed56fc8163690c209f594dbfe9dd49b7053739b.tar.gz |
Comments only, in CSE (#13340)
Reviewers: simonpj, austin, bgamari, dfeuer
Reviewed By: dfeuer
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3268
-rw-r--r-- | compiler/simplCore/CSE.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs index b8e26b593e..8597579e67 100644 --- a/compiler/simplCore/CSE.hs +++ b/compiler/simplCore/CSE.hs @@ -217,8 +217,10 @@ Consider Here 'foo' has a stable unfolding, but its (optimised) RHS is trivial. (Turns out that this actually happens for the enumFromTo method of -the Integer instance of Enum in GHC.Enum.) Then we obviously do NOT -want to extend the substitution with (foo->x)! See similar +the Integer instance of Enum in GHC.Enum.) Suppose moreover that foo's +stable unfolding originates from an INLINE or INLINEABLE pragma on foo. +Then we obviously do NOT want to extend the substitution with (foo->x), +because we promised to inline foo as what the user wrote. See similar SimplUtils Note [Stable unfoldings and postInlineUnconditionally]. Nor do we want to change the reverse mapping. Suppose we have @@ -232,6 +234,11 @@ There could conceivably be merit in rewriting the RHS of bar: but now bar's inlining behaviour will change, and importing modules might see that. So it seems dodgy and we don't do it. +Stable unfoldings are also created during worker/wrapper when we decide +that a function's definition is so small that it should always inline. +In this case we still want to do CSE (#13340). Hence the use of +isAnyInlinePragma rather than isStableUnfolding. + Note [Corner case for case expressions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is another reason that we do not use SUBSTITUTE for @@ -367,7 +374,6 @@ noCSE :: InId -> Bool noCSE id = not (isAlwaysActive (idInlineActivation id)) -- See Note [CSE for INLINE and NOINLINE] || isAnyInlinePragma (idInlinePragma id) - --isStableUnfolding (idUnfolding id) -- See Note [CSE for stable unfoldings] || isJoinId id -- See Note [CSE for join points?] |