Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mandrel 23.0.4 update #726

Merged
merged 6 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GuardNode> guards = loop.whole().nodes().filter(GuardNode.class);
if (LoopPredicationMainPath.getValue(graph.getOptions())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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.lir.gen.ArithmeticLIRGeneratorTool;
import org.graalvm.compiler.nodeinfo.NodeInfo;
Expand Down Expand Up @@ -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) {
Expand All @@ -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<ZeroExtend> getOp(ArithmeticOpTable table) {
return table.getZeroExtend();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@ 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) {
if (limitStamp.asConstant() != null && limitStamp.asConstant().asLong() == counterStamp.lowerBound()) {
// 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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions espresso/mx.espresso/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
4 changes: 2 additions & 2 deletions regex/mx.regex/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
4 changes: 2 additions & 2 deletions sdk/mx.sdk/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tools/mx.tools/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions truffle/mx.truffle/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions vm/mx.vm/suite.py
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
Loading