[commit: ghc] master: Comments only, in CSE (#13340) (5ed56fc)
git at git.haskell.org
git at git.haskell.org
Fri Mar 3 21:36:11 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/5ed56fc8163690c209f594dbfe9dd49b7053739b/ghc
>---------------------------------------------------------------
commit 5ed56fc8163690c209f594dbfe9dd49b7053739b
Author: Reid Barton <rwbarton at gmail.com>
Date: Fri Mar 3 15:49:51 2017 -0500
Comments only, in CSE (#13340)
Reviewers: simonpj, austin, bgamari, dfeuer
Reviewed By: dfeuer
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3268
>---------------------------------------------------------------
5ed56fc8163690c209f594dbfe9dd49b7053739b
compiler/simplCore/CSE.hs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/compiler/simplCore/CSE.hs b/compiler/simplCore/CSE.hs
index b8e26b5..8597579 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?]
More information about the ghc-commits
mailing list