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

Commits:

2 changed files:

Changes:

  • compiler/GHC/Core/Opt/OccurAnal.hs
    ... ... @@ -1124,7 +1124,7 @@ mkNonRecRhsCtxt lvl bndr unf
    1124 1124
             -- Distressing delicacy ... has to line up with preInlineUnconditionally
    
    1125 1125
             case idOccInfo bndr of
    
    1126 1126
               OneOcc { occ_in_lam = NotInsideLam, occ_n_br = 1 }
    
    1127
    -            -> active && not (isTopLevel lvl) && not stable_unf
    
    1127
    +            -> active && not stable_unf
    
    1128 1128
               _ -> False
    
    1129 1129
     
    
    1130 1130
         active     = isAlwaysActive (idInlineActivation bndr)
    

  • compiler/GHC/Core/Opt/Simplify/Utils.hs
    ... ... @@ -1465,7 +1465,7 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_env
    1465 1465
                       , occ_in_lam  = NotInsideLam
    
    1466 1466
                       , occ_int_cxt = int_cxt }
    
    1467 1467
           =  isNotTopLevel top_lvl      -- Get rid of allocation
    
    1468
    -      || (int_cxt==IsInteresting)   -- Function is applied
    
    1468
    +      || (int_cxt==IsInteresting && idArity bndr > 0)   -- Function is applied
    
    1469 1469
        --   || (early_phase && not (isConLikeUnfolding unf))  -- See early_phase
    
    1470 1470
         one_occ OneOcc{ occ_n_br   = 1
    
    1471 1471
                       , occ_in_lam = IsInsideLam
    
    ... ... @@ -1632,6 +1632,7 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs
    1632 1632
         unfolding   = idUnfolding bndr
    
    1633 1633
     --    arity       = idArity bndr
    
    1634 1634
         is_cheap    = isCheapUnfolding unfolding
    
    1635
    +    is_exp      = isExpandableUnfolding unfolding
    
    1635 1636
         uf_opts     = seUnfoldingOpts env
    
    1636 1637
         phase       = sePhase env
    
    1637 1638
         active      = isActive phase (idInlineActivation bndr)
    
    ... ... @@ -1639,6 +1640,8 @@ postInlineUnconditionally env bind_cxt old_bndr bndr rhs
    1639 1640
     
    
    1640 1641
         -- Check for code-size blow-up from inlining in multiple places
    
    1641 1642
         code_dup_ok n_br
    
    1643
    +      | is_top_lvl          -- Don't inline top-level datacons, ever; no advantage,
    
    1644
    +      , is_exp      = False -- and float-out may have carefully created them
    
    1642 1645
           | n_br == 1   = True  -- No duplication
    
    1643 1646
           | n_br >= 100 = False -- See #23627
    
    1644 1647
           | is_demanded = False -- Demanded => no allocation (it'll be a case expression