diff --git a/compiler/mx.compiler/suite.py b/compiler/mx.compiler/suite.py index 910c91335e3c..288abc267805 100644 --- a/compiler/mx.compiler/suite.py +++ b/compiler/mx.compiler/suite.py @@ -4,8 +4,8 @@ "sourceinprojectwhitelist" : [], "groupId" : "org.graalvm.compiler", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "url" : "http://www.graalvm.org/", "developer" : { "name" : "GraalVM Development", 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 7b958f650493..b5231c475d3b 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 @@ -187,14 +187,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.loop.phases/src/org/graalvm/compiler/loop/phases/LoopPredicationPhase.java b/compiler/src/org.graalvm.compiler.loop.phases/src/org/graalvm/compiler/loop/phases/LoopPredicationPhase.java index b52a4c070fa7..79f3b6134381 100644 --- a/compiler/src/org.graalvm.compiler.loop.phases/src/org/graalvm/compiler/loop/phases/LoopPredicationPhase.java +++ b/compiler/src/org.graalvm.compiler.loop.phases/src/org/graalvm/compiler/loop/phases/LoopPredicationPhase.java @@ -112,9 +112,8 @@ protected void run(StructuredGraph graph, MidTierContext context) { final InductionVariable counter = counted.getLimitCheckedIV(); final Condition condition = ((CompareNode) counted.getLimitTest().condition()).condition().asCondition(); final boolean inverted = loop.counted().isInverted(); - if ((((IntegerStamp) counter.valueNode().stamp(NodeView.DEFAULT)).getBits() == 32) && - !counted.isUnsignedCheck() && - ((condition != NE && condition != EQ) || (counter.isConstantStride() && Math.abs(counter.constantStride()) == 1)) && + if ((((IntegerStamp) counter.valueNode().stamp(NodeView.DEFAULT)).getBits() == 32) && !counted.isUnsignedCheck() && + ((condition != NE && condition != EQ) || (counter.isConstantStride() && LoopEx.absStrideIsOne(counter))) && (loop.loopBegin().isMainLoop() || loop.loopBegin().isSimpleLoop())) { NodeIterable guards = loop.whole().nodes().filter(GuardNode.class); if (LoopPredicationMainPath.getValue(graph.getOptions())) { 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 3c006ec01eed..4d7526109ade 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 @@ -124,7 +124,7 @@ private static ValueNode canonical(SignExtendNode self, ValueNode forValue, int if ((inputStamp.mayBeSet() & (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 9e903c274f98..6e134cc8a43b 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.lir.gen.ArithmeticLIRGeneratorTool; import org.graalvm.compiler.nodeinfo.NodeInfo; @@ -67,14 +68,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) { @@ -86,15 +88,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(); diff --git a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/loop/LoopEx.java b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/loop/LoopEx.java index a5052d7dc47c..9221e841ea0e 100644 --- a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/loop/LoopEx.java +++ b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/loop/LoopEx.java @@ -332,7 +332,7 @@ public boolean detectCounted() { // signed: i < MAX_INT } else if (limitStamp.asConstant() != null && limitStamp.asConstant().asLong() == counterStamp.unsignedUpperBound()) { unsigned = true; - } else if (!iv.isConstantStride() || Math.abs(iv.constantStride()) != 1 || initStamp.upperBound() > limitStamp.lowerBound()) { + } else if (!iv.isConstantStride() || !absStrideIsOne(iv) || initStamp.upperBound() > limitStamp.lowerBound()) { return false; } } else if (iv.direction() == Direction.Down) { @@ -340,7 +340,7 @@ public boolean detectCounted() { // signed: MIN_INT > i } else if (limitStamp.asConstant() != null && limitStamp.asConstant().asLong() == counterStamp.unsignedLowerBound()) { unsigned = true; - } else if (!iv.isConstantStride() || Math.abs(iv.constantStride()) != 1 || initStamp.lowerBound() < limitStamp.upperBound()) { + } else if (!iv.isConstantStride() || !absStrideIsOne(iv) || initStamp.lowerBound() < limitStamp.upperBound()) { return false; } } else { @@ -387,6 +387,15 @@ public boolean detectCounted() { return false; } + public static boolean absStrideIsOne(InductionVariable limitCheckedIV) { + /* + * While Math.abs can overflow for MIN_VALUE it is fine here. In case of overflow we still + * get a value != 1 (namely MIN_VALUE again). Overflow handling for the limit checked IV is + * done in CountedLoopInfo and is an orthogonal issue. + */ + return Math.abs(limitCheckedIV.constantStride()) == 1; + } + public boolean isCfgLoopExit(AbstractBeginNode begin) { HIRBlock block = data.getCFG().blockFor(begin); return loop.getDepth() > block.getLoopDepth() || loop.isNaturalExit(block); diff --git a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/util/LoopUtility.java b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/util/LoopUtility.java index 59434d6166c3..57e549801225 100644 --- a/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/util/LoopUtility.java +++ b/compiler/src/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/util/LoopUtility.java @@ -28,6 +28,7 @@ import org.graalvm.compiler.core.common.type.IntegerStamp; import org.graalvm.compiler.core.common.type.Stamp; +import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.graph.Graph.NodeEvent; import org.graalvm.compiler.graph.Graph.NodeEventScope; import org.graalvm.compiler.nodes.LoopExitNode; @@ -48,6 +49,38 @@ public class LoopUtility { + public static boolean canTakeAbs(long l, int bits) { + try { + abs(l, bits); + return true; + } catch (ArithmeticException e) { + return false; + } + } + + /** + * Compute {@link Math#abs(long)} for the given arguments and the given bit size. Throw a + * {@link ArithmeticException} if the abs operation would overflow. + */ + public static long abs(long l, int bits) throws ArithmeticException { + if (bits == 32) { + if (l == Integer.MIN_VALUE) { + throw new ArithmeticException("Abs on Integer.MIN_VALUE would cause an overflow because abs(Integer.MIN_VALUE) = Integer.MAX_VALUE + 1 which does not fit in int (32 bits)"); + } else { + final int i = (int) l; + return Math.abs(i); + } + } else if (bits == 64) { + if (l == Long.MIN_VALUE) { + throw new ArithmeticException("Abs on Long.MIN_VALUE would cause an overflow because abs(Long.MIN_VALUE) = Long.MAX_VALUE + 1 which does not fit in long (64 bits)"); + } else { + return Math.abs(l); + } + } else { + throw GraalError.shouldNotReachHere("Must be one of java's core datatypes int/long but is " + bits); + } + } + public static boolean isNumericInteger(ValueNode v) { Stamp s = v.stamp(NodeView.DEFAULT); return s instanceof IntegerStamp; diff --git a/espresso/mx.espresso/suite.py b/espresso/mx.espresso/suite.py index fa1d179f325f..77278b997828 100644 --- a/espresso/mx.espresso/suite.py +++ b/espresso/mx.espresso/suite.py @@ -23,8 +23,8 @@ suite = { "mxversion": "6.17.0", "name": "espresso", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "groupId" : "org.graalvm.espresso", "url" : "https://www.graalvm.org/reference-manual/java-on-truffle/", "developer" : { diff --git a/regex/mx.regex/suite.py b/regex/mx.regex/suite.py index d3ee9caddde7..ea47e7fc1b20 100644 --- a/regex/mx.regex/suite.py +++ b/regex/mx.regex/suite.py @@ -43,8 +43,8 @@ "name" : "regex", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "groupId" : "org.graalvm.regex", "url" : "http://www.graalvm.org/", "developer" : { diff --git a/sdk/mx.sdk/suite.py b/sdk/mx.sdk/suite.py index 6dc751c84a45..92211c8cd645 100644 --- a/sdk/mx.sdk/suite.py +++ b/sdk/mx.sdk/suite.py @@ -41,8 +41,8 @@ suite = { "mxversion": "6.17.0", "name" : "sdk", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "sourceinprojectwhitelist" : [], "url" : "https://github.com/oracle/graal", "groupId" : "org.graalvm.sdk", diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index ad2ed11ac34a..074e5a52e850 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -2,8 +2,8 @@ suite = { "mxversion": "6.17.0", "name": "substratevm", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "url" : "https://github.com/oracle/graal/tree/master/substratevm", "groupId" : "org.graalvm.nativeimage", diff --git a/tools/mx.tools/suite.py b/tools/mx.tools/suite.py index ab00884c8fb4..710e38f41dca 100644 --- a/tools/mx.tools/suite.py +++ b/tools/mx.tools/suite.py @@ -26,8 +26,8 @@ "defaultLicense" : "GPLv2-CPE", "groupId" : "org.graalvm.tools", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "url" : "http://openjdk.java.net/projects/graal", "developer" : { "name" : "GraalVM Development", diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index a258dc4275b1..658b310f7869 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -41,8 +41,8 @@ suite = { "mxversion": "6.17.0", "name" : "truffle", - "version" : "23.0.4.0", - "release" : True, + "version" : "23.0.4.1", + "release" : False, "groupId" : "org.graalvm.truffle", "sourceinprojectwhitelist" : [], "url" : "http://openjdk.java.net/projects/graal", diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index edb5ba071c62..dfd9869727cf 100644 --- a/vm/mx.vm/suite.py +++ b/vm/mx.vm/suite.py @@ -1,8 +1,8 @@ suite = { "name": "vm", - "version" : "23.0.4.0", + "version" : "23.0.4.1", "mxversion": "6.17.0", - "release" : True, + "release" : False, "groupId" : "org.graalvm", "url" : "http://www.graalvm.org/",