Search in sources :

Example 11 with FloatStamp

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;
}
Also used : ArrayList(java.util.ArrayList) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp) Parameters(org.junit.runners.Parameterized.Parameters)

Example 12 with FloatStamp

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));
        }
    }
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp) Test(org.junit.Test)

Example 13 with FloatStamp

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;
}
Also used : ArithmeticOpTable(org.graalvm.compiler.core.common.type.ArithmeticOpTable) Neg(org.graalvm.compiler.core.common.type.ArithmeticOpTable.UnaryOp.Neg) ValueNode(org.graalvm.compiler.nodes.ValueNode) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp)

Example 14 with FloatStamp

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);
}
Also used : ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp)

Aggregations

FloatStamp (org.graalvm.compiler.core.common.type.FloatStamp)14 ValueNode (org.graalvm.compiler.nodes.ValueNode)5 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)3 ArrayList (java.util.ArrayList)2 Constant (jdk.vm.ci.meta.Constant)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 PrimitiveStamp (org.graalvm.compiler.core.common.type.PrimitiveStamp)2 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)2 Test (org.junit.Test)2 Parameters (org.junit.runners.Parameterized.Parameters)2 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)1 AbstractObjectStamp (org.graalvm.compiler.core.common.type.AbstractObjectStamp)1 ArithmeticOpTable (org.graalvm.compiler.core.common.type.ArithmeticOpTable)1 Neg (org.graalvm.compiler.core.common.type.ArithmeticOpTable.UnaryOp.Neg)1 LogicNode (org.graalvm.compiler.nodes.LogicNode)1 NodeView (org.graalvm.compiler.nodes.NodeView)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)1 FloatDivNode (org.graalvm.compiler.nodes.calc.FloatDivNode)1