[commit: ghc] wip/nested-cpr: Do not generate workers with one element (# .. #) types (96d5641)

git at git.haskell.org git at git.haskell.org
Thu Nov 28 16:06:13 UTC 2013


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

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

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

commit 96d5641fddf6aea3a6654a857637e0940e9fe163
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Thu Nov 28 16:06:18 2013 +0000

    Do not generate workers with one element (# .. #) types


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

96d5641fddf6aea3a6654a857637e0940e9fe163
 compiler/stranal/WwLib.lhs |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/compiler/stranal/WwLib.lhs b/compiler/stranal/WwLib.lhs
index ce6b61c..99e4dad 100644
--- a/compiler/stranal/WwLib.lhs
+++ b/compiler/stranal/WwLib.lhs
@@ -534,16 +534,24 @@ mkWWcpr :: Type                              -- function body type
                    Type)                        -- Type of worker's body
 mkWWcpr body_ty res
   = do (arg_vars, con_app, decon) <- mkWWcpr_help False body_ty res
-       wrap_wild_uniq <- getUniqueM
-
-       let wrap_wild = mk_ww_local wrap_wild_uniq ubx_tup_ty
-           ubx_tup_con  = tupleCon UnboxedTuple (length arg_vars)
-           ubx_tup_app  = mkConApp2 ubx_tup_con (map idType arg_vars) arg_vars
-           ubx_tup_ty   = exprType ubx_tup_app
-
-       return ( \ wkr_call -> Case wkr_call wrap_wild (exprType con_app)  [(DataAlt ubx_tup_con, arg_vars, con_app)]
-              , \ body     -> decon body ubx_tup_app
-              , ubx_tup_ty )
+       case arg_vars of
+         -- When we have to wrap only on argument, skip the (# .. #)
+         [arg_var] -> do
+           return ( \ wkr_call -> mkRename wkr_call arg_var con_app
+                  , \ body     -> decon body (Var arg_var)
+                  , idType arg_var )
+
+         _ -> do
+           wrap_wild_uniq <- getUniqueM
+
+           let wrap_wild = mk_ww_local wrap_wild_uniq ubx_tup_ty
+               ubx_tup_con  = tupleCon UnboxedTuple (length arg_vars)
+               ubx_tup_app  = mkConApp2 ubx_tup_con (map idType arg_vars) arg_vars
+               ubx_tup_ty   = exprType ubx_tup_app
+
+           return ( \ wkr_call -> Case wkr_call wrap_wild (exprType con_app)  [(DataAlt ubx_tup_con, arg_vars, con_app)]
+                  , \ body     -> decon body ubx_tup_app
+                  , ubx_tup_ty )
 
 mkWWcpr_help :: Bool ->  -- This this an inner call?
                 Type ->



More information about the ghc-commits mailing list