diff options
author | simonpj <unknown> | 2001-10-03 13:57:33 +0000 |
---|---|---|
committer | simonpj <unknown> | 2001-10-03 13:57:33 +0000 |
commit | e205a0ce83c11de96656cf0b870eee3955b1c440 (patch) | |
tree | b6b1dbc6212b5c20d2864ee025a8db9e98dd990b | |
parent | 5e1f86a7bf4d8ee342a0155b49bfc3077bceeefa (diff) | |
download | haskell-e205a0ce83c11de96656cf0b870eee3955b1c440.tar.gz |
[project @ 2001-10-03 13:57:33 by simonpj]
-------------------------------------------
Don't bomb out on inlining big constructors
-------------------------------------------
The unfolder bombs out if the expression get too big; no point in
computing its exact size when it's vast. But for *constructors*
applied to a lot of args, it's worth keeping going, because we
get a big *disount* too
$fFooInt = :CFoo a1 a2 a3 ... a50
We want to keep the inlining for $fFooInt in interface files, so
that importing guys can do the selection.
Solution: only bomb out when size-discount gets too big.
-rw-r--r-- | ghc/compiler/coreSyn/CoreUnfold.lhs | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/ghc/compiler/coreSyn/CoreUnfold.lhs b/ghc/compiler/coreSyn/CoreUnfold.lhs index fe7b8f2c3a..7412f0d698 100644 --- a/ghc/compiler/coreSyn/CoreUnfold.lhs +++ b/ghc/compiler/coreSyn/CoreUnfold.lhs @@ -58,7 +58,7 @@ import FastTypes import Outputable #if __GLASGOW_HASKELL__ >= 404 -import GlaExts ( fromInt ) +import GlaExts ( fromInt, Int# ) #endif \end{code} @@ -132,7 +132,7 @@ calcUnfoldingGuidance bOMB_OUT_SIZE expr -- but no more. in - case (sizeExpr bOMB_OUT_SIZE val_binders body) of + case (sizeExpr (iUnbox bOMB_OUT_SIZE) val_binders body) of TooBig | not inline -> UnfoldNever @@ -176,7 +176,7 @@ calcUnfoldingGuidance bOMB_OUT_SIZE expr \end{code} \begin{code} -sizeExpr :: Int -- Bomb out if it gets bigger than this +sizeExpr :: Int# -- Bomb out if it gets bigger than this -> [Id] -- Arguments; we're interested in which of these -- get case'd -> CoreExpr @@ -335,35 +335,27 @@ sizeExpr bOMB_OUT_SIZE top_args expr -- These addSize things have to be here because -- I don't want to give them bOMB_OUT_SIZE as an argument - addSizeN TooBig _ = TooBig - addSizeN (SizeIs n xs d) m - | n_tot ># (iUnbox bOMB_OUT_SIZE) = TooBig - | otherwise = SizeIs n_tot xs d - where - n_tot = n +# iUnbox m + addSizeN TooBig _ = TooBig + addSizeN (SizeIs n xs d) m = mkSizeIs bOMB_OUT_SIZE (n +# iUnbox m) xs d - addSize TooBig _ = TooBig - addSize _ TooBig = TooBig - addSize (SizeIs n1 xs d1) (SizeIs n2 ys d2) - | n_tot ># (iUnbox bOMB_OUT_SIZE) = TooBig - | otherwise = SizeIs n_tot xys d_tot - where - n_tot = n1 +# n2 - d_tot = d1 +# d2 - xys = xs `unionBags` ys + addSize TooBig _ = TooBig + addSize _ TooBig = TooBig + addSize (SizeIs n1 xs d1) (SizeIs n2 ys d2) + = mkSizeIs bOMB_OUT_SIZE (n1 +# n2) (xs `unionBags` ys) (d1 +# d2) \end{code} Code for manipulating sizes \begin{code} - data ExprSize = TooBig | SizeIs FastInt -- Size found (Bag (Id,Int)) -- Arguments cased herein, and discount for each such FastInt -- Size to subtract if result is scrutinised -- by a case expression - +mkSizeIs max n xs d | (n -# d) ># max = TooBig + | otherwise = SizeIs n xs d + maxSize TooBig _ = TooBig maxSize _ TooBig = TooBig maxSize s1@(SizeIs n1 _ _) s2@(SizeIs n2 _ _) | n1 ># n2 = s1 |