[commit: ghc] master: Comments only (7f45906)

git at git.haskell.org git at git.haskell.org
Thu Jun 7 10:06:15 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7f45906428c97a097ca4d9e1f46d35495380bee1/ghc

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

commit 7f45906428c97a097ca4d9e1f46d35495380bee1
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Jun 7 11:02:55 2018 +0100

    Comments only


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

7f45906428c97a097ca4d9e1f46d35495380bee1
 compiler/prelude/PrelRules.hs  |  4 ++++
 compiler/simplCore/Simplify.hs | 54 ++++++++++++++++++++++--------------------
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs
index d0ad6c5..84e4173 100644
--- a/compiler/prelude/PrelRules.hs
+++ b/compiler/prelude/PrelRules.hs
@@ -1067,6 +1067,10 @@ Implementing seq#.  The compiler has magic for SeqOp in
 
 - CoreUtils.exprOkForSpeculation;
   see Note [seq# and expr_ok] in CoreUtils
+
+- Simplify.addEvals records evaluated-ness for the result; see
+  Note [Adding evaluatedness info to pattern-bound variables]
+  in Simplify
 -}
 
 seqRule :: RuleM CoreExpr
diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs
index 89e7df2..a4651bb 100644
--- a/compiler/simplCore/Simplify.hs
+++ b/compiler/simplCore/Simplify.hs
@@ -2615,32 +2615,34 @@ simplAlt env scrut' _ case_bndr' cont' (DataAlt con, vs, rhs)
         ; rhs' <- simplExprC env'' rhs cont'
         ; return (DataAlt con, vs', rhs') }
 
--- Note [Adding evaluatedness info to pattern-bound variables]
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
--- add_evals records the evaluated-ness of the bound variables of
--- a case pattern.  This is *important*.  Consider
---
---      data T = T !Int !Int
---
---      case x of { T a b -> T (a+1) b }
---
--- We really must record that b is already evaluated so that we don't
--- go and re-evaluate it when constructing the result.
--- See Note [Data-con worker strictness] in MkId.hs
---
--- NB: simplLamBinders preserves this eval info
---
--- In addition to handling data constructor fields with !s, add_evals
--- also records the fact that the result of seq# is always in WHNF.
--- in
---
---   case seq# v s of
---     (# s', v' #) -> E
---
--- we want the compiler to be aware that v' is in WHNF in E. See #15226.
--- We don't record that v itself is in WHNF (and we can't do it here).
--- I don't know if we should attempt to do so.
+{- Note [Adding evaluatedness info to pattern-bound variables]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+addEvals records the evaluated-ness of the bound variables of
+a case pattern.  This is *important*.  Consider
+
+     data T = T !Int !Int
+
+     case x of { T a b -> T (a+1) b }
+
+We really must record that b is already evaluated so that we don't
+go and re-evaluate it when constructing the result.
+See Note [Data-con worker strictness] in MkId.hs
+
+NB: simplLamBinders preserves this eval info
+
+In addition to handling data constructor fields with !s, addEvals
+also records the fact that the result of seq# is always in WHNF.
+See Note [seq# magic] in PrelRules.  Example (Trac #15226):
+
+  case seq# v s of
+    (# s', v' #) -> E
+
+we want the compiler to be aware that v' is in WHNF in E.
+
+Open problem: we don't record that v itself is in WHNF (and we can't
+do it here).  The right thing is to do some kind of binder-swap;
+see Trac #15226 for discussion.
+-}
 
 addEvals :: Maybe OutExpr -> DataCon -> [Id] -> [Id]
 -- See Note [Adding evaluatedness info to pattern-bound variables]



More information about the ghc-commits mailing list