Search in sources :

Example 26 with IntegerStamp

use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.

the class IntegerSubOverflowsTest method testOverflowCheckStamp09.

@Test
public void testOverflowCheckStamp09() {
    IntegerStamp s1 = StampFactory.forInteger(64, Long.MAX_VALUE, Long.MAX_VALUE);
    IntegerStamp s2 = StampFactory.forInteger(64, Long.MAX_VALUE, Long.MAX_VALUE);
    Assert.assertFalse(IntegerStamp.subtractionCanOverflow(s1, s2));
}
Also used : IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) Test(org.junit.Test)

Example 27 with IntegerStamp

use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.

the class AArch64ReadNode method replace.

/**
 * replace a ReadNode with an AArch64-specific variant which knows how to merge a downstream
 * zero or sign extend into the read operation.
 *
 * @param readNode
 */
public static void replace(ReadNode readNode) {
    assert readNode.getUsageCount() == 1;
    assert readNode.getUsageAt(0) instanceof ZeroExtendNode || readNode.getUsageAt(0) instanceof SignExtendNode;
    ValueNode usage = (ValueNode) readNode.getUsageAt(0);
    boolean isSigned = usage instanceof SignExtendNode;
    IntegerStamp accessStamp = ((IntegerStamp) readNode.getAccessStamp());
    AddressNode address = readNode.getAddress();
    LocationIdentity location = readNode.getLocationIdentity();
    Stamp stamp = usage.stamp(NodeView.DEFAULT);
    GuardingNode guard = readNode.getGuard();
    BarrierType barrierType = readNode.getBarrierType();
    boolean nullCheck = readNode.getNullCheck();
    FrameState stateBefore = readNode.stateBefore();
    AArch64ReadNode clone = new AArch64ReadNode(address, location, stamp, guard, barrierType, nullCheck, stateBefore, accessStamp, isSigned);
    StructuredGraph graph = readNode.graph();
    graph.add(clone);
    // splice out the extend node
    usage.replaceAtUsagesAndDelete(readNode);
    // swap the clone for the read
    graph.replaceFixedWithFixed(readNode, clone);
}
Also used : SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) FrameState(org.graalvm.compiler.nodes.FrameState) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LocationIdentity(org.graalvm.word.LocationIdentity) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode)

Example 28 with IntegerStamp

use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method testShiftBoundaryValues.

private static void testShiftBoundaryValues(ShiftOp<?> shiftOp, HashSet<PrimitiveStamp> stamps, HashSet<IntegerStamp> shifts) {
    for (PrimitiveStamp testStamp : stamps) {
        if (testStamp instanceof IntegerStamp) {
            IntegerStamp stamp = (IntegerStamp) testStamp;
            for (IntegerStamp shiftStamp : shifts) {
                IntegerStamp foldedStamp = (IntegerStamp) shiftOp.foldStamp(stamp, shiftStamp);
                if (foldedStamp.isEmpty()) {
                    assertTrue(stamp.isEmpty() || shiftStamp.isEmpty());
                    continue;
                }
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.lowerBound());
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.upperBound());
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.lowerBound());
                checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.upperBound());
            }
        }
    }
}
Also used : IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp)

Example 29 with IntegerStamp

use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method checkShiftOperation.

private static void checkShiftOperation(int bits, ShiftOp<?> op, IntegerStamp result, long v1, long v2) {
    IntegerStamp v1stamp = IntegerStamp.create(bits, v1, v1);
    IntegerStamp v2stamp = IntegerStamp.create(32, v2, v2);
    IntegerStamp folded = (IntegerStamp) op.foldStamp(v1stamp, v2stamp);
    Constant constant = op.foldConstant(JavaConstant.forPrimitiveInt(bits, v1), (int) v2);
    assertTrue(constant != null);
    assertTrue(folded.asConstant() != null, "should constant fold %s %s %s %s", op, v1stamp, v2stamp, folded);
    assertTrue(result.meet(folded).equals(result), "result out of range %s %s %s %s %s %s", op, v1stamp, v2stamp, folded, result, result.meet(folded));
}
Also used : Constant(jdk.vm.ci.meta.Constant) JavaConstant(jdk.vm.ci.meta.JavaConstant) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp)

Example 30 with IntegerStamp

use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.

the class PrimitiveStampBoundaryTest method boundaryStamp.

private static Stamp boundaryStamp(Stamp v1, boolean upper) {
    if (v1.isEmpty()) {
        return v1;
    }
    if (v1 instanceof IntegerStamp) {
        IntegerStamp istamp = (IntegerStamp) v1;
        long bound = upper ? istamp.upperBound() : istamp.lowerBound();
        return IntegerStamp.create(istamp.getBits(), bound, bound);
    } else if (v1 instanceof FloatStamp) {
        FloatStamp floatStamp = (FloatStamp) v1;
        double bound = upper ? floatStamp.upperBound() : floatStamp.lowerBound();
        int bits = floatStamp.getBits();
        return floatStampForConstant(bound, bits);
    } else {
        throw new InternalError("unexpected stamp type " + v1);
    }
}
Also used : IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) FloatStamp(org.graalvm.compiler.core.common.type.FloatStamp)

Aggregations

IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)65 Test (org.junit.Test)21 ValueNode (org.graalvm.compiler.nodes.ValueNode)19 Stamp (org.graalvm.compiler.core.common.type.Stamp)13 NodeView (org.graalvm.compiler.nodes.NodeView)8 AddNode (org.graalvm.compiler.nodes.calc.AddNode)6 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)5 JavaConstant (jdk.vm.ci.meta.JavaConstant)4 Node (org.graalvm.compiler.graph.Node)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 SignExtendNode (org.graalvm.compiler.nodes.calc.SignExtendNode)4 ArrayList (java.util.ArrayList)3 Constant (jdk.vm.ci.meta.Constant)3 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)3 ArithmeticOpTable (org.graalvm.compiler.core.common.type.ArithmeticOpTable)3 GraphTest (org.graalvm.compiler.graph.test.GraphTest)3 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)3 IntegerBelowNode (org.graalvm.compiler.nodes.calc.IntegerBelowNode)3