[commit: ghc] master: Better computeDiscount for ValAppCtxt (7f2a10f)

Simon Peyton Jones simonpj at microsoft.com
Thu Jun 6 15:30:42 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/7f2a10f4b0f87a1b3f28543b5f85d1813dbd75c4

>---------------------------------------------------------------

commit 7f2a10f4b0f87a1b3f28543b5f85d1813dbd75c4
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Jun 5 17:46:10 2013 +0100

    Better computeDiscount for ValAppCtxt

>---------------------------------------------------------------

 compiler/coreSyn/CoreUnfold.lhs | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/compiler/coreSyn/CoreUnfold.lhs b/compiler/coreSyn/CoreUnfold.lhs
index b2df6c8..83a40d2 100644
--- a/compiler/coreSyn/CoreUnfold.lhs
+++ b/compiler/coreSyn/CoreUnfold.lhs
@@ -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.





More information about the ghc-commits mailing list