Skip to content

Commit 41863b1

Browse files
committed
[GR-33496] Better guarded replacements in read elimination
PullRequest: graal/9711
2 parents ec2efa3 + 9b1b357 commit 41863b1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/src/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/ReadEliminationClosure.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected boolean processNode(Node node, ReadEliminationBlockState state, GraphE
107107
LoadCacheEntry identifier = new LoadCacheEntry(object, new FieldLocationIdentity(access.field()));
108108
ValueNode cachedValue = state.getCacheEntry(identifier);
109109
if (node instanceof LoadFieldNode) {
110-
if (cachedValue != null && access.stamp(NodeView.DEFAULT).isCompatible(cachedValue.stamp(NodeView.DEFAULT))) {
110+
if (cachedValue != null && areValuesReplaceable(access, cachedValue, considerGuards)) {
111111
effects.replaceAtUsages(access, cachedValue, access);
112112
addScalarAlias(access, cachedValue);
113113
deleted = true;
@@ -224,7 +224,7 @@ protected boolean processNode(Node node, ReadEliminationBlockState state, GraphE
224224
return deleted;
225225
}
226226

227-
private static boolean areValuesReplaceable(ValueNode originalValue, ValueNode replacementValue, boolean considerGuards) {
227+
protected static boolean areValuesReplaceable(ValueNode originalValue, ValueNode replacementValue, boolean considerGuards) {
228228
return originalValue.stamp(NodeView.DEFAULT).isCompatible(replacementValue.stamp(NodeView.DEFAULT)) &&
229229
(!considerGuards || (getGuard(originalValue) == null || getGuard(originalValue) == getGuard(replacementValue)));
230230
}

0 commit comments

Comments
 (0)