diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-27 08:52:12 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-27 08:52:12 -0700 |
| commit | c5ef4e52fd7d183861b33476db999fa04f777607 (patch) | |
| tree | fae4a9fb155a2e60b4b4390cd0ad3d30851257c8 /chapter18/src/main/java/com/seaofnodes | |
| parent | 4391fcc03a214e6296e19ca42487de023ab12f6a (diff) | |
| download | Simple-c5ef4e52fd7d183861b33476db999fa04f777607.tar.gz Simple-c5ef4e52fd7d183861b33476db999fa04f777607.zip | |
Remove -disablePeephole
Diffstat (limited to 'chapter18/src/main/java/com/seaofnodes')
5 files changed, 5 insertions, 29 deletions
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 @@ -285,12 +285,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<nIns(); i++ ) diff --git a/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java b/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java index 9a076dea..b3aa27be 100644 --- a/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java +++ b/chapter18/src/main/java/com/seaofnodes/simple/node/RegionNode.java @@ -68,8 +68,7 @@ public class RegionNode extends CFGNode { return in(1); // Collapse if no Phis; 1-input Phis will collapse on their own // If a CFG diamond with no merging, delete: "if( pred ) {} else {};" - if( !_disablePeephole && // Optional - !hasPhi() && // No Phi users, just a control user + if( !hasPhi() && // No Phi users, just a control user in(1) instanceof CProjNode p1 && in(2) instanceof CProjNode p2 && p1.in(0).addDep(this)==p2.in(0).addDep(this) && |
