So in this case we want that the *only* uses of n are in case statements.
+Note [Good arguments]
+~~~~~~~~~~~~~~~~~~~~~
So we look for
* A self-recursive function. Ignore mutual recursion for now,
scBind env (Rec [(fn,rhs)])
| notNull val_bndrs
= scExpr env_fn_body body `thenUs` \ (usg, body') ->
- specialise env fn bndrs body usg `thenUs` \ (rules, spec_prs) ->
+ specialise env fn bndrs body' usg `thenUs` \ (rules, spec_prs) ->
+ -- Note body': the specialised copies should be based on the
+ -- optimised version of the body, in case there were
+ -- nested functions inside.
let
SCU { calls = calls, occs = occs } = usg
in
---------------------
good_arg :: ConstrEnv -> IdEnv ArgOcc -> (CoreBndr, CoreArg) -> Bool
+-- See Note [Good arguments] above
good_arg con_env arg_occs (bndr, arg)
= case is_con_app_maybe con_env arg of
Just _ -> bndr_usg_ok arg_occs bndr arg