Skip to content
Snippets Groups Projects
Commit 65284c96 authored by Simon Marlow's avatar Simon Marlow
Browse files

[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).
parent 69a603fb
No related merge requests found
...@@ -205,7 +205,7 @@ calcUnfoldingGuidance bOMB_OUT_SIZE expr ...@@ -205,7 +205,7 @@ calcUnfoldingGuidance bOMB_OUT_SIZE expr
discount_for b discount_for b
| num_cases == 0 = 0 | num_cases == 0 = 0
| is_fun_ty = num_cases * opt_UF_FunAppDiscount | 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 | otherwise = num_cases * opt_UF_PrimArgDiscount
where where
num_cases = foldlBag (\n b' -> if b==b' then n+1 else n) 0 cased_args 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 ...@@ -267,6 +267,7 @@ sizeExpr (I# bOMB_OUT_SIZE) args expr
= nukeScrutDiscount (size_up scrut) `addSize` = nukeScrutDiscount (size_up scrut) `addSize`
arg_discount scrut `addSize` arg_discount scrut `addSize`
foldr (addSize . size_up_alt) sizeZero alts 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 -- Just charge for the alts that exist, not the ones that might exist
-- `addSizeN` -- `addSizeN`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment