From 7584bb74cd50f6f43d8652e9a69aeb36a1a92353 Mon Sep 17 00:00:00 2001 From: Thalia Archibald Date: Sat, 7 Sep 2024 10:24:18 -0700 Subject: Fix typos in chapter 14 --- .../src/main/java/com/seaofnodes/simple/node/AddNode.java | 2 +- chapter14/src/main/java/com/seaofnodes/simple/node/OrNode.java | 10 +++++----- .../src/main/java/com/seaofnodes/simple/node/XorNode.java | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'chapter14/src/main/java/com/seaofnodes') diff --git a/chapter14/src/main/java/com/seaofnodes/simple/node/AddNode.java b/chapter14/src/main/java/com/seaofnodes/simple/node/AddNode.java index 6a28e9e6..f3b213fb 100644 --- a/chapter14/src/main/java/com/seaofnodes/simple/node/AddNode.java +++ b/chapter14/src/main/java/com/seaofnodes/simple/node/AddNode.java @@ -111,7 +111,7 @@ public class AddNode extends Node { return null; } - // Rotation is only valid for associative ops, e.g. Add, Mul, And, Or. + // Rotation is only valid for associative ops, e.g. Add, Mul, And, Or, Xor. // Do we have ((phi cons)|(x + (phi cons)) + con|(phi cons)) ? // Push constant up through the phi: x + (phi con0+con0 con1+con1...) static Node phiCon(Node op, boolean rotate) { diff --git a/chapter14/src/main/java/com/seaofnodes/simple/node/OrNode.java b/chapter14/src/main/java/com/seaofnodes/simple/node/OrNode.java index 24577b16..1b32d4fb 100644 --- a/chapter14/src/main/java/com/seaofnodes/simple/node/OrNode.java +++ b/chapter14/src/main/java/com/seaofnodes/simple/node/OrNode.java @@ -36,8 +36,8 @@ public class OrNode extends Node { Type t1 = lhs._type; Type t2 = rhs._type; - // Or of 0. We do not check for (0&x) because this will already - // canonicalize to (x&0) + // Or of 0. We do not check for (0|x) because this will already + // canonicalize to (x|0) if( t2.isConstant() && t2 instanceof TypeInteger i && i.value()==0 ) return lhs; @@ -45,9 +45,9 @@ public class OrNode extends Node { if ( t1.isConstant() && !t2.isConstant() ) return swap12(); - // Do we have ((x & (phi cons)) & con) ? - // Do we have ((x & (phi cons)) & (phi cons)) ? - // Push constant up through the phi: x & (phi con0&con0 con1&con1...) + // Do we have ((x | (phi cons)) | con) ? + // Do we have ((x | (phi cons)) | (phi cons)) ? + // Push constant up through the phi: x | (phi con0|con0 con1|con1...) Node phicon = AddNode.phiCon(this,true); if( phicon!=null ) return phicon; diff --git a/chapter14/src/main/java/com/seaofnodes/simple/node/XorNode.java b/chapter14/src/main/java/com/seaofnodes/simple/node/XorNode.java index 0e235eae..30a88dca 100644 --- a/chapter14/src/main/java/com/seaofnodes/simple/node/XorNode.java +++ b/chapter14/src/main/java/com/seaofnodes/simple/node/XorNode.java @@ -36,8 +36,8 @@ public class XorNode extends Node { Type t1 = lhs._type; Type t2 = rhs._type; - // Xor of 0. We do not check for (0&x) because this will already - // canonicalize to (x&0) + // Xor of 0. We do not check for (0^x) because this will already + // canonicalize to (x^0) if( t2.isConstant() && t2 instanceof TypeInteger i && i.value()==0 ) return lhs; @@ -45,9 +45,9 @@ public class XorNode extends Node { if ( t1.isConstant() && !t2.isConstant() ) return swap12(); - // Do we have ((x & (phi cons)) & con) ? - // Do we have ((x & (phi cons)) & (phi cons)) ? - // Push constant up through the phi: x & (phi con0&con0 con1&con1...) + // Do we have ((x ^ (phi cons)) ^ con) ? + // Do we have ((x ^ (phi cons)) ^ (phi cons)) ? + // Push constant up through the phi: x ^ (phi con0^con0 con1^con1...) Node phicon = AddNode.phiCon(this,true); if( phicon!=null ) return phicon; -- cgit v1.2.3