[commit: ghc] wip/better-ho-cardinality: Do not split void functions (ba78bf1)

git at git.haskell.org git at git.haskell.org
Thu Dec 12 12:15:41 UTC 2013


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

On branch  : wip/better-ho-cardinality
Link       : http://ghc.haskell.org/trac/ghc/changeset/ba78bf1772c9d695a0ded932eeceed10622d91a4/ghc

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

commit ba78bf1772c9d695a0ded932eeceed10622d91a4
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Dec 11 18:30:54 2013 +0000

    Do not split void functions
    
    This is authored by SPJ, and split out out "Improve the handling of
    used-once stuff" by Joachim.


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

ba78bf1772c9d695a0ded932eeceed10622d91a4
 compiler/stranal/WorkWrap.lhs |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/compiler/stranal/WorkWrap.lhs b/compiler/stranal/WorkWrap.lhs
index b66a449..14a01d5 100644
--- a/compiler/stranal/WorkWrap.lhs
+++ b/compiler/stranal/WorkWrap.lhs
@@ -17,6 +17,7 @@ import CoreSyn
 import CoreUnfold	( certainlyWillInline, mkInlineUnfolding, mkWwInlineRule )
 import CoreUtils	( exprType, exprIsHNF )
 import CoreArity	( exprArity )
+import Type             ( isVoidTy )
 import Var
 import Id
 import IdInfo
@@ -256,7 +257,7 @@ tryWW dflags is_rec fn_id rhs
 	-- Furthermore, don't even expose strictness info
   = return [ (fn_id, rhs) ]
 
-  | is_fun && (any worthSplittingArgDmd wrap_dmds || returnsCPR res_info)
+  | is_fun && (worth_splitting_args wrap_dmds rhs || returnsCPR res_info)
   = checkSize dflags new_fn_id rhs $
     splitFun dflags new_fn_id fn_info wrap_dmds res_info rhs
 
@@ -274,6 +275,12 @@ tryWW dflags is_rec fn_id rhs
     fn_dmd       = demandInfo fn_info
     inline_act   = inlinePragmaActivation (inlinePragInfo fn_info)
 
+    worth_splitting_args [d] (Lam b _)
+      | isAbsDmd d && isVoidTy (idType b)
+      = False  -- Note [Do not split void functions]
+    worth_splitting_args wrap_dmds _
+      = any worthSplittingArgDmd wrap_dmds
+
 	-- In practice it always will have a strictness
 	-- signature, even if it's a uninformative one
     strict_sig  = strictnessInfo fn_info
@@ -394,6 +401,17 @@ noOneShotInfo :: [Bool]
 noOneShotInfo = repeat False
 \end{code}
 
+Note [Do not split void functions]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Consider this rather common form of binding:
+        $j = \x:Void# -> ...no use of x...
+
+Since x is not used it'll be marked as absent.  But there is no point
+in w/w-ing because we'll simply add (\y:Void#), see WwLib.mkWorerArgs.
+
+If x has a more interesting type (eg Int, or Int#), there *is* a point
+in w/w so that we don't pass the argument at all.
+
 Note [Thunk splitting]
 ~~~~~~~~~~~~~~~~~~~~~~
 Suppose x is used strictly (never mind whether it has the CPR



More information about the ghc-commits mailing list