From ef8d9c4630db6af79c25526c8e80c54a48df4e39 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 19 Oct 2026 09:33:28 -0700 Subject: Fix memory on Load splitting up --- chapter19/src/main/java/com/seaofnodes/simple/node/LoadNode.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'chapter19/src/main') diff --git a/chapter19/src/main/java/com/seaofnodes/simple/node/LoadNode.java b/chapter19/src/main/java/com/seaofnodes/simple/node/LoadNode.java index a06d1291..ec0a81c9 100644 --- a/chapter19/src/main/java/com/seaofnodes/simple/node/LoadNode.java +++ b/chapter19/src/main/java/com/seaofnodes/simple/node/LoadNode.java @@ -143,6 +143,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 && + // 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 -- cgit v1.2.3