Simon Peyton Jones pushed to branch wip/T28169 at Glasgow Haskell Compiler / GHC Commits: 36da5e74 by Simon Peyton Jones at 2026-11-28T23:47:01+00:00 Add INLINE pragmas to tiny MCoercion functions Now that interestingArg returns TrivArg for an OtherCon [] argument, mkSymMCo (and friends) no longer inline in the type-family rewriter, where their argument is evaluated but its constructor is unknown. That cost ~2.5% allocation in T9872{a,b,c,d} and TcPlugin_RewritePerf: mkSymMCo went from 0 to 1.9M out-of-line calls in T9872b, and the MRefl fast path in GHC.Tc.Solver.Rewrite was lost. The benefit of inlining comes from downstream consumers of the result, which neither the argument nor the call context reveals, so we use INLINE pragmas instead. See the new Note [Inline tiny MCo functions] in GHC.Core.TyCo.Make. Also add a paragraph to (IA2) in Note [Interesting arguments] explaining the trade-off, and pointing to the new Note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - e3d48dcf by Simon Peyton Jones at 2026-11-28T23:47:01+00:00 Fix evaluated-ness bug in Simplifier (#26548) adjustFieldsIdInfo decided whether to attach evaluated-ness to the pattern-bound variables of a case alternative by testing whether the data constructor has a wrapper (`dataConWrapId_maybe`). But a constructor can have strict fields and yet no wrapper, so we failed to mark its strict fields as evaluated. Fix: test `isLazyDataConRep`. Fixing this gives many more variables an OtherCon [] unfolding, which disturbs the inlining heuristics. So also: * interestingArg returns TrivArg (rather than NonTrivArg) for an argument with an OtherCon [] unfolding: knowing only that an argument is evaluated rarely makes inlining worthwhile (e.g. maMB in T18140). See (IA2) in Note [Interesting arguments]. * interestingCallContext treats a StrictBind continuation as RhsCtxt NonRecursive rather than BoringCtxt. * A lambda argument remains a ValueArg; new (IA5) in Note [Interesting arguments] explains why, and discusses T17516. New test T26548. T26615.stderr is regenerated (only its fEqList lines are checked). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 17559045 by Simon Peyton Jones at 2026-11-29T01:18:21+00:00 Make adjustFieldsIdInfo cheaper Since the fix for #26548, adjustFieldsIdInfo takes its slow path for every constructor with strict fields, which put T9233 (a record with 100 strict fields) up 2%. Make the slow path cheaper: (a) build the result list strictly; it is consumed in full right away (b) update each field binder's IdInfo at most once, rather than once for evaluated-ness and once more for occ-info (c) leave alone a field binder that is dead and will stay dead Factor out fieldOccInfoStable, and replace adjustFieldOccInfo by the simpler zapFieldOccInfo. The seq# case now uses the same `go` loop. T9233 now allocates 0.6% less than master (it was 2.1% more), and T9675 1.2% less. T19641.stderr goes back to master's version (binder names only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 10 changed files: - compiler/GHC/Core/Opt/Simplify/Inline.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/TyCo/Make.hs - compiler/GHC/Types/Demand.hs - libraries/ghc-internal/src/GHC/Internal/IO.hs - + testsuite/tests/simplCore/should_compile/T26548.hs - + testsuite/tests/simplCore/should_compile/T26548.stderr - testsuite/tests/simplCore/should_compile/T26615.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Inline.hs ===================================== @@ -385,7 +385,7 @@ tryUnfolding env logger id lone_variable arg_infos -- be *something* interesting about some argument, or the -- result context, to make it worth inlining calc_some_benefit :: Arity -> Bool -> Bool -- The Arity is the number of args - -- expected by the unfolding + -- expected by the unfolding calc_some_benefit uf_arity is_inline | not saturated = interesting_args -- Under-saturated -- Note [Unsaturated applications] ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -3557,7 +3557,8 @@ life" in one of two ways: Thus, when we are simply reconstructing a case (the common case), and the case binder is not dead, or the scrutinee is a variable, we zap the -occurrence info on DataAlt field binders. See `adjustFieldOccInfo`. +occurrence info on DataAlt field binders. See `fieldOccInfoStable` +and `adjustFieldsIdInfo`. Note [Improving seq] ~~~~~~~~~~~~~~~~~~~~ @@ -3765,70 +3766,81 @@ do it here). The right thing is to do some kind of binder-swap; see #15226 for discussion. -} -adjustFieldsIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision -> DataCon -> [Id] -> [Id] +adjustFieldsIdInfo :: Maybe OutExpr -> OutId -> BinderSwapDecision + -> DataCon -> [InBndr] -> [InBndr] -- See Note [Adding evaluatedness info to pattern-bound variables] -- and Note [DataAlt occ info] +-- +-- This can be a hot path in the compiler (e.g. T9233 which has a large strict record) +-- Hence +-- (a) we build the result list strictly: it is consumed in full right away, +-- so thunks for the elements or the spine are pure waste +-- (b) we update each field binder's IdInfo at most once +-- (c) we leave alone a field binder that is dead and will stay dead +-- (see `fieldOccInfoStable`); its evaluated-ness is irrelevant adjustFieldsIdInfo scrut case_bndr bndr_swap con vs + -- Deal with seq# applications + -- See (SEQ3) in Note [seq# magic] in GHC.Types.Id.Make + -- case (seq# a b) of (# _, x' #) -> .... + -- we can mark x' as evaluated | Just scr <- scrut , isUnboxedTupleDataCon con - , [s,x] <- vs -- Use stripNArgs rather than collectArgsTicks to avoid building -- a list of arguments only to throw it away immediately. , Just (Var f) <- stripNArgs 4 scr , f `hasKey` seqHashKey - , let x' = setCaseBndrEvald MarkedStrict x - = map (adjustFieldOccInfo case_bndr bndr_swap) [s, x'] - - -- Deal with banged datacon fields - -- This case is quite allocation sensitive to T9233 which has a large record - -- with strict fields. Hence we try not to update vs twice! -adjustFieldsIdInfo _scrut case_bndr bndr_swap con vs - | Nothing <- dataConWrapId_maybe con - -- A common fast path; no need to allocate the_strs when they are all lazy - -- anyway! It shaves off 2% in T9675 - = map (adjustFieldOccInfo case_bndr bndr_swap) vs + = go vs [topDmd, evalDmd] -- seq# returns an evaluated x + + -- General case | otherwise = go vs wkr_dmds where -- The demand signature of the worker has a strict demand for exactly the - -- strict (banged) fields; one demand for each value argument, including + -- strict (banged) fields; one demand for each value argument, /including/ -- existential CoVars. See GHC.Types.Id.Make.mkDataConWorkId. - -- NB: we do /not/ mark an unlifted field as evaluated: that gains nothing, - -- and an OtherCon[] unfolding makes `interestingArg` say NonTrivArg, - -- which changes inlining decisions (we saw this in compiler/perf/T19695). + -- NB: an unlifted field has a lazy demand, and hence won't be marked as + -- evaluated: doing so gains nothing. Not a big deal because `interestingArg` + -- says `TrivArg` for OtherCon[] unfoldings, but it's a bit delicate + -- (compiler/perf/T19695 is an example of this delicacy) DmdSig (DmdType _ wkr_dmds) = idDmdSig (dataConWorkId con) + occ_stable = fieldOccInfoStable case_bndr bndr_swap go [] [] = [] - go (v:vs') dmds | isTyVar v = v : go vs' dmds - go (v:vs') (dmd:dmds) = adjustFieldOccInfo case_bndr bndr_swap (set_evald dmd v) : go vs' dmds - go _ _ = pprPanic "Simplify.adjustFieldsIdInfo" - (ppr con $$ - ppr vs $$ - ppr_with_length wkr_dmds $$ - ppr_with_length (dataConRepArgTys con)) - where - ppr_with_length list - = ppr list <+> parens (text "length =" <+> ppr (length list)) - - set_evald dmd v | isStrDataConDmd dmd = setCaseBndrEvald MarkedStrict v - | otherwise = v - -adjustFieldOccInfo :: OutId -> BinderSwapDecision -> CoreBndr -> CoreBndr --- Kill occ info if we do binder swap and the case binder is alive; --- see Note [DataAlt occ info] -adjustFieldOccInfo case_bndr bndr_swap field_bndr - | isTyVar field_bndr - = field_bndr - - | not (isDeadBinder case_bndr) -- (1) in the Note: If the case binder is alive, - = zapIdOccInfo field_bndr -- the field binders might come back alive - - | DoBinderSwap{} <- bndr_swap -- (2) in the Note: If binder swap might take place, - = zapIdOccInfo field_bndr -- the case binder might come back alive - - | otherwise - = field_bndr -- otherwise the field binders stay dead + go (v:vs') dmds@(dmd:dmds') + | isTyVar v = let !vs'' = go vs' dmds in v : vs'' + | otherwise = let !v' = adjust dmd v + !vs'' = go vs' dmds' + in v' : vs'' + go vs' ds = pprPanic "Simplify.adjustFieldsIdInfo" (ppr con $$ ppr vs $$ ppr vs' $$ ppr ds) + + -- Set evaluated-ness (if dmd is strict) and zap occ-info + -- (if not occ_stable), with at most one IdInfo update + adjust :: Demand -> Id -> Id + adjust dmd v + = case isStrDataConDmd dmd of + True | occ_stable -> if isDeadBinder v then nop v else set_evald v + | otherwise -> set_evald_zap_occ v + False | occ_stable -> nop v + | otherwise -> zap_occ v + + nop v = v + set_evald v = v `setIdUnfolding` evaldUnfolding + zap_occ v = zapIdOccInfo v + set_evald_zap_occ v = modifyIdInfo (\info -> info `setUnfoldingInfo` evaldUnfolding + `setOccInfo` noOccInfo) v + +fieldOccInfoStable :: OutId -> BinderSwapDecision -> Bool +-- True <=> the occ-info on the field binders of a DataAlt remains valid; +-- in particular a dead field binder will stay dead. +-- False <=> we must zap the field binders' occ-info. +-- See Note [DataAlt occ info] +fieldOccInfoStable case_bndr bndr_swap + | not (isDeadBinder case_bndr) = False -- (1) in the Note: If the case binder is alive, + -- the field binders might come back alive + | DoBinderSwap{} <- bndr_swap = False -- (2) in the Note: If binder swap might take place, + -- the case binder might come back alive + | otherwise = True -- Otherwise the field binders stay dead addDefaultUnfoldings :: SimplEnv -> OutId -> BinderSwapDecision -> [AltCon] -> SimplEnv addDefaultUnfoldings env case_bndr bndr_swap imposs_deflt_cons ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1123,7 +1123,7 @@ interestingCallContext env cont -- in GHC.Core.Unfold interesting (StrictArg { sc_fun = fun }) = strictArgContext fun - interesting (StrictBind {}) = BoringCtxt + interesting (StrictBind {}) = RhsCtxt NonRecursive interesting (Stop _ cci _) = cci interesting (TickIt _ k) = interesting k interesting (ApplyToTy { sc_cont = k }) = interesting k @@ -1208,13 +1208,29 @@ Wrinkles: (IA2) OtherCon. interestingArg returns - (a) NonTrivArg for an arg with an OtherCon [] unfolding + (a) TrivArg for an arg with an OtherCon [] unfolding (b) ValueArg for an arg with an OtherCon [c1,c2..] unfolding. - Reason for (a): I found (in the GHC.Internal.Bignum.Integer module) that I was - inlining a pretty big function when all we knew was that its arguments - were evaluated, nothing more. That in turn make the enclosing function - too big to inline elsewhere. + Reason for (a): knowing only that an argument is evaluated, but not which + constructor it is, rarely makes inlining worthwhile. For example, in test + T18140 we have + data D = D !(Maybe Bool) ... !(Maybe Bool) + maMB :: Maybe Bool -> Maybe Bool -> Maybe Bool + maD (D x1 ... x18) (D y1 ... y18) = D (maMB x1 y1) ... (maMB x18 y18) + The xi and yi come from strict fields, so they have OtherCon [] unfoldings. + If that made them interesting we would inline maMB 18 times, to no benefit, + just bloating maD. (Similarly, in GHC.Internal.Bignum.Integer I found that + I was inlining a pretty big function when all we knew was that its + arguments were evaluated. That in turn made the enclosing function too big + to inline elsewhere.) + + But this choice is delicate. Sometimes inlining a tiny function applied to + an evaluated argument /is/ very beneficial, because the /result/ is + scrutinised downstream; mkSymMCo in the type-family rewriter is an example. + Neither the argument nor the call context reveals this, so in those cases + we use an INLINE pragma: see Note [Inline tiny MCo functions] in + GHC.Core.TyCo.Make. (Without those INLINE pragmas, returning TrivArg here + makes the compiler itself slower: T9872{a,b,c,d} allocate ~2.5% more.) Reason for (b): we want to inline integerCompare here integerLt# :: Integer -> Integer -> Bool# @@ -1247,6 +1263,25 @@ Wrinkles: Conclusion: `interestingArg` should give some encouragement (NonTrivArg) to `f` when the argument is expandable. Hence `uf_expandable` in the `Var` case. +(IA5) We are keen to inline a higher-order function applied to lambda, e.g. + f (\x. blah) + where + f h = ...(h xs)... + Doing so specialises `f` to the particular argument which can make a + big difference. Note, however, that we don't want to be defeated if + the lambda is let-bound: + let h = (\x.blah) + in ...f h... + So we need to look through h's unfolding. + + This makes parser combinators, which are usually applied to functions, + rather keen to inline, so whether they do so is mostly decided by their + size. Test T17516 is a delicate example: if `max` on positions inlines + into the combinators in T17516A, the combinators are too big to inline into + the client module T17516; if not (because max's arguments are merely + evaluated, see (IA2)), they are small and do inline, making T17516 itself + slower to compile. But inlining makes the code better too, with fewer + unknown calls. -} interestingArg :: SimplEnv -> StaticEnv -> CoreExpr -> ArgSummary @@ -1275,7 +1310,7 @@ interestingArg env se e go env n (Lam v e) | isTyVar v = go env n e | n>0 = NonTrivArg -- (\x.b) e is NonTriv - | otherwise = ValueArg + | otherwise = ValueArg -- (\x.b) is Value: see (IA5) go _ _ (Case {}) = NonTrivArg go env n (Let b e) = case go env' n e of ValueArg -> ValueArg @@ -1285,17 +1320,16 @@ interestingArg env se e go_var n v | isConLikeId v = ValueArg -- Experimenting with 'conlike' rather that - -- data constructors here - -- DFuns are con-like; + -- data constructors here (includes DFuns) -- see (IA1) in Note [Interesting arguments] - | idArity v > n = ValueArg -- Catches (eg) primops with arity but no unfolding + | idArity v > n = ValueArg -- See (IA5) in Note [Interesting arguments] | n > 0 = NonTrivArg -- Saturated or unknown call | otherwise -- n==0, no value arguments; look for an interesting unfolding = case idUnfolding v of - OtherCon [] -> NonTrivArg -- It's evaluated, but that's all we know + OtherCon [] -> TrivArg -- It's evaluated, but that's all we know OtherCon _ -> ValueArg -- Evaluated and we know it isn't these constructors - -- See (IA2) in Note [Interesting arguments] - DFunUnfolding {} -> ValueArg -- We konw that idArity=0 + -- See (IA2) in Note [Interesting arguments] + DFunUnfolding {} -> ValueArg -- We know that idArity=0 CoreUnfolding{ uf_cache = cache } | uf_is_conlike cache -> ValueArg -- Includes constructor applications | uf_expandable cache -> NonTrivArg -- See (IA4) ===================================== compiler/GHC/Core/TyCo/Make.hs ===================================== @@ -1322,42 +1322,88 @@ mkGReflCo r ty mco mkGReflMCo :: HasDebugCallStack => Role -> Type -> CoercionN -> Coercion mkGReflMCo r ty co = mkGReflCo r ty (MCo co) +{- Note [Inline tiny MCo functions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The MCoercion functions (mkSymMCo, mkCastTyMCo, mkCoherenceRightMCo, etc.) +are tiny wrappers whose whole purpose is the fast path for MRefl. We give +them INLINE pragmas, rather than relying on the inliner's heuristics, because +the benefit of inlining them is usually invisible at the call site. + +Example: homogeniseHetRedn (in GHC.Core.Reduction) is used in the type-family +rewriter. After inlining it and mkCoherenceRightMRedn (both INLINE) we get +something like + let kco' = mkSymMCo kco + in Reduction (mkCoherenceRightMCo r ty2 kco' co1) + (mkCastTyMCo ty2 kco') +where `kco` is typically already evaluated (has an OtherCon [] unfolding), +but its constructor is unknown. `kco'` is used twice, so it is not inlined +at its use sites; and its RHS is a boring context for a non-INLINE function. +So, judged by its argument and context alone, `mkSymMCo kco` has no +discernible benefit, and does not inline. But if it does inline, case-of-case +moves the (cheap) `case kco` outwards, and the two consumers become +case-of-known-constructor: + case kco of + MRefl -> Reduction co1 ty2 -- No allocation at all + MCo co -> ... +Kind coercions are usually reflexive, so this MRefl path is the hot one. +The benefit comes entirely from the downstream consumers of the result. + +Why not just make interestingArg regard an evaluated (OtherCon []) argument as +interesting? Because in exactly the same situation it causes useless +inlining: see `maMB` in test T18140, where the arguments come from strict +fields and the result goes into a constructor field. See (IA2) in +Note [Interesting arguments] in GHC.Core.Opt.Simplify.Utils. + +Being tiny, these functions cost little to inline even when nothing is known +about the argument. Without these pragmas, tests T9872{a,b,c,d} and +TcPlugin_RewritePerf allocated around 2.5% more (Nov 2026), almost all of it +due to out-of-line calls of mkSymMCo from GHC.Tc.Solver.Rewrite. +-} + -- | Compose two MCoercions via transitivity mkTransMCo :: MCoercion -> MCoercion -> MCoercion mkTransMCo MRefl co2 = co2 mkTransMCo co1 MRefl = co1 mkTransMCo (MCo co1) (MCo co2) = MCo (mkTransCo co1 co2) +{-# INLINE mkTransMCo #-} -- See Note [Inline tiny MCo functions] mkTransMCoL :: MCoercion -> Coercion -> MCoercion mkTransMCoL MRefl co2 = coToMCo co2 mkTransMCoL (MCo co1) co2 = MCo (mkTransCo co1 co2) +{-# INLINE mkTransMCoL #-} -- See Note [Inline tiny MCo functions] mkTransMCoR :: Coercion -> MCoercion -> MCoercion mkTransMCoR co1 MRefl = coToMCo co1 mkTransMCoR co1 (MCo co2) = MCo (mkTransCo co1 co2) +{-# INLINE mkTransMCoR #-} -- See Note [Inline tiny MCo functions] -- | Get the reverse of an 'MCoercion' mkSymMCo :: MCoercion -> MCoercion mkSymMCo MRefl = MRefl mkSymMCo (MCo co) = MCo (mkSymCo co) +{-# INLINE mkSymMCo #-} -- See Note [Inline tiny MCo functions] -- | Cast a type by an 'MCoercion' mkCastTyMCo :: Type -> MCoercion -> Type mkCastTyMCo ty MRefl = ty mkCastTyMCo ty (MCo co) = ty `mkCastTy` co +{-# INLINE mkCastTyMCo #-} -- See Note [Inline tiny MCo functions] mkGReflLeftMCo :: Role -> Type -> MCoercionN -> Coercion mkGReflLeftMCo r ty MRefl = mkReflCo r ty mkGReflLeftMCo r ty (MCo co) = mkGReflLeftCo r ty co +{-# INLINE mkGReflLeftMCo #-} -- See Note [Inline tiny MCo functions] mkGReflRightMCo :: Role -> Type -> MCoercionN -> Coercion mkGReflRightMCo r ty MRefl = mkReflCo r ty mkGReflRightMCo r ty (MCo co) = mkGReflRightCo r ty co +{-# INLINE mkGReflRightMCo #-} -- See Note [Inline tiny MCo functions] -- | Like 'mkCoherenceRightCo', but with an 'MCoercion' mkCoherenceRightMCo :: Role -> Type -> MCoercionN -> Coercion -> Coercion mkCoherenceRightMCo _ _ MRefl co2 = co2 mkCoherenceRightMCo r ty (MCo co) co2 = mkCoherenceRightCo r ty co co2 +{-# INLINE mkCoherenceRightMCo #-} -- See Note [Inline tiny MCo functions] isReflMCo :: MCoercion -> Bool isReflMCo MRefl = True ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -1003,9 +1003,10 @@ isStrUsedDmd :: Demand -> Bool isStrUsedDmd (n :* _) = isStrict n && not (isAbs n) -- | Is this demand, taken from the demand signature of a data constructor --- /worker/, the demand for a strict field? The demands in a worker's --- signature are never absent (see GHC.Types.Id.Make.mkDataConWorkId), so --- unlike 'isStrUsedDmd' we don't need to check for absence. +-- /worker/, the demand for a strict field? It would be more obviously correct +-- to use isStrUsedDmd, in case the dmd is Absent. But data constructor workers +-- never have absent arguments, and isStrictDmd is more efficient. +-- See GHC.Types.Id.Make.mkDataConWorkId. isStrDataConDmd :: Demand -> Bool isStrDataConDmd = isStrictDmd ===================================== libraries/ghc-internal/src/GHC/Internal/IO.hs ===================================== @@ -483,7 +483,7 @@ a `finally` sequel = -- | The primitive used to implement 'GHC.IO.evaluate'. -- Prefer to use 'GHC.IO.evaluate' whenever possible! seq# :: forall a s. a -> State# s -> (# State# s, a #) --- See Note [seq# magic] in GHC.Types.Id.Make +-- See Note [seq# magic] in GHC.Builtin.WiredIn.Ids {-# NOINLINE seq# #-} -- seq# is inlined manually in CorePrep seq# a s = let !a' = lazy a in (# s, a' #) ===================================== testsuite/tests/simplCore/should_compile/T26548.hs ===================================== @@ -0,0 +1,7 @@ +module T26548 where + +newtype N a = MkN (Maybe a) +data T = MkT !(N Int) !(N Bool) + +f x = case x of { MkT a b -> + case x of { MkT c d -> MkT a d } } ===================================== testsuite/tests/simplCore/should_compile/T26548.stderr ===================================== @@ -0,0 +1,19 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 3, types: 3, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +f :: T -> T +[GblId, + Arity=1, + Str=<1!P(L,L)>, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True) + Tmpl= \ (x [Occ=Once1] :: T) -> x}] +f = \ (x :: T) -> x + + + ===================================== testsuite/tests/simplCore/should_compile/T26615.stderr ===================================== @@ -2,7 +2,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 1,229, types: 1,163, coercions: 18, joins: 17/29} + = {terms: 1,220, types: 1,160, coercions: 18, joins: 17/29} -- RHS size: {terms: 6, types: 8, coercions: 0, joins: 0/0} unArray :: forall a. Array a -> SmallArray# a @@ -107,7 +107,7 @@ T26615a.$tcLeaf T26615a.$trModule $tcLeaf2 0# - GHC.Internal.Types.krep$*->*->* + krepStarArrStarArr -- RHS size: {terms: 3, types: 2, coercions: 0, joins: 0/0} $krep7 :: [GHC.Internal.Types.KindRep] @@ -181,7 +181,7 @@ T26615a.$tcArray T26615a.$trModule $tcArray2 0# - GHC.Internal.Types.krep$*Arr* + krepStarArr -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} $krep12 :: GHC.Internal.Types.KindRep @@ -251,7 +251,7 @@ T26615a.$tcHashMap T26615a.$trModule $tcHashMap2 0# - GHC.Internal.Types.krep$*->*->* + krepStarArrStarArr -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} $krep16 :: GHC.Internal.Types.KindRep @@ -612,7 +612,7 @@ lvl1 = GHC.Internal.Control.Exception.Base.patError @LiftedRep @() lvl Rec { --- RHS size: {terms: 136, types: 130, coercions: 0, joins: 1/2} +-- RHS size: {terms: 133, types: 129, coercions: 0, joins: 1/2} T26615a.disjointSubtrees_$s$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] :: forall k a b. @@ -635,7 +635,6 @@ T26615a.disjointSubtrees_$s$wdisjointSubtrees Empty -> GHC.Internal.Types.True; Leaf bx ds -> case ds of { L kB ds1 -> - case kB of k0 { __DEFAULT -> case eqWord# bx sc2 of { __DEFAULT -> GHC.Internal.Types.True; 1# -> @@ -668,8 +667,7 @@ T26615a.disjointSubtrees_$s$wdisjointSubtrees } }; } in jump $wlookupInArrayCont_ - sc k0 sc3 0# (sizeofSmallArray# @Lifted @(Leaf k a) sc3) - } + sc kB sc3 0# (sizeofSmallArray# @Lifted @(Leaf k a) sc3) } }; Collision bx bx1 -> @@ -710,7 +708,7 @@ T26615a.disjointSubtrees_$s$wdisjointSubtrees end Rec } Rec { --- RHS size: {terms: 719, types: 748, coercions: 18, joins: 13/23} +-- RHS size: {terms: 713, types: 746, coercions: 18, joins: 13/23} T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] :: forall k a b. Eq k => Int# -> HashMap k a -> HashMap k b -> Bool [GblId[StrictWorker([~, ~, !])], @@ -740,7 +738,6 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] Empty -> GHC.Internal.Types.True; Leaf bx [Occ=Once1] ds2 [Occ=Once1!] -> case ds2 of { L kB [Occ=Once1] _ [Occ=Dead] -> - case kB of k0 [Occ=Once1] { __DEFAULT -> joinrec { lookupCont_ [Occ=LoopBreakerT[5]] :: Eq k => Word -> k -> Int -> HashMap k a -> Bool @@ -868,8 +865,7 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] } }; } in jump lookupCont_ - $dEq (GHC.Internal.Types.W# bx) k0 (GHC.Internal.Types.I# ww) ds - } + $dEq (GHC.Internal.Types.W# bx) kB (GHC.Internal.Types.I# ww) ds }; Collision _ [Occ=Dead] _ [Occ=Dead] -> T26615a.$wdisjointSubtrees @k @b @a $dEq ww wild ds @@ -880,7 +876,6 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] case ds1 of { L kA [Occ=Once2] _ [Occ=Dead] -> case _b of wild2 [Occ=Once1] { __DEFAULT -> - case kA of k0 [Occ=Once1] { __DEFAULT -> joinrec { lookupCont_ [Occ=LoopBreakerT[5]] :: Eq k => Word -> k -> Int -> HashMap k b -> Bool @@ -1004,8 +999,11 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] } }; } in jump lookupCont_ - $dEq (GHC.Internal.Types.W# bx) k0 (GHC.Internal.Types.I# ww) wild2 - }; + $dEq + (GHC.Internal.Types.W# bx) + kA + (GHC.Internal.Types.I# ww) + wild2; Leaf bx1 [Occ=Once1] ds3 [Occ=Once1!] -> case ds3 of { L kB [Occ=Once1] _ [Occ=Dead] -> case GHC.Internal.Classes.neWord @@ -1091,13 +1089,14 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] [LclId[JoinId(1)(Nothing)], Arity=1, Str=<L>, Unf=OtherCon []] go (ds1 [Occ=Once1!] :: Word) = case ds1 of { W# ds2 [Occ=Once1!] -> - case ds2 of ds3 { + case ds2 of wild5 { __DEFAULT -> let { m :: Word# [LclId] m = and# - ds3 (int2Word# (negateInt# (word2Int# ds3))) } in + wild5 + (int2Word# (negateInt# (word2Int# wild5))) } in case indexSmallArray# @Lifted @(HashMap k a) @@ -1118,7 +1117,7 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] of { False -> GHC.Internal.Types.False; True -> - jump go (GHC.Internal.Types.W# (and# ds3 (not# m))) + jump go (GHC.Internal.Types.W# (and# wild5 (not# m))) } } }; @@ -1137,12 +1136,12 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] [LclId[JoinId(1)(Nothing)], Arity=1, Str=<L>, Unf=OtherCon []] go (ds1 [Occ=Once1!] :: Word) = case ds1 of { W# ds2 [Occ=Once1!] -> - case ds2 of ds3 { + case ds2 of wild3 { __DEFAULT -> let { m :: Word# [LclId] - m = and# ds3 (int2Word# (negateInt# (word2Int# ds3))) } in + m = and# wild3 (int2Word# (negateInt# (word2Int# wild3))) } in case indexSmallArray# @Lifted @(HashMap k a) @@ -1161,7 +1160,7 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] case T26615a.$wdisjointSubtrees @k @a @b $dEq (+# ww 5#) ipv ipv1 of { False -> GHC.Internal.Types.False; - True -> jump go (GHC.Internal.Types.W# (and# ds3 (not# m))) + True -> jump go (GHC.Internal.Types.W# (and# wild3 (not# m))) } } }; @@ -1179,12 +1178,12 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] [LclId[JoinId(1)(Nothing)], Arity=1, Str=<L>, Unf=OtherCon []] go (ds1 [Occ=Once1!] :: Word) = case ds1 of { W# ds2 [Occ=Once1!] -> - case ds2 of ds3 { + case ds2 of wild3 { __DEFAULT -> let { m :: Word# [LclId] - m = and# ds3 (int2Word# (negateInt# (word2Int# ds3))) } in + m = and# wild3 (int2Word# (negateInt# (word2Int# wild3))) } in case indexSmallArray# @Lifted @(HashMap k a) @@ -1203,7 +1202,7 @@ T26615a.$wdisjointSubtrees [InlPrag=INLINABLE[2], Occ=LoopBreaker] case T26615a.$wdisjointSubtrees @k @a @b $dEq (+# ww 5#) ipv ipv1 of { False -> GHC.Internal.Types.False; - True -> jump go (GHC.Internal.Types.W# (and# ds3 (not# m))) + True -> jump go (GHC.Internal.Types.W# (and# wild3 (not# m))) } } }; @@ -1277,7 +1276,6 @@ T26615a.$wdisjointSubtrees Empty -> GHC.Internal.Types.True; Leaf bx ds2 -> case ds2 of { L kB ds3 -> - case kB of k0 { __DEFAULT -> join { exit [Dmd=LC(S,C(1,C(1,C(1,L))))] :: Word# -> k -> Word# -> Leaf k a -> Bool @@ -1392,8 +1390,7 @@ T26615a.$wdisjointSubtrees } } }; } in - jump $wlookupCont_ $dEq bx k0 ww ds - } + jump $wlookupCont_ $dEq bx kB ww ds }; Collision bx bx1 -> T26615a.disjointSubtrees_$s$wdisjointSubtrees @@ -1405,7 +1402,6 @@ T26615a.$wdisjointSubtrees case ds1 of { L kA ds2 -> case _b of wild2 { __DEFAULT -> - case kA of k0 { __DEFAULT -> join { exit [Dmd=LC(S,C(1,C(1,C(1,L))))] :: Word# -> k -> Word# -> Leaf k b -> Bool @@ -1519,8 +1515,7 @@ T26615a.$wdisjointSubtrees } } }; } in - jump $wlookupCont_ $dEq bx k0 ww wild2 - }; + jump $wlookupCont_ $dEq bx kA ww wild2; Leaf bx1 ds3 -> case ds3 of { L kB ds4 -> case neWord# bx bx1 of { @@ -1604,12 +1599,12 @@ T26615a.$wdisjointSubtrees $wgo [InlPrag=[2], Occ=LoopBreaker, Dmd=SC(S,L)] :: Word# -> Bool [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] $wgo (ww1 :: Word#) - = case ww1 of ds1 { + = case ww1 of wild4 { __DEFAULT -> let { m :: Word# [LclId] - m = and# ds1 (int2Word# (negateInt# (word2Int# ds1))) } in + m = and# wild4 (int2Word# (negateInt# (word2Int# wild4))) } in case indexSmallArray# @Lifted @(HashMap k a) @@ -1626,7 +1621,7 @@ T26615a.$wdisjointSubtrees { (# ipv1 #) -> case T26615a.$wdisjointSubtrees @k @a @b $dEq lvl2 ipv ipv1 of { False -> GHC.Internal.Types.False; - True -> jump $wgo (and# ds1 (not# m)) + True -> jump $wgo (and# wild4 (not# m)) } } }; @@ -1647,12 +1642,12 @@ T26615a.$wdisjointSubtrees $wgo [InlPrag=[2], Occ=LoopBreaker, Dmd=SC(S,L)] :: Word# -> Bool [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] $wgo (ww1 :: Word#) - = case ww1 of ds1 { + = case ww1 of wild2 { __DEFAULT -> let { m :: Word# [LclId] - m = and# ds1 (int2Word# (negateInt# (word2Int# ds1))) } in + m = and# wild2 (int2Word# (negateInt# (word2Int# wild2))) } in case indexSmallArray# @Lifted @(HashMap k a) @@ -1669,7 +1664,7 @@ T26615a.$wdisjointSubtrees { (# ipv1 #) -> case T26615a.$wdisjointSubtrees @k @a @b $dEq lvl2 ipv ipv1 of { False -> GHC.Internal.Types.False; - True -> jump $wgo (and# ds1 (not# m)) + True -> jump $wgo (and# wild2 (not# m)) } } }; @@ -1689,12 +1684,12 @@ T26615a.$wdisjointSubtrees $wgo [InlPrag=[2], Occ=LoopBreaker, Dmd=SC(S,L)] :: Word# -> Bool [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] $wgo (ww1 :: Word#) - = case ww1 of ds1 { + = case ww1 of wild2 { __DEFAULT -> let { m :: Word# [LclId] - m = and# ds1 (int2Word# (negateInt# (word2Int# ds1))) } in + m = and# wild2 (int2Word# (negateInt# (word2Int# wild2))) } in case indexSmallArray# @Lifted @(HashMap k a) @@ -1711,7 +1706,7 @@ T26615a.$wdisjointSubtrees { (# ipv1 #) -> case T26615a.$wdisjointSubtrees @k @a @b $dEq lvl2 ipv ipv1 of { False -> GHC.Internal.Types.False; - True -> jump $wgo (and# ds1 (not# m)) + True -> jump $wgo (and# wild2 (not# m)) } } }; @@ -1845,32 +1840,7 @@ disjointSubtrees ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 622, types: 674, coercions: 18, joins: 8/14} - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -$trModule1 :: GHC.Internal.Prim.Addr# -[GblId, Unf=OtherCon []] -$trModule1 = "T26615"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -$trModule2 :: GHC.Internal.Types.TrName -[GblId, Unf=OtherCon []] -$trModule2 = GHC.Internal.Types.TrNameS $trModule1 - --- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} -$trModule3 :: GHC.Internal.Prim.Addr# -[GblId, Unf=OtherCon []] -$trModule3 = "main"# - --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -$trModule4 :: GHC.Internal.Types.TrName -[GblId, Unf=OtherCon []] -$trModule4 = GHC.Internal.Types.TrNameS $trModule3 - --- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} -T26615.$trModule [InlPrag=[~]] :: GHC.Internal.Types.Module -[GblId, Unf=OtherCon []] -T26615.$trModule = GHC.Internal.Types.Module $trModule4 $trModule2 + = {terms: 603, types: 666, coercions: 18, joins: 8/14} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} lvl :: GHC.Internal.Prim.Addr# @@ -2029,7 +1999,7 @@ $wpoly_lookupCont_ end Rec } Rec { --- RHS size: {terms: 450, types: 507, coercions: 18, joins: 8/13} +-- RHS size: {terms: 445, types: 504, coercions: 18, joins: 8/13} T26615.$s$wdisjointSubtrees [InlPrag=[~], Occ=LoopBreaker] :: forall a b. GHC.Internal.Prim.Int# @@ -2067,11 +2037,7 @@ T26615.$s$wdisjointSubtrees T26615a.Leaf bx1 ds3 -> case ds3 of { T26615a.L kB ds4 -> case GHC.Internal.Prim.neWord# bx bx1 of { - __DEFAULT -> - case GHC.Internal.Classes.$fEqList_$s$c==1 kA kB of { - False -> GHC.Internal.Types.True; - True -> GHC.Internal.Types.False - }; + __DEFAULT -> GHC.Internal.Classes.$fEqList_$s$c/=1 kA kB; 1# -> GHC.Internal.Types.True } } @@ -2094,14 +2060,14 @@ T26615.$s$wdisjointSubtrees $s$wfoldr_ [InlPrag=[2], Occ=LoopBreaker, Dmd=SC(S,C(1,C(1,C(1,L))))] - :: GHC.Internal.Prim.SmallArray# (T26615a.Leaf [Char] a) + :: GHC.Internal.Prim.SmallArray# (T26615a.Leaf String a) -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Int# -> Bool -> Bool [LclId[JoinId(4)(Nothing)], Arity=4, Str=<L><L><L><L>, Unf=OtherCon []] $s$wfoldr_ (sc - :: GHC.Internal.Prim.SmallArray# (T26615a.Leaf [Char] a)) + :: GHC.Internal.Prim.SmallArray# (T26615a.Leaf String a)) (sc1 :: GHC.Internal.Prim.Int#) (sc2 :: GHC.Internal.Prim.Int#) (sc3 :: Bool) @@ -2243,16 +2209,16 @@ T26615.$s$wdisjointSubtrees :: GHC.Internal.Prim.Word# -> Bool [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] $wgo (ww1 :: GHC.Internal.Prim.Word#) - = case ww1 of ds3 { + = case ww1 of wild5 { __DEFAULT -> let { m :: GHC.Internal.Prim.Word# [LclId] m = GHC.Internal.Prim.and# - ds3 + wild5 (GHC.Internal.Prim.int2Word# (GHC.Internal.Prim.negateInt# - (GHC.Internal.Prim.word2Int# ds3))) } in + (GHC.Internal.Prim.word2Int# wild5))) } in case GHC.Internal.Prim.indexSmallArray# @GHC.Internal.Types.Lifted @(HashMap String a) @@ -2279,7 +2245,7 @@ T26615.$s$wdisjointSubtrees False -> GHC.Internal.Types.False; True -> jump $wgo - (GHC.Internal.Prim.and# ds3 (GHC.Internal.Prim.not# m)) + (GHC.Internal.Prim.and# wild5 (GHC.Internal.Prim.not# m)) } } }; @@ -2297,16 +2263,16 @@ T26615.$s$wdisjointSubtrees :: GHC.Internal.Prim.Word# -> Bool [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] $wgo (ww1 :: GHC.Internal.Prim.Word#) - = case ww1 of ds3 { + = case ww1 of wild3 { __DEFAULT -> let { m :: GHC.Internal.Prim.Word# [LclId] m = GHC.Internal.Prim.and# - ds3 + wild3 (GHC.Internal.Prim.int2Word# (GHC.Internal.Prim.negateInt# - (GHC.Internal.Prim.word2Int# ds3))) } in + (GHC.Internal.Prim.word2Int# wild3))) } in case GHC.Internal.Prim.indexSmallArray# @GHC.Internal.Types.Lifted @(HashMap String a) @@ -2332,7 +2298,7 @@ T26615.$s$wdisjointSubtrees of { False -> GHC.Internal.Types.False; True -> - jump $wgo (GHC.Internal.Prim.and# ds3 (GHC.Internal.Prim.not# m)) + jump $wgo (GHC.Internal.Prim.and# wild3 (GHC.Internal.Prim.not# m)) } } }; @@ -2349,16 +2315,16 @@ T26615.$s$wdisjointSubtrees :: GHC.Internal.Prim.Word# -> Bool [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] $wgo (ww1 :: GHC.Internal.Prim.Word#) - = case ww1 of ds3 { + = case ww1 of wild3 { __DEFAULT -> let { m :: GHC.Internal.Prim.Word# [LclId] m = GHC.Internal.Prim.and# - ds3 + wild3 (GHC.Internal.Prim.int2Word# (GHC.Internal.Prim.negateInt# - (GHC.Internal.Prim.word2Int# ds3))) } in + (GHC.Internal.Prim.word2Int# wild3))) } in case GHC.Internal.Prim.indexSmallArray# @GHC.Internal.Types.Lifted @(HashMap String a) @@ -2384,7 +2350,7 @@ T26615.$s$wdisjointSubtrees of { False -> GHC.Internal.Types.False; True -> - jump $wgo (GHC.Internal.Prim.and# ds3 (GHC.Internal.Prim.not# m)) + jump $wgo (GHC.Internal.Prim.and# wild3 (GHC.Internal.Prim.not# m)) } } }; ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -602,6 +602,7 @@ test('T26615', [grep_errmsg(r'fEqList')], multimod_compile, ['T26615', '-O -fsp # T26722: there should be no reboxing in $wg test('T26722', [grep_errmsg(r'SPEC')], compile, ['-O -dno-typeable-binds']) +test('T26548', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds']) test('T26805', [grep_errmsg(r'fromInteger')], compile, ['-O -dno-typeable-binds -ddump-simpl -dsuppress-uniques']) test('T26826', normal, compile, ['-O']) test('T26903', [grep_errmsg(r'reverse')], compile, ['-O -dno-typeable-binds -ddump-simpl -dsuppress-uniques -dsuppress-all']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea77df4174d336ee1d04fee371a4d74... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea77df4174d336ee1d04fee371a4d74... 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)