From 4410e4e3d7a4b9e0424de7678633e2a7240695cd Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 30 Oct 2023 09:01:57 -0700 Subject: Bug fix last peephole --- chapter05/src/main/java/com/seaofnodes/simple/node/AddNode.java | 4 ++-- chapter05/src/main/java/com/seaofnodes/simple/node/PhiNode.java | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'chapter05/src/main') 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); } -- cgit v1.2.3