diff options
| author | Cliff Click <cliffc@acm.org> | 2023-10-30 09:01:57 -0700 |
|---|---|---|
| committer | Dibyendu Majumdar <dibyendumajumdar@users.noreply.github.com> | 2023-11-01 18:56:50 +0000 |
| commit | 4410e4e3d7a4b9e0424de7678633e2a7240695cd (patch) | |
| tree | b7a9944f86abd8f0cb1eb986d9fd2db0cf68792a /chapter05/src/main/java/com | |
| parent | b59828ac09a88310640d8b8d3d95a8be0cee1187 (diff) | |
| download | Simple-4410e4e3d7a4b9e0424de7678633e2a7240695cd.tar.gz Simple-4410e4e3d7a4b9e0424de7678633e2a7240695cd.zip | |
Bug fix last peephole
Diffstat (limited to 'chapter05/src/main/java/com')
| -rw-r--r-- | chapter05/src/main/java/com/seaofnodes/simple/node/AddNode.java | 4 | ||||
| -rw-r--r-- | chapter05/src/main/java/com/seaofnodes/simple/node/PhiNode.java | 5 |
2 files changed, 2 insertions, 7 deletions
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/node/AddNode.java b/chapter05/src/main/java/com/seaofnodes/simple/node/AddNode.java index 7cb0f822..1e9cc6c9 100644 --- a/chapter05/src/main/java/com/seaofnodes/simple/node/AddNode.java +++ b/chapter05/src/main/java/com/seaofnodes/simple/node/AddNode.java @@ -79,9 +79,9 @@ public class AddNode extends Node { // Push constant up through the phi: x + (phi con0+con0 con1+con1...) // Note that this is the exact reverse of Phi pulling a common op - // down to reduce total op-count. We don't get in a endless push- + // down to reduce total op-count. We don't get in an endless push- // up push-down peephole cycle because the constants all fold first. - (t2.isConstant() || (rhs instanceof PhiNode && rhs.all_cons()) ) ) { + (t2.isConstant() || (rhs instanceof PhiNode && phi.in(0) == rhs.in(0) && rhs.all_cons()) ) ) { Node[] ns = new Node[phi.nIns()]; ns[0] = phi.in(0); // Push constant up through the phi: x + (phi con0+con0 con1+con1...) diff --git a/chapter05/src/main/java/com/seaofnodes/simple/node/PhiNode.java b/chapter05/src/main/java/com/seaofnodes/simple/node/PhiNode.java index 4334ac10..8e0c9a79 100644 --- a/chapter05/src/main/java/com/seaofnodes/simple/node/PhiNode.java +++ b/chapter05/src/main/java/com/seaofnodes/simple/node/PhiNode.java @@ -50,11 +50,6 @@ public class PhiNode extends Node { } Node phi_lhs = new PhiNode(lhss).peephole(); Node phi_rhs = new PhiNode(rhss).peephole(); - //if( phi_lhs instanceof PhiNode && phi_rhs instanceof PhiNode ) { - // phi_lhs.kill(); - // phi_rhs.kill(); - // return null; // No progress, no profit - //} return op.copy(phi_lhs,phi_rhs); } |
