diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-11 16:56:07 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-11 16:56:07 -0700 |
| commit | 5b07c027577503f4d9ecb7ea6c950cb24a144347 (patch) | |
| tree | 6501296eb5399b84498bd581dbe0488e54cc1761 /chapter25/src/main/java | |
| parent | 5d1e4944f474191bedbd61b311114e361cd7ed32 (diff) | |
| download | Simple-5b07c027577503f4d9ecb7ea6c950cb24a144347.tar.gz Simple-5b07c027577503f4d9ecb7ea6c950cb24a144347.zip | |
Removing a phi-of-guard, remove nested guards
Diffstat (limited to 'chapter25/src/main/java')
| -rw-r--r-- | chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java b/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java index 2b6d2666..17868faf 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java @@ -125,13 +125,19 @@ public class PhiNode extends Node { // If merging Phi(ZERO, guardNZ(N)) - we are losing the cast JOIN effects, so just remove. if( nIns()==3 ) { - if( in(1) instanceof GuardNode cast && cast._nonZero && in(2)._type.makeZero()==in(2)._type && cast.in(1)!=this ) return cast.in(1); - if( in(2) instanceof GuardNode cast && cast._nonZero && in(1)._type.makeZero()==in(1)._type && cast.in(1)!=this ) return cast.in(1); + if( in(1) instanceof GuardNode cast && cast._nonZero && in(2)._type.makeZero()==in(2)._type && cast.in(1)!=this ) return unguard(cast.in(1)); + if( in(2) instanceof GuardNode cast && cast._nonZero && in(1)._type.makeZero()==in(1)._type && cast.in(1)!=this ) return unguard(cast.in(1)); } return null; } + private static Node unguard(Node n) { + while( n instanceof GuardNode guard ) + n = guard.in(1); + return n; + } + // Same op on all Phi paths; all ops have only the Phi as a use. // None have a control input. private boolean same_op() { |
