diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-04-20 13:56:52 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-20 21:33:09 -0400 |
commit | b7980b5d94d34943b3965cf79c4e610f00a9ee7d (patch) | |
tree | 053655e4603523d7571e9532a79392a3a5fa74c5 | |
parent | fdbead70d5920c35b6fd96b723f00aaa95763ae2 (diff) | |
download | haskell-b7980b5d94d34943b3965cf79c4e610f00a9ee7d.tar.gz |
Fix occAnalApp
In OccurAnal the function occAnalApp was failing to reset occ_encl to
OccVanilla. This omission sometimes resulted in over-pessimistic
occurrence information.
I tripped over this when analysing eta-expansions.
Compile times in perf/compiler fell slightly (no increases)
PmSeriesG(normal) ghc/alloc 50738104.0 50580440.0 -0.3%
PmSeriesS(normal) ghc/alloc 64045284.0 63739384.0 -0.5%
PmSeriesT(normal) ghc/alloc 94430324.0 93800688.0 -0.7%
PmSeriesV(normal) ghc/alloc 63051056.0 62758240.0 -0.5%
T10547(normal) ghc/alloc 29322840.0 29307784.0 -0.1%
T10858(normal) ghc/alloc 191988716.0 189801744.0 -1.1%
T11195(normal) ghc/alloc 282654016.0 281839440.0 -0.3%
T11276(normal) ghc/alloc 142994648.0 142338688.0 -0.5%
T11303b(normal) ghc/alloc 46435532.0 46343376.0 -0.2%
T11374(normal) ghc/alloc 256866536.0 255653056.0 -0.5%
T11822(normal) ghc/alloc 140210356.0 138935296.0 -0.9%
T12234(optasm) ghc/alloc 60753880.0 60720648.0 -0.1%
T14052(ghci) ghc/alloc 2235105796.0 2230906584.0 -0.2%
T17096(normal) ghc/alloc 297725396.0 296237112.0 -0.5%
T17836(normal) ghc/alloc 1127785292.0 1125316160.0 -0.2%
T17836b(normal) ghc/alloc 54761928.0 54637592.0 -0.2%
T17977(normal) ghc/alloc 47529464.0 47397048.0 -0.3%
T17977b(normal) ghc/alloc 42906972.0 42809824.0 -0.2%
T18478(normal) ghc/alloc 777385708.0 774219280.0 -0.4%
T18698a(normal) ghc/alloc 415097664.0 409009120.0 -1.5% GOOD
T18698b(normal) ghc/alloc 500082104.0 493124016.0 -1.4% GOOD
T18923(normal) ghc/alloc 72252364.0 72216016.0 -0.1%
T1969(normal) ghc/alloc 811581860.0 804883136.0 -0.8%
T5837(normal) ghc/alloc 37688048.0 37666288.0 -0.1%
Nice!
Metric Decrease:
T18698a
T18698b
-rw-r--r-- | compiler/GHC/Core/Opt/OccurAnal.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler/GHC/Core/Opt/OccurAnal.hs b/compiler/GHC/Core/Opt/OccurAnal.hs index 83c44dcec2..7efcba8cd8 100644 --- a/compiler/GHC/Core/Opt/OccurAnal.hs +++ b/compiler/GHC/Core/Opt/OccurAnal.hs @@ -2124,10 +2124,22 @@ occAnalApp env (fun, args, ticks) -- often leaves behind beta redexs like -- (\x y -> e) a1 a2 -- Here we would like to mark x,y as one-shot, and treat the whole - -- thing much like a let. We do this by pushing some True items + -- thing much like a let. We do this by pushing some OneShotLam items -- onto the context stack. !(args_uds, args') = occAnalArgs env args [] +addAppCtxt :: OccEnv -> [Arg CoreBndr] -> OccEnv +addAppCtxt env@(OccEnv { occ_one_shots = ctxt }) args + | n_val_args > 0 + = env { occ_one_shots = replicate n_val_args OneShotLam ++ ctxt + , occ_encl = OccVanilla } + -- OccVanilla: the function part of the application + -- is no longer on OccRhs or OccScrut + | otherwise + = env + where + n_val_args = valArgCount args + {- Note [Sources of one-shot information] @@ -2407,10 +2419,6 @@ markJoinOneShots mb_join_arity bndrs b' | isId b = setOneShotLambda b | otherwise = b -addAppCtxt :: OccEnv -> [Arg CoreBndr] -> OccEnv -addAppCtxt env@(OccEnv { occ_one_shots = ctxt }) args - = env { occ_one_shots = replicate (valArgCount args) OneShotLam ++ ctxt } - -------------------- transClosureFV :: VarEnv VarSet -> VarEnv VarSet -- If (f,g), (g,h) are in the input, then (f,h) is in the output |