use of org.graalvm.compiler.core.common.type.FloatStamp in project graal by oracle.
the class ReinterpretStampDoubleToLongTest method data.
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
List<Object[]> ret = new ArrayList<>();
for (long x : interestingLongs) {
double lowerBound = Double.longBitsToDouble(x);
if (Double.isNaN(lowerBound)) {
continue;
}
for (long y : interestingLongs) {
double upperBound = Double.longBitsToDouble(y);
if (Double.isNaN(upperBound)) {
continue;
}
if (Double.compare(lowerBound, upperBound) <= 0) {
ret.add(new Object[] { new FloatStamp(Double.SIZE, lowerBound, upperBound, true) });
ret.add(new Object[] { new FloatStamp(Double.SIZE, lowerBound, upperBound, false) });
}
}
}
ret.add(new Object[] { new FloatStamp(Double.SIZE, Double.NaN, Double.NaN, false) });
return ret;
}
use of org.graalvm.compiler.core.common.type.FloatStamp in project graal by oracle.
the class ReinterpretStampIntToFloatTest method run.
@Test
public void run() {
ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
ValueNode reinterpret = ReinterpretNode.create(JavaKind.Float, param, NodeView.DEFAULT);
reinterpret.inferStamp();
FloatStamp resultStamp = (FloatStamp) reinterpret.stamp(NodeView.DEFAULT);
Assert.assertEquals(Float.SIZE, resultStamp.getBits());
for (int input : interestingInts) {
float result = Float.intBitsToFloat(input);
if (inputStamp.contains(input) && !resultStamp.contains(result)) {
Assert.fail(String.format("value 0x%x (%f) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
}
}
}
use of org.graalvm.compiler.core.common.type.FloatStamp in project graal by oracle.
the class NegateNode method findSynonym.
protected static ValueNode findSynonym(ValueNode forValue, NodeView view) {
ArithmeticOpTable.UnaryOp<Neg> negOp = ArithmeticOpTable.forStamp(forValue.stamp(view)).getNeg();
ValueNode synonym = UnaryArithmeticNode.findSynonym(forValue, negOp);
if (synonym != null) {
return synonym;
}
if (forValue instanceof NegateNode) {
return ((NegateNode) forValue).getValue();
}
if (forValue instanceof SubNode && !(forValue.stamp(view) instanceof FloatStamp)) {
SubNode sub = (SubNode) forValue;
return SubNode.create(sub.getY(), sub.getX(), view);
}
return null;
}
use of org.graalvm.compiler.core.common.type.FloatStamp in project graal by oracle.
the class ExpandLogicPhase method processNormalizeCompareNode.
private static void processNormalizeCompareNode(NormalizeCompareNode normalize) {
LogicNode equalComp;
LogicNode lessComp;
StructuredGraph graph = normalize.graph();
ValueNode x = normalize.getX();
ValueNode y = normalize.getY();
if (x.stamp(NodeView.DEFAULT) instanceof FloatStamp) {
equalComp = graph.addOrUniqueWithInputs(FloatEqualsNode.create(x, y, NodeView.DEFAULT));
lessComp = graph.addOrUniqueWithInputs(FloatLessThanNode.create(x, y, normalize.isUnorderedLess(), NodeView.DEFAULT));
} else {
equalComp = graph.addOrUniqueWithInputs(IntegerEqualsNode.create(x, y, NodeView.DEFAULT));
lessComp = graph.addOrUniqueWithInputs(IntegerLessThanNode.create(x, y, NodeView.DEFAULT));
}
Stamp stamp = normalize.stamp(NodeView.DEFAULT);
ConditionalNode equalValue = graph.unique(new ConditionalNode(equalComp, ConstantNode.forIntegerStamp(stamp, 0, graph), ConstantNode.forIntegerStamp(stamp, 1, graph)));
ConditionalNode value = graph.unique(new ConditionalNode(lessComp, ConstantNode.forIntegerStamp(stamp, -1, graph), equalValue));
normalize.replaceAtUsagesAndDelete(value);
}
Aggregations