From c7445ad142aeaece5b2b1059c193735ba7e509d9 Mon Sep 17 00:00:00 2001 From: Robert Obkircher Date: Mon, 16 Sep 2024 14:22:13 +0200 Subject: remove peephole from ProjNode::idealize that is already handled by compute --- .../main/java/com/seaofnodes/simple/node/ProjNode.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'chapter10/src/main/java/com') diff --git a/chapter10/src/main/java/com/seaofnodes/simple/node/ProjNode.java b/chapter10/src/main/java/com/seaofnodes/simple/node/ProjNode.java index 18526677..735fcdf3 100644 --- a/chapter10/src/main/java/com/seaofnodes/simple/node/ProjNode.java +++ b/chapter10/src/main/java/com/seaofnodes/simple/node/ProjNode.java @@ -40,17 +40,14 @@ public class ProjNode extends Node { @Override public Node idealize() { - if( ctrl()._type instanceof TypeTuple tt ) { - if( tt._types[_idx]==Type.XCONTROL ) - return new ConstantNode(Type.XCONTROL).peephole(); // We are dead - if( ctrl() instanceof IfNode && tt._types[1-_idx]==Type.XCONTROL ) // Only true for IfNodes - return ctrl().in(0); // We become our input control - } - - // Flip a negating if-test, to remove the not - if( ctrl() instanceof IfNode iff && iff.pred().addDep(this) instanceof NotNode not ) - return new ProjNode((MultiNode)new IfNode(iff.ctrl(),not.in(1)).peephole(),1-_idx,_idx==0 ? "False" : "True"); + if ( ctrl() instanceof IfNode iff ) { + if ( iff._type instanceof TypeTuple tt && tt._types[1 - _idx] == Type.XCONTROL ) + return iff.in(0); // We become our input control + // Flip a negating if-test, to remove the not + if( iff.pred().addDep(this) instanceof NotNode not ) + return new ProjNode((MultiNode)new IfNode(iff.ctrl(),not.in(1)).peephole(),1-_idx,_idx==0 ? "False" : "True"); + } return null; } -- cgit v1.2.3