summaryrefslogtreecommitdiff
path: root/chapter17a/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'chapter17a/src/main/java/com')
-rw-r--r--chapter17a/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/chapter17a/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java b/chapter17a/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java
index eba99128..c6d02b27 100644
--- a/chapter17a/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java
+++ b/chapter17a/src/main/java/com/seaofnodes/simple/GlobalCodeMotion.java
@@ -207,10 +207,11 @@ public abstract class GlobalCodeMotion {
lca = anti_dep(load,late[st._nid],st.cfg0(),lca,st,anti);
break;
case PhiNode phi:
- // Repeat anti-dep for matching Phi inputs.
- // No anti-dep edges but may raise the LCA.
+ // Inputs carrying different memory might overwrite this alias.
+ // Raise the LCA for those paths; unchanged memory does not
+ // clobber the load. No scheduling edge to the Phi.
for( int i=1; i<phi.nIns(); i++ )
- if( phi.in(i)==load.mem() )
+ if( phi.in(i)!=load.mem() )
lca = anti_dep(load,phi.region().cfg(i),load.mem().cfg0(),lca,null,anti);
break;
default: throw Utils.TODO();
@@ -223,7 +224,9 @@ public abstract class GlobalCodeMotion {
private static CFGNode anti_dep( LoadNode load, CFGNode stblk, CFGNode defblk, CFGNode lca, Node st, int[] anti ) {
// Preserve the full store range for the earlier evaluator scheduler.
// It places nodes independently of GCM and may hoist this store.
- for( ; stblk != defblk.idom(); stblk = stblk.idom() ) {
+ // Another Phi input need not be dominated by this memory definition.
+ // Include its depth, and retain the sentinel for an entry's null idom.
+ for( ; stblk != defblk.idom() && stblk.idepth() >= defblk.idepth(); stblk = stblk.idom() ) {
// Store and Load overlap, need anti-dependence
if( anti[stblk._nid]==load._nid ) {
lca = stblk.domLCA(lca,null); // Raise Loads LCA