[Git][ghc/ghc][master] 3 commits: Comments only in FloatIn

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Dec 8 20:55:33 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
03ca551d by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Comments only in FloatIn

Relevant to #3458

- - - - -
50c78779 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Comments only in SpecConstr

- - - - -
9431e195 by Simon Peyton Jones at 2023-12-08T15:54:50-05:00
Add test for #22238

- - - - -


4 changed files:

- compiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- + testsuite/tests/quantified-constraints/T22238.hs
- testsuite/tests/quantified-constraints/all.T


Changes:

=====================================
compiler/GHC/Core/Opt/FloatIn.hs
=====================================
@@ -234,6 +234,29 @@ Every jump must be exact, so the jump to j must have three arguments. Hence
 we're careful not to float into the target of a jump (though we can float into
 the arguments just fine).
 
+Floating in can /enhance/ join points.  Consider this (#3458)
+    f2 x = let g :: Int -> Int
+               g y = if y==0 then y+x else g (y-1)
+           in case g x of
+                0 -> True
+                _ -> False
+
+Here `g` is not a join point. But if we float inwards it becomes one!  We
+float in; the occurrence analyser identifies `g` as a join point; the Simplifier
+retains that property, so we get
+    f2 x = case (joinrec
+                    g y = if y==0 then y+x else g (y-1)
+                 in jump g x) of
+              0 -> True
+              _ -> False
+
+Now that outer case gets pushed into the RHS of the joinrec, giving
+    f2 x = joinrec g y = if y==0
+                         then case y+x of { 0 -> True; _ -> False }
+                         else jump g (y-1)
+           in jump g x
+Nice!
+
 Note [Floating in past a lambda group]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * We must be careful about floating inside a value lambda.


=====================================
compiler/GHC/Core/Opt/SpecConstr.hs
=====================================
@@ -1948,6 +1948,7 @@ spec_one env fn arg_bndrs body (call_pat, rule_number)
                              `asJoinId_maybe` spec_join_arity
 
         -- Conditionally use result of new worker-wrapper transform
+        -- mkSeqs: see Note [SpecConstr and strict fields]
               spec_rhs = mkLams spec_lam_args (mkSeqs cbv_args spec_body_ty spec_body)
               rule_rhs = mkVarApps (Var spec_id) spec_call_args
               inline_act = idInlineActivation fn
@@ -2345,6 +2346,8 @@ Then it's fine for `co2` to mention `a`.  We'll get
 data CallPat = CP { cp_qvars :: [Var]           -- Quantified variables
                   , cp_args  :: [CoreExpr]      -- Arguments
                   , cp_strict_args :: [Var] }   -- Arguments we want to pass unlifted even if they are boxed
+                                                -- See Note [SpecConstr and strict fields]
+
      -- See Note [SpecConstr call patterns]
 
 instance Outputable CallPat where


=====================================
testsuite/tests/quantified-constraints/T22238.hs
=====================================
@@ -0,0 +1,12 @@
+{-# LANGUAGE ImpredicativeTypes #-}
+{-# LANGUAGE GADTs #-}
+
+module T22238 where
+
+import Data.Kind (Constraint)
+
+data Dict (c :: Constraint) where
+    MkDict :: c => Dict c
+
+forallListEqDict :: Dict (forall a. Eq a => Eq [a])
+forallListEqDict = MkDict


=====================================
testsuite/tests/quantified-constraints/all.T
=====================================
@@ -44,3 +44,4 @@ test('T19690', normal, compile_fail, [''])
 test('T23143', normal, compile, [''])
 test('T23333', normal, compile, [''])
 test('T23323', normal, compile, [''])
+test('T22238', normal, compile, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8baa1bdeea1753afc939a20119d3ce555301167...9431e1953b29b2fe3e383b038258877efe9f6595

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8baa1bdeea1753afc939a20119d3ce555301167...9431e1953b29b2fe3e383b038258877efe9f6595
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231208/652d7641/attachment-0001.html>


More information about the ghc-commits mailing list