[commit: ghc] wip/rwbarton-float-unboxed: More comments and cleanup (28664d7)
git at git.haskell.org
git at git.haskell.org
Mon Feb 27 18:25:40 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/rwbarton-float-unboxed
Link : http://ghc.haskell.org/trac/ghc/changeset/28664d742eb0f790e5dbbcdd30d4dbc3bbec5412/ghc
>---------------------------------------------------------------
commit 28664d742eb0f790e5dbbcdd30d4dbc3bbec5412
Author: Reid Barton <rwbarton at gmail.com>
Date: Mon Feb 27 13:16:31 2017 -0500
More comments and cleanup
>---------------------------------------------------------------
28664d742eb0f790e5dbbcdd30d4dbc3bbec5412
compiler/simplCore/SetLevels.hs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/compiler/simplCore/SetLevels.hs b/compiler/simplCore/SetLevels.hs
index e51c6d0..94d5bcd 100644
--- a/compiler/simplCore/SetLevels.hs
+++ b/compiler/simplCore/SetLevels.hs
@@ -611,6 +611,7 @@ lvlMFE env strict_ctxt ann_expr
mb_bot_str = exprBotStrictness_maybe expr
-- See Note [Bottoming floats]
-- esp Bottoming floats (2)
+ expr_ok_for_spec = exprOkForSpeculation expr
dest_lvl = destLevel env fvs is_function is_bot need_join
abs_vars = abstractVars dest_lvl env fvs
@@ -646,8 +647,6 @@ lvlMFE env strict_ctxt ann_expr
&& floatConsts env
&& (not strict_ctxt || is_bot || exprIsHNF expr)
- expr_ok_for_spec = exprOkForSpeculation expr
-
isBottomThunk :: Maybe (Arity, s) -> Bool
-- See Note [Bottoming floats] (2)
isBottomThunk (Just (0, _)) = True -- Zero arity
@@ -720,6 +719,15 @@ float a boxed version
and replace the original (f x) with
case (case y of I# r -> r) of r -> blah
+However if the expression to be floated (f x) is okay for speculation,
+just float it without any boxing/unboxing. We'll evaluate it earlier,
+but that's okay because the expression is okay for speculation. Simpler
+and cheaper than boxing and unboxing. The only potential snag is that
+we can't float an unlifted binding to top-level (unless it is an unboxed
+string literal). In this case, we just don't float the expression at all.
+No great loss since, by assumption, it is cheap to compute anyways. See
+Note [Test cheapness with exprOkForSpeculation].
+
Being able to float unboxed expressions is sometimes important; see
Trac #12603. I'm not sure how /often/ it is important, but it's
not hard to achieve.
More information about the ghc-commits
mailing list