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

git at git.haskell.org git at git.haskell.org
Wed Dec 11 18:52:10 UTC 2013


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

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

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

commit 7583c20521b40f4a4d9ab354e4bc88d3f4040ebe
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.


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

7583c20521b40f4a4d9ab354e4bc88d3f4040ebe
 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