diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-09 17:01:02 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-09 17:01:02 -0700 |
| commit | 1f4006e88df54e2b7086bc49e05ffc6d2068e8fd (patch) | |
| tree | 92e8204618117676e962679fa0b385b2db047674 /chapter06/src/main/java | |
| parent | 91c6ed0f6978215a0448f5bf91600e5fdb2a77d8 (diff) | |
| parent | 6b4ed4d07831f738755cb8162eff24d6d9a695fc (diff) | |
| download | Simple-1f4006e88df54e2b7086bc49e05ffc6d2068e8fd.tar.gz Simple-1f4006e88df54e2b7086bc49e05ffc6d2068e8fd.zip | |
Merge branch 'main' of https://github.com/SeaOfNodes/Simple
Diffstat (limited to 'chapter06/src/main/java')
| -rw-r--r-- | chapter06/src/main/java/com/seaofnodes/simple/node/AddNode.java | 10 | ||||
| -rw-r--r-- | chapter06/src/main/java/com/seaofnodes/simple/node/BoolNode.java | 7 |
2 files changed, 9 insertions, 8 deletions
diff --git a/chapter06/src/main/java/com/seaofnodes/simple/node/AddNode.java b/chapter06/src/main/java/com/seaofnodes/simple/node/AddNode.java index b37785f6..af2a41b3 100644 --- a/chapter06/src/main/java/com/seaofnodes/simple/node/AddNode.java +++ b/chapter06/src/main/java/com/seaofnodes/simple/node/AddNode.java @@ -64,7 +64,7 @@ public class AddNode extends Node { // Now we might see (add add non) or (add non non) but never (add non add) nor (add add add) if( !(lhs instanceof AddNode) ) // Rotate; look for (add (phi cons) con/(phi cons)) - return spline_cmp(lhs,rhs) ? swap12() : phiCon(this,true); + return spine_cmp(lhs,rhs) ? swap12() : phiCon(this,true); // Now we only see (add add non) @@ -80,11 +80,11 @@ public class AddNode extends Node { Node phicon = phiCon(this,true); if( phicon!=null ) return phicon; - // Now we sort along the spline via rotates, to gather similar things together. + // Now we sort along the spine via rotates, to gather similar things together. // Do we rotate (x + y) + z // into (x + z) + y ? - if( spline_cmp(lhs.in(2),rhs) ) + if( spine_cmp(lhs.in(2),rhs) ) return new AddNode(new AddNode(lhs.in(1),rhs).peephole(),lhs.in(2)); return null; @@ -131,12 +131,12 @@ public class AddNode extends Node { return op instanceof PhiNode phi && phi.allCons() ? phi : null; } - // Compare two off-spline nodes and decide what order they should be in. + // Compare two off-spine nodes and decide what order they should be in. // Do we rotate ((x + hi) + lo) into ((x + lo) + hi) ? // Generally constants always go right, then Phi-of-constants, then muls, then others. // Ties with in a category sort by node ID. // TRUE if swapping hi and lo. - static boolean spline_cmp( Node hi, Node lo ) { + static boolean spine_cmp( Node hi, Node lo ) { if( lo._type.isConstant() ) return false; if( hi._type.isConstant() ) return true ; diff --git a/chapter06/src/main/java/com/seaofnodes/simple/node/BoolNode.java b/chapter06/src/main/java/com/seaofnodes/simple/node/BoolNode.java index a9ec6838..79c65c60 100644 --- a/chapter06/src/main/java/com/seaofnodes/simple/node/BoolNode.java +++ b/chapter06/src/main/java/com/seaofnodes/simple/node/BoolNode.java @@ -43,9 +43,10 @@ abstract public class BoolNode extends Node { if( in(1)==in(2) ) return new ConstantNode(TypeInteger.constant(doOp(3,3)?1:0)); - // 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 ((phi cons) cmp con) ? + // Do we have ((phi cons) cmp (phi cons)) ? + // Push the compare up through the phi: (phi con0 cmp con, con1 cmp con...) + // No rotate: compares are not associative. Node phicon = AddNode.phiCon(this,false); if( phicon!=null ) return phicon; |
