summaryrefslogtreecommitdiff
path: root/chapter25/src/main/java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-19 09:33:28 -0700
committerCliff Click <cliffc@acm.org>2026-10-19 09:33:28 -0700
commitef8d9c4630db6af79c25526c8e80c54a48df4e39 (patch)
treec21474ceab3af7d8661ae93f7fc49002d96fcd43 /chapter25/src/main/java
parent300d2a9c3672acacc8bdd8d5370a424651a00571 (diff)
downloadSimple-ef8d9c4630db6af79c25526c8e80c54a48df4e39.tar.gz
Simple-ef8d9c4630db6af79c25526c8e80c54a48df4e39.zip
Fix memory on Load splitting up
Diffstat (limited to 'chapter25/src/main/java')
-rw-r--r--chapter25/src/main/java/com/seaofnodes/simple/node/LoadNode.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/chapter25/src/main/java/com/seaofnodes/simple/node/LoadNode.java b/chapter25/src/main/java/com/seaofnodes/simple/node/LoadNode.java
index 0a997083..c58bba39 100644
--- a/chapter25/src/main/java/com/seaofnodes/simple/node/LoadNode.java
+++ b/chapter25/src/main/java/com/seaofnodes/simple/node/LoadNode.java
@@ -169,8 +169,9 @@ public class LoadNode extends MemOpNode {
// else ptr.x = e1; : e1;
// val = ptr.x; ptr.x = val;
if( mem() instanceof MemPhiNode memphi && memphi.region()._type == Type.CONTROL && memphi.nIns()== 3 &&
- // Array access control must not be moved across the merge.
- in(0)==null &&
+ // Retain control on both copies only if it dominates both paths.
+ // The Region itself, or a later range check, cannot move to its inputs.
+ (in(0)==null || cfg0().domLCA(memphi.region().idom(this),this)==cfg0()) &&
// Offset can be hoisted
off() instanceof ConstantNode &&
// Pointer can be hoisted