summaryrefslogtreecommitdiff
path: root/compiler/coreSyn
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-08-29 15:18:08 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-08-29 17:16:54 +0100
commit3521c5078dace81b23a72d1e463f9c31d07f3816 (patch)
tree98639ff97166c640ba5d6d30a144ba89f778aeef /compiler/coreSyn
parentab4c27e917e959778726b82fa6cc8b80eca28e74 (diff)
downloadhaskell-3521c5078dace81b23a72d1e463f9c31d07f3816.tar.gz
When finding loop breakers, distinguish INLINE from INLINEABLE
Previously INLINE and INLINEABLE were treated identically, but it's crucial that we don't choose a wrapper (INLINE) as a loop breaker, when it is mutually recursive with an INLINEABLE worker.
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r--compiler/coreSyn/CoreSyn.lhs17
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs
index 6627ab07bd..babece47fe 100644
--- a/compiler/coreSyn/CoreSyn.lhs
+++ b/compiler/coreSyn/CoreSyn.lhs
@@ -58,7 +58,7 @@ module CoreSyn (
maybeUnfoldingTemplate, otherCons,
isValueUnfolding, isEvaldUnfolding, isCheapUnfolding,
isExpandableUnfolding, isConLikeUnfolding, isCompulsoryUnfolding,
- isStableUnfolding, isStableCoreUnfolding_maybe,
+ isStableUnfolding, hasStableCoreUnfolding_maybe,
isClosedUnfolding, hasSomeUnfolding,
canUnfold, neverUnfoldGuidance, isStableSource,
@@ -929,10 +929,17 @@ expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr
expandUnfolding_maybe (CoreUnfolding { uf_expandable = True, uf_tmpl = rhs }) = Just rhs
expandUnfolding_maybe _ = Nothing
-isStableCoreUnfolding_maybe :: Unfolding -> Maybe UnfoldingSource
-isStableCoreUnfolding_maybe (CoreUnfolding { uf_src = src })
- | isStableSource src = Just src
-isStableCoreUnfolding_maybe _ = Nothing
+hasStableCoreUnfolding_maybe :: Unfolding -> Maybe Bool
+-- Just True <=> has stable inlining, very keen to inline (eg. INLINE pragma)
+-- Just False <=> has stable inlining, open to inlining it (eg. INLINEABLE pragma)
+-- Nothing <=> not table, or cannot inline it anyway
+hasStableCoreUnfolding_maybe (CoreUnfolding { uf_src = src, uf_guidance = guide })
+ | isStableSource src
+ = case guide of
+ UnfWhen {} -> Just True
+ UnfIfGoodArgs {} -> Just False
+ UnfNever -> Nothing
+hasStableCoreUnfolding_maybe _ = Nothing
isCompulsoryUnfolding :: Unfolding -> Bool
isCompulsoryUnfolding (CoreUnfolding { uf_src = InlineCompulsory }) = True