From 218c483532aa9565e905d8a3dd843b2fe66c6503 Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Fri, 22 Dec 2023 10:39:26 +0100 Subject: [PATCH] Deprecate ZeroExtendNode.inputAlwaysPositive. --- .../amd64/AMD64HotSpotAddressLowering.java | 4 ++-- .../compiler/nodes/calc/SignExtendNode.java | 2 +- .../compiler/nodes/calc/ZeroExtendNode.java | 15 ++++----------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotAddressLowering.java b/compiler/src/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotAddressLowering.java index 7417b4ad3240..8dc3b7c18b6b 100644 --- a/compiler/src/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotAddressLowering.java +++ b/compiler/src/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotAddressLowering.java @@ -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)); } } } diff --git a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignExtendNode.java b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignExtendNode.java index 0d258dc33153..87f3f63a7134 100644 --- a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignExtendNode.java +++ b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignExtendNode.java @@ -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) { diff --git a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ZeroExtendNode.java b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ZeroExtendNode.java index accd76d8adb9..61d6946bf082 100644 --- a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ZeroExtendNode.java +++ b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ZeroExtendNode.java @@ -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; @@ -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) { @@ -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 getOp(ArithmeticOpTable table) { return table.getZeroExtend();