[commit: ghc] wip/nested-cpr: Apply state hack only to information about arguments (5eb7fc7)

git at git.haskell.org git at git.haskell.org
Thu Nov 28 15:52:42 UTC 2013


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

On branch  : wip/nested-cpr
Link       : http://ghc.haskell.org/trac/ghc/changeset/5eb7fc7482c6979402e1bd0ac886bd76c514985b/ghc

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

commit 5eb7fc7482c6979402e1bd0ac886bd76c514985b
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Thu Nov 28 10:29:47 2013 +0000

    Apply state hack only to information about arguments


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

5eb7fc7482c6979402e1bd0ac886bd76c514985b
 compiler/basicTypes/Demand.lhs |    8 ++++++++
 compiler/stranal/DmdAnal.lhs   |    4 +++-
 compiler/stranal/WwLib.lhs     |    2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/compiler/basicTypes/Demand.lhs b/compiler/basicTypes/Demand.lhs
index 7680d00..4de09bd 100644
--- a/compiler/basicTypes/Demand.lhs
+++ b/compiler/basicTypes/Demand.lhs
@@ -20,6 +20,7 @@ module Demand (
 
         DmdType(..), dmdTypeDepth, lubDmdType, bothDmdEnv, bothDmdType, bothDmdTypeCase,
         topDmdType, botDmdType, mkDmdType, mkTopDmdType, 
+        dmdTypeArgTop,
 
         DmdEnv, emptyDmdEnv,
 
@@ -1147,6 +1148,13 @@ splitDmdTy :: DmdType -> (Demand, DmdType)
 splitDmdTy (DmdType fv (dmd:dmds) res_ty) = (dmd, DmdType fv dmds res_ty)
 splitDmdTy ty@(DmdType _ [] res_ty)       = (resTypeArgDmd res_ty, ty)
 
+-- We want to forget what we know about the arguments, but keep the information
+-- of the result, see Note [IO State Hack]
+dmdTypeArgTop :: DmdType -> DmdType
+dmdTypeArgTop d@(DmdType _ _ res)
+  = let (DmdType env' ds' _) = d `lubDmdType` topDmdType
+    in   DmdType env' ds' res
+
 deferAndUse :: Bool    -- Lazify (defer) the type
             -> Count   -- Many => manify the type
             -> DmdType -> DmdType
diff --git a/compiler/stranal/DmdAnal.lhs b/compiler/stranal/DmdAnal.lhs
index 6aba874..79ed129 100644
--- a/compiler/stranal/DmdAnal.lhs
+++ b/compiler/stranal/DmdAnal.lhs
@@ -303,9 +303,11 @@ dmdAnalAlt env dmd (con,bndrs,rhs)
 	(rhs_ty, rhs')   = dmdAnal env dmd rhs
         rhs_ty'          = addDataConPatDmds con bndrs rhs_ty
 	(alt_ty, bndrs') = annotateBndrs env rhs_ty' bndrs
-	final_alt_ty | io_hack_reqd = alt_ty `lubDmdType` topDmdType
+	final_alt_ty | io_hack_reqd = dmdTypeArgTop alt_ty
 		     | otherwise    = alt_ty
 
+        -- Note [IO State Hack]
+        --
 	-- There's a hack here for I/O operations.  Consider
 	-- 	case foo x s of { (# s, r #) -> y }
 	-- Is this strict in 'y'.  Normally yes, but what if 'foo' is an I/O
diff --git a/compiler/stranal/WwLib.lhs b/compiler/stranal/WwLib.lhs
index e11a352..d8074c0 100644
--- a/compiler/stranal/WwLib.lhs
+++ b/compiler/stranal/WwLib.lhs
@@ -501,7 +501,7 @@ deepSplitCprType_maybe :: ConTag -> Type -> Maybe (DataCon, [Type], [Type], Coer
 deepSplitCprType_maybe con_tag ty
   | let (co, ty1) = topNormaliseNewType_maybe ty `orElse` (mkReflCo Representational ty, ty)
   , Just (tc, tc_args) <- splitTyConApp_maybe ty1
-  , isDataTyCon tc
+  , isDataTyCon tc || isUnboxedTupleTyCon tc
   , let cons = tyConDataCons tc
         con = ASSERT( cons `lengthAtLeast` con_tag ) cons !! (con_tag - fIRST_TAG)
   = Just (con, tc_args, dataConInstArgTys con tc_args, co)



More information about the ghc-commits mailing list