From fded7dd4300df8e1657b710f4deed16aa1d35ebe Mon Sep 17 00:00:00 2001 From: Sebastian Graf <sgraf1337@gmail.com> Date: Thu, 19 Oct 2023 15:15:54 +0000 Subject: [PATCH] CorePrep: Allow floating dictionary applications in -O0 into a Rec (#24102) --- compiler/GHC/CoreToStg/Prep.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/GHC/CoreToStg/Prep.hs b/compiler/GHC/CoreToStg/Prep.hs index 02180b86c8b2..079fa081cfa6 100644 --- a/compiler/GHC/CoreToStg/Prep.hs +++ b/compiler/GHC/CoreToStg/Prep.hs @@ -643,13 +643,20 @@ cpeBind top_lvl env (Rec pairs) where (bndrs, rhss) = unzip pairs - -- Flatten all the floats, and the current - -- group into a single giant Rec + -- Flatten all the floats, and the current + -- group into a single giant Rec add_float (Float bind bound _) prs2 - | bound /= CaseBound = case bind of + | bound /= CaseBound + || all (definitelyLiftedType . idType) (bindersOf bind) + -- The latter check is hit in -O0 (i.e., flavours quick, devel2) + -- for dictionary args which haven't been floated out yet, #24102. + -- They are preferably CaseBound, but since they are lifted we may + -- just as well put them in the Rec, in contrast to lifted bindings. + = case bind of NonRec x e -> (x,e) : prs2 Rec prs1 -> prs1 ++ prs2 - add_float f _ = pprPanic "cpeBind" (ppr f) + add_float f _ = pprPanic "cpeBind" (ppr f) + --------------- cpePair :: TopLevelFlag -> RecFlag -> Demand -> Bool -- GitLab