pub enum Quality {
Unknown,
Guessed,
Adjusted,
Precise,
}Expand description
How much a probability or a frequency is worth believing.
The order is the point, and it is GCC’s order out of enum profile_quality in
gcc/profile-count.h: worse first, so the quality of a computed value is the smaller of what
went into it and Ord says so without a table.
Variants§
Unknown
Nobody has said anything about this one.
What a block a pass created gets until the pass says otherwise. It is not zero and it is not one, it is the absence of a claim, and a consumer that treats it as either is the third failure mode in section 11.6.
Guessed
A static predictor said so, from the shape of the code and nothing else.
Everything in M4 is this, because there is no profile data yet. A guess is still much better than nothing: the hit rates in section 11.2 are measurements of how people write programs, and those have held up for thirty years.
Adjusted
It came from a measurement, and then a transformation scaled it.
Splitting a block, unrolling a loop or threading a jump all divide a measured count across paths that were not measured separately. The result is worth more than a guess and less than what was measured, which is exactly what this says.
Precise
Measured, and nothing has touched it since.
Also what a branch on a constant gets, because that one is not a measurement or a guess. It is arithmetic.
Implementations§
Source§impl Quality
impl Quality
Sourcepub const fn is_measured(self) -> bool
pub const fn is_measured(self) -> bool
Whether this came from running the program rather than from looking at it.
The question a consumer asks when it is about to do something it could not undo. Section 40.5’s rule that a statically predicted branch never counts as predictable is this predicate, and it is here rather than at each call site so that the rule is one thing.