enumstd.builtin.BranchHint[src]

This data structure is used by the Zig language code generation and therefore must be kept in sync with the compiler implementation.

Fields

none

Equivalent to no hint given.

likely

This branch of control flow is more likely to be reached than its peers. The optimizer should optimize for reaching it.

unlikely

This branch of control flow is less likely to be reached than its peers. The optimizer should optimize for not reaching it.

cold

This branch of control flow is unlikely to ever be reached. The optimizer may place it in a different page of memory to optimize other branches.

unpredictable

It is difficult to predict whether this branch of control flow will be reached. The optimizer should avoid branching behavior with expensive mispredictions.

Source Code

Source code
pub const BranchHint = enum(u3) {
    /// Equivalent to no hint given.
    none,
    /// This branch of control flow is more likely to be reached than its peers.
    /// The optimizer should optimize for reaching it.
    likely,
    /// This branch of control flow is less likely to be reached than its peers.
    /// The optimizer should optimize for not reaching it.
    unlikely,
    /// This branch of control flow is unlikely to *ever* be reached.
    /// The optimizer may place it in a different page of memory to optimize other branches.
    cold,
    /// It is difficult to predict whether this branch of control flow will be reached.
    /// The optimizer should avoid branching behavior with expensive mispredictions.
    unpredictable,
}