From dd907c2d86eaaad0910e7bfe3f0d25e5caf8bdf7 Mon Sep 17 00:00:00 2001 From: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Date: Sat, 26 Sep 2026 06:35:22 +0800 Subject: Extend and backport SubNode peephole (#254) * Extend and backport SubNode peephole * Add tests * Restrict subtraction zero peepholes to integer operands Require resolved integer mode in chapter 25 so zero subtraction preserves floating-point signed zero. Keep nonnumeric operands in the graph for subtraction diagnostics. Add signed-zero coverage from chapter 12 and null-subtraction diagnostics from chapter 22. Confirmed the regressions fail on the original PR. Full Make suites pass in chapters 4-25 (5462 tests), including fresh chapter 25 sys.o compilation. --------- Co-authored-by: Cliff Click --- chapter04/README.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'chapter04/README.md') 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 -- cgit v1.2.3