summaryrefslogtreecommitdiff
path: root/ghc/compiler
diff options
context:
space:
mode:
authorsof <unknown>1997-10-19 21:51:43 +0000
committersof <unknown>1997-10-19 21:51:43 +0000
commitadf74bb1c724edd4a8d1ea22b464203fc2ddb55c (patch)
tree9b455e3af2a7c0b67be68fee0ea9e4b0efc8fd74 /ghc/compiler
parentd6de1c958fd66c94fc6a7dca59402983be8d7408 (diff)
downloadhaskell-adf74bb1c724edd4a8d1ea22b464203fc2ddb55c.tar.gz
[project @ 1997-10-19 21:51:43 by sof]
Bargain multiplier opt_UnfoldingKeenessFactor added to discount computation
Diffstat (limited to 'ghc/compiler')
-rw-r--r--ghc/compiler/coreSyn/CoreUnfold.lhs15
1 files changed, 12 insertions, 3 deletions
diff --git a/ghc/compiler/coreSyn/CoreUnfold.lhs b/ghc/compiler/coreSyn/CoreUnfold.lhs
index 36a6746567..e254958625 100644
--- a/ghc/compiler/coreSyn/CoreUnfold.lhs
+++ b/ghc/compiler/coreSyn/CoreUnfold.lhs
@@ -45,7 +45,8 @@ import Bag ( emptyBag, unitBag, unionBags, Bag )
import CmdLineOpts ( opt_UnfoldingCreationThreshold,
opt_UnfoldingUseThreshold,
- opt_UnfoldingConDiscount
+ opt_UnfoldingConDiscount,
+ opt_UnfoldingKeenessFactor
)
import Constants ( uNFOLDING_CHEAP_OP_COST,
uNFOLDING_DEAR_OP_COST,
@@ -482,13 +483,21 @@ smallEnoughToInline _ _ UnfoldNever = False
smallEnoughToInline arg_is_evald_s result_is_scruted
(UnfoldIfGoodArgs m_tys_wanted n_vals_wanted discount_vec size scrut_discount)
= enough_args n_vals_wanted arg_is_evald_s &&
- discounted_size <= opt_UnfoldingUseThreshold
+ size - discount <= opt_UnfoldingUseThreshold
where
enough_args n [] | n > 0 = False -- A function with no value args => don't unfold
enough_args _ _ = True -- Otherwise it's ok to try
- discounted_size = (size - args_discount) - result_discount
+ -- We multiple the raw discounts (args_discount and result_discount)
+ -- ty opt_UnfoldingKeenessFactor because the former have to do with
+ -- *size* whereas the discounts imply that there's some extra *efficiency*
+ -- to be gained (e.g. beta reductions, case reductions) by inlining.
+ discount :: Int
+ discount = round (
+ opt_UnfoldingKeenessFactor *
+ fromInt (args_discount + result_discount)
+ )
args_discount = sum (zipWith arg_discount discount_vec arg_is_evald_s)
result_discount | result_is_scruted = scrut_discount