Search in sources :

Example 11 with CompareNode

use of org.graalvm.compiler.nodes.calc.CompareNode in project graal by oracle.

the class ConvertDeoptimizeToGuardPhase method trySplitFixedGuard.

private void trySplitFixedGuard(FixedGuardNode fixedGuard, PhaseContext context) {
    LogicNode condition = fixedGuard.condition();
    if (condition instanceof CompareNode) {
        CompareNode compare = (CompareNode) condition;
        ValueNode x = compare.getX();
        ValuePhiNode xPhi = (x instanceof ValuePhiNode) ? (ValuePhiNode) x : null;
        if (x instanceof ConstantNode || xPhi != null) {
            ValueNode y = compare.getY();
            ValuePhiNode yPhi = (y instanceof ValuePhiNode) ? (ValuePhiNode) y : null;
            if (y instanceof ConstantNode || yPhi != null) {
                processFixedGuardAndPhis(fixedGuard, context, compare, x, xPhi, y, yPhi);
            }
        }
    }
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode)

Example 12 with CompareNode

use of org.graalvm.compiler.nodes.calc.CompareNode in project graal by oracle.

the class LoopTransformations method updatePreLoopLimit.

private static void updatePreLoopLimit(IfNode preLimit, InductionVariable preIv, CountedLoopInfo preCounted) {
    // Update the pre loops limit test
    StructuredGraph graph = preLimit.graph();
    LogicNode ifTest = preLimit.condition();
    CompareNode compareNode = (CompareNode) ifTest;
    ValueNode prePhi = preIv.valueNode();
    // Make new limit one iteration
    ValueNode initIv = preCounted.getStart();
    ValueNode newLimit = add(graph, initIv, preIv.strideNode());
    // Fetch the variable we are not replacing and configure the one we are
    ValueNode ub;
    if (compareNode.getX() == prePhi) {
        ub = compareNode.getY();
    } else if (compareNode.getY() == prePhi) {
        ub = compareNode.getX();
    } else {
        throw GraalError.shouldNotReachHere();
    }
    // Re-wire the condition with the new limit
    if (preIv.direction() == Direction.Up) {
        compareNode.replaceFirstInput(ub, graph.unique(new ConditionalNode(graph.unique(new IntegerLessThanNode(newLimit, ub)), newLimit, ub)));
    } else {
        compareNode.replaceFirstInput(ub, graph.unique(new ConditionalNode(graph.unique(new IntegerLessThanNode(ub, newLimit)), newLimit, ub)));
    }
}
Also used : ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) IntegerLessThanNode(org.graalvm.compiler.nodes.calc.IntegerLessThanNode) LogicNode(org.graalvm.compiler.nodes.LogicNode)

Example 13 with CompareNode

use of org.graalvm.compiler.nodes.calc.CompareNode in project graal by oracle.

the class NodeLIRBuilder method emitConditional.

public Variable emitConditional(LogicNode node, Value trueValue, Value falseValue) {
    if (node instanceof IsNullNode) {
        IsNullNode isNullNode = (IsNullNode) node;
        LIRKind kind = gen.getLIRKind(isNullNode.getValue().stamp(NodeView.DEFAULT));
        Value nullValue = gen.emitConstant(kind, JavaConstant.NULL_POINTER);
        return gen.emitConditionalMove(kind.getPlatformKind(), operand(isNullNode.getValue()), nullValue, Condition.EQ, false, trueValue, falseValue);
    } else if (node instanceof CompareNode) {
        CompareNode compare = (CompareNode) node;
        PlatformKind kind = gen.getLIRKind(compare.getX().stamp(NodeView.DEFAULT)).getPlatformKind();
        return gen.emitConditionalMove(kind, operand(compare.getX()), operand(compare.getY()), compare.condition().asCondition(), compare.unorderedIsTrue(), trueValue, falseValue);
    } else if (node instanceof LogicConstantNode) {
        return gen.emitMove(((LogicConstantNode) node).getValue() ? trueValue : falseValue);
    } else if (node instanceof IntegerTestNode) {
        IntegerTestNode test = (IntegerTestNode) node;
        return gen.emitIntegerTestMove(operand(test.getX()), operand(test.getY()), trueValue, falseValue);
    } else {
        throw GraalError.unimplemented(node.toString());
    }
}
Also used : CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) LIRKind(org.graalvm.compiler.core.common.LIRKind) PlatformKind(jdk.vm.ci.meta.PlatformKind)

Aggregations

CompareNode (org.graalvm.compiler.nodes.calc.CompareNode)13 ValueNode (org.graalvm.compiler.nodes.ValueNode)10 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 LogicNode (org.graalvm.compiler.nodes.LogicNode)5 IntegerLessThanNode (org.graalvm.compiler.nodes.calc.IntegerLessThanNode)5 IfNode (org.graalvm.compiler.nodes.IfNode)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 Value (jdk.vm.ci.meta.Value)3 LIRKind (org.graalvm.compiler.core.common.LIRKind)3 Condition (org.graalvm.compiler.core.common.calc.Condition)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 ArrayList (java.util.ArrayList)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 PlatformKind (jdk.vm.ci.meta.PlatformKind)2 Node (org.graalvm.compiler.graph.Node)2 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)2 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)2 IntegerBelowNode (org.graalvm.compiler.nodes.calc.IntegerBelowNode)2 IntegerEqualsNode (org.graalvm.compiler.nodes.calc.IntegerEqualsNode)2