From 65284c9655167101ad716863bc8db5cc8ad76a2b Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 7 Jul 1999 15:27:27 +0000 Subject: [PATCH] [project @ 1999-07-07 15:27:27 by simonmar] - charge 1 for a case expression - give a discount of opt_UF_ScrutConDiscount each time a constructor is scrutinised (previously a case expression was not charged for at all, and the discount for a scrutinised constructor was (opt_UF_ScrutConDiscount * tyconFamilySize). In 4.02, a case expression was also charged tyconFamilySize to balance the discount, but this had the disadvantage of charging for alternatives which may not be present in the actual case expression). --- ghc/compiler/coreSyn/CoreUnfold.lhs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/coreSyn/CoreUnfold.lhs b/ghc/compiler/coreSyn/CoreUnfold.lhs index f27289e..0c8e6e1 100644 --- a/ghc/compiler/coreSyn/CoreUnfold.lhs +++ b/ghc/compiler/coreSyn/CoreUnfold.lhs @@ -205,7 +205,7 @@ calcUnfoldingGuidance bOMB_OUT_SIZE expr discount_for b | num_cases == 0 = 0 | is_fun_ty = num_cases * opt_UF_FunAppDiscount - | is_data_ty = num_cases * tyConFamilySize tycon * opt_UF_ScrutConDiscount + | is_data_ty = num_cases * opt_UF_ScrutConDiscount | otherwise = num_cases * opt_UF_PrimArgDiscount where num_cases = foldlBag (\n b' -> if b==b' then n+1 else n) 0 cased_args @@ -267,6 +267,7 @@ sizeExpr (I# bOMB_OUT_SIZE) args expr = nukeScrutDiscount (size_up scrut) `addSize` arg_discount scrut `addSize` foldr (addSize . size_up_alt) sizeZero alts + `addSizeN` 1 -- charge one for the case itself. -- Just charge for the alts that exist, not the ones that might exist -- `addSizeN` -- 1.7.10.4