[Git][ghc/ghc][wip/romes/eqsat-pmc] tWeaks

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Sun Jul 2 19:14:22 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/eqsat-pmc at Glasgow Haskell Compiler / GHC


Commits:
e04bab20 by Rodrigo Mesquita at 2023-07-02T20:14:17+01:00
tWeaks

- - - - -


3 changed files:

- compiler/GHC/Core/Equality.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs


Changes:

=====================================
compiler/GHC/Core/Equality.hs
=====================================
@@ -7,6 +7,11 @@
 
 module GHC.Core.Equality where
 
+-- ROMES:TODO:
+-- I think, for the particular usages of Core e-graphs, we can do much better
+-- than this for equality.
+-- E.g. representation could transform the CoreExpr to an actual debruijnized one (with Ints for Vars)
+
 import GHC.Exts (dataToTag#, tagToEnum#, (>#), (<#))
 import GHC.Prelude
 


=====================================
compiler/GHC/HsToCore/Pmc.hs
=====================================
@@ -110,6 +110,14 @@ pmcPatBind ctxt@(DsMatchContext PatBindRhs loc) var p = do
   tracePm "}: " (ppr (cr_uncov result0))
   -- romes:todo: this seems redundant, hints that the right thing might be for desugar to return already the match variables already "represented" in the e-graph
   -- doing this, however, wouuld require for desugar pat binds to care about/thread through nablas
+  -- DESIGN:TODO: However, if we represent the variables while desugaring, we
+  -- would no longer need representId to represent VarF in the e-class, and can
+  -- instead do newEClass. This would further reduce allocations.
+  -- The reason why we can't do that currently is that on checkPatBind we'll
+  -- representIds, and when we represent them again in the next line, we want
+  -- them to match the ones we represented during checkPatBind. If we made
+  -- empty-eclasses, the representId on the next line wouldn't match the match
+  -- ids we defined in checkPatBind.
   let (varid, cr_uncov') = representId var (cr_uncov result0)
   formatReportWarnings ReportPatBind ctxt [varid] result0{cr_uncov = cr_uncov'}
 pmcPatBind _ _ _ = pure ()


=====================================
compiler/GHC/HsToCore/Pmc/Solver.hs
=====================================
@@ -838,7 +838,7 @@ addVarCt nabla at MkNabla{ nabla_tm_st = ts at TmSt{ ts_facts = env } } x y =
   -- equate should also update e-graph, basically re-implement "equateUSDFM" in terms of the e-graph, or inline it or so
   case equate env x y of
     -- Add the constraints we had for x to y
-    -- See Note [Joining e-classes PMC] todo mention from joinA
+    -- See Note (TODO) Joining e-classes PMC] todo mention from joinA
     -- Now, here's a really tricky bit (TODO Write note, is it the one above?)
     -- Bc the joinA operation is unlawful, and because the makeA operation for
     -- expressions is also unlawful (sets the type to ()::(), mostly out of



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e04bab20ab8cfcfdf2df8d557bd0af21ddb37b8c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e04bab20ab8cfcfdf2df8d557bd0af21ddb37b8c
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/20230702/9346b2d4/attachment-0001.html>


More information about the ghc-commits mailing list