Simon Peyton Jones pushed to branch wip/T27261 at Glasgow Haskell Compiler / GHC Commits: 65d6391c by Simon Peyton Jones at 2026-05-22T12:27:34+01:00 Wibbles - - - - - 1 changed file: - compiler/GHC/Core/Opt/Simplify/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -502,6 +502,7 @@ contIsTrivial _ = False ------------------- contStop :: SimplCont -> SimplCont -- Get the Stop at the tail of the argument +-- Always returns a continuation of form (Stop ...) contStop stop@(Stop {}) = stop contStop (CastIt { sc_cont = k }) = contStop k contStop (StrictBind { sc_cont = k }) = contStop k @@ -670,20 +671,26 @@ mkBottomCont ::SimplCont -> SimplCont -- looking like (case <hole> of {}). -- This is used when we are going to fill in the <hole> with bottom -- See (TC2,3) in Note [Trimming the continuation for bottoming functions] -mkBottomCont cont@(Stop {}) = cont -mkBottomCont cont@(Select { sc_alts = [], sc_cont = Stop {} }) = cont -mkBottomCont cont - | Stop res_ty _ _ <- stop_cont - , hole_ty `eqTypeIgnoringMultiplicity` res_ty - = stop_cont - | otherwise - = Select { sc_alts = [] - , sc_bndr = mkWildValBinder OneTy hole_ty - , sc_env = Simplified OkDup - , sc_cont = stop_cont } +-- But don't bother to trim, making a `case <hole> of {}`, if we have only +-- an essentially-trivial continuation; e.g. (<hole> @ty |> co) +mkBottomCont cont = go cont where - hole_ty = contHoleType cont - stop_cont = contStop cont + go k@(Stop {}) = k + go (TickIt t k') = TickIt t (go k') + go k@(CastIt { sc_cont = k' }) = k { sc_cont = go k' } + go k@(ApplyToTy { sc_cont = k' }) = k { sc_cont = go k' } + go k@(Select { sc_alts = [], sc_cont = Stop {} }) = k -- Optimisation only + go k | Stop res_ty _ _ <- stop_cont + , hole_ty `eqTypeIgnoringMultiplicity` res_ty + = stop_cont + | otherwise + = Select { sc_alts = [] + , sc_bndr = mkWildValBinder OneTy hole_ty + , sc_env = Simplified OkDup + , sc_cont = stop_cont } + where + hole_ty = contHoleType k + stop_cont = contStop k ------------------- mkArgInfo :: SimplEnv -> Id -> [CoreRule] -> SimplCont -> ArgInfo View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65d6391c0d4209b390f8cd9868ef7aa5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65d6391c0d4209b390f8cd9868ef7aa5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)