oracle/graal · error · GraalError

A probability of more than 1.0 ( + probabilityValue + ) is n

Error message

A probability of more than 1.0 ( + probabilityValue + ) is not allowed!

What it means

The sibling check in BranchProbabilityNode.simplify: a probability constant greater than 1.0 throws GraalError with the value in the message. Probabilities are true likelihoods, so anything above 1.0 is invalid input to the branch-probability intrinsic.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/extended/BranchProbabilityNode.java:156

    public Node canonical(CanonicalizerTool tool) {
        if (condition.isConstant()) {
            // fold constant conditions early during PE
            return condition;
        }
        return this;
    }

    @Override
    public void simplify(SimplifierTool tool) {
        if (!hasUsages()) {
            return;
        }
        if (probability.isConstant()) {
            double probabilityValue = probability.asJavaConstant().asDouble();
            if (probabilityValue < 0.0) {
                throw new GraalError("A negative probability of " + probabilityValue + " is not allowed!");
            } else if (probabilityValue > 1.0) {
                throw new GraalError("A probability of more than 1.0 (" + probabilityValue + ") is not allowed!");
            } else if (Double.isNaN(probabilityValue)) {
                /*
                 * We allow NaN if the node is in unreachable code that will eventually fall away,
                 * or else an error will be thrown during lowering since we keep the node around.
                 */
                return;
            }
            boolean usageFound = false;
            for (IntegerEqualsNode node : this.usages().filter(IntegerEqualsNode.class)) {
                assert node.condition() == CanonicalCondition.EQ : Assertions.errorMessage(node, node.condition());
                ValueNode other = node.getX();
                if (node.getX() == this) {
                    other = node.getY();
                }
                if (other.isConstant()) {
                    double probabilityToSet = probabilityValue;
                    if (other.asJavaConstant().asInt() == 0) {
                        probabilityToSet = 1.0 - probabilityToSet;

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Normalize the value into [0.0, 1.0]; for 'very likely' use the provided constants such as LIKELY_PROBABILITY or 1.0 - DELTA_ON_TAKEN
  2. Replace weight-style arithmetic with direct selection of a probability constant
  3. Add a unit assertion in snippet frameworks that probability inputs stay within [0,1]

Example fix

// before
BranchProbabilityNode.probability(1.2, cond)

// after
BranchProbabilityNode.probability(BranchProbabilityNode.LIKELY_PROBABILITY, cond)
Defensive patterns

Strategy: validation

Validate before calling

static double clampProbability(double p) {
    if (p < 0.0) return 0.0;
    if (p > 1.0) return 1.0;
    return p;
}

Prevention

When it happens

Trigger: probability(1.5, cond) or an arithmetic expression over likelihood constants that constant-folds above 1.0 (e.g., LIKELY_PROBABILITY + 0.1) reaching the intrinsic's probability input.

Common situations: Developers treating probability as a weight/hint multiplier; combining several probability constants additively; porting 'weights' from another compiler's API (e.g., __builtin_expect semantics) into probability semantics.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/e23e0f95099ae523. Report an issue: GitHub.