Skip to content

Commit

Permalink
[GR-50693] Propagate information through CompressionNodes during cond…
Browse files Browse the repository at this point in the history
…itional elimination.

PullRequest: graal/16866
  • Loading branch information
rmosaner committed Feb 19, 2024
2 parents dc877ee + 5ae9a83 commit c1bc909
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ protected void appendString(StringBuilder str) {

@Override
public Stamp meet(Stamp otherStamp) {
assert isCompatible(otherStamp) : "Cannot union incompatible stamps: " + this + " | " + otherStamp;
if (this == otherStamp) {
return this;
}
Expand Down Expand Up @@ -224,6 +225,7 @@ public Stamp improveWith(Stamp other) {
}

private Stamp join0(Stamp otherStamp, boolean improve) {
assert isCompatible(otherStamp) : "Cannot join incompatible stamps: " + this + " | " + otherStamp;
if (this == otherStamp) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.graalvm.collections.MapCursor;

import jdk.graal.compiler.core.common.cfg.BlockMap;
import jdk.graal.compiler.core.common.type.AbstractObjectStamp;
import jdk.graal.compiler.core.common.type.ArithmeticOpTable;
import jdk.graal.compiler.core.common.type.ArithmeticOpTable.BinaryOp;
import jdk.graal.compiler.core.common.type.ArithmeticOpTable.BinaryOp.And;
Expand All @@ -55,6 +56,7 @@
import jdk.graal.compiler.nodes.AbstractBeginNode;
import jdk.graal.compiler.nodes.AbstractMergeNode;
import jdk.graal.compiler.nodes.BinaryOpLogicNode;
import jdk.graal.compiler.nodes.CompressionNode;
import jdk.graal.compiler.nodes.ConditionAnchorNode;
import jdk.graal.compiler.nodes.DeoptimizeNode;
import jdk.graal.compiler.nodes.DeoptimizingGuard;
Expand Down Expand Up @@ -601,6 +603,24 @@ private void tryImproveAnchoredPi(PiNode piNode) {
registerNewStamp(piNode.object(), piNode.piStamp(), piNode.getGuard());
}

private void processCompressionNode(CompressionNode compression) {
if (!(compression.stamp(NodeView.DEFAULT) instanceof AbstractObjectStamp)) {
return;
}

AbstractObjectStamp stamp = (AbstractObjectStamp) compression.stamp(NodeView.DEFAULT);
ConditionalEliminationUtil.InfoElement infoElement = infoElementProvider.infoElements(compression.getValue());
while (infoElement != null) {
if (infoElement.getStamp() instanceof AbstractObjectStamp objStamp) {
Stamp improvedStamp = compression.foldStamp(infoElement.getStamp());
if (!stamp.equals(improvedStamp)) {
registerNewStamp(compression, improvedStamp, infoElement.getGuard());
}
}
infoElement = infoElementProvider.nextElement(infoElement);
}
}

@Override
public ConditionalEliminationUtil.Marks enter(HIRBlock block) {
int infoElementsMark = undoOperations.size();
Expand Down Expand Up @@ -671,6 +691,8 @@ protected void processNode(Node node) {
processEnd((EndNode) node);
} else if (node instanceof ValueAnchorNode) {
processValueAnchor((ValueAnchorNode) node);
} else if (node instanceof CompressionNode c) {
processCompressionNode(c);
}
}
}
Expand Down

0 comments on commit c1bc909

Please sign in to comment.