diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/type/AbstractObjectStamp.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/type/AbstractObjectStamp.java index a4655301b103..245705bc68b3 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/type/AbstractObjectStamp.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/type/AbstractObjectStamp.java @@ -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; } @@ -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; } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/phases/common/ConditionalEliminationPhase.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/phases/common/ConditionalEliminationPhase.java index 447a7f0c23fd..2e6a29658250 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/phases/common/ConditionalEliminationPhase.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/phases/common/ConditionalEliminationPhase.java @@ -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; @@ -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; @@ -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(); @@ -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); } } }