use of org.graalvm.compiler.nodes.NodeView in project graal by oracle.
the class NarrowNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
NodeView view = NodeView.from(tool);
ValueNode ret = super.canonical(tool, forValue);
if (ret != this) {
return ret;
}
if (forValue instanceof NarrowNode) {
// zzzzzzzz yyyyxxxx -(narrow)-> yyyyxxxx -(narrow)-> xxxx
// ==> zzzzzzzz yyyyxxxx -(narrow)-> xxxx
NarrowNode other = (NarrowNode) forValue;
return new NarrowNode(other.getValue(), other.getInputBits(), getResultBits());
} else if (forValue instanceof IntegerConvertNode) {
// SignExtendNode or ZeroExtendNode
IntegerConvertNode<?, ?> other = (IntegerConvertNode<?, ?>) forValue;
if (other.getValue().hasExactlyOneUsage() && other.hasMoreThanOneUsage()) {
// If the convert's usage count is <=1, it will be dead code eliminated.
return this;
}
if (getResultBits() == other.getInputBits()) {
// ==> no-op
return other.getValue();
} else if (getResultBits() < other.getInputBits()) {
// ==> yyyyxxxx -(narrow)-> xxxx
return new NarrowNode(other.getValue(), other.getInputBits(), getResultBits());
} else {
if (other instanceof SignExtendNode) {
// ==> sxxx -(sign-extend)-> sssssxxx
return SignExtendNode.create(other.getValue(), other.getInputBits(), getResultBits(), view);
} else if (other instanceof ZeroExtendNode) {
// ==> xxxx -(zero-extend)-> 0000xxxx
return new ZeroExtendNode(other.getValue(), other.getInputBits(), getResultBits(), ((ZeroExtendNode) other).isInputAlwaysPositive());
}
}
} else if (forValue instanceof AndNode) {
AndNode andNode = (AndNode) forValue;
IntegerStamp yStamp = (IntegerStamp) andNode.getY().stamp(view);
IntegerStamp xStamp = (IntegerStamp) andNode.getX().stamp(view);
long relevantMask = CodeUtil.mask(this.getResultBits());
if ((relevantMask & yStamp.downMask()) == relevantMask) {
return create(andNode.getX(), this.getResultBits(), view);
} else if ((relevantMask & xStamp.downMask()) == relevantMask) {
return create(andNode.getY(), this.getResultBits(), view);
}
}
return this;
}
use of org.graalvm.compiler.nodes.NodeView in project graal by oracle.
the class ObjectEqualsNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
NodeView view = NodeView.from(tool);
ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, false, forX, forY, view);
if (value != null) {
return value;
}
return this;
}
use of org.graalvm.compiler.nodes.NodeView in project graal by oracle.
the class PointerEqualsNode method canonical.
@Override
public Node canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
NodeView view = NodeView.from(tool);
ValueNode value = OP.canonical(tool.getConstantReflection(), tool.getMetaAccess(), tool.getOptions(), tool.smallestCompareWidth(), CanonicalCondition.EQ, false, forX, forY, view);
if (value != null) {
return value;
}
return this;
}
use of org.graalvm.compiler.nodes.NodeView in project graal by oracle.
the class RightShiftNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
NodeView view = NodeView.from(tool);
ValueNode ret = super.canonical(tool, forX, forY);
if (ret != this) {
return ret;
}
return canonical(this, getArithmeticOp(), stamp(view), forX, forY, view);
}
use of org.graalvm.compiler.nodes.NodeView in project graal by oracle.
the class LoadHubNode method canonical.
@Override
public ValueNode canonical(CanonicalizerTool tool) {
if (!GeneratePIC.getValue(tool.getOptions())) {
NodeView view = NodeView.from(tool);
MetaAccessProvider metaAccess = tool.getMetaAccess();
ValueNode curValue = getValue();
ValueNode newNode = findSynonym(curValue, stamp(view), metaAccess, tool.getConstantReflection());
if (newNode != null) {
return newNode;
}
}
return this;
}
Aggregations