Skip to content

Commit

Permalink
[GR-51300] Backport to 21.3: Deprecate ZeroExtendNode.inputAlwaysPosi…
Browse files Browse the repository at this point in the history
…tive.

PullRequest: graal/16555
  • Loading branch information
mur47x111 committed Mar 27, 2024
2 parents 23cdd21 + 218c483 commit e30195e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ private static ValueNode signExtend(ValueNode input, LoopEx loop) {
if (init >= 0 && extremum >= 0) {
long shortestTrip = (extremum - init) / stride + 1;
if (countedLoopInfo.constantMaxTripCount().equals(shortestTrip)) {
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, true));
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, false));
}
}
}
if (countedLoopInfo.getLimitCheckedIV() == inductionVariable &&
inductionVariable.direction() == InductionVariable.Direction.Up &&
(countedLoopInfo.getOverFlowGuard() != null || countedLoopInfo.counterNeverOverflows())) {
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, true));
return graph.unique(new ZeroExtendNode(input, INT_BITS, ADDRESS_BITS, false));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static ValueNode canonical(SignExtendNode self, ValueNode forValue, int
if ((inputStamp.upMask() & (1L << (inputBits - 1))) == 0L) {
// 0xxx -(sign-extend)-> 0000 0xxx
// ==> 0xxx -(zero-extend)-> 0000 0xxx
return ZeroExtendNode.create(forValue, inputBits, resultBits, view, true);
return ZeroExtendNode.create(forValue, inputBits, resultBits, view, false);
}
}
if (forValue instanceof NarrowNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.graalvm.compiler.core.common.type.IntegerStamp;
import org.graalvm.compiler.core.common.type.PrimitiveStamp;
import org.graalvm.compiler.core.common.type.Stamp;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.graph.NodeClass;
import org.graalvm.compiler.nodes.spi.CanonicalizerTool;
import org.graalvm.compiler.lir.gen.ArithmeticLIRGeneratorTool;
Expand Down Expand Up @@ -63,14 +64,15 @@ public ZeroExtendNode(ValueNode input, int resultBits) {
public ZeroExtendNode(ValueNode input, int inputBits, int resultBits, boolean inputAlwaysPositive) {
super(TYPE, getArithmeticOpTable(input).getZeroExtend(), inputBits, resultBits, input);
this.inputAlwaysPositive = inputAlwaysPositive;
GraalError.guarantee(!inputAlwaysPositive, "ZeroExtendNode.inputAlwaysPositive is deprecated.");
}

public static ValueNode create(ValueNode input, int resultBits, NodeView view) {
return create(input, PrimitiveStamp.getBits(input.stamp(view)), resultBits, view, inputAlwaysPositive(input));
return create(input, PrimitiveStamp.getBits(input.stamp(view)), resultBits, view, false);
}

public static ValueNode create(ValueNode input, int inputBits, int resultBits, NodeView view) {
return create(input, inputBits, resultBits, view, inputAlwaysPositive(input));
return create(input, inputBits, resultBits, view, false);
}

public static ValueNode create(ValueNode input, int inputBits, int resultBits, NodeView view, boolean alwaysPositive) {
Expand All @@ -82,15 +84,6 @@ public static ValueNode create(ValueNode input, int inputBits, int resultBits, N
return canonical(null, input, inputBits, resultBits, view, alwaysPositive);
}

private static boolean inputAlwaysPositive(ValueNode v) {
Stamp s = v.stamp(NodeView.DEFAULT);
if (s instanceof IntegerStamp) {
return ((IntegerStamp) s).isPositive();
} else {
return false;
}
}

@Override
protected IntegerConvertOp<ZeroExtend> getOp(ArithmeticOpTable table) {
return table.getZeroExtend();
Expand Down

0 comments on commit e30195e

Please sign in to comment.