Search in sources :

Example 1 with Add

use of org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add in project graal by oracle.

the class AddNode method canonical.

@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
    ValueNode ret = super.canonical(tool, forX, forY);
    if (ret != this) {
        return ret;
    }
    if (forX.isConstant() && !forY.isConstant()) {
        // we try to swap and canonicalize
        ValueNode improvement = canonical(tool, forY, forX);
        if (improvement != this) {
            return improvement;
        }
        // if this fails we only swap
        return new AddNode(forY, forX);
    }
    BinaryOp<Add> op = getOp(forX, forY);
    NodeView view = NodeView.from(tool);
    return canonical(this, op, forX, forY, view);
}
Also used : Add(org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add) ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 2 with Add

use of org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add in project graal by oracle.

the class AddNode method create.

public static ValueNode create(ValueNode x, ValueNode y, NodeView view) {
    BinaryOp<Add> op = ArithmeticOpTable.forStamp(x.stamp(view)).getAdd();
    Stamp stamp = op.foldStamp(x.stamp(view), y.stamp(view));
    ConstantNode tryConstantFold = tryConstantFold(op, x, y, stamp, view);
    if (tryConstantFold != null) {
        return tryConstantFold;
    }
    if (x.isConstant() && !y.isConstant()) {
        return canonical(null, op, y, x, view);
    } else {
        return canonical(null, op, x, y, view);
    }
}
Also used : Add(org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Stamp(org.graalvm.compiler.core.common.type.Stamp)

Aggregations

Add (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add)2 Stamp (org.graalvm.compiler.core.common.type.Stamp)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 NodeView (org.graalvm.compiler.nodes.NodeView)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1