Simon Peyton Jones pushed to branch wip/T20264 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Core/Opt/FloatIn.hs
    ... ... @@ -432,9 +432,20 @@ idRuleAndUnfoldingVars of x. No need for type variables, hence not using
    432 432
     idFreeVars.
    
    433 433
     -}
    
    434 434
     
    
    435
    +fiExpr platform to_drop (_,AnnLet (AnnNonRec bndr (rhs_fvs, rhs)) body)
    
    436
    +  | Just bind' <- is_tyco_rhs rhs -- See Note [Don't float in type or coercion lets]
    
    437
    +  = wrapFloats drop_here $
    
    438
    +    Let bind' (fiExpr platform body_drop body)
    
    439
    +  where
    
    440
    +    is_tyco_rhs :: CoreExprWithFVs' -> Maybe CoreBind
    
    441
    +    is_tyco_rhs  (AnnType     ty) = Just (NonRec bndr (Type ty))
    
    442
    +    is_tyco_rhs  (AnnCoercion co) = Just (NonRec bndr (Coercion co))
    
    443
    +    is_tyco_rhs _ = Nothing
    
    444
    +
    
    445
    +    (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop
    
    446
    +                                             rhs_fvs [freeVarsOf body]
    
    447
    +
    
    435 448
     fiExpr platform to_drop (_,AnnLet bind body)
    
    436
    -  | Just bind' <- is_tyco_bind bind -- See Note [Don't float in type or coercion lets]
    
    437
    -  = Let bind' (fiExpr platform to_drop body)
    
    438 449
       | otherwise
    
    439 450
       = fiExpr platform (after ++ new_float : before) body
    
    440 451
                -- to_drop is in reverse dependency order
    
    ... ... @@ -442,10 +453,6 @@ fiExpr platform to_drop (_,AnnLet bind body)
    442 453
         (before, new_float, after) = fiBind platform to_drop bind body_fvs
    
    443 454
         body_fvs                   = freeVarsOf body
    
    444 455
     
    
    445
    -    is_tyco_bind :: CoreBindWithFVs -> Maybe CoreBind
    
    446
    -    is_tyco_bind (AnnNonRec bndr (_, AnnType     ty)) = Just (NonRec bndr (Type ty))
    
    447
    -    is_tyco_bind (AnnNonRec bndr (_, AnnCoercion co)) = Just (NonRec bndr (Coercion co))
    
    448
    -    is_tyco_bind _ = Nothing
    
    449 456
     
    
    450 457
     {- Note [Floating primops]
    
    451 458
     ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ... ... @@ -530,7 +537,7 @@ Note [Don't float in type or coercion lets]
    530 537
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    531 538
     We don't float type-lets or coercion-lets inward. Doing so does not
    
    532 539
     save allocation; and if we did we't have to be careful of the variables
    
    533
    -mentiond in the idType of the case-binder.  For example
    
    540
    +mentioned in the idType of the case-binder.  For example
    
    534 541
         \(x :: Maybe b) -> let a = Maybe b in
    
    535 542
                            case x of (cb :: a) of { Just y -> ... }
    
    536 543
     We must not float the `a = Maybe b` into the case alternatives, because
    

  • compiler/GHC/Core/Opt/OccurAnal.hs
    ... ... @@ -2718,9 +2718,10 @@ occAnalApp !env (Var fun, args, ticks)
    2718 2718
       --     we don't want to occ-anal them twice in the runRW# case!
    
    2719 2719
       --     This caused #18296
    
    2720 2720
       | fun `hasKey` runRWKey
    
    2721
    -  , [t1, t2, arg]  <- args
    
    2721
    +  , [a1@(Type t1), a2@(Type t2), arg]  <- args
    
    2722 2722
       , WUD usage arg' <- adjustNonRecRhs (JoinPoint 1) $ occAnalLamTail env arg
    
    2723
    -  = WUD usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg'])
    
    2723
    +  = WUD (usage `addTyCoOccs` occAnalTy t1 `addTyCoOccs` occAnalTy t2)
    
    2724
    +        (mkTicks ticks $ mkApps (Var fun) [a1, a2, arg'])
    
    2724 2725
     
    
    2725 2726
     occAnalApp env (Var fun_id, args, ticks)
    
    2726 2727
       = WUD all_uds (mkTicks ticks app')