Version 3 (modified by kirsten, 11 years ago) (diff)



Instead of:

type DmdEnv = VarEnv Demand

we want:

type DmdEnv = Env CoreExpr Demand

We keep track of demands on partial applications.

After calling dmd_anal on the body of a let, which results in demand type dmd_ty with demand env dmd_env, we do the following for each let-bound variable f:

  1. Iterate through all the keys in dmd_env, finding all applications of f to n arguments.
  2. For each i from 1 through n (where n is f's arity), if each of the applications of f to i arguments has usage demand OneOrZero, then it's safe to mark the corresponding lambda-expression as a one-shot lambda.

This might work, but is kind of kludgy.