Simon Peyton Jones pushed to branch wip/T26548 at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/Core/Opt/Simplify/Utils.hs
    ... ... @@ -1034,6 +1034,15 @@ Wrinkles:
    1034 1034
        Conclusion: `interestingArg` should give some encouragement (NonTrivArg) to `f`
    
    1035 1035
        when the argument is expandable. Hence `uf_expandable` in the `Var` case.
    
    1036 1036
     
    
    1037
    +(IA5) We are keen to inline a higher-order function applied to lambda, e.g.
    
    1038
    +             f (\x. blah)
    
    1039
    +  where
    
    1040
    +    f h = ...(h xs)...
    
    1041
    +  Doing so specialises `f` to the particular argument which can make a
    
    1042
    +  big difference.  Note, however, that we don't want to be defeated if
    
    1043
    +  the lambda is let-bound:
    
    1044
    +      let h = (\x.blah)
    
    1045
    +      in ...f h...
    
    1037 1046
     -}
    
    1038 1047
     
    
    1039 1048
     interestingArg :: SimplEnv -> CoreExpr -> ArgSummary
    
    ... ... @@ -1059,9 +1068,7 @@ interestingArg env e = go env 0 e
    1059 1068
         go env n (Lam v e)
    
    1060 1069
            | isTyVar v             = go env n e
    
    1061 1070
            | n>0                   = NonTrivArg     -- (\x.b) e   is NonTriv
    
    1062
    -       | otherwise             = ValueArg       -- (\x.b)     is Value
    
    1063
    -                                                -- Having ValueArg here is very important
    
    1064
    -                                                -- for getting higher order functions to inline
    
    1071
    +       | otherwise             = ValueArg       -- (\x.b)     is Value: see (IA5)
    
    1065 1072
         go _ _ (Case {})           = NonTrivArg
    
    1066 1073
         go env n (Let b e)         = case go env' n e of
    
    1067 1074
                                        ValueArg -> ValueArg
    
    ... ... @@ -1073,7 +1080,7 @@ interestingArg env e = go env 0 e
    1073 1080
            | isConLikeId v = ValueArg   -- Experimenting with 'conlike' rather that
    
    1074 1081
                                         --    data constructors here (includes DFuns)
    
    1075 1082
                                         --    see (IA1) in Note [Interesting arguments]
    
    1076
    -       | idArity v > n = NonTrivArg -- Catches (eg) primops with arity but no unfolding
    
    1083
    +       | idArity v > n = ValueArg   -- See (IA5) in Note [Interesting arguments]
    
    1077 1084
            | n > 0         = NonTrivArg -- Saturated or unknown call
    
    1078 1085
            | otherwise  -- n==0, no value arguments; look for an interesting unfolding
    
    1079 1086
            = case idUnfolding v of