Simon Peyton Jones pushed to branch wip/substitution-via-mapper at Glasgow Haskell Compiler / GHC Commits: ad86061e by Simon Peyton Jones at 2026-10-06T16:21:03+01:00 Fixing perf regressions in T27336, T9872d, T14683 What caused each regression 1. T27336 and T9872d: mkKindCo lost its "kinds are equal ⇒ Refl" case when it moved into TyCo/Make.hs. As a result, toPhantomCo kept the whole type-family proof inside phantom UnivCos, which reached 22M coercion nodes on T27336. 2. T14683, first part: mkUnivCo lost its eqType short cut, which left reflexive phantom casts in place. 3. T14683, second part: isReflForAllCo used == instead of eqForAllVis. That turned a forall {a} vs forall a coercion into a real cast, and the cast caused the extra simplifier iteration. 4. T27336 residual: zonk_tcapp took mk as an unknown function, so each result thunk was one word bigger. {-# INLINE zonk_tcapp #-} fixed it. What changed - mkKindCo and mkUnivCo moved to GHC.Core.Coercion, with Note [mkKindCo and mkUnivCo] explaining why they live there. Make.hs gets them via Coercion.hs-boot, and I removed three unused declarations from that boot file. - ForAllTyFlag moved, with all its functions and its Outputable/Binary instances, from L.H.S.Specificity into GHC.Types.Var. That module also now holds: - eqForAllVis and cmpForAllVis, still re-exported from Compare - the new isCoreTyLamForAllTyFlag - the new cmpForAllTyFlagExactly - ForAllTyFlag has no Eq or Ord, so the compiler now checks that every comparison follows Note [Comparing visibility]. - IfaceForAllTyFlag is a new newtype in GHC.Iface.Type with exact Eq/Ord (via cmpForAllTyFlagExactly), which the interface deduplication table needs. Its Binary instance delegates to ForAllTyFlag's, so the .hi format is unchanged. - Eq (HieType a) is now hand-written, so that the public HIE API keeps its ForAllTyFlag field. Plus: - (FT2)/(FC7) covar-binder checks in mkForAllTy, assertGoodForAllCo and Lint now use isCoreTyLamForAllTyFlag. These checks are slightly weaker than before: they no longer catch an Inferred covar binder. - ty_co_match now compares visibilities with eqForAllVis. It's slightly more permissive, but consistent with eqType. - mkEtaForAllMCo now returns MRefl for any invisible flag. That matches what mkForAllCo produces now anyway. - Unchanged behaviour: comparisons against a fixed flag (in Type.hs, Tc/Gen/App.hs, Tc/Errors/Ppr.hs, Tc/TyCl/Instance.hs, and the Iface printing code) use the exact predicates, such as isInferredForAllTyFlag and isSpecifiedForAllTyFlag. They behave exactly as before. - - - - - 34 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Core/TyCo/Make.hs - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToIface.hs-boot - compiler/GHC/Iface/Decl.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Iface/Type.hs-boot - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Zonk/TcType.hs - compiler/GHC/Tc/Zonk/Type.hs - compiler/GHC/Types/Var.hs - compiler/GHC/Types/Var.hs-boot - compiler/GHC/Utils/Binary.hs - compiler/GHC/Utils/Outputable.hs - compiler/Language/Haskell/Syntax/Specificity.hs - utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ad86061ecbf755a53abd07f49b1c4d8b... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ad86061ecbf755a53abd07f49b1c4d8b... 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)
-
Simon Peyton Jones (@simonpj)