From e9d9542d246a8e91a62ba9a82b9899959fd386a8 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Fri, 18 Oct 2024 16:47:55 -0700 Subject: Bunch of fuzzer fixes Mostly minor progress. Lost? shl/shr/sar high-type fixes. Turn off some printing crept back in --- .../src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java | 10 +++++----- .../src/main/java/com/seaofnodes/simple/node/MulNode.java | 2 ++ .../src/main/java/com/seaofnodes/simple/node/RegionNode.java | 6 +++--- .../src/main/java/com/seaofnodes/simple/node/SarNode.java | 7 +++++-- .../src/main/java/com/seaofnodes/simple/node/ShlNode.java | 7 +++++-- .../src/main/java/com/seaofnodes/simple/node/ShrNode.java | 7 +++++-- 6 files changed, 25 insertions(+), 14 deletions(-) (limited to 'chapter16/src/main/java/com') diff --git a/chapter16/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java b/chapter16/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java index 35dc19ab..fb6477d3 100644 --- a/chapter16/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java +++ b/chapter16/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java @@ -69,6 +69,10 @@ public abstract class GlobalCodeMotion { cfg.loopDepth(); for( Node n : cfg._inputs ) _schedEarly(n,visit); + if( cfg instanceof RegionNode ) + for( Node phi : cfg._outputs ) + if( phi instanceof PhiNode ) + _schedEarly(phi,visit); } } @@ -91,7 +95,7 @@ public abstract class GlobalCodeMotion { // a data-only loop, eventually attempting relying on some pre-visited- // not-post-visited data op with no scheduled control. for( Node def : n._inputs ) - if( def!=null && !def.isPinned() ) + if( def!=null && !(def instanceof PhiNode) ) _schedEarly(def,visit); // If not-pinned (e.g. constants, projections, phi) and not-CFG if( !n.isPinned() ) { @@ -103,10 +107,6 @@ public abstract class GlobalCodeMotion { early = n.in(i).cfg0(); // Latest/deepest input n.setDef(0,early); // First place this can go } - // Also the pinned inputs we skipped earlier - for( Node def : n._inputs ) - if( def!=null && def.isPinned() ) - _schedEarly(def,visit); } // ------------------------------------------------------------------------ diff --git a/chapter16/src/main/java/com/seaofnodes/simple/node/MulNode.java b/chapter16/src/main/java/com/seaofnodes/simple/node/MulNode.java index f231a97b..b5ef91e9 100644 --- a/chapter16/src/main/java/com/seaofnodes/simple/node/MulNode.java +++ b/chapter16/src/main/java/com/seaofnodes/simple/node/MulNode.java @@ -26,6 +26,8 @@ public class MulNode extends Node { return TypeInteger.TOP; if( t1 instanceof TypeInteger i1 && t2 instanceof TypeInteger i2 ) { + if( i1==TypeInteger.ZERO || i2==TypeInteger.ZERO) + return TypeInteger.ZERO; if (i1.isConstant() && i2.isConstant()) return TypeInteger.constant(i1.value()*i2.value()); } diff --git a/chapter16/src/main/java/com/seaofnodes/simple/node/RegionNode.java b/chapter16/src/main/java/com/seaofnodes/simple/node/RegionNode.java index 68f8cbe6..941de76b 100644 --- a/chapter16/src/main/java/com/seaofnodes/simple/node/RegionNode.java +++ b/chapter16/src/main/java/com/seaofnodes/simple/node/RegionNode.java @@ -102,7 +102,7 @@ public class RegionNode extends CFGNode { // A walk that can be cutoff early private static final BitSet VISIT = new BitSet(); - private static boolean walk( IfNode iff, CProjNode cproj, Node n ) { + private boolean walk( IfNode iff, CProjNode cproj, Node n ) { if( VISIT.get(n._nid) ) return false; VISIT.set(n._nid); if( n instanceof CFGNode ) return false; @@ -110,7 +110,7 @@ public class RegionNode extends CFGNode { return false; boolean progress = false; Node pred = iff.pred(); - if( pred._type.isConstant() ) return false; // This will collapse the IF already + if( pred._type.isHighOrConst() ) return false; // This will collapse the IF already for( int i=1; i