[Git][ghc/ghc][wip/T27724] Redesign the noinline magic
Magnus pushed to branch wip/T27724 at Glasgow Haskell Compiler / GHC Commits: cdcdfcf7 by Simon Peyton Jones at 2026-11-19T12:04:18+01:00 Redesign the noinline magic The principal goal of this MR is to avoid `noinline` getting in the way of strictness analysis and specialisation. It involves a bit of redesign. Main idea: * When simplifying `noinline (f e1 e2)`, switch off inlining when simplifying `f`, but not when simplifying `e1` and `e2`. * Mechanism: see `simplOutId`, the `noinlineIdKey` case * If: we see `noinline (f e1) e2`, the simplifier moves the `e2` inside; see the `splitContArgs` call. This is important so you can write `noinline f e1 e2` and have it mean the same as `noinline (f e1 e2)`. * Now `f` sees all its arguments, hence: * Fixes #27724 (noinline inhibits specialisation) * Fixes #23911 (noinline worsens demand signatures) * Also fixes #27803 where we were not respecting `noinline` if the RHS was trivial See Note [noinlineId magic] for lots of specifics. It's surprisingly tricky! For some reason a couple of perf tests allocate 1.2% less at compile time,n namely T29872 and T8095. Geom mean decease of 0.1% Metric Decrease: T9872d - - - - - 1 changed file: - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs Changes: ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -4281,7 +4281,7 @@ module GHC.Base where newSmallArray# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)) d. Int# -> a -> State# d -> (# State# d, SmallMutableArray# d a #) newTVar# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)) d. a -> State# d -> (# State# d, TVar# d a #) noDuplicate# :: forall d. State# d -> State# d - noinline :: forall a. a -> a + noinline :: forall {q :: RuntimeRep} (a :: TYPE q). a -> a not :: Bool -> Bool not# :: Word# -> Word# not64# :: Word64# -> Word64# @@ -6324,7 +6324,7 @@ module GHC.Exts where newSmallArray# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)) d. Int# -> a -> State# d -> (# State# d, SmallMutableArray# d a #) newTVar# :: forall {l :: Levity} (a :: TYPE (BoxedRep l)) d. a -> State# d -> (# State# d, TVar# d a #) noDuplicate# :: forall d. State# d -> State# d - noinline :: forall a. a -> a + noinline :: forall {q :: RuntimeRep} (a :: TYPE q). a -> a not# :: Word# -> Word# not64# :: Word64# -> Word64# notI# :: Int# -> Int# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdcdfcf7f1dd523fdbbcd73cfc15a670... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdcdfcf7f1dd523fdbbcd73cfc15a670... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Magnus (@MangoIV)