use of org.graalvm.compiler.core.common.calc.Condition.CanonicalizedCondition in project graal by oracle.
the class BytecodeParser method genIf.
protected void genIf(ValueNode x, Condition cond, ValueNode y) {
assert x.getStackKind() == y.getStackKind();
assert currentBlock.getSuccessorCount() == 2;
BciBlock trueBlock = currentBlock.getSuccessor(0);
BciBlock falseBlock = currentBlock.getSuccessor(1);
if (trueBlock == falseBlock) {
// The target block is the same independent of the condition.
appendGoto(trueBlock);
return;
}
ValueNode a = x;
ValueNode b = y;
BciBlock trueSuccessor = trueBlock;
BciBlock falseSuccessor = falseBlock;
CanonicalizedCondition canonicalizedCondition = cond.canonicalize();
// Check whether the condition needs to mirror the operands.
if (canonicalizedCondition.mustMirror()) {
a = y;
b = x;
}
if (canonicalizedCondition.mustNegate()) {
trueSuccessor = falseBlock;
falseSuccessor = trueBlock;
}
// Create the logic node for the condition.
LogicNode condition = createLogicNode(canonicalizedCondition.getCanonicalCondition(), a, b);
double probability = -1;
if (condition instanceof IntegerEqualsNode) {
probability = extractInjectedProbability((IntegerEqualsNode) condition);
// the probability coming from here is about the actual condition
}
if (probability == -1) {
probability = getProfileProbability(canonicalizedCondition.mustNegate());
}
probability = clampProbability(probability);
genIf(condition, trueSuccessor, falseSuccessor, probability);
}
use of org.graalvm.compiler.core.common.calc.Condition.CanonicalizedCondition in project graal by oracle.
the class WordOperationPlugin method comparisonOp.
private ValueNode comparisonOp(GraphBuilderContext graph, Condition condition, ValueNode left, ValueNode right) {
assert left.getStackKind() == wordKind && right.getStackKind() == wordKind;
CanonicalizedCondition canonical = condition.canonicalize();
ValueNode a = canonical.mustMirror() ? right : left;
ValueNode b = canonical.mustMirror() ? left : right;
CompareNode comparison;
if (canonical.getCanonicalCondition() == CanonicalCondition.EQ) {
comparison = new IntegerEqualsNode(a, b);
} else if (canonical.getCanonicalCondition() == CanonicalCondition.BT) {
comparison = new IntegerBelowNode(a, b);
} else {
assert canonical.getCanonicalCondition() == CanonicalCondition.LT;
comparison = new IntegerLessThanNode(a, b);
}
ConstantNode trueValue = graph.add(forInt(1));
ConstantNode falseValue = graph.add(forInt(0));
if (canonical.mustNegate()) {
ConstantNode temp = trueValue;
trueValue = falseValue;
falseValue = temp;
}
return graph.add(new ConditionalNode(graph.add(comparison), trueValue, falseValue));
}
Aggregations