[Git][ghc/ghc][wip/spj-try-opt-coercion] Don't take an extra run of the Simplifier with -O0
Simon Peyton Jones pushed to branch wip/spj-try-opt-coercion at Glasgow Haskell Compiler / GHC Commits: f94fb33c by Simon Peyton Jones at 2025-12-24T12:56:37+00:00 Don't take an extra run of the Simplifier with -O0 - - - - - 2 changed files: - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Utils.hs Changes: ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -220,11 +220,15 @@ getCoreToDo dflags hpt_rule_base extra_vars -- minimum effort please -- Specialisation is best done before full laziness -- so that overloaded functions have all their dictionary lambdas manifest - runWhen (do_specialise || do_co_opt) $ + runWhen do_specialise $ CoreDoPasses [ simpl_gently - , runWhen do_co_opt CoreOptCoercion , runWhen do_specialise CoreDoSpecialising ], + -- Optimise coercions + -- With -O do this after one run of the Simplifier. + -- Without -O, just take what the desugarer produced + runWhen do_co_opt CoreOptCoercion, + if full_laziness then CoreDoFloatOutwards $ FloatOutSwitches { floatOutLambdas = Just 0 @@ -257,7 +261,8 @@ getCoreToDo dflags hpt_rule_base extra_vars -- Run the simplifier phases 2,1,0 to allow rewrite rules to fire runWhen do_simpl3 (CoreDoPasses $ [ simpl_phase (Phase phase) "main" max_iter - | phase <- [phases, phases-1 .. 1] ] ++ + | phase <- [phases, phases-1 .. 1] ] + ++ [ simpl_phase (Phase 0) "main" (max max_iter 3) ]), -- Phase 0: allow all Ids to be inlined now -- This gets foldr inlined before strictness analysis @@ -310,6 +315,8 @@ getCoreToDo dflags hpt_rule_base extra_vars runWhen do_float_in CoreDoFloatInwards, + --------- Final run of the Simplifier --------------- + -- This runs even with -O0 simplify "final", -- Final tidy-up maybe_rule_check FinalPhase, ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -747,7 +747,7 @@ mergeCaseAlts _ _ _ = Nothing okToFloatJoin :: BinderSwapDecision -> Id -> CoreBind -> Maybe [CoreBind] -- Check a join-point binding to see if it can be floated out of -- the DEFAULT branch of a `case`. A Just result means "yes", --- and the [CoreBInd] are the extra fix-up bindings to add. +-- and the [CoreBind] are the extra fix-up bindings to add. -- See Note [Floating join points out of DEFAULT alternatives] okToFloatJoin bndr_swap outer_bndr bind | outer_bndr `elem` bindersOf bind -- (a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f94fb33cdcc192e81b01424017008f8a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f94fb33cdcc192e81b01424017008f8a... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)