From c5ef4e52fd7d183861b33476db999fa04f777607 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 27 Sep 2026 08:52:12 -0700 Subject: Remove -disablePeephole --- .../src/main/java/com/seaofnodes/simple/CodeGen.java | 7 ++----- .../main/java/com/seaofnodes/simple/node/IfNode.java | 1 - .../main/java/com/seaofnodes/simple/node/Node.java | 20 ++------------------ .../java/com/seaofnodes/simple/node/PhiNode.java | 3 --- .../java/com/seaofnodes/simple/node/RegionNode.java | 3 +-- 5 files changed, 5 insertions(+), 29 deletions(-) (limited to 'chapter18/src/main/java/com') diff --git a/chapter18/src/main/java/com/seaofnodes/simple/CodeGen.java b/chapter18/src/main/java/com/seaofnodes/simple/CodeGen.java index 65d820f5..a9dfe476 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/CodeGen.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/CodeGen.java @@ -45,14 +45,12 @@ public class CodeGen { CodeGen( String src, TypeInteger arg ) { _phase = null; _src = src; _arg=arg; CODE=this; } public CodeGen( String src ) { this(src,TypeInteger.BOT); } - public CodeGen parse() { return parse(false); } - public CodeGen parse(boolean disable) { + public CodeGen parse() { assert _phase == null; _phase = Phase.Parse; _linker.clear(); P = new Parser(_src,_arg); - Node._disablePeephole = disable; _stop = P.parse(); _start = Parser.START; // Capture global start if( _obs != null ) _obs.phase("Parse"); @@ -75,8 +73,7 @@ public class CodeGen { public CodeGen typeCheck() { // Demand phase Opto for cleaning up dead control flow at least, - // required for the following GCM. Note that peeps can be disabled, - // but still the dead CFG will get cleaned. + // required for the following GCM. assert _phase == Phase.Opto; _phase = Phase.TypeCheck; diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/IfNode.java b/chapter18/src/main/java/com/seaofnodes/simple/node/IfNode.java index eafcdf5b..c49ee662 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/IfNode.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/IfNode.java @@ -34,7 +34,6 @@ public class IfNode extends CFGNode implements MultiNode { // If the If node is not reachable then neither is any following Proj if (ctrl()._type != Type.CONTROL && ctrl()._type != Type.BOTTOM ) return TypeTuple.IF_NEITHER; - if( _disablePeephole ) return TypeTuple.IF_BOTH; Node pred = pred(); Type t = pred._type; // High types mean NEITHER side is reachable. diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/Node.java b/chapter18/src/main/java/com/seaofnodes/simple/node/Node.java index 637f4b14..0016c711 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/Node.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/Node.java @@ -284,12 +284,6 @@ public abstract class Node implements Cloneable { // ------------------------------------------------------------------------ // Graph-based optimizations - /** - * We allow disabling peephole opt so that we can observe the - * full graph, vs the optimized graph. - */ - public static boolean _disablePeephole = false; - /** * Try to peephole at this node and return a better replacement Node. * Always returns some not-null Node (often this). @@ -326,17 +320,8 @@ public abstract class Node implements Cloneable { // Compute initial or improved Type Type old = setType(compute()); - // Peepholes can be turned off - except for cleaning up dead CFG paths. - // These need to clean up so the following code motion algorithms don't - // get confused by dead or infinite paths. - if( _disablePeephole && !(this instanceof RegionNode) && !(this instanceof PhiNode) ) - return old==_type ? null : this; // Peephole optimizations turned off - - // Replace constant computations from non-constants with a constant - // node. If peeps are disabled, still allow high Phis to collapse; - // they typically come from dead Regions, and we want the Region to - // collapse, which requires the Phis to die first. - if( _type.isHighOrConst() && !isConst() && (!_disablePeephole || _type.isHigh()) ) + // Replace constant computations from non-constants with a constant node. + if( _type.isHighOrConst() && !isConst() ) return ConstantNode.make(_type).peepholeOpt(); // Global Value Numbering @@ -633,7 +618,6 @@ public abstract class Node implements Cloneable { */ public static void reset() { UNIQUE_ID = 1; - _disablePeephole=false; GVN.clear(); ITER_CNT = ITER_NOP_CNT = 0; } diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/PhiNode.java b/chapter18/src/main/java/com/seaofnodes/simple/node/PhiNode.java index b3e36d41..1f3062e8 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/PhiNode.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/PhiNode.java @@ -70,9 +70,6 @@ public class PhiNode extends Node { Node live = singleUniqueInput(); if (live != null) return live; - // No more fancy peeps - if( _disablePeephole ) - return null; // No bother if region is going to fold dead paths soon for( int i=1; i