summaryrefslogtreecommitdiff
path: root/chapter05/README.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-12-04 13:51:35 -0800
committerGitHub <noreply@github.com>2026-12-04 13:51:35 -0800
commit7be87ff4db692a392af1c68abe7752a1da55637f (patch)
treed5e8e68bed74166aeaf4b658f9ce104d1df48c8a /chapter05/README.md
parentf0a6c6757a795b8e186de0076836a87acef59fa7 (diff)
parentebdb2c71237506d67cfa8f3bb459b41902840481 (diff)
downloadSimple-7be87ff4db692a392af1c68abe7752a1da55637f.tar.gz
Simple-7be87ff4db692a392af1c68abe7752a1da55637f.zip
Merge pull request #265 from SeaOfNodes/ch32main
Land Chapter 32 compiler performance work and backported fixes
Diffstat (limited to 'chapter05/README.md')
-rw-r--r--chapter05/README.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/chapter05/README.md b/chapter05/README.md
index 40886af2..0955f36a 100644
--- a/chapter05/README.md
+++ b/chapter05/README.md
@@ -413,6 +413,21 @@ return a;
+### Factoring after strength reduction
+
+Peephole order should not hide the same arithmetic from Phi factoring.
+`Phi(x+x,y+x)` can become `Phi(x,y)+x`, but an earlier peephole may already have
+replaced `x+x` with `x*2`. The Phi matcher therefore views `x*2` as two copies of
+`x` while factoring mixed Add/Mul arms. It does not expand the graph into an Add
+that would immediately fold back to a multiply. If all arms are multiplies,
+ordinary multiply factoring still applies.
+
+[Chapter05Test](src/test/java/com/seaofnodes/simple/Chapter05Test.java)
+checks the factored operands before and after strength reduction and with either
+arm order. Later chapters extend this same view to `x<<1` when shifts arrive.
+The rule stays local to doubling; arbitrary coefficients would require creating
+another multiplication, with a less clear benefit.
+
[^1]: Click, C. (1995).
Combining Analyses, Combining Optimizations, 132.