[commit: ghc] supercompiler: Do not assume that the RHS of an unlifted Let is ok-for-speculation (3d9f524)

Max Bolingbroke <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : supercompiler

http://hackage.haskell.org/trac/ghc/changeset/3d9f524659b80633785eccb9126f5533f99bde8b

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

commit 3d9f524659b80633785eccb9126f5533f99bde8b
Author: Max Bolingbroke <[email protected]>
Date:   Tue Aug 2 19:47:57 2011 +0100

    Do not assume that the RHS of an unlifted Let is ok-for-speculation

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

 compiler/supercompile/Supercompile.hs             |    4 ++--
 compiler/supercompile/Supercompile/Core/Syntax.hs |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/compiler/supercompile/Supercompile.hs b/compiler/supercompile/Supercompile.hs
index 1621f60..f1dbc55 100644
--- a/compiler/supercompile/Supercompile.hs
+++ b/compiler/supercompile/Supercompile.hs
@@ -9,7 +9,7 @@ import qualified Supercompile.Drive.Process as S
 import BasicTypes (InlinePragma(..), InlineSpec(..), isActiveIn)
 import CoreSyn
 import CoreFVs    (exprFreeVars)
-import CoreUtils  (exprType)
+import CoreUtils  (exprType, bindNonRec)
 import CoreUnfold (exprIsConApp_maybe)
 import Coercion   (Coercion, isCoVar, isCoVarType, mkCoVarCo, mkAxInstCo)
 import DataCon    (DataCon, dataConWorkId, dataConAllTyVars, dataConRepArgTys, dataConTyCon, dataConName)
@@ -184,7 +184,7 @@ termToCoreExpr = term
         S.App e x           -> term e `App` Var x
         S.PrimOp pop tys es -> Var (mkPrimOpId pop) `mkTyApps` tys `mkApps` map term es
         S.Case e x ty alts  -> Case (term e) x ty (map alt alts)
-        S.Let x e1 e2       -> Let (NonRec x (term e1)) (term e2)
+        S.Let x e1 e2       -> bindNonRec x (term e1) (term e2)
         S.LetRec xes e      -> Let (Rec (map (second term) xes)) (term e)
         S.Cast e co         -> Cast (term e) co
     
diff --git a/compiler/supercompile/Supercompile/Core/Syntax.hs b/compiler/supercompile/Supercompile/Core/Syntax.hs
index 752c775..a1bd47f 100644
--- a/compiler/supercompile/Supercompile/Core/Syntax.hs
+++ b/compiler/supercompile/Supercompile/Core/Syntax.hs
@@ -74,7 +74,7 @@ data TermF ann = Var Id
                | App (ann (TermF ann)) Id
                | PrimOp PrimOp [Type] [ann (TermF ann)]
                | Case (ann (TermF ann)) Id Type [AltF ann]
-               | Let Id (ann (TermF ann)) (ann (TermF ann)) -- NB: might bind an unlifted thing, in which case the evaluation rules must change
+               | Let Id (ann (TermF ann)) (ann (TermF ann)) -- NB: might bind an unlifted thing, in which case evaluation changes. Unlike GHC, we do NOT assume the RHSes of unlifted bindings are ok-for-speculation.
                | LetRec [(Id, ann (TermF ann))] (ann (TermF ann))
                | Cast (ann (TermF ann)) Coercion
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.