Commit 7f2a10f4 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Better computeDiscount for ValAppCtxt

parent 9616743c
......@@ -1112,7 +1112,7 @@ AND
then we should not inline it (unless there is some other reason,
e.g. is is the sole occurrence). That is what is happening at
the use of 'lone_variable' in 'interesting_saturated_call'.
the use of 'lone_variable' in 'interesting_call'.
Why? At least in the case-scrutinee situation, turning
let x = (a,b) in case x of y -> ...
......@@ -1183,9 +1183,9 @@ This kind of thing can occur if you have
which Roman did.
\begin{code}
computeDiscount :: DynFlags -> Int -> [Int] -> Int -> [ArgSummary] -> CallCtxt
computeDiscount :: DynFlags -> Arity -> [Int] -> Int -> [ArgSummary] -> CallCtxt
-> Int
computeDiscount dflags n_vals_wanted arg_discounts res_discount arg_infos cont_info
computeDiscount dflags uf_arity arg_discounts res_discount arg_infos cont_info
-- 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
......@@ -1195,7 +1195,7 @@ computeDiscount dflags n_vals_wanted arg_discounts res_discount arg_infos cont_i
= 10 -- Discount of 1 because the result replaces the call
-- so we count 1 for the function itself
+ 10 * length (take n_vals_wanted arg_infos)
+ 10 * length (take uf_arity arg_infos)
-- Discount of (un-scaled) 1 for each arg supplied,
-- because the result replaces the call
......@@ -1210,8 +1210,9 @@ computeDiscount dflags n_vals_wanted arg_discounts res_discount arg_infos cont_i
res_discount' = case cont_info of
BoringCtxt -> 0
CaseCtxt -> res_discount
_other -> 40 `min` res_discount
CaseCtxt -> res_discount -- Presumably a constructor
ValAppCtxt -> res_discount -- Presumably a function
ArgCtxt {} -> 40 `min` res_discount
-- res_discount can be very large when a function returns
-- constructors; but we only want to invoke that large discount
-- when there's a case continuation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment