summaryrefslogtreecommitdiff
path: root/chapter04/README.md
diff options
context:
space:
mode:
authorfuhsnn <66062782+fuhsnn@users.noreply.github.com>2026-09-25 07:25:49 +0800
committerfuhsnn <66062782+fuhsnn@users.noreply.github.com>2026-09-25 11:27:48 +0800
commit349c23d0527569284a8bec67f27130c4358e056c (patch)
treeb404934d6562db8e1e7c8abdf8d30cd496abea84 /chapter04/README.md
parente9e02b18ee3223f2cfe1990be00674f9868e1a26 (diff)
downloadSimple-349c23d0527569284a8bec67f27130c4358e056c.tar.gz
Simple-349c23d0527569284a8bec67f27130c4358e056c.zip
Extend and backport SubNode peephole
Diffstat (limited to 'chapter04/README.md')
-rw-r--r--chapter04/README.md4
1 files changed, 4 insertions, 0 deletions
diff --git a/chapter04/README.md b/chapter04/README.md
index 2c7f7e9c..07085e80 100644
--- a/chapter04/README.md
+++ b/chapter04/README.md
@@ -305,6 +305,7 @@ Here is a list of peepholes introduced in this Chapter, more will be introduced
| Before | After | Description |
|-----------------------|-----------------------|------------------------------------------------|
| (arg + 0 ) | arg | Add of zero identity |
+| (arg - 0 ) | arg | Sub of zero identity |
| (arg * 1 ) | arg | Multiple of one identity |
| (con + arg) | (arg + con) | Move constants to right, to encourage folding |
| (con * arg) | (arg * con) | Move constants to right, to encourage folding |
@@ -312,6 +313,9 @@ Here is a list of peepholes introduced in this Chapter, more will be introduced
| ((arg1 + con) + arg2) | ((arg1 + arg2) + con) | Move constants to right, to encourage folding |
| (arg + arg) | (arg * 2) | Sum-of-products form |
| (arg - arg) | 0 | Sub of same is 0
+| (0 - arg) | (-arg) | Sub from 0 is negation
+| (arg1 - (-arg2)) | (arg1 + arg2) | Sub of negation is add
+| ((-arg1) - arg2) | -(arg1 + arg2) | Sub from negation is negation of sum
| (con / 1) | con | Division by one
| (arg == arg) | 1 | Compare of same
| (arg != arg) | 0 | Compare of same