
On Wed, 11 Oct 2006, Simon Peyton-Jones wrote:
Correct. GHC generates case (x# >=# 0#) of { True -> ...; False -> ... } But the argument discount only applies when we have case y of { ... }
So you really want a discount for the args of a primop.
Do you think it should be that general? I was thinking the discount should only apply in the situtation where a case expression contains an expression with one free varaible that is a function argument, and all operations are primitive. So I was thinking the right place to patch is in sizeExpr: size_up (Case (Var v) _ _ alts) | v `elem` top_args = ... And make this branch activate is a wider range of circumstances. SamB is/was working on such a patch. But making sure that all operations are primitive is not quite right, for instance in f :: Int -> ... f x | gcd x 21 > 1 = ... we cannot give x an argument discount because (gcd (5::Int) 21) is not rewritten into 1 (for some strange reason). So, is there a way of deciding if a primitive op will be rewritten if all its arguements are given? -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''