Simon Peyton Jones pushed to branch wip/T26989 at Glasgow Haskell Compiler / GHC
Commits:
-
d2ad273a
by Simon Peyton Jones at 2026-04-26T17:50:21+01:00
-
9e642e00
by Simon Peyton Jones at 2026-04-27T00:11:49+01:00
25 changed files:
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- testsuite/tests/codeGen/should_compile/T25177.stderr
- testsuite/tests/deSugar/should_compile/T13208.stdout
- testsuite/tests/numeric/should_compile/T15547.stderr
- testsuite/tests/numeric/should_compile/T20347.stderr
- testsuite/tests/numeric/should_compile/T20374.stderr
- testsuite/tests/numeric/should_compile/T20376.stderr
- testsuite/tests/printer/T18052a.stderr
- testsuite/tests/simplCore/should_compile/DsSpecPragmas.stderr
- testsuite/tests/simplCore/should_compile/RewriteHigherOrderPatterns.stderr
- testsuite/tests/simplCore/should_compile/T18668.stderr
- testsuite/tests/simplCore/should_compile/T19246.stderr
- testsuite/tests/simplCore/should_compile/T19599.stderr
- testsuite/tests/simplCore/should_compile/T19599a.stderr
- testsuite/tests/simplCore/should_compile/T21917.stderr
- testsuite/tests/simplCore/should_compile/T23074.stderr
- testsuite/tests/simplCore/should_compile/T25160.stderr
- testsuite/tests/simplCore/should_compile/T25718c.stderr-ws-64
- testsuite/tests/simplCore/should_compile/T26051.stderr
- testsuite/tests/simplCore/should_compile/T26116.stderr
- testsuite/tests/simplCore/should_compile/T8331.stderr
- testsuite/tests/simplCore/should_compile/T8848a.stderr
- testsuite/tests/typecheck/should_compile/T13032.stderr
Changes:
| ... | ... | @@ -28,7 +28,7 @@ module GHC.Core.Opt.Simplify.Env ( |
| 28 | 28 | SimplEnvIS, checkSimplEnvIS, pprBadSimplEnvIS,
|
| 29 | 29 | |
| 30 | 30 | -- * Substitution results
|
| 31 | - SimplSR(..), mkContEx, substId, lookupRecBndr,
|
|
| 31 | + SimplSR(..), substId, lookupRecBndr,
|
|
| 32 | 32 | |
| 33 | 33 | -- * Simplifying 'Id' binders
|
| 34 | 34 | simplNonRecBndr, simplNonRecJoinBndr, simplRecBndrs, simplRecJoinBndrs,
|
| ... | ... | @@ -488,12 +488,11 @@ data SimplSR |
| 488 | 488 | -- and v is a join-point of arity a
|
| 489 | 489 | -- <=> x is a join-point of arity a
|
| 490 | 490 | |
| 491 | - | ContEx TvSubstEnv -- A suspended substitution
|
|
| 492 | - CvSubstEnv
|
|
| 493 | - SimplIdSubst
|
|
| 491 | + | ContEx SimplEnv
|
|
| 494 | 492 | InExpr
|
| 495 | - -- If x :-> ContEx tv cv id e is in the SimplISubst
|
|
| 496 | - -- then replace occurrences of x by (subst (tv,cv,id) e)
|
|
| 493 | + MOutCoercion
|
|
| 494 | + -- If x :-> ContEx static_env e mco is in the SimplISubst
|
|
| 495 | + -- then replace occurrences of x by (subst (tv,cv,id) e) |> mco
|
|
| 497 | 496 | |
| 498 | 497 | instance Outputable SimplSR where
|
| 499 | 498 | ppr (DoneId v) = text "DoneId" <+> ppr v
|
| ... | ... | @@ -503,8 +502,8 @@ instance Outputable SimplSR where |
| 503 | 502 | NotJoinPoint -> empty
|
| 504 | 503 | JoinPoint n -> parens (int n)
|
| 505 | 504 | |
| 506 | - ppr (ContEx _tv _cv _id e) = vcat [text "ContEx" <+> ppr e {-,
|
|
| 507 | - ppr (filter_env tv), ppr (filter_env id) -}]
|
|
| 505 | + ppr (ContEx _env e _mco) = text "ContEx" <+> ppr e
|
|
| 506 | + -- ppr (filter_env tv), ppr (filter_env id)
|
|
| 508 | 507 | -- where
|
| 509 | 508 | -- fvs = exprFreeVars e
|
| 510 | 509 | -- filter_env env = filterVarEnv_Directly keep env
|
| ... | ... | @@ -736,9 +735,6 @@ zapSubstEnv env@(SimplEnv { seInlineDepth = n }) |
| 736 | 735 | setSubstEnv :: SimplEnv -> TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> SimplEnv
|
| 737 | 736 | setSubstEnv env tvs cvs ids = env { seTvSubst = tvs, seCvSubst = cvs, seIdSubst = ids }
|
| 738 | 737 | |
| 739 | -mkContEx :: SimplEnv -> InExpr -> SimplSR
|
|
| 740 | -mkContEx (SimplEnv { seTvSubst = tvs, seCvSubst = cvs, seIdSubst = ids }) e = ContEx tvs cvs ids e
|
|
| 741 | - |
|
| 742 | 738 | {-
|
| 743 | 739 | ************************************************************************
|
| 744 | 740 | * *
|
| ... | ... | @@ -1368,17 +1364,15 @@ getTCvSubst (SimplEnv { seInScope = in_scope, seTvSubst = tv_env, seCvSubst = cv |
| 1368 | 1364 | |
| 1369 | 1365 | getFullSubst :: InScopeSet -> SimplEnv -> Subst
|
| 1370 | 1366 | getFullSubst in_scope (SimplEnv { seIdSubst = id_env, seTvSubst = tv_env, seCvSubst = cv_env })
|
| 1371 | - = mk_full_subst in_scope tv_env cv_env id_env
|
|
| 1372 | - |
|
| 1373 | -mk_full_subst :: InScopeSet -> TvSubstEnv -> CvSubstEnv -> SimplIdSubst -> Subst
|
|
| 1374 | -mk_full_subst in_scope tv_env cv_env id_env
|
|
| 1375 | 1367 | = mkSubst in_scope (mapVarEnv to_expr id_env) tv_env cv_env
|
| 1376 | 1368 | where
|
| 1377 | 1369 | to_expr :: SimplSR -> CoreExpr
|
| 1378 | 1370 | -- A tiresome impedence-matcher
|
| 1379 | - to_expr (DoneEx e _) = e
|
|
| 1380 | - to_expr (DoneId v) = Var v
|
|
| 1381 | - to_expr (ContEx tvs cvs ids e) = GHC.Core.Subst.substExprSC (mk_full_subst in_scope tvs cvs ids) e
|
|
| 1371 | + to_expr (DoneEx e _) = e
|
|
| 1372 | + to_expr (DoneId v) = Var v
|
|
| 1373 | + to_expr (ContEx env e mco) = mkCastMCo e' mco
|
|
| 1374 | + where
|
|
| 1375 | + e' = GHC.Core.Subst.substExprSC (getFullSubst in_scope env) e
|
|
| 1382 | 1376 | |
| 1383 | 1377 | substTy :: HasDebugCallStack => SimplEnv -> Type -> Type
|
| 1384 | 1378 | substTy env ty = Type.substTy (getTCvSubst env) ty
|
| ... | ... | @@ -283,7 +283,7 @@ simplRecOrTopPair :: SimplEnv |
| 283 | 283 | |
| 284 | 284 | simplRecOrTopPair env bind_cxt old_bndr new_bndr rhs
|
| 285 | 285 | | Just env' <- preInlineUnconditionally env (bindContextLevel bind_cxt)
|
| 286 | - old_bndr rhs (UnSimplified env)
|
|
| 286 | + old_bndr (UnSimplified env) rhs MRefl
|
|
| 287 | 287 | = {-#SCC "simplRecOrTopPair-pre-inline-uncond" #-}
|
| 288 | 288 | simplTrace "SimplBindr:inline-uncond1" (ppr old_bndr) $
|
| 289 | 289 | do { tick (PreInlineUnconditionally old_bndr)
|
| ... | ... | @@ -1263,7 +1263,7 @@ simplExprF1 env (App fun arg) cont |
| 1263 | 1263 | simplExprF env fun $
|
| 1264 | 1264 | ApplyToVal { sc_arg = arg, sc_env = UnSimplified env
|
| 1265 | 1265 | , sc_hole_ty = substTy env (exprType fun)
|
| 1266 | - , sc_cont = cont }
|
|
| 1266 | + , sc_cast = MRefl, sc_cont = cont }
|
|
| 1267 | 1267 | |
| 1268 | 1268 | simplExprF1 env expr@(Lam {}) cont
|
| 1269 | 1269 | = {-#SCC "simplExprF1-Lam" #-}
|
| ... | ... | @@ -1298,7 +1298,7 @@ simplExprF1 env (Let (NonRec bndr rhs) body) cont |
| 1298 | 1298 | do { ty' <- simplType env ty
|
| 1299 | 1299 | ; simplExprF (extendTvSubst env bndr ty') body cont }
|
| 1300 | 1300 | |
| 1301 | - | Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs (UnSimplified env)
|
|
| 1301 | + | Just env' <- preInlineUnconditionally env NotTopLevel bndr (UnSimplified env) rhs MRefl
|
|
| 1302 | 1302 | -- Because of the let-can-float invariant, it's ok to
|
| 1303 | 1303 | -- inline freely, or to drop the binding if it is dead.
|
| 1304 | 1304 | = do { simplTrace "SimplBindr:inline-uncond2" (ppr bndr) $
|
| ... | ... | @@ -1606,10 +1606,10 @@ rebuild_go env expr cont |
| 1606 | 1606 | ApplyToTy { sc_arg_ty = ty, sc_cont = cont}
|
| 1607 | 1607 | -> rebuild_go env (App expr (Type ty)) cont
|
| 1608 | 1608 | |
| 1609 | - ApplyToVal { sc_arg = arg, sc_env = se
|
|
| 1609 | + ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cast = arg_mco
|
|
| 1610 | 1610 | , sc_cont = cont, sc_hole_ty = fun_ty }
|
| 1611 | 1611 | -- See Note [Avoid redundant simplification]
|
| 1612 | - -> do { (_, arg') <- simplArg env fun_ty Nothing se arg
|
|
| 1612 | + -> do { arg' <- simplArg env Nothing fun_ty arg_se arg arg_mco
|
|
| 1613 | 1613 | ; rebuild_go env (App expr arg') cont }
|
| 1614 | 1614 | |
| 1615 | 1615 | completeBindX :: SimplEnv
|
| ... | ... | @@ -1728,6 +1728,11 @@ optOutCoercion env co already_optimised |
| 1728 | 1728 | empty_subst = mkEmptySubst (seInScope env)
|
| 1729 | 1729 | opts = seOptCoercionOpts env
|
| 1730 | 1730 | |
| 1731 | +addCastMCo :: MOutCoercion -> SimplCont -> SimplCont
|
|
| 1732 | +-- Simpler version of `pushCast` when optionally want to add a cast to the top
|
|
| 1733 | +addCastMCo MRefl cont = cont
|
|
| 1734 | +addCastMCo (MCo co) cont = CastIt { sc_co = co, sc_opt = False, sc_cont = cont }
|
|
| 1735 | + |
|
| 1731 | 1736 | pushCast :: SimplEnv -> OutCoercion -> SimplCont -> SimplM SimplCont
|
| 1732 | 1737 | pushCast env co cont
|
| 1733 | 1738 | = go co True cont
|
| ... | ... | @@ -1753,8 +1758,7 @@ pushCast env co cont |
| 1753 | 1758 | -- co1 :: t1 ~ s1
|
| 1754 | 1759 | -- co2 :: s2 ~ t2
|
| 1755 | 1760 | go co co_is_opt cont@(ApplyToVal { sc_arg = arg, sc_env = arg_se
|
| 1756 | - , sc_cont = tail
|
|
| 1757 | - , sc_hole_ty = fun_ty })
|
|
| 1761 | + , sc_cast = arg_mco, sc_cont = tail })
|
|
| 1758 | 1762 | | not co_is_opt
|
| 1759 | 1763 | = -- pushCoValArg duplicates the coercion, so optimise first
|
| 1760 | 1764 | go (optOutCoercion (zapSubstEnv env) co co_is_opt) True cont
|
| ... | ... | @@ -1762,22 +1766,11 @@ pushCast env co cont |
| 1762 | 1766 | | Just (m_co1, m_co2) <- pushCoValArg co
|
| 1763 | 1767 | = {-#SCC "addCoerce-pushCoValArg" #-}
|
| 1764 | 1768 | do { tail' <- go_mco m_co2 co_is_opt tail
|
| 1765 | - ; case m_co1 of {
|
|
| 1766 | - MRefl -> return (cont { sc_cont = tail'
|
|
| 1767 | - , sc_hole_ty = coercionLKind co }) ;
|
|
| 1768 | - -- See Note [Avoiding simplifying repeatedly]
|
|
| 1769 | - |
|
| 1770 | - MCo co1 ->
|
|
| 1771 | - do { (arg_se', arg') <- simplArg env fun_ty Nothing arg_se arg
|
|
| 1772 | - -- When we build the ApplyTo we can't mix the OutCoercion
|
|
| 1773 | - -- 'co' with the InExpr 'arg', so we simplify
|
|
| 1774 | - -- to make it all consistent. It's a bit messy.
|
|
| 1775 | - -- But it isn't a common case.
|
|
| 1776 | - -- Example of use: #995
|
|
| 1777 | - ; return (ApplyToVal { sc_arg = mkCast arg' co1
|
|
| 1778 | - , sc_env = arg_se'
|
|
| 1769 | + ; return (ApplyToVal { sc_arg = arg
|
|
| 1770 | + , sc_env = arg_se
|
|
| 1771 | + , sc_cast = m_co1 `mkTransMCo` arg_mco
|
|
| 1779 | 1772 | , sc_cont = tail'
|
| 1780 | - , sc_hole_ty = coercionLKind co }) } } }
|
|
| 1773 | + , sc_hole_ty = coercionLKind co }) }
|
|
| 1781 | 1774 | |
| 1782 | 1775 | go co co_is_opt cont
|
| 1783 | 1776 | | isReflCo co = return cont -- Having this at the end makes a huge
|
| ... | ... | @@ -1793,25 +1786,24 @@ pushCast env co cont |
| 1793 | 1786 | go_mco (MCo co) opt cont = go co opt cont
|
| 1794 | 1787 | |
| 1795 | 1788 | simplArg :: SimplEnvIS -- ^ Used only for its InScopeSet
|
| 1796 | - -> OutType -- ^ Type of the function applied to this arg
|
|
| 1797 | 1789 | -> Maybe ArgInfo -- ^ Just <=> This arg `ai` occurs in an app
|
| 1798 | 1790 | -- `f a1 ... an` where we have ArgInfo on
|
| 1799 | 1791 | -- how `f` uses `ai`, affecting the Stop
|
| 1800 | 1792 | -- continuation passed to 'simplExprC'
|
| 1793 | + -> OutType -- ^ Type of the function applied to this arg
|
|
| 1801 | 1794 | -> StaticEnv -> CoreExpr -- ^ Expression with its static envt
|
| 1802 | - -> SimplM (StaticEnv, OutExpr)
|
|
| 1803 | -simplArg _ _ _ se@(Simplified {}) arg
|
|
| 1804 | - = return (se, arg)
|
|
| 1805 | -simplArg env fun_ty mb_arg_info (UnSimplified arg_se) arg
|
|
| 1795 | + -> MOutCoercion -- Wrap this around the result
|
|
| 1796 | + -> SimplM OutExpr
|
|
| 1797 | +simplArg _ _ _ (Simplified {}) arg mco
|
|
| 1798 | + = return (mkCastMCo arg mco)
|
|
| 1799 | +simplArg env mb_arg_info fun_ty (UnSimplified arg_se) arg mco
|
|
| 1806 | 1800 | = do { let arg_env' = arg_se `setInScopeFromE` env
|
| 1807 | 1801 | arg_ty = funArgTy fun_ty
|
| 1808 | 1802 | stop = case mb_arg_info of
|
| 1809 | - Nothing -> mkBoringStop arg_ty
|
|
| 1810 | - Just ai -> mkLazyArgStop arg_ty ai
|
|
| 1811 | - ; arg' <- simplExprC arg_env' arg stop
|
|
| 1812 | - ; return (Simplified NoDup, arg') }
|
|
| 1813 | - -- Return a StaticEnv that includes the in-scope set from 'env',
|
|
| 1814 | - -- because arg' may well mention those variables (#20639)
|
|
| 1803 | + Nothing -> mkBoringStop arg_ty
|
|
| 1804 | + Just ai -> mkLazyArgStop arg_ty ai
|
|
| 1805 | + cont = addCastMCo mco stop
|
|
| 1806 | + ; simplExprC arg_env' arg cont }
|
|
| 1815 | 1807 | |
| 1816 | 1808 | {-
|
| 1817 | 1809 | ************************************************************************
|
| ... | ... | @@ -1844,54 +1836,67 @@ simpl_lam env bndr body (ApplyToTy { sc_arg_ty = arg_ty, sc_cont = cont }) |
| 1844 | 1836 | = do { tick (BetaReduction bndr)
|
| 1845 | 1837 | ; simplLam (extendTvSubst env bndr arg_ty) body cont }
|
| 1846 | 1838 | |
| 1839 | +{- Next case handles this
|
|
| 1847 | 1840 | -- Coercion beta-reduction
|
| 1848 | 1841 | simpl_lam env bndr body (ApplyToVal { sc_arg = Coercion arg_co, sc_env = arg_se
|
| 1849 | - , sc_cont = cont })
|
|
| 1842 | + , sc_cast = arg_mco, sc_cont = cont })
|
|
| 1843 | + | let arg_co' = case arg_se of
|
|
| 1844 | + Simplified {} -> arg_co
|
|
| 1845 | + UnSimplified arg_se -> substCo (arg_se `setInScopeFromE` env) arg_co
|
|
| 1846 | + , Just final_arg_co <- case mco of -- C.f. GHC.Core.Utils.mkCast
|
|
| 1847 | + MRefl -> Just arg_co'
|
|
| 1848 | + MCo co' | isEqPred (coercionRKind co')
|
|
| 1849 | + -> Just (mkCoCast arg_co' co')
|
|
| 1850 | + | otherwise
|
|
| 1851 | + -> Nothing
|
|
| 1850 | 1852 | = assertPpr (isCoVar bndr) (ppr bndr) $
|
| 1851 | 1853 | do { tick (BetaReduction bndr)
|
| 1852 | - ; let arg_co' = case arg_se of
|
|
| 1853 | - Simplified {} -> arg_co
|
|
| 1854 | - UnSimplified arg_se -> substCo (arg_se `setInScopeFromE` env) arg_co
|
|
| 1855 | 1854 | ; simplLam (extendCvSubst env bndr arg_co') body cont }
|
| 1855 | +-}
|
|
| 1856 | 1856 | |
| 1857 | 1857 | -- Value beta-reduction
|
| 1858 | 1858 | -- This works for /coercion/ lambdas too
|
| 1859 | 1859 | simpl_lam env bndr body (ApplyToVal { sc_arg = arg, sc_env = arg_se
|
| 1860 | - , sc_cont = cont
|
|
| 1860 | + , sc_cast = arg_mco, sc_cont = cont
|
|
| 1861 | 1861 | , sc_hole_ty = fun_ty})
|
| 1862 | - = do { tick (BetaReduction bndr)
|
|
| 1863 | - ; let from_what = FromBeta arg_levity
|
|
| 1864 | - arg_levity
|
|
| 1865 | - | isForAllTy fun_ty = assertPpr (isCoVar bndr) (ppr bndr) Unlifted
|
|
| 1866 | - | otherwise = typeLevity (funArgTy fun_ty)
|
|
| 1867 | - -- Example: (\(cv::a ~# b). blah) co
|
|
| 1868 | - -- The type of (\cv.blah) can be (forall cv. ty); see GHC.Core.Utils.mkLamType
|
|
| 1869 | - |
|
| 1870 | - -- Using fun_ty: see Note [Dark corner with representation polymorphism]
|
|
| 1871 | - -- e.g (\r \(a::TYPE r) \(x::a). blah) @LiftedRep @Int arg
|
|
| 1872 | - -- When we come to `x=arg` we must choose lazy/strict correctly
|
|
| 1873 | - -- It's wrong to err in either direction
|
|
| 1874 | - -- But fun_ty is an OutType, so is fully substituted
|
|
| 1875 | - |
|
| 1876 | - ; if | Just env' <- preInlineUnconditionally env NotTopLevel bndr arg arg_se
|
|
| 1877 | - , not (needsCaseBindingL arg_levity arg)
|
|
| 1862 | + | Just env' <- preInlineUnconditionally env NotTopLevel bndr arg_se arg arg_mco
|
|
| 1863 | + , not (needsCaseBindingL arg_levity arg)
|
|
| 1878 | 1864 | -- Ok to test arg::InExpr in needsCaseBinding because
|
| 1879 | 1865 | -- exprOkForSpeculation is stable under simplification
|
| 1880 | - -> do { simplTrace "SimplBindr:inline-uncond3" (ppr bndr <+> text ":=" <+> ppr arg $$ ppr (seIdSubst env)) $
|
|
| 1881 | - tick (PreInlineUnconditionally bndr)
|
|
| 1882 | - ; simplLam env' body cont }
|
|
| 1883 | - |
|
| 1884 | - | otherwise
|
|
| 1885 | - -> case arg_se of
|
|
| 1886 | - Simplified {}
|
|
| 1887 | - -- Don't re-simplify if we've simplified it once
|
|
| 1888 | - -- Including don't preInlineUnconditionally
|
|
| 1889 | - -- See Note [Avoiding simplifying repeatedly]
|
|
| 1890 | - -> completeBindX env from_what bndr arg body cont
|
|
| 1891 | - |
|
| 1892 | - UnSimplified arg_env
|
|
| 1893 | - -> simplNonRecE env from_what bndr (arg, arg_env) body cont
|
|
| 1866 | + = simplTrace "SimplBindr:inline-uncond3"
|
|
| 1867 | + (vcat [ ppr bndr <+> text ":=" <+> ppr arg
|
|
| 1868 | + , ppr (seIdSubst env) ]) $
|
|
| 1869 | + do { tick (BetaReduction bndr)
|
|
| 1870 | + ; tick (PreInlineUnconditionally bndr)
|
|
| 1871 | + ; simplLam env' body cont }
|
|
| 1872 | + |
|
| 1873 | + | otherwise
|
|
| 1874 | + = do { tick (BetaReduction bndr)
|
|
| 1875 | + ; let from_what = FromBeta arg_levity
|
|
| 1876 | + |
|
| 1877 | + ; case (arg_se, arg_mco) of
|
|
| 1878 | + (UnSimplified arg_env, MRefl)
|
|
| 1879 | + -- Optimisation: when there is no wrapping coercion use simplNonRecE
|
|
| 1880 | + -- so that the clever floating out of let-bindings can take place
|
|
| 1881 | + -- in this round of the Simplifier
|
|
| 1882 | + -> simplNonRecE env from_what bndr (arg, arg_env) body cont
|
|
| 1883 | + |
|
| 1884 | + _ -> do { arg' <- simplArg env Nothing fun_ty arg_se arg arg_mco
|
|
| 1885 | + ; completeBindX env from_what bndr arg' body cont }
|
|
| 1894 | 1886 | }
|
| 1887 | + where
|
|
| 1888 | + arg_levity
|
|
| 1889 | + | isForAllTy fun_ty = assertPpr (isCoVar bndr) (ppr bndr) Unlifted
|
|
| 1890 | + | otherwise = typeLevity (funArgTy fun_ty)
|
|
| 1891 | + -- Example: (\(cv::a ~# b). blah) co
|
|
| 1892 | + -- The type of (\cv.blah) can be (forall cv. ty); see GHC.Core.Utils.mkLamType
|
|
| 1893 | + |
|
| 1894 | + -- Using fun_ty: see Note [Dark corner with representation polymorphism]
|
|
| 1895 | + -- e.g (\r \(a::TYPE r) \(x::a). blah) @LiftedRep @Int arg
|
|
| 1896 | + -- When we come to `x=arg` we must choose lazy/strict correctly
|
|
| 1897 | + -- It's wrong to err in either direction
|
|
| 1898 | + -- But fun_ty is an OutType, so is fully substituted
|
|
| 1899 | + |
|
| 1895 | 1900 | |
| 1896 | 1901 | -- Discard a non-counting tick on a lambda. This may change the
|
| 1897 | 1902 | -- cost attribution slightly (moving the allocation of the
|
| ... | ... | @@ -2289,17 +2294,18 @@ simplInId env var cont |
| 2289 | 2294 | = rebuild env (Var var) cont
|
| 2290 | 2295 | | otherwise
|
| 2291 | 2296 | = case substId env var of
|
| 2292 | - ContEx tvs cvs ids e -> simplExprF env' e cont
|
|
| 2297 | + ContEx se e mco
|
|
| 2298 | + -> simplExprF (se `setInScopeFromE` env) e (addCastMCo mco cont)
|
|
| 2293 | 2299 | -- Don't trimJoinCont; haven't already simplified e,
|
| 2294 | 2300 | -- so the cont is not embodied in e
|
| 2295 | - where
|
|
| 2296 | - env' = setSubstEnv env tvs cvs ids
|
|
| 2297 | 2301 | |
| 2298 | - DoneId out_id -> simplOutId zapped_env out_id cont'
|
|
| 2302 | + DoneId out_id
|
|
| 2303 | + -> simplOutId zapped_env out_id cont'
|
|
| 2299 | 2304 | where
|
| 2300 | 2305 | cont' = trimJoinCont out_id (idJoinPointHood out_id) cont
|
| 2301 | 2306 | |
| 2302 | - DoneEx e mb_join -> simplOutExpr zapped_env e cont'
|
|
| 2307 | + DoneEx e mb_join
|
|
| 2308 | + -> simplOutExpr zapped_env e cont'
|
|
| 2303 | 2309 | where
|
| 2304 | 2310 | cont' = trimJoinCont var mb_join cont
|
| 2305 | 2311 | where
|
| ... | ... | @@ -2353,12 +2359,12 @@ simplOutId :: SimplEnvIS -> OutId -> SimplCont -> SimplM (SimplFloats, OutExpr) |
| 2353 | 2359 | -- See Note [Simplification of runRW#] in GHC.CoreToSTG.Prep.
|
| 2354 | 2360 | --
|
| 2355 | 2361 | -- runRW# :: forall (r :: RuntimeRep) (o :: TYPE r). (State# RealWorld -> o) -> o
|
| 2356 | --- K[ runRW# @rr @hole_ty body ] --> runRW @rr' @ty' (\s. K[ body s ])
|
|
| 2362 | +-- K[ runRW# @rr @hole_ty arg ] --> runRW @rr' @ty' (\s. K[ arg s ])
|
|
| 2357 | 2363 | simplOutId env fun cont
|
| 2358 | 2364 | | fun `hasKey` runRWKey
|
| 2359 | 2365 | , ApplyToTy { sc_cont = cont1 } <- cont
|
| 2360 | 2366 | , ApplyToTy { sc_cont = cont2, sc_arg_ty = hole_ty } <- cont1
|
| 2361 | - , ApplyToVal { sc_cont = cont3, sc_arg = arg
|
|
| 2367 | + , ApplyToVal { sc_cont = cont3, sc_arg = arg, sc_cast = arg_mco
|
|
| 2362 | 2368 | , sc_env = arg_se, sc_hole_ty = fun_ty } <- cont2
|
| 2363 | 2369 | -- Do this even if (contIsStop cont), or if seCaseCase is off.
|
| 2364 | 2370 | -- See Note [No eta-expansion in runRW#]
|
| ... | ... | @@ -2387,7 +2393,8 @@ simplOutId env fun cont |
| 2387 | 2393 | _ -> do { s' <- newId (fsLit "s") ManyTy realWorldStatePrimTy
|
| 2388 | 2394 | ; let (m,_,_) = splitFunTy fun_ty
|
| 2389 | 2395 | env' = arg_env `addNewInScopeIds` [s']
|
| 2390 | - cont' = ApplyToVal { sc_arg = Var s'
|
|
| 2396 | + cont' = addCastMCo arg_mco $
|
|
| 2397 | + ApplyToVal { sc_arg = Var s', sc_cast = MRefl
|
|
| 2391 | 2398 | , sc_env = Simplified OkDup, sc_cont = inner_cont
|
| 2392 | 2399 | , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy new_runrw_res_ty }
|
| 2393 | 2400 | -- cont' applies to s', then K
|
| ... | ... | @@ -2472,16 +2479,17 @@ rebuildCall env info (ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_c |
| 2472 | 2479 | |
| 2473 | 2480 | ---------- Simplify value arguments --------------------
|
| 2474 | 2481 | rebuildCall env fun_info
|
| 2475 | - (ApplyToVal { sc_arg = arg, sc_env = arg_se
|
|
| 2482 | + (ApplyToVal { sc_arg = arg, sc_env = arg_se, sc_cast = arg_mco
|
|
| 2476 | 2483 | , sc_hole_ty = fun_ty, sc_cont = cont })
|
| 2477 | 2484 | | UnSimplified arg_env <- arg_se
|
| 2478 | 2485 | , isStrictArgInfo fun_info -- Strict arguments
|
| 2479 | 2486 | , seCaseCase env -- But only when case-of-case is on.
|
| 2480 | 2487 | -- See Note [Case-of-case and full laziness]
|
| 2481 | - = simplExprF (arg_env `setInScopeFromE` env) arg
|
|
| 2482 | - (StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty
|
|
| 2483 | - , sc_dup = NoDup
|
|
| 2484 | - , sc_cont = cont })
|
|
| 2488 | + = simplExprF (arg_env `setInScopeFromE` env) arg $
|
|
| 2489 | + addCastMCo arg_mco $
|
|
| 2490 | + StrictArg { sc_fun = fun_info, sc_fun_ty = fun_ty
|
|
| 2491 | + , sc_dup = NoDup
|
|
| 2492 | + , sc_cont = cont }
|
|
| 2485 | 2493 | -- Note [Shadowing in the Simplifier]
|
| 2486 | 2494 | |
| 2487 | 2495 | | otherwise -- Lazy, or already simplified arguments
|
| ... | ... | @@ -2489,7 +2497,7 @@ rebuildCall env fun_info |
| 2489 | 2497 | -- There is no benefit (unlike in a let-binding), and we'd
|
| 2490 | 2498 | -- have to be very careful about bogus strictness through
|
| 2491 | 2499 | -- floating a demanded let.
|
| 2492 | - = do { (_, arg') <- simplArg env fun_ty (Just fun_info) arg_se arg
|
|
| 2500 | + = do { arg' <- simplArg env (Just fun_info) fun_ty arg_se arg arg_mco
|
|
| 2493 | 2501 | ; rebuildCall env (addValArgTo fun_info arg' fun_ty) cont }
|
| 2494 | 2502 | |
| 2495 | 2503 | ---------- No further useful info, revert to generic rebuild ------------
|
| ... | ... | @@ -2804,6 +2812,7 @@ trySeqRules in_env scrut rhs cont |
| 2804 | 2812 | , as_dmd = seqDmd
|
| 2805 | 2813 | , as_hole_ty = res3_ty } ]
|
| 2806 | 2814 | rule_cont = ApplyToVal { sc_env = UnSimplified in_env, sc_arg = rhs
|
| 2815 | + , sc_cast = MRefl
|
|
| 2807 | 2816 | , sc_cont = cont, sc_hole_ty = res4_ty }
|
| 2808 | 2817 | |
| 2809 | 2818 | out_args = [Type rhs_rep, Type scrut_ty, Type rhs_ty, no_cast_scrut]
|
| ... | ... | @@ -3900,7 +3909,8 @@ knownCon env scrut dc dc_args case_bndr alt_bndrs rhs cont |
| 3900 | 3909 | return ( emptyFloats env
|
| 3901 | 3910 | , extendIdSubst env case_bndr (DoneEx scrut NotJoinPoint))
|
| 3902 | 3911 | |
| 3903 | - | Just env' <- preInlineUnconditionally env NotTopLevel case_bndr con_app (UnSimplified env)
|
|
| 3912 | + | Just env' <- preInlineUnconditionally env NotTopLevel case_bndr
|
|
| 3913 | + (UnSimplified env) con_app MRefl
|
|
| 3904 | 3914 | = return (emptyFloats env', env')
|
| 3905 | 3915 | |
| 3906 | 3916 | | otherwise
|
| ... | ... | @@ -4088,7 +4098,7 @@ mkDupableContWithDmds env dmds |
| 4088 | 4098 | , sc_arg_ty = arg_ty, sc_hole_ty = hole_ty }) }
|
| 4089 | 4099 | |
| 4090 | 4100 | mkDupableContWithDmds env dmds
|
| 4091 | - (ApplyToVal { sc_arg = arg, sc_env = se
|
|
| 4101 | + (ApplyToVal { sc_arg = arg, sc_env = se, sc_cast = arg_mco
|
|
| 4092 | 4102 | , sc_cont = cont, sc_hole_ty = hole_ty })
|
| 4093 | 4103 | = -- e.g. [...hole...] (...arg...)
|
| 4094 | 4104 | -- ==>
|
| ... | ... | @@ -4098,12 +4108,12 @@ mkDupableContWithDmds env dmds |
| 4098 | 4108 | do { let dmd:|cont_dmds = expectNonEmpty dmds
|
| 4099 | 4109 | ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont
|
| 4100 | 4110 | ; let env' = env `setInScopeFromF` floats1
|
| 4101 | - ; (_, arg') <- simplArg env' hole_ty Nothing se arg
|
|
| 4111 | + ; arg' <- simplArg env' Nothing hole_ty se arg arg_mco
|
|
| 4102 | 4112 | ; (let_floats2, triv_arg) <- makeTrivial env' NotTopLevel dmd (fsLit "karg") arg'
|
| 4103 | 4113 | ; let all_floats = floats1 `addLetFloats` let_floats2
|
| 4104 | 4114 | ; return ( all_floats
|
| 4105 | 4115 | , ApplyToVal { sc_arg = triv_arg, sc_env = Simplified OkDup
|
| 4106 | - , sc_cont = cont', sc_hole_ty = hole_ty }) }
|
|
| 4116 | + , sc_cast = MRefl, sc_cont = cont', sc_hole_ty = hole_ty }) }
|
|
| 4107 | 4117 | |
| 4108 | 4118 | mkDupableContWithDmds env _
|
| 4109 | 4119 | (Select { sc_bndr = case_bndr, sc_alts = alts, sc_env = se, sc_cont = cont })
|
| ... | ... | @@ -172,10 +172,11 @@ data SimplCont |
| 172 | 172 | , sc_cont :: SimplCont }
|
| 173 | 173 | |
| 174 | 174 | | ApplyToVal -- (ApplyToVal arg K)[e] = K[ e arg ]
|
| 175 | - { sc_hole_ty :: OutType -- Type of the function, presumably (forall a. blah)
|
|
| 176 | - -- See Note [The hole type in ApplyToTy]
|
|
| 177 | - , sc_env :: StaticEnv -- See Note [StaticEnv]
|
|
| 178 | - , sc_arg :: CoreExpr -- The argument,
|
|
| 175 | + { sc_hole_ty :: OutType -- Type of the function, presumably (forall a. blah)
|
|
| 176 | + -- See Note [The hole type in ApplyToTy]
|
|
| 177 | + , sc_env :: StaticEnv -- See Note [StaticEnv]
|
|
| 178 | + , sc_arg :: CoreExpr -- The argument
|
|
| 179 | + , sc_cast :: MOutCoercion -- Wrap this OutCoercion around the (simplified) argument
|
|
| 179 | 180 | , sc_cont :: SimplCont }
|
| 180 | 181 | |
| 181 | 182 | | ApplyToTy -- (ApplyToTy ty K)[e] = K[ e ty ]
|
| ... | ... | @@ -416,7 +417,7 @@ pushArgs fun_ty (arg:args) cont |
| 416 | 417 | = ApplyToTy { sc_hole_ty = fun_ty, sc_arg_ty = ty
|
| 417 | 418 | , sc_cont = pushArgs (piResultTy fun_ty ty) args cont }
|
| 418 | 419 | | otherwise
|
| 419 | - = ApplyToVal { sc_hole_ty = fun_ty
|
|
| 420 | + = ApplyToVal { sc_hole_ty = fun_ty, sc_cast = MRefl
|
|
| 420 | 421 | , sc_arg = arg, sc_env = Simplified NoDup
|
| 421 | 422 | , sc_cont = pushArgs (funResultTy fun_ty) args cont}
|
| 422 | 423 | |
| ... | ... | @@ -428,7 +429,7 @@ pushArgSpec :: ArgSpec -> SimplCont -> SimplCont |
| 428 | 429 | pushArgSpec (TyArg { as_arg_ty = arg_ty, as_hole_ty = hole_ty }) cont
|
| 429 | 430 | = ApplyToTy { sc_arg_ty = arg_ty, sc_hole_ty = hole_ty, sc_cont = cont }
|
| 430 | 431 | pushArgSpec (ValArg { as_arg = arg, as_hole_ty = hole_ty }) cont
|
| 431 | - = ApplyToVal { sc_arg = arg, sc_env = Simplified NoDup
|
|
| 432 | + = ApplyToVal { sc_arg = arg, sc_env = Simplified NoDup, sc_cast = MRefl
|
|
| 432 | 433 | , sc_hole_ty = hole_ty, sc_cont = cont }
|
| 433 | 434 | |
| 434 | 435 | argSpecArg :: ArgSpec -> OutExpr
|
| ... | ... | @@ -1083,8 +1084,8 @@ interestingArg env se e |
| 1083 | 1084 | go env n (Var v)
|
| 1084 | 1085 | = case substId env v of
|
| 1085 | 1086 | DoneId v' -> go_var n v'
|
| 1086 | - DoneEx e _ -> go (zapSubstEnv env) n e
|
|
| 1087 | - ContEx tvs cvs ids e -> go (setSubstEnv env tvs cvs ids) n e
|
|
| 1087 | + DoneEx e _ -> go (zapSubstEnv env) n e
|
|
| 1088 | + ContEx se e _mco -> go (se `setInScopeFromE` env) n e
|
|
| 1088 | 1089 | |
| 1089 | 1090 | go _ _ (Lit l)
|
| 1090 | 1091 | | isLitRubbish l = NonTrivArg -- See (IA3) in Note [Interesting arguments]
|
| ... | ... | @@ -1585,13 +1586,13 @@ the former. |
| 1585 | 1586 | |
| 1586 | 1587 | preInlineUnconditionally
|
| 1587 | 1588 | :: SimplEnv -> TopLevelFlag -> InId
|
| 1588 | - -> InExpr -> StaticEnv -- These two go together
|
|
| 1589 | + -> StaticEnv -> CoreExpr -> MOutCoercion -- The argument
|
|
| 1589 | 1590 | -> Maybe SimplEnv -- Returned env has extended substitution
|
| 1590 | 1591 | -- Precondition: rhs satisfies the let-can-float invariant
|
| 1591 | 1592 | -- See Note [Core let-can-float invariant] in GHC.Core
|
| 1592 | 1593 | -- Reason: we don't want to inline single uses, or discard dead bindings,
|
| 1593 | 1594 | -- for unlifted, side-effect-ful bindings
|
| 1594 | -preInlineUnconditionally env top_lvl bndr rhs rhs_se
|
|
| 1595 | +preInlineUnconditionally env top_lvl bndr rhs_se rhs rhs_mco
|
|
| 1595 | 1596 | | not pre_inline_unconditionally = Nothing
|
| 1596 | 1597 | | not active = Nothing
|
| 1597 | 1598 | | isTopLevel top_lvl && isDeadEndId bndr = Nothing -- Note [Top-level bottoming Ids]
|
| ... | ... | @@ -1603,7 +1604,8 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_se |
| 1603 | 1604 | |
| 1604 | 1605 | -- See Note [Stable unfoldings and preInlineUnconditionally]
|
| 1605 | 1606 | | not (isInlinePragma inline_prag)
|
| 1606 | - , Just inl <- maybeUnfoldingTemplate unf = Just $! (extend_subst_with inl)
|
|
| 1607 | + , Just inl <- maybeUnfoldingTemplate unf = assertPpr (isReflMCo rhs_mco) (ppr bndr) $
|
|
| 1608 | + Just $! (extend_subst_with inl)
|
|
| 1607 | 1609 | |
| 1608 | 1610 | | otherwise = Nothing
|
| 1609 | 1611 | where
|
| ... | ... | @@ -1613,9 +1615,10 @@ preInlineUnconditionally env top_lvl bndr rhs rhs_se |
| 1613 | 1615 | -- If not then ContEx
|
| 1614 | 1616 | -- ToDo: flesh this note out
|
| 1615 | 1617 | extend_subst_with inl_rhs
|
| 1616 | - = case rhs_se of
|
|
| 1617 | - Simplified _ -> extendIdSubst env bndr $! DoneEx inl_rhs NotJoinPoint
|
|
| 1618 | - UnSimplified rhs_env -> extendIdSubst env bndr $! mkContEx rhs_env inl_rhs
|
|
| 1618 | + = extendIdSubst env bndr $!
|
|
| 1619 | + case rhs_se of
|
|
| 1620 | + Simplified _ -> DoneEx (mkCastMCo inl_rhs rhs_mco) NotJoinPoint
|
|
| 1621 | + UnSimplified rhs_env -> ContEx rhs_env inl_rhs rhs_mco
|
|
| 1619 | 1622 | |
| 1620 | 1623 | one_occ IAmDead = True -- Happens in ((\x.1) v)
|
| 1621 | 1624 | one_occ OneOcc{ occ_n_br = 1
|
| ... | ... | @@ -9,7 +9,7 @@ d = D 10## RUBBISH(IntRep) |
| 9 | 9 | |
| 10 | 10 | lvl = foo d
|
| 11 | 11 | |
| 12 | -bar1 = \ _ eta -> case lvl of { W# ipv -> (# eta, () #) }
|
|
| 12 | +bar1 = \ x eta -> case lvl of { W# ipv -> (# eta, () #) }
|
|
| 13 | 13 | |
| 14 | 14 | bar = bar1 `cast` <Co:6> :: ...
|
| 15 | 15 |
| 1 | 1 | Unf=Unf{Src=<vanilla>, TopLvl=True,
|
| 2 | 2 | Value=True, ConLike=True, WorkFree=True, Expandable=True,
|
| 3 | 3 | Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
|
| 4 | -f = \ (@p) _ [Occ=Dead] -> GHC.Internal.Types.True
|
|
| 4 | +f = \ (@p) (x [Occ=Dead] :: p) -> GHC.Internal.Types.True
|
|
| 5 | 5 | Unf=Unf{Src=<vanilla>, TopLvl=True,
|
| 6 | 6 | Value=True, ConLike=True, WorkFree=True, Expandable=True, |
| ... | ... | @@ -4,28 +4,28 @@ Result size of Tidy Core |
| 4 | 4 | = {terms: 40, types: 122, coercions: 26, joins: 0/0}
|
| 5 | 5 | |
| 6 | 6 | nat2Word#
|
| 7 | - = \ @n $dKnownNat _ ->
|
|
| 7 | + = \ @n $dKnownNat p1 ->
|
|
| 8 | 8 | naturalToWord# ((natSing $dKnownNat) `cast` <Co:2> :: ...)
|
| 9 | 9 | |
| 10 | -foo = \ _ -> 18##
|
|
| 10 | +foo = \ ds -> 18##
|
|
| 11 | 11 | |
| 12 | 12 | fd
|
| 13 | - = \ @n $dKnownNat _ ->
|
|
| 13 | + = \ @n $dKnownNat ds ->
|
|
| 14 | 14 | naturalToWord# ((natSing $dKnownNat) `cast` <Co:6> :: ...)
|
| 15 | 15 | |
| 16 | -d = \ _ -> 3##
|
|
| 16 | +d = \ ds -> 3##
|
|
| 17 | 17 | |
| 18 | 18 | fm
|
| 19 | - = \ @n $dKnownNat _ ->
|
|
| 19 | + = \ @n $dKnownNat ds ->
|
|
| 20 | 20 | naturalToWord# ((natSing $dKnownNat) `cast` <Co:8> :: ...)
|
| 21 | 21 | |
| 22 | -m = \ _ -> 9##
|
|
| 22 | +m = \ ds -> 9##
|
|
| 23 | 23 | |
| 24 | 24 | fp
|
| 25 | - = \ @n $dKnownNat _ ->
|
|
| 25 | + = \ @n $dKnownNat ds ->
|
|
| 26 | 26 | naturalToWord# ((natSing $dKnownNat) `cast` <Co:10> :: ...)
|
| 27 | 27 | |
| 28 | -p = \ _ -> 512##
|
|
| 28 | +p = \ ds -> 512##
|
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 |
| ... | ... | @@ -5,7 +5,7 @@ Result size of Tidy Core |
| 5 | 5 | |
| 6 | 6 | foo0 = \ x -> -# 10# x
|
| 7 | 7 | |
| 8 | -foo1 = \ _ -> 10#
|
|
| 8 | +foo1 = \ x -> 10#
|
|
| 9 | 9 | |
| 10 | 10 | foo2 = \ x -> +# 10# x
|
| 11 | 11 |
| ... | ... | @@ -3,15 +3,15 @@ |
| 3 | 3 | Result size of Tidy Core
|
| 4 | 4 | = {terms: 44, types: 107, coercions: 0, joins: 0/0}
|
| 5 | 5 | |
| 6 | -foo0 = \ _ -> (# 0#, 0#, 683234160# #)
|
|
| 6 | +foo0 = \ ds -> (# 0#, 0#, 683234160# #)
|
|
| 7 | 7 | |
| 8 | -foo1 = \ _ -> (# 0#, -1#, -683234160# #)
|
|
| 8 | +foo1 = \ ds -> (# 0#, -1#, -683234160# #)
|
|
| 9 | 9 | |
| 10 | 10 | foo2 = foo0
|
| 11 | 11 | |
| 12 | 12 | foo3 = foo1
|
| 13 | 13 | |
| 14 | -foo4 = \ _ -> (# 0#, 0#, 0# #)
|
|
| 14 | +foo4 = \ ds -> (# 0#, 0#, 0# #)
|
|
| 15 | 15 | |
| 16 | 16 | foo5 = foo4
|
| 17 | 17 | |
| ... | ... | @@ -19,11 +19,11 @@ foo6 = \ other -> other |
| 19 | 19 | |
| 20 | 20 | foo7 = foo6
|
| 21 | 21 | |
| 22 | -foo8 = \ _ -> (# 0#, 0#, 128# #)
|
|
| 22 | +foo8 = \ ds -> (# 0#, 0#, 128# #)
|
|
| 23 | 23 | |
| 24 | -foo9 = \ _ -> (# 0#, -1#, -128# #)
|
|
| 24 | +foo9 = \ ds -> (# 0#, -1#, -128# #)
|
|
| 25 | 25 | |
| 26 | -foo10 = \ _ -> 1#
|
|
| 26 | +foo10 = \ ds -> 1#
|
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 |
| ... | ... | @@ -3,11 +3,11 @@ |
| 3 | 3 | Result size of Tidy Core
|
| 4 | 4 | = {terms: 71, types: 45, coercions: 0, joins: 0/0}
|
| 5 | 5 | |
| 6 | -foo0 = \ _ -> 16##
|
|
| 6 | +foo0 = \ ds -> 16##
|
|
| 7 | 7 | |
| 8 | -foo1 = \ _ -> 4##
|
|
| 8 | +foo1 = \ ds -> 4##
|
|
| 9 | 9 | |
| 10 | -foo2 = \ _ -> 11##
|
|
| 10 | +foo2 = \ ds -> 11##
|
|
| 11 | 11 | |
| 12 | 12 | foo3 = foo0
|
| 13 | 13 | |
| ... | ... | @@ -21,11 +21,11 @@ foo3' = foo0' |
| 21 | 21 | |
| 22 | 22 | foo4' = I# 31#
|
| 23 | 23 | |
| 24 | -ctz0 = \ _ -> 30##
|
|
| 24 | +ctz0 = \ ds -> 30##
|
|
| 25 | 25 | |
| 26 | -ctz1 = \ _ -> 6##
|
|
| 26 | +ctz1 = \ ds -> 6##
|
|
| 27 | 27 | |
| 28 | -ctz2 = \ _ -> 14##
|
|
| 28 | +ctz2 = \ ds -> 14##
|
|
| 29 | 29 | |
| 30 | 30 | ctz3 = ctz0
|
| 31 | 31 | |
| ... | ... | @@ -39,11 +39,11 @@ ctz3' = ctz0' |
| 39 | 39 | |
| 40 | 40 | ctz4' = I# 62#
|
| 41 | 41 | |
| 42 | -clz1 = \ _ -> 5##
|
|
| 42 | +clz1 = \ ds -> 5##
|
|
| 43 | 43 | |
| 44 | -clz2 = \ _ -> 13##
|
|
| 44 | +clz2 = \ ds -> 13##
|
|
| 45 | 45 | |
| 46 | -clz3 = \ _ -> 29##
|
|
| 46 | +clz3 = \ ds -> 29##
|
|
| 47 | 47 | |
| 48 | 48 | clz1' = I# 5#
|
| 49 | 49 |
| ... | ... | @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS |
| 6 | 6 | PATTERN SYNONYMS
|
| 7 | 7 | (:||:) :: forall {a} {b}. a -> b -> (a, b)
|
| 8 | 8 | Dependent modules: []
|
| 9 | -Dependent packages: [(normal, base-4.21.0.0)]
|
|
| 9 | +Dependent packages: [(normal, base-4.23.0.0)]
|
|
| 10 | 10 | |
| 11 | 11 | ==================== Tidy Core ====================
|
| 12 | 12 | Result size of Tidy Core
|
| ... | ... | @@ -35,7 +35,7 @@ T18052a.$m:||: |
| 35 | 35 | (@b)
|
| 36 | 36 | (scrut :: (a, b))
|
| 37 | 37 | (cont :: a -> b -> r)
|
| 38 | - _ [Occ=Dead] ->
|
|
| 38 | + (fail [Occ=Dead] :: (# #) -> r) ->
|
|
| 39 | 39 | case scrut of { (x, y) -> cont x y }
|
| 40 | 40 | |
| 41 | 41 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "USPEC f1 @Word @[e]"
|
| 4 | - forall (@e) ($dNum :: Num Word) ($dEq :: Eq [e]).
|
|
| 4 | + forall (@e) ($dNum [Occ=Dead] :: Num Word) ($dEq :: Eq [e]).
|
|
| 5 | 5 | f1 @Word @[e] $dNum $dEq
|
| 6 | - = \ _ [Occ=Dead] _ [Occ=Dead] -> I# 111#
|
|
| 6 | + = \ (ds [Occ=Dead] :: Word) (ds1 [Occ=Dead] :: [e]) -> I# 111#
|
|
| 7 | 7 | "USPEC f1 @Word @_"
|
| 8 | - forall (@e) ($dNum :: Num Word) ($dEq :: Eq e).
|
|
| 8 | + forall (@e) ($dNum [Occ=Dead] :: Num Word) ($dEq :: Eq e).
|
|
| 9 | 9 | f1 @Word @e $dNum $dEq
|
| 10 | - = \ _ [Occ=Dead] _ [Occ=Dead] -> I# 111#
|
|
| 10 | + = \ (ds [Occ=Dead] :: Word) (ds1 [Occ=Dead] :: e) -> I# 111#
|
|
| 11 | 11 | "USPEC f1_qc @_ @(g e) @Word"
|
| 12 | 12 | forall (@(g :: * -> *))
|
| 13 | 13 | (@e)
|
| 14 | 14 | (df :: forall x. Eq x => Eq (g x))
|
| 15 | 15 | ($dEq :: Eq (g e))
|
| 16 | - ($dNum :: Num Word).
|
|
| 16 | + ($dNum [Occ=Dead] :: Num Word).
|
|
| 17 | 17 | f1_qc @g @(g e) @Word df $dEq $dNum
|
| 18 | - = \ _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> C# 'q'#
|
|
| 18 | + = \ (ds [Occ=Dead] :: Proxy g)
|
|
| 19 | + (ds1 [Occ=Dead] :: g e)
|
|
| 20 | + (ds2 [Occ=Dead] :: Word) ->
|
|
| 21 | + C# 'q'#
|
|
| 19 | 22 | "USPEC f2 @_ @_ @Word"
|
| 20 | - forall (@c) ($dEq :: Eq c) ($dEq1 :: Eq c) ($dNum :: Num Word).
|
|
| 23 | + forall (@c)
|
|
| 24 | + ($dEq [Occ=Dead] :: Eq c)
|
|
| 25 | + ($dEq1 :: Eq c)
|
|
| 26 | + ($dNum [Occ=Dead] :: Num Word).
|
|
| 21 | 27 | f2 @c @c @Word $dEq $dEq1 $dNum
|
| 22 | - = \ _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> I# 2#
|
|
| 28 | + = \ (ds [Occ=Dead] :: c)
|
|
| 29 | + (ds1 [Occ=Dead] :: c)
|
|
| 30 | + (ds2 [Occ=Dead] :: Word) ->
|
|
| 31 | + I# 2#
|
|
| 23 | 32 | "USPEC f3 @Int @_"
|
| 24 | 33 | forall (@(g :: * -> *))
|
| 25 | - ($dEq :: Eq Int)
|
|
| 34 | + ($dEq [Occ=Dead] :: Eq Int)
|
|
| 26 | 35 | (df :: forall x. Eq x => Eq (g x)).
|
| 27 | 36 | f3 @Int @g $dEq df
|
| 28 | 37 | = f3_$sf3 @g df
|
| 29 | 38 | "USPEC f3 @_ @[]"
|
| 30 | - forall (@c) ($dEq :: Eq c) (df :: forall x. Eq x => Eq [x]).
|
|
| 39 | + forall (@c)
|
|
| 40 | + ($dEq :: Eq c)
|
|
| 41 | + (df [Occ=Dead] :: forall x. Eq x => Eq [x]).
|
|
| 31 | 42 | f3 @c @[] $dEq df
|
| 32 | 43 | = f3_$sf1 @c $dEq
|
| 33 | 44 | "USPEC f4 @_ @(ST s)"
|
| 34 | - forall (@b) (@s) ($dEq :: Eq b) ($dMonad :: Monad (ST s)).
|
|
| 45 | + forall (@b)
|
|
| 46 | + (@s)
|
|
| 47 | + ($dEq :: Eq b)
|
|
| 48 | + ($dMonad [Occ=Dead] :: Monad (ST s)).
|
|
| 35 | 49 | f4 @b @(ST s) $dEq $dMonad
|
| 36 | 50 | = $fApplicativeST_$cpure @s @b
|
| 37 | 51 | "USPEC f4_qc @Int @_ @_"
|
| 38 | 52 | forall (@(r :: (* -> *) -> * -> *))
|
| 39 | 53 | (@(n :: * -> *))
|
| 40 | - ($dEq :: Eq Int)
|
|
| 54 | + ($dEq [Occ=Dead] :: Eq Int)
|
|
| 41 | 55 | (df :: forall (m :: * -> *). Monad m => Monad (r m)).
|
| 42 | 56 | f4_qc @Int @r @n $dEq df
|
| 43 | - = \ _ [Occ=Dead] -> ()
|
|
| 57 | + = \ (ds [Occ=Dead] :: r n Int) -> ()
|
|
| 44 | 58 | "USPEC f5 @(D Int)"
|
| 45 | - forall ($dEq :: Eq (D Int)). f5 @(D Int) $dEq = f5_$sf5
|
|
| 59 | + forall ($dEq [Occ=Dead] :: Eq (D Int)). f5 @(D Int) $dEq = f5_$sf5
|
|
| 46 | 60 | "USPEC f5_qc @Int @D"
|
| 47 | - forall ($dEq :: Eq Int)
|
|
| 48 | - ($dEq1 :: Eq (T Int))
|
|
| 49 | - (df :: forall x. (Eq x, Eq (T x)) => Eq (D x)).
|
|
| 61 | + forall ($dEq [Occ=Dead] :: Eq Int)
|
|
| 62 | + ($dEq1 [Occ=Dead] :: Eq (T Int))
|
|
| 63 | + (df [Occ=Dead] :: forall x. (Eq x, Eq (T x)) => Eq (D x)).
|
|
| 50 | 64 | f5_qc @Int @D $dEq $dEq1 df
|
| 51 | 65 | = f5_$sf5
|
| 52 | 66 | "USPEC f5_qc @Int @_"
|
| 53 | 67 | forall (@(g :: * -> *))
|
| 54 | - ($dEq :: Eq Int)
|
|
| 55 | - ($dEq1 :: Eq (T Int))
|
|
| 68 | + ($dEq [Occ=Dead] :: Eq Int)
|
|
| 69 | + ($dEq1 [Occ=Dead] :: Eq (T Int))
|
|
| 56 | 70 | (df :: forall x. (Eq x, Eq (T x)) => Eq (g x)).
|
| 57 | 71 | f5_qc @Int @g $dEq $dEq1 df
|
| 58 | 72 | = f5_qc_$sf5_qc @g df
|
| 59 | 73 | "USPEC f6 @_ @_ @Word"
|
| 60 | - forall (@c) ($dEq :: Eq c) ($dOrd :: Ord c) ($dNum :: Num Word).
|
|
| 74 | + forall (@c)
|
|
| 75 | + ($dEq [Occ=Dead] :: Eq c)
|
|
| 76 | + ($dOrd :: Ord c)
|
|
| 77 | + ($dNum [Occ=Dead] :: Num Word).
|
|
| 61 | 78 | f6 @c @c @Word $dEq $dOrd $dNum
|
| 62 | - = \ _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> C# 'c'#
|
|
| 79 | + = \ (ds [Occ=Dead] :: c)
|
|
| 80 | + (ds1 [Occ=Dead] :: c)
|
|
| 81 | + (ds2 [Occ=Dead] :: Word) ->
|
|
| 82 | + C# 'c'#
|
|
| 63 | 83 | "USPEC f6_qc @_ @_ @Word"
|
| 64 | 84 | forall (@(h :: * -> *))
|
| 65 | - (df :: forall x. Eq x => Eq (h x))
|
|
| 85 | + (df [Occ=Dead] :: forall x. Eq x => Eq (h x))
|
|
| 66 | 86 | (df1 :: forall y. Eq y => Ord (h y))
|
| 67 | - ($dNum :: Num Word).
|
|
| 87 | + ($dNum [Occ=Dead] :: Num Word).
|
|
| 68 | 88 | f6_qc @h @h @Word df df1 $dNum
|
| 69 | - = \ _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> C# 'd'#
|
|
| 89 | + = \ (ds [Occ=Dead] :: Proxy h)
|
|
| 90 | + (ds1 [Occ=Dead] :: Proxy h)
|
|
| 91 | + (ds2 [Occ=Dead] :: Word) ->
|
|
| 92 | + C# 'd'#
|
|
| 70 | 93 | "USPEC f7 @Int"
|
| 71 | - forall ($dCls :: Cls (TF Int)) ($dEq :: Eq Int).
|
|
| 94 | + forall ($dCls :: Cls (TF Int)) ($dEq [Occ=Dead] :: Eq Int).
|
|
| 72 | 95 | f7 @Int $dCls $dEq
|
| 73 | 96 | = \ (x [Occ=Once1] :: Int) -> x
|
| 74 | 97 | "USPEC qcfd @C @G"
|
| 75 | - forall ($dF :: F C G) (df :: forall a b. C (a, b)).
|
|
| 98 | + forall ($dF [Occ=Dead] :: F C G)
|
|
| 99 | + (df [Occ=Dead] :: forall a b. C (a, b)).
|
|
| 76 | 100 | qcfd @C @G $dF df
|
| 77 | 101 | = qcfd_x
|
| 78 | 102 |
| ... | ... | @@ -3,28 +3,28 @@ Rule fired |
| 3 | 3 | Module: (RewriteHigherOrderPatterns)
|
| 4 | 4 | Full arity: 1
|
| 5 | 5 | Before: bar \ x y z -> two (two x y) z
|
| 6 | - After: (\ f -> True) (\ x y -> two (two x y))
|
|
| 6 | + After: (\ f -> True) (\ x y -> two (two x y))
|
|
| 7 | 7 | Rule fired
|
| 8 | 8 | Rule: bar
|
| 9 | 9 | Module: (RewriteHigherOrderPatterns)
|
| 10 | 10 | Full arity: 1
|
| 11 | - Before: bar \ x _ z -> two (two x (I# 2#)) z
|
|
| 12 | - After: (\ f -> True) (\ x _ -> two (two x (I# 2#)))
|
|
| 11 | + Before: bar \ x y z -> two (two x (I# 2#)) z
|
|
| 12 | + After: (\ f -> True) (\ x y -> two (two x (I# 2#)))
|
|
| 13 | 13 | Rule fired
|
| 14 | 14 | Rule: foo
|
| 15 | 15 | Module: (RewriteHigherOrderPatterns)
|
| 16 | 16 | Full arity: 1
|
| 17 | 17 | Before: foo \ x -> two (two x (I# 2#)) x
|
| 18 | - After: (\ f -> True) (\ x -> two (two x (I# 2#)) x)
|
|
| 18 | + After: (\ f -> True) (\ x -> two (two x (I# 2#)) x)
|
|
| 19 | 19 | Rule fired
|
| 20 | 20 | Rule: qux
|
| 21 | 21 | Module: (RewriteHigherOrderPatterns)
|
| 22 | 22 | Full arity: 1
|
| 23 | 23 | Before: qux \ x y -> three (two x (I# 1#)) (I# 2#) y
|
| 24 | - After: (\ f -> True) (\ x -> three (two x (I# 1#)))
|
|
| 24 | + After: (\ f -> True) (\ x -> three (two x (I# 1#)))
|
|
| 25 | 25 | Rule fired
|
| 26 | 26 | Rule: baz
|
| 27 | 27 | Module: (RewriteHigherOrderPatterns)
|
| 28 | 28 | Full arity: 1
|
| 29 | 29 | Before: baz \ x -> three (two x (I# 1#)) (I# 2#) x
|
| 30 | - After: (\ f -> True) (\ x -> three (two x (I# 1#)) (I# 2#)) |
|
| 30 | + After: (\ f -> True) (\ x -> three (two x (I# 1#)) (I# 2#)) |
| ... | ... | @@ -3,23 +3,24 @@ Rule fired |
| 3 | 3 | Module: (T18668)
|
| 4 | 4 | Full arity: 0
|
| 5 | 5 | Before: GHC.Internal.Prim.+# 2# 3#
|
| 6 | - After: GHC.Internal.Prim.*#
|
|
| 6 | + After: GHC.Internal.Prim.*#
|
|
| 7 | 7 | Rule fired
|
| 8 | 8 | Rule: *#
|
| 9 | 9 | Module: (BUILTIN)
|
| 10 | 10 | Full arity: 2
|
| 11 | 11 | Before: GHC.Internal.Prim.*# 2# 3#
|
| 12 | - After: 6#
|
|
| 12 | + After: 6#
|
|
| 13 | 13 | Rule fired
|
| 14 | 14 | Rule: flip
|
| 15 | 15 | Module: (T18668)
|
| 16 | 16 | Full arity: 1
|
| 17 | 17 | Before: GHC.Internal.Prim.># 1# 0#
|
| 18 | - After: (\ (x :: GHC.Internal.Prim.Int#) -> GHC.Internal.Prim.<# x)
|
|
| 19 | - 1#
|
|
| 18 | + After: (\ (x [Occ=Once1] :: GHC.Internal.Prim.Int#) ->
|
|
| 19 | + GHC.Internal.Prim.<# x)
|
|
| 20 | + 1#
|
|
| 20 | 21 | Rule fired
|
| 21 | 22 | Rule: <#
|
| 22 | 23 | Module: (BUILTIN)
|
| 23 | 24 | Full arity: 2
|
| 24 | 25 | Before: GHC.Internal.Prim.<# 1# 0#
|
| 25 | - After: 0# |
|
| 26 | + After: 0# |
| ... | ... | @@ -5,7 +5,8 @@ |
| 5 | 5 | |
| 6 | 6 | ==================== Tidy Core rules ====================
|
| 7 | 7 | "SPEC/T19246 $wf @Int" [2]
|
| 8 | - forall ($dOrd :: Ord Int). $wf @Int $dOrd = $s$wf
|
|
| 9 | -"USPEC f @Int" [2] forall ($dOrd :: Ord Int). f @Int $dOrd = $sf
|
|
| 8 | + forall ($dOrd [Occ=Dead] :: Ord Int). $wf @Int $dOrd = $s$wf
|
|
| 9 | +"USPEC f @Int" [2]
|
|
| 10 | + forall ($dOrd [Occ=Dead] :: Ord Int). f @Int $dOrd = $sf
|
|
| 10 | 11 | |
| 11 | 12 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "SPEC myShow_impl @Int"
|
| 4 | - forall ($dMyShow :: MyShow Int). myShow_impl @Int $dMyShow = foo
|
|
| 4 | + forall ($dMyShow [Occ=Dead] :: MyShow Int).
|
|
| 5 | + myShow_impl @Int $dMyShow
|
|
| 6 | + = foo
|
|
| 5 | 7 | |
| 6 | 8 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "SPEC r_bar @Int"
|
| 4 | - forall ($dC :: C Int). r_bar @Int $dC = $fCInt_$sr_bar
|
|
| 4 | + forall ($dC [Occ=Dead] :: C Int). r_bar @Int $dC = $fCInt_$sr_bar
|
|
| 5 | 5 | |
| 6 | 6 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "SPEC foo @IO @Int"
|
| 4 | - forall ($dMonad :: Monad IO) ($dIntegral :: Integral Int).
|
|
| 4 | + forall ($dMonad [Occ=Dead] :: Monad IO)
|
|
| 5 | + ($dIntegral [Occ=Dead] :: Integral Int).
|
|
| 5 | 6 | foo1 @IO @Int $dMonad $dIntegral
|
| 6 | 7 | = foo_$sfoo
|
| 7 | 8 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "SPEC $cstimes @Int"
|
| 4 | - forall ($dIntegral :: Integral Int).
|
|
| 4 | + forall ($dIntegral [Occ=Dead] :: Integral Int).
|
|
| 5 | 5 | $fSemigroupSumInt_$cstimes @Int $dIntegral
|
| 6 | 6 | = foo
|
| 7 | 7 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | -"USPEC bar @_" forall (@a) ($dC :: C a). bar @a $dC = bar_$sbar @a
|
|
| 3 | +"USPEC bar @_"
|
|
| 4 | + forall (@a) ($dC [Occ=Dead] :: C a). bar @a $dC = bar_$sbar @a
|
|
| 4 | 5 | |
| 5 | 6 |
| ... | ... | @@ -3,37 +3,37 @@ |
| 3 | 3 | Result size of Tidy Core
|
| 4 | 4 | = {terms: 161, types: 140, coercions: 0, joins: 0/0}
|
| 5 | 5 | |
| 6 | -narrow8_ge_lb = \ _ -> True
|
|
| 6 | +narrow8_ge_lb = \ x -> True
|
|
| 7 | 7 | |
| 8 | 8 | narrow8_le_ub = narrow8_ge_lb
|
| 9 | 9 | |
| 10 | -narrow8_gt_ub_false = \ _ -> False
|
|
| 10 | +narrow8_gt_ub_false = \ x -> False
|
|
| 11 | 11 | |
| 12 | 12 | narrow16_ge_lb = narrow8_ge_lb
|
| 13 | 13 | |
| 14 | 14 | narrow16_le_ub = narrow8_ge_lb
|
| 15 | 15 | |
| 16 | -narrow8w_lt_ub = \ _ -> True
|
|
| 16 | +narrow8w_lt_ub = \ x -> True
|
|
| 17 | 17 | |
| 18 | 18 | narrow16w_lt_ub = narrow8w_lt_ub
|
| 19 | 19 | |
| 20 | -word16_lt_ub = \ _ -> True
|
|
| 20 | +word16_lt_ub = \ x -> True
|
|
| 21 | 21 | |
| 22 | -word16_ge_ub_false = \ _ -> False
|
|
| 22 | +word16_ge_ub_false = \ x -> False
|
|
| 23 | 23 | |
| 24 | 24 | word_to_word8_lt = narrow8w_lt_ub
|
| 25 | 25 | |
| 26 | 26 | word_to_word16_lt = narrow8w_lt_ub
|
| 27 | 27 | |
| 28 | -word8_to_int8_ge = \ _ -> True
|
|
| 28 | +word8_to_int8_ge = \ x -> True
|
|
| 29 | 29 | |
| 30 | 30 | word16_to_int16_ge = word16_lt_ub
|
| 31 | 31 | |
| 32 | -int8_to_word8_le = \ _ -> True
|
|
| 32 | +int8_to_word8_le = \ x -> True
|
|
| 33 | 33 | |
| 34 | -int16_to_word16_le = \ _ -> True
|
|
| 34 | +int16_to_word16_le = \ x -> True
|
|
| 35 | 35 | |
| 36 | -word8_add_lt_256 = \ _ _ -> True
|
|
| 36 | +word8_add_lt_256 = \ x y -> True
|
|
| 37 | 37 | |
| 38 | 38 | word16_alts
|
| 39 | 39 | = \ x ->
|
| ... | ... | @@ -51,15 +51,15 @@ narrow8_alts |
| 51 | 51 | |
| 52 | 52 | word8_sub_lt_256 = word8_add_lt_256
|
| 53 | 53 | |
| 54 | -word16_add_lt_ub = \ _ _ -> True
|
|
| 54 | +word16_add_lt_ub = \ x y -> True
|
|
| 55 | 55 | |
| 56 | 56 | word16_sub_lt_ub = word16_add_lt_ub
|
| 57 | 57 | |
| 58 | -int8_add_ge_lb = \ _ _ -> True
|
|
| 58 | +int8_add_ge_lb = \ x y -> True
|
|
| 59 | 59 | |
| 60 | 60 | int8_sub_le_ub = int8_add_ge_lb
|
| 61 | 61 | |
| 62 | -int16_add_ge_lb = \ _ _ -> True
|
|
| 62 | +int16_add_ge_lb = \ x y -> True
|
|
| 63 | 63 | |
| 64 | 64 | int16_sub_le_ub = int16_add_ge_lb
|
| 65 | 65 | |
| ... | ... | @@ -67,11 +67,11 @@ narrow32_ge_lb = narrow8_ge_lb |
| 67 | 67 | |
| 68 | 68 | narrow32_le_ub = narrow8_ge_lb
|
| 69 | 69 | |
| 70 | -word32_to_int32_ge = \ _ -> True
|
|
| 70 | +word32_to_int32_ge = \ x -> True
|
|
| 71 | 71 | |
| 72 | -int32_to_word32_le = \ _ -> True
|
|
| 72 | +int32_to_word32_le = \ x -> True
|
|
| 73 | 73 | |
| 74 | -int32_add_ge_lb = \ _ _ -> True
|
|
| 74 | +int32_add_ge_lb = \ x y -> True
|
|
| 75 | 75 | |
| 76 | 76 | int32_sub_le_ub = int32_add_ge_lb
|
| 77 | 77 | |
| ... | ... | @@ -88,7 +88,7 @@ word16_and_lt = word16_lt_ub |
| 88 | 88 | |
| 89 | 89 | word32_and_lt = word32_to_int32_ge
|
| 90 | 90 | |
| 91 | -word64_and_le = \ _ -> True
|
|
| 91 | +word64_and_le = \ x -> True
|
|
| 92 | 92 | |
| 93 | 93 | int_and_ge = narrow8_ge_lb
|
| 94 | 94 | |
| ... | ... | @@ -103,11 +103,11 @@ narrow32w_lt_ub = narrow8w_lt_ub |
| 103 | 103 | |
| 104 | 104 | word32_lt_ub = word32_to_int32_ge
|
| 105 | 105 | |
| 106 | -word32_ge_ub_false = \ _ -> False
|
|
| 106 | +word32_ge_ub_false = \ x -> False
|
|
| 107 | 107 | |
| 108 | 108 | word_to_word32_lt = narrow8w_lt_ub
|
| 109 | 109 | |
| 110 | -word32_add_lt_ub = \ _ _ -> True
|
|
| 110 | +word32_add_lt_ub = \ x y -> True
|
|
| 111 | 111 | |
| 112 | 112 | word32_sub_lt_ub = word32_add_lt_ub
|
| 113 | 113 |
| ... | ... | @@ -7,7 +7,7 @@ Result size of Specialise = {terms: 31, types: 39, coercions: 8, joins: 0/1} |
| 7 | 7 | specMe [InlPrag=INLINABLE] :: forall n a. (Integral n, MaybeShowNum a n) => a -> n -> (String, n)
|
| 8 | 8 | [LclIdX,
|
| 9 | 9 | Arity=4,
|
| 10 | - Unf=Unf{Src=StableUser, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [30 0 0 20] 260 10
|
|
| 10 | + Unf=Unf{Src=StableUser, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [90 60 0 20] 260 10
|
|
| 11 | 11 | Tmpl= \ (@n) (@a) ($dIntegral [Occ=Once1] :: Integral n) (irred :: MaybeShowNum a n) (eta [Occ=Once1] :: a) (eta [Occ=Once1] :: n) ->
|
| 12 | 12 | let {
|
| 13 | 13 | $dNum :: Num n
|
| ... | ... | @@ -63,7 +63,7 @@ foo = \ (x :: Int) -> specMe @Int @Bool GHC.Internal.Real.$fIntegralInt ($dCTupl |
| 63 | 63 | -- RHS size: {terms: 37, types: 26, coercions: 0, joins: 0/0}
|
| 64 | 64 | main :: State# RealWorld -> (# State# RealWorld, () #)
|
| 65 | 65 | [LclId, Arity=1, Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 301 0}]
|
| 66 | -main = \ (eta [OS=OneShot] :: State# RealWorld) -> GHC.Internal.IO.Handle.Text.hPutStr2 GHC.Internal.IO.StdHandles.stdout (case GHC.Internal.Enum.eftIntFB @(Int -> Int) (GHC.Internal.Base.mapFB @Int @(Int -> Int) @Int (\ (ds :: Int) (ds1 [OS=OneShot] :: Int -> Int) (v [OS=OneShot] :: Int) -> case v of { I# ipv -> ds1 (case ds of { I# y -> GHC.Internal.Types.I# (+# ipv y) }) }) (\ (x :: Int) -> case foo x of { (_ [Occ=Dead], y) -> y })) (breakpoint @Int) 1# 1000# (GHC.Internal.Types.I# 0#) of { I# n -> GHC.Internal.Show.itos n (GHC.Internal.Types.[] @Char) }) GHC.Internal.Types.True eta
|
|
| 66 | +main = \ (eta [OS=OneShot] :: State# RealWorld) -> GHC.Internal.IO.Handle.Text.hPutStr2 GHC.Internal.IO.Handle.FD.stdout (case GHC.Internal.Enum.eftIntFB @(Int -> Int) (GHC.Internal.Base.mapFB @Int @(Int -> Int) @Int (\ (ds :: Int) (ds1 [OS=OneShot] :: Int -> Int) (v [OS=OneShot] :: Int) -> case v of { I# ipv -> ds1 (case ds of { I# y -> GHC.Internal.Types.I# (+# ipv y) }) }) (\ (x :: Int) -> case foo x of { (_ [Occ=Dead], y) -> y })) (breakpoint @Int) 1# 1000# (GHC.Internal.Types.I# 0#) of { I# n -> GHC.Internal.Show.itos n (GHC.Internal.Types.[] @Char) }) GHC.Internal.Types.True eta
|
|
| 67 | 67 | |
| 68 | 68 | -- RHS size: {terms: 1, types: 0, coercions: 3, joins: 0/0}
|
| 69 | 69 | main :: IO ()
|
| ... | ... | @@ -72,7 +72,7 @@ main = main `cast` (Sym (GHC.Internal.Types.N:IO <()>_R) :: (State# RealWorld -> |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | ------ Local rules for imported ids --------
|
| 75 | -"SPEC/T26051 $wspecMe @Int @Bool" [2] forall ($dIntegral :: Integral Int) (irred :: MaybeShowNum Bool Int). T26051_Import.$wspecMe @Int @Bool $dIntegral irred = $s$wspecMe
|
|
| 76 | -"SPEC/T26051 specMe @Int @Bool" [2] forall ($dIntegral :: Integral Int) (irred :: MaybeShowNum Bool Int). specMe @Int @Bool $dIntegral irred = $sspecMe
|
|
| 75 | +"SPEC/T26051 $wspecMe @Int @Bool" [2] forall ($dIntegral [Occ=Dead] :: Integral Int) (irred [Occ=Dead] :: MaybeShowNum Bool Int). T26051_Import.$wspecMe @Int @Bool $dIntegral irred = $s$wspecMe
|
|
| 76 | +"SPEC/T26051 specMe @Int @Bool" [2] forall ($dIntegral [Occ=Dead] :: Integral Int) (irred [Occ=Dead] :: MaybeShowNum Bool Int). specMe @Int @Bool $dIntegral irred = $sspecMe
|
|
| 77 | 77 | |
| 78 | 78 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "USPEC $cop1 @T @_"
|
| 4 | - forall (@a) ($dEq :: Eq (T a)) ($dD :: D a).
|
|
| 4 | + forall (@a) ($dEq [Occ=Dead] :: Eq (T a)) ($dD :: D a).
|
|
| 5 | 5 | $fCTYPEfa_$cop1 @T @a $dEq $dD
|
| 6 | - = \ _ [Occ=Dead] -> I# 3#
|
|
| 6 | + = \ (x [Occ=Dead] :: T a) -> I# 3#
|
|
| 7 | 7 | "USPEC $fCTYPEfa @T @_"
|
| 8 | - forall (@a) ($dEq :: Eq (T a)) ($dD :: D a).
|
|
| 8 | + forall (@a) ($dEq [Occ=Dead] :: Eq (T a)) ($dD :: D a).
|
|
| 9 | 9 | $fCTYPEfa @T @a $dEq $dD
|
| 10 | 10 | = $fCTYPEfa_$s$fCTYPEfa @a $dD
|
| 11 | 11 |
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "SPEC $c*> @(ST s) @_"
|
| 4 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 4 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 5 | 5 | $fApplicativeReaderT_$c*> @(ST s) @r $dApplicative
|
| 6 | 6 | = ($fApplicativeReaderT2 @s @r)
|
| 7 | 7 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N).
|
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | (forall a b.
|
| 16 | 16 | ReaderT r (ST s) a -> ReaderT r (ST s) b -> ReaderT r (ST s) b))
|
| 17 | 17 | "SPEC $c<$ @(ST s) @_"
|
| 18 | - forall (@s) (@r) ($dFunctor :: Functor (ST s)).
|
|
| 18 | + forall (@s) (@r) ($dFunctor [Occ=Dead] :: Functor (ST s)).
|
|
| 19 | 19 | $fFunctorReaderT_$c<$ @(ST s) @r $dFunctor
|
| 20 | 20 | = ($fApplicativeReaderT6 @s @r)
|
| 21 | 21 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N).
|
| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | (forall a b. a -> ReaderT r (ST s) b -> r -> STRep s a)
|
| 28 | 28 | (forall a b. a -> ReaderT r (ST s) b -> ReaderT r (ST s) a))
|
| 29 | 29 | "SPEC $c<* @(ST s) @_"
|
| 30 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 30 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 31 | 31 | $fApplicativeReaderT_$c<* @(ST s) @r $dApplicative
|
| 32 | 32 | = ($fApplicativeReaderT1 @s @r)
|
| 33 | 33 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N).
|
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 | (forall a b.
|
| 42 | 42 | ReaderT r (ST s) a -> ReaderT r (ST s) b -> ReaderT r (ST s) a))
|
| 43 | 43 | "SPEC $c<*> @(ST s) @_"
|
| 44 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 44 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 45 | 45 | $fApplicativeReaderT9 @(ST s) @r $dApplicative
|
| 46 | 46 | = ($fApplicativeReaderT4 @s @r)
|
| 47 | 47 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N).
|
| ... | ... | @@ -55,11 +55,11 @@ |
| 55 | 55 | (forall a b.
|
| 56 | 56 | ReaderT r (ST s) (a -> b) -> ReaderT r (ST s) a -> r -> ST s b))
|
| 57 | 57 | "SPEC $c>> @(ST s) @_"
|
| 58 | - forall (@s) (@r) ($dMonad :: Monad (ST s)).
|
|
| 58 | + forall (@s) (@r) ($dMonad [Occ=Dead] :: Monad (ST s)).
|
|
| 59 | 59 | $fMonadReaderT_$c>> @(ST s) @r $dMonad
|
| 60 | 60 | = $fMonadAbstractIOSTReaderT_$s$c>> @s @r
|
| 61 | 61 | "SPEC $c>>= @(ST s) @_"
|
| 62 | - forall (@s) (@r) ($dMonad :: Monad (ST s)).
|
|
| 62 | + forall (@s) (@r) ($dMonad [Occ=Dead] :: Monad (ST s)).
|
|
| 63 | 63 | $fMonadReaderT1 @(ST s) @r $dMonad
|
| 64 | 64 | = ($fMonadAbstractIOSTReaderT2 @s @r)
|
| 65 | 65 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N).
|
| ... | ... | @@ -73,7 +73,7 @@ |
| 73 | 73 | (forall a b.
|
| 74 | 74 | ReaderT r (ST s) a -> (a -> ReaderT r (ST s) b) -> r -> ST s b))
|
| 75 | 75 | "SPEC $cfmap @(ST s) @_"
|
| 76 | - forall (@s) (@r) ($dFunctor :: Functor (ST s)).
|
|
| 76 | + forall (@s) (@r) ($dFunctor [Occ=Dead] :: Functor (ST s)).
|
|
| 77 | 77 | $fFunctorReaderT_$cfmap @(ST s) @r $dFunctor
|
| 78 | 78 | = ($fApplicativeReaderT7 @s @r)
|
| 79 | 79 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N).
|
| ... | ... | @@ -85,7 +85,7 @@ |
| 85 | 85 | (forall a b. (a -> b) -> ReaderT r (ST s) a -> r -> STRep s b)
|
| 86 | 86 | (forall a b. (a -> b) -> ReaderT r (ST s) a -> ReaderT r (ST s) b))
|
| 87 | 87 | "SPEC $cliftA2 @(ST s) @_"
|
| 88 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 88 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 89 | 89 | $fApplicativeReaderT_$cliftA2 @(ST s) @r $dApplicative
|
| 90 | 90 | = ($fApplicativeReaderT3 @s @r)
|
| 91 | 91 | `cast` (forall (a ::~ <*>_N) (b ::~ <*>_N) (c ::~ <*>_N).
|
| ... | ... | @@ -102,15 +102,15 @@ |
| 102 | 102 | (a -> b -> c)
|
| 103 | 103 | -> ReaderT r (ST s) a -> ReaderT r (ST s) b -> ReaderT r (ST s) c))
|
| 104 | 104 | "SPEC $cp1Applicative @(ST s) @_"
|
| 105 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 105 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 106 | 106 | $fApplicativeReaderT_$cp1Applicative @(ST s) @r $dApplicative
|
| 107 | 107 | = $fApplicativeReaderT_$s$fFunctorReaderT @s @r
|
| 108 | 108 | "SPEC $cp1Monad @(ST s) @_"
|
| 109 | - forall (@s) (@r) ($dMonad :: Monad (ST s)).
|
|
| 109 | + forall (@s) (@r) ($dMonad [Occ=Dead] :: Monad (ST s)).
|
|
| 110 | 110 | $fMonadReaderT_$cp1Monad @(ST s) @r $dMonad
|
| 111 | 111 | = $fApplicativeReaderT_$s$fApplicativeReaderT @s @r
|
| 112 | 112 | "SPEC $cpure @(ST s) @_"
|
| 113 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 113 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 114 | 114 | $fApplicativeReaderT_$cpure @(ST s) @r $dApplicative
|
| 115 | 115 | = ($fApplicativeReaderT5 @s @r)
|
| 116 | 116 | `cast` (forall (a ::~ <*>_N).
|
| ... | ... | @@ -121,7 +121,7 @@ |
| 121 | 121 | (forall a. a -> r -> STRep s a)
|
| 122 | 122 | (forall a. a -> ReaderT r (ST s) a))
|
| 123 | 123 | "SPEC $creturn @(ST s) @_"
|
| 124 | - forall (@s) (@r) ($dMonad :: Monad (ST s)).
|
|
| 124 | + forall (@s) (@r) ($dMonad [Occ=Dead] :: Monad (ST s)).
|
|
| 125 | 125 | $fMonadReaderT_$creturn @(ST s) @r $dMonad
|
| 126 | 126 | = ($fApplicativeReaderT5 @s @r)
|
| 127 | 127 | `cast` (forall (a ::~ <*>_N).
|
| ... | ... | @@ -132,20 +132,21 @@ |
| 132 | 132 | (forall a. a -> r -> STRep s a)
|
| 133 | 133 | (forall a. a -> ReaderT r (ST s) a))
|
| 134 | 134 | "SPEC $fApplicativeReaderT @(ST s) @_"
|
| 135 | - forall (@s) (@r) ($dApplicative :: Applicative (ST s)).
|
|
| 135 | + forall (@s) (@r) ($dApplicative [Occ=Dead] :: Applicative (ST s)).
|
|
| 136 | 136 | $fApplicativeReaderT @(ST s) @r $dApplicative
|
| 137 | 137 | = $fApplicativeReaderT_$s$fApplicativeReaderT @s @r
|
| 138 | 138 | "SPEC $fFunctorReaderT @(ST s) @_"
|
| 139 | - forall (@s) (@r) ($dFunctor :: Functor (ST s)).
|
|
| 139 | + forall (@s) (@r) ($dFunctor [Occ=Dead] :: Functor (ST s)).
|
|
| 140 | 140 | $fFunctorReaderT @(ST s) @r $dFunctor
|
| 141 | 141 | = $fApplicativeReaderT_$s$fFunctorReaderT @s @r
|
| 142 | 142 | "SPEC $fMonadReaderT @(ST s) @_"
|
| 143 | - forall (@s) (@r) ($dMonad :: Monad (ST s)).
|
|
| 143 | + forall (@s) (@r) ($dMonad [Occ=Dead] :: Monad (ST s)).
|
|
| 144 | 144 | $fMonadReaderT @(ST s) @r $dMonad
|
| 145 | 145 | = $fMonadAbstractIOSTReaderT_$s$fMonadReaderT @s @r
|
| 146 | 146 | "USPEC useAbstractMonad @(ReaderT Int (ST s))"
|
| 147 | 147 | forall (@s)
|
| 148 | - ($dMonadAbstractIOST :: MonadAbstractIOST (ReaderT Int (ST s))).
|
|
| 148 | + ($dMonadAbstractIOST [Occ=Dead]
|
|
| 149 | + :: MonadAbstractIOST (ReaderT Int (ST s))).
|
|
| 149 | 150 | useAbstractMonad @(ReaderT Int (ST s)) $dMonadAbstractIOST
|
| 150 | 151 | = (useAbstractMonad1 @s)
|
| 151 | 152 | `cast` (<Int>_R
|
| 1 | 1 | |
| 2 | 2 | ==================== Tidy Core rules ====================
|
| 3 | 3 | "USPEC f @[Int] @_"
|
| 4 | - forall (@b) ($dOrd :: Ord [Int]). f @[Int] @b $dOrd = f_$sf @b
|
|
| 4 | + forall (@b) ($dOrd [Occ=Dead] :: Ord [Int]).
|
|
| 5 | + f @[Int] @b $dOrd
|
|
| 6 | + = f_$sf @b
|
|
| 5 | 7 | |
| 6 | 8 |
| ... | ... | @@ -9,7 +9,11 @@ f :: forall a b. (a ~ b) => a -> b -> Bool |
| 9 | 9 | Unf=Unf{Src=<vanilla>, TopLvl=True,
|
| 10 | 10 | Value=True, ConLike=True, WorkFree=True, Expandable=True,
|
| 11 | 11 | Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=True)}]
|
| 12 | -f = \ (@a) (@b) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] ->
|
|
| 12 | +f = \ (@a)
|
|
| 13 | + (@b)
|
|
| 14 | + ($d~ [Occ=Dead] :: a ~ b)
|
|
| 15 | + (x [Occ=Dead] :: a)
|
|
| 16 | + (y [Occ=Dead] :: b) ->
|
|
| 13 | 17 | GHC.Internal.Types.True
|
| 14 | 18 | |
| 15 | 19 | -- RHS size: {terms: 5, types: 0, coercions: 0, joins: 0/0}
|