summaryrefslogtreecommitdiff
path: root/chapter12/src/main/java/com/seaofnodes
diff options
context:
space:
mode:
authorRobert Obkircher <robert.obkircher@gmail.com>2024-09-16 14:22:13 +0200
committerCliff Click <cliffc@acm.org>2024-09-16 09:07:32 -0700
commitc7445ad142aeaece5b2b1059c193735ba7e509d9 (patch)
treeaeac3ebcdd1591bd9cab7d110bec6a0e672331cb /chapter12/src/main/java/com/seaofnodes
parentbb3147d5b212d675ca2575ac1b571aaaf478cf5e (diff)
downloadSimple-c7445ad142aeaece5b2b1059c193735ba7e509d9.tar.gz
Simple-c7445ad142aeaece5b2b1059c193735ba7e509d9.zip
remove peephole from ProjNode::idealize that is already handled by compute
Diffstat (limited to 'chapter12/src/main/java/com/seaofnodes')
-rw-r--r--chapter12/src/main/java/com/seaofnodes/simple/node/CProjNode.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/chapter12/src/main/java/com/seaofnodes/simple/node/CProjNode.java b/chapter12/src/main/java/com/seaofnodes/simple/node/CProjNode.java
index 3d6fd1fa..fb0ff879 100644
--- a/chapter12/src/main/java/com/seaofnodes/simple/node/CProjNode.java
+++ b/chapter12/src/main/java/com/seaofnodes/simple/node/CProjNode.java
@@ -37,17 +37,14 @@ public class CProjNode extends CFGNode {
@Override
public Node idealize() {
- if( ctrl()._type instanceof TypeTuple tt ) {
- if( tt._types[_idx]==Type.XCONTROL )
- return Parser.XCTRL; // 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 CProjNode(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 CProjNode(new IfNode(iff.ctrl(),not.in(1)).peephole(),1-_idx,_idx==0 ? "False" : "True");
+ }
return null;
}