--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ZeroExtendNode.java Fri Feb 02 10:37:48 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ZeroExtendNode.java Fri Feb 02 17:28:17 2018 -0800
@@ -24,7 +24,7 @@
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_1;
-import org.graalvm.compiler.core.common.calc.Condition;
+import org.graalvm.compiler.core.common.calc.CanonicalCondition;
import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
import org.graalvm.compiler.core.common.type.ArithmeticOpTable.IntegerConvertOp;
import org.graalvm.compiler.core.common.type.ArithmeticOpTable.IntegerConvertOp.Narrow;
@@ -50,26 +50,33 @@
public static final NodeClass<ZeroExtendNode> TYPE = NodeClass.create(ZeroExtendNode.class);
+ private final boolean inputAlwaysPositive;
+
public ZeroExtendNode(ValueNode input, int resultBits) {
- this(input, PrimitiveStamp.getBits(input.stamp(NodeView.DEFAULT)), resultBits);
+ this(input, PrimitiveStamp.getBits(input.stamp(NodeView.DEFAULT)), resultBits, false);
assert 0 < PrimitiveStamp.getBits(input.stamp(NodeView.DEFAULT)) && PrimitiveStamp.getBits(input.stamp(NodeView.DEFAULT)) <= resultBits;
}
- public ZeroExtendNode(ValueNode input, int inputBits, int resultBits) {
+ public ZeroExtendNode(ValueNode input, int inputBits, int resultBits, boolean inputAlwaysPositive) {
super(TYPE, ArithmeticOpTable::getZeroExtend, ArithmeticOpTable::getNarrow, inputBits, resultBits, input);
+ this.inputAlwaysPositive = inputAlwaysPositive;
}
public static ValueNode create(ValueNode input, int resultBits, NodeView view) {
- return create(input, PrimitiveStamp.getBits(input.stamp(view)), resultBits, view);
+ 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, false);
+ }
+
+ public static ValueNode create(ValueNode input, int inputBits, int resultBits, NodeView view, boolean alwaysPositive) {
IntegerConvertOp<ZeroExtend> signExtend = ArithmeticOpTable.forStamp(input.stamp(view)).getZeroExtend();
ValueNode synonym = findSynonym(signExtend, input, inputBits, resultBits, signExtend.foldStamp(inputBits, resultBits, input.stamp(view)));
if (synonym != null) {
return synonym;
}
- return canonical(null, input, inputBits, resultBits, view);
+ return canonical(null, input, inputBits, resultBits, view, alwaysPositive);
}
@Override
@@ -77,12 +84,13 @@
return true;
}
+ public boolean isInputAlwaysPositive() {
+ return inputAlwaysPositive;
+ }
+
@Override
- public boolean preservesOrder(Condition cond) {
+ public boolean preservesOrder(CanonicalCondition cond) {
switch (cond) {
- case GE:
- case GT:
- case LE:
case LT:
return false;
default:
@@ -98,16 +106,16 @@
return ret;
}
- return canonical(this, forValue, getInputBits(), getResultBits(), view);
+ return canonical(this, forValue, getInputBits(), getResultBits(), view, inputAlwaysPositive);
}
- private static ValueNode canonical(ZeroExtendNode zeroExtendNode, ValueNode forValue, int inputBits, int resultBits, NodeView view) {
+ private static ValueNode canonical(ZeroExtendNode zeroExtendNode, ValueNode forValue, int inputBits, int resultBits, NodeView view, boolean alwaysPositive) {
ZeroExtendNode self = zeroExtendNode;
if (forValue instanceof ZeroExtendNode) {
// xxxx -(zero-extend)-> 0000 xxxx -(zero-extend)-> 00000000 0000xxxx
// ==> xxxx -(zero-extend)-> 00000000 0000xxxx
ZeroExtendNode other = (ZeroExtendNode) forValue;
- return new ZeroExtendNode(other.getValue(), other.getInputBits(), resultBits);
+ return new ZeroExtendNode(other.getValue(), other.getInputBits(), resultBits, other.isInputAlwaysPositive());
}
if (forValue instanceof NarrowNode) {
NarrowNode narrow = (NarrowNode) forValue;
@@ -135,7 +143,7 @@
}
if (self == null) {
- self = new ZeroExtendNode(forValue, inputBits, resultBits);
+ self = new ZeroExtendNode(forValue, inputBits, resultBits, alwaysPositive);
}
return self;
}