X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FsimplCore%2FSetLevels.lhs;h=0797ad7727eb1fd5a37d22e7a9be2970f8c74def;hb=fe204a040a0381a1c18be10b9870cb3d20b0486b;hp=6f48272a9fe5f278d78931cae337bbdc826faad1;hpb=9ffadf219cbc4f8ec57264786df936a3cee88aec;p=ghc-hetmet.git diff --git a/compiler/simplCore/SetLevels.lhs b/compiler/simplCore/SetLevels.lhs index 6f48272..0797ad7 100644 --- a/compiler/simplCore/SetLevels.lhs +++ b/compiler/simplCore/SetLevels.lhs @@ -60,7 +60,7 @@ import CoreUtils ( exprType, exprIsTrivial, mkPiTypes ) import CoreFVs -- all of it import CoreSubst ( Subst, emptySubst, extendInScope, extendIdSubst, cloneIdBndr, cloneRecIdBndrs ) -import Id ( Id, idType, mkSysLocal, isOneShotLambda, +import Id ( idType, mkSysLocal, isOneShotLambda, zapDemandIdInfo, transferPolyIdInfo, idSpecialisation, idWorkerInfo, setIdInfo ) @@ -366,6 +366,14 @@ For example: where h :: Int -> Int# is expensive. We'd like to float the (h y) outside the \x, but we don't because it's unboxed. Possible solution: box it. +Note [Case MFEs] +~~~~~~~~~~~~~~~~ +We don't float a case expression as an MFE from a strict context. Why not? +Because in doing so we share a tiny bit of computation (the switch) but +in exchange we build a thunk, which is bad. This case reduces allocation +by 7% in spectral/puzzle (a rather strange benchmark) and 1.2% in real/fem. +Doesn't change any other allocation at all. + \begin{code} lvlMFE :: Bool -- True <=> strict context [body of case or let] -> Level -- Level of innermost enclosing lambda/tylam @@ -384,6 +392,10 @@ lvlMFE strict_ctxt ctxt_lvl env (_, AnnCast e co) = do { expr' <- lvlMFE strict_ctxt ctxt_lvl env e ; return (Cast expr' co) } +-- Note [Case MFEs] +lvlMFE True ctxt_lvl env e@(_, AnnCase {}) + = lvlExpr ctxt_lvl env e -- Don't share cases + lvlMFE strict_ctxt ctxt_lvl env ann_expr@(fvs, _) | isUnLiftedType ty -- Can't let-bind it; see Note [Unlifted MFEs] || isInlineCtxt ctxt_lvl -- Don't float out of an __inline__ context @@ -851,7 +863,7 @@ newPolyBndrs dest_lvl env abs_vars bndrs = do let new_bndrs = zipWith mk_poly_bndr bndrs uniqs return (extendPolyLvlEnv dest_lvl env abs_vars (bndrs `zip` new_bndrs), new_bndrs) where - mk_poly_bndr bndr uniq = transferPolyIdInfo bndr $ -- Note [transferPolyIdInfo] in Id.lhs + mk_poly_bndr bndr uniq = transferPolyIdInfo bndr abs_vars $ -- Note [transferPolyIdInfo] in Id.lhs mkSysLocal (mkFastString str) uniq poly_ty where str = "poly_" ++ occNameString (getOccName bndr)