Simon Peyton Jones pushed to branch wip/spj-try-opt-coercion at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Core/Opt/Pipeline.hs
    ... ... @@ -220,11 +220,15 @@ getCoreToDo dflags hpt_rule_base extra_vars
    220 220
             --                   minimum effort please
    
    221 221
             -- Specialisation is best done before full laziness
    
    222 222
             -- so that overloaded functions have all their dictionary lambdas manifest
    
    223
    -        runWhen (do_specialise || do_co_opt) $
    
    223
    +        runWhen do_specialise $
    
    224 224
             CoreDoPasses [ simpl_gently
    
    225
    -                     , runWhen do_co_opt     CoreOptCoercion
    
    226 225
                          , runWhen do_specialise CoreDoSpecialising ],
    
    227 226
     
    
    227
    +        -- Optimise coercions
    
    228
    +        -- With -O do this after one run of the Simplifier.
    
    229
    +        -- Without -O, just take what the desugarer produced
    
    230
    +        runWhen do_co_opt CoreOptCoercion,
    
    231
    +
    
    228 232
             if full_laziness then
    
    229 233
                CoreDoFloatOutwards $ FloatOutSwitches
    
    230 234
                     { floatOutLambdas     = Just 0
    
    ... ... @@ -257,7 +261,8 @@ getCoreToDo dflags hpt_rule_base extra_vars
    257 261
             -- Run the simplifier phases 2,1,0 to allow rewrite rules to fire
    
    258 262
             runWhen do_simpl3
    
    259 263
                 (CoreDoPasses $ [ simpl_phase (Phase phase) "main" max_iter
    
    260
    -                            | phase <- [phases, phases-1 .. 1] ] ++
    
    264
    +                            | phase <- [phases, phases-1 .. 1] ]
    
    265
    +                            ++
    
    261 266
                                 [ simpl_phase (Phase 0) "main" (max max_iter 3) ]),
    
    262 267
                     -- Phase 0: allow all Ids to be inlined now
    
    263 268
                     -- This gets foldr inlined before strictness analysis
    
    ... ... @@ -310,6 +315,8 @@ getCoreToDo dflags hpt_rule_base extra_vars
    310 315
     
    
    311 316
             runWhen do_float_in CoreDoFloatInwards,
    
    312 317
     
    
    318
    +        --------- Final run of the Simplifier ---------------
    
    319
    +        -- This runs even with -O0
    
    313 320
             simplify "final",  -- Final tidy-up
    
    314 321
     
    
    315 322
             maybe_rule_check FinalPhase,
    

  • compiler/GHC/Core/Utils.hs
    ... ... @@ -747,7 +747,7 @@ mergeCaseAlts _ _ _ = Nothing
    747 747
     okToFloatJoin :: BinderSwapDecision -> Id -> CoreBind -> Maybe [CoreBind]
    
    748 748
     -- Check a join-point binding to see if it can be floated out of
    
    749 749
     -- the DEFAULT branch of a `case`.   A Just result means "yes",
    
    750
    +-- and the [CoreBind] are the extra fix-up bindings to add.
    
    750 751
     -- See Note [Floating join points out of DEFAULT alternatives]
    
    751 752
     okToFloatJoin bndr_swap outer_bndr bind
    
    752 753
       | outer_bndr `elem` bindersOf bind          -- (a)