Simon Peyton Jones pushed to branch wip/T26831 at Glasgow Haskell Compiler / GHC
Commits:
-
2655e4f2
by Simon Peyton Jones at 2026-03-12T17:43:18+00:00
4 changed files:
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs
- testsuite/tests/simplCore/should_compile/T15205.stderr
Changes:
| ... | ... | @@ -794,6 +794,7 @@ classOpSize opts cls top_args (dict_arg:other_val_args) |
| 794 | 794 | arg_discount (Var dict) | dict `elem` top_args = unitBag (dict, dict_discount)
|
| 795 | 795 | arg_discount _ = emptyBag
|
| 796 | 796 | |
| 797 | +-- TODO: document this change!
|
|
| 797 | 798 | dict_discount
|
| 798 | 799 | | null other_val_args = unfoldingDictDiscount opts
|
| 799 | 800 | | otherwise = unfoldingDictDiscount opts + unfoldingFunAppDiscount opts
|
| ... | ... | @@ -420,16 +420,22 @@ coreToStgExpr expr@(App _ _) |
| 420 | 420 | res_ty = exprType expr
|
| 421 | 421 | (app_head, args, ticks) = myCollectArgs expr res_ty
|
| 422 | 422 | |
| 423 | -coreToStgExpr expr@(Lam _ _)
|
|
| 424 | - = let
|
|
| 425 | - (args, body) = myCollectBinders expr
|
|
| 426 | - in
|
|
| 427 | - case filterStgBinders args of
|
|
| 428 | - |
|
| 429 | - [] -> coreToStgExpr body
|
|
| 430 | - |
|
| 431 | - _ -> pprPanic "coretoStgExpr" $
|
|
| 432 | - text "Unexpected value lambda:" $$ ppr expr
|
|
| 423 | +coreToStgExpr expr@(Lam {})
|
|
| 424 | + | null val_bndrs
|
|
| 425 | + = coreToStgExpr body
|
|
| 426 | + | otherwise
|
|
| 427 | + = do { body' <- extendVarEnvCts [ (a, LambdaBound) | a <- val_bndrs ] $
|
|
| 428 | + coreToStgExpr body
|
|
| 429 | + ; let body_ty = exprType body
|
|
| 430 | + fun_ty = mkLamTypes bndrs body_ty
|
|
| 431 | + rhs = StgRhsClosure noExtFieldSilent currentCCS
|
|
| 432 | + ReEntrant val_bndrs body' body_ty
|
|
| 433 | + tmp_fun = mkTemplateLocal 0 fun_ty
|
|
| 434 | + ; return (StgLet noExtFieldSilent (StgNonRec tmp_fun rhs) $
|
|
| 435 | + StgApp tmp_fun []) }
|
|
| 436 | + where
|
|
| 437 | + (bndrs, body) = myCollectBinders expr
|
|
| 438 | + val_bndrs = filterStgBinders bndrs
|
|
| 433 | 439 | |
| 434 | 440 | coreToStgExpr (Tick tick expr)
|
| 435 | 441 | = do
|
| ... | ... | @@ -925,6 +925,7 @@ cpeBody env expr |
| 925 | 925 | rhsToBody :: CorePrepEnv -> CpeRhs -> UniqSM (Floats, CpeBody)
|
| 926 | 926 | -- Remove top level lambdas by let-binding
|
| 927 | 927 | |
| 928 | +{-
|
|
| 928 | 929 | rhsToBody env (Tick t expr)
|
| 929 | 930 | | tickishScoped t == NoScope -- only float out of non-scoped annotations
|
| 930 | 931 | = do { (floats, expr') <- rhsToBody env expr
|
| ... | ... | @@ -946,6 +947,7 @@ rhsToBody env expr@(Lam {}) -- See Note [No eta reduction needed in rhsToBody] |
| 946 | 947 | ; return (unitFloat float, Var fn) }
|
| 947 | 948 | where
|
| 948 | 949 | (bndrs,_) = collectBinders expr
|
| 950 | +-}
|
|
| 949 | 951 | |
| 950 | 952 | rhsToBody _env expr = return (emptyFloats, expr)
|
| 951 | 953 |
| ... | ... | @@ -10,7 +10,7 @@ f :: forall a b. C a b => a -> b |
| 10 | 10 | Str=<1P(A,1C(1,C(1,L)))><L>,
|
| 11 | 11 | Unf=Unf{Src=<vanilla>, TopLvl=True,
|
| 12 | 12 | Value=True, ConLike=True, WorkFree=True, Expandable=True,
|
| 13 | - Guidance=IF_ARGS [30 0] 40 0}]
|
|
| 13 | + Guidance=IF_ARGS [90 0] 40 0}]
|
|
| 14 | 14 | f = \ (@a) (@b) ($dC :: C a b) (x :: a) -> op @a @b $dC x x
|
| 15 | 15 | |
| 16 | 16 |