Skip to content

Commit bc773fa

Browse files
committed
refine situations where speculation is allowed in coreprep
1 parent 0500a66 commit bc773fa

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
diff --git a/compiler/GHC/CoreToStg/Prep.hs b/compiler/GHC/CoreToStg/Prep.hs
2-
index c463f41121..58b1d957c8 100644
2+
index c463f41121..3673b94991 100644
33
--- a/compiler/GHC/CoreToStg/Prep.hs
44
+++ b/compiler/GHC/CoreToStg/Prep.hs
5-
@@ -1759,7 +1759,7 @@ data OkToSpec
5+
@@ -1785,7 +1785,14 @@ mkFloat env dmd is_unlifted bndr rhs
6+
where
7+
is_hnf = exprIsHNF rhs
8+
is_strict = isStrUsedDmd dmd
9+
- ok_for_spec = exprOkForSpecEval (not . is_rec_call) rhs
10+
+ ok_for_spec = exprOkForSpecEval fun_ok_for_spec rhs
11+
+ fun_ok_for_spec i
12+
+ | is_rec_call i = False
13+
+ | otherwise =
14+
+ case idDetails i of
15+
+ DFunId {} -> False
16+
+ DataConWorkId {} -> False
17+
+ _ -> True
18+
is_rec_call = (`elemUnVarSet` cpe_rec_ids env)
619

7-
mkFloat :: CorePrepEnv -> Demand -> Bool -> Id -> CpeRhs -> FloatingBind
8-
mkFloat env dmd is_unlifted bndr rhs
9-
- | is_strict || ok_for_spec -- See Note [Speculative evaluation]
10-
+ | is_strict {-|| ok_for_spec-} -- See Note [Speculative evaluation]
11-
, not is_hnf = FloatCase rhs bndr DEFAULT [] ok_for_spec
12-
-- Don't make a case for a HNF binding, even if it's strict
13-
-- Otherwise we get case (\x -> e) of ...!
20+
emptyFloats :: Floats

0 commit comments

Comments
 (0)