summaryrefslogtreecommitdiff
path: root/chapter04
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-10-06 09:19:00 -0700
committerCliff Click <cliffc@acm.org>2024-10-06 09:20:04 -0700
commit95276331d269cf0d93c242fcd5dfaab909237df7 (patch)
tree1c61fb4eca3a50640996bf4e387d0abd506f8b49 /chapter04
parent0e463a0cc99ed35d89ab912470a12d1d76731791 (diff)
downloadSimple-95276331d269cf0d93c242fcd5dfaab909237df7.tar.gz
Simple-95276331d269cf0d93c242fcd5dfaab909237df7.zip
Update DCE comments
Diffstat (limited to 'chapter04')
-rw-r--r--chapter04/README.md15
1 files changed, 10 insertions, 5 deletions
diff --git a/chapter04/README.md b/chapter04/README.md
index 8bf29f94..e71ff8a7 100644
--- a/chapter04/README.md
+++ b/chapter04/README.md
@@ -352,16 +352,21 @@ The peephole method does following:
`peephole()` calls `deadCodeElim()` which is shown below.
-## Dead Code Elimination(DCE)
-We call DCE every time we lose a use of a Node; when replacing via peeps and exciting scopes.
-DCE recursively deletes Nodes:
+## Dead Code Elimination(DCE)
-- `delUse` deletes a Node use; if the use count goes to zero recursively.
-- `kill` deletes all inputs on self, while calling `delUse` to remove the matching use.
+We call `kill` every time a Node makes the 1-user-to-0-users transition during
+graph editing. This commonly happens when replacing via peeps and exiting
+scopes. This recursive `kill` amounts to Dead Code Elimination in many other
+compilers; here we call it in a very fine-grained way. Many Nodes will be
+created by the parser, only to be killed before the very next lexeme is parsed.
For more information please read the [appendix section](appendix/dce.md#appendix) on dead code elimination.
+The suggestively called `deadCodeElim` function is a thin wrapper over `kill`
+used by `peepholeOpt` to avoid prematurely killing a Node which only briefly
+makes the 1->0 users transition.
+
```java
// m is the new Node, self is the old.
// Return 'm', which may have zero uses but is alive nonetheless.