Skip to content

Commit 0eda3ff

Browse files
committed
ES: added explanation to CopyPropagation
1 parent e64ae12 commit 0eda3ff

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

grin/src/Transformations/Optimising/CopyPropagation.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ import Transformations.Util
1515
NOTE:
1616
Do not propagate literal values because literals are not used for optimisations. (GRIN is not a supercompiler)
1717
Only propagates variables. It does not cause performance penalty, LLVM will optimise the code further.
18-
19-
TODO:
20-
CUrrently, copy propagation does not remove the resulting dead bindings, SDVE does. However, SDVE needs interprocedural
21-
information such as the type env (this can be removed) and the effect map. Maybe copy propagation should remove
22-
the binding for which it already substituted the variable.
23-
2418
-}
2519

2620
type Env = (Map Val Val, Map Name Name)
@@ -70,6 +64,13 @@ copyPropagation e = hylo folder builder (mempty, e) where
7064
, isConstant val
7165
-> rightExp
7266
-- left unit law ; cleanup x <- pure y copies
67+
{- NOTE: This case could be handled by SDVE as well, however
68+
performing it locally saves us an effect tracking analysis.
69+
This is because here, we have more information about variable
70+
bidnings. We know for sure that such copying bindings are not needed
71+
since all the occurences of the left-hand side have been replaced with
72+
the variable on the right-hand side.
73+
-}
7374
EBindF (SReturn Var{}) Var{} rightExp
7475
-> rightExp
7576

0 commit comments

Comments
 (0)