summaryrefslogtreecommitdiff
path: root/chapter14/src/main/java/com
diff options
context:
space:
mode:
authorThalia Archibald <thalia@archibald.dev>2024-09-07 10:24:18 -0700
committerThalia Archibald <thalia@archibald.dev>2024-09-07 10:54:48 -0700
commit7584bb74cd50f6f43d8652e9a69aeb36a1a92353 (patch)
treee29eaa54dc10f41fdb2b3052f794de4350c47246 /chapter14/src/main/java/com
parenteccda096c2e8e30f76e4c4a21421243159cd9026 (diff)
downloadSimple-7584bb74cd50f6f43d8652e9a69aeb36a1a92353.tar.gz
Simple-7584bb74cd50f6f43d8652e9a69aeb36a1a92353.zip
Fix typos in chapter 14
Diffstat (limited to 'chapter14/src/main/java/com')
-rw-r--r--chapter14/src/main/java/com/seaofnodes/simple/node/AddNode.java2
-rw-r--r--chapter14/src/main/java/com/seaofnodes/simple/node/OrNode.java10
-rw-r--r--chapter14/src/main/java/com/seaofnodes/simple/node/XorNode.java10
3 files changed, 11 insertions, 11 deletions
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;