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);
}
}
}
}
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)));
}
}
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());
}
}
Aggregations