Build1 distinct publisher3 min readUpdated
A dev.to experiment deliberately annotates the wrong branch. The disassembly shows the hint only decides which side gets fall-through, and the hot path pays for a bad pick every iteration.
The Engineer · Build desk
Compiled by The EngineerSomething wrong?How this is made
Read the two disassemblies side by side and the mechanism stops being mysterious. In the build using `likely()`, the compare is followed by a `b.eq` that leaves the loop body for a block parked past the loop's exit branch, and that block ends with an unconditional jump back to the counter increment [10]. In the build using `unlikely()`, the same compare becomes a `b.ne` to the rare block, and the common body sits inline immediately after the not-taken branch [11]. The arithmetic is identical. What the annotation bought was the answer to one question: which side of the branch gets to fall through.
That makes the cost of a wrong answer countable. The mis-annotated loop's common path carries two extra taken control transfers per iteration, the conditional jump out to the relocated block and the unconditional jump back [12], and with the modulus at 1000 that path runs 99.9% of the time [6]. Call it a little under two million extra taken jumps for every million iterations [13]. The 0.1% case, the one the programmer told the compiler to favour, gets the inline body it did not need.
This is why the macro belongs downstream of a profile rather than in muscle memory. The direction of the effect is set entirely by a runtime frequency the compiler cannot see, and the author's own result is that the hint degrades as the annotated branch gets rarer [8]. The definition itself is honest about how little is being said: `unlikely(e)` is `__builtin_expect(!!(e), 0)` [2], and `__builtin_expect` does nothing but assert that an expression's value will equal the second argument [3]. It is a claim about your workload, worth exactly as much as the measurement behind it. The pattern is all over the Linux kernel [1], which is the reason it gets copied and the reason copying is risky: the macro travels between codebases, and the frequency data that justified it does not.
Two limits on how far to carry the numbers. The article names `gcc -O2` as the command [9], but the mnemonics and registers in the listing are AArch64 [14], so this is one instruction set and one compiler configuration, on branch bodies consisting of a single add [5]. And the text asserts worse performance for the bad hint without printing a single timing figure [15], so what a reader can actually verify here is the block reordering, not its magnitude on their own hardware. That split is the useful takeaway: the layout change is deterministic and inspectable in the object file, while the cycle cost depends on a predictor you are not being shown. If you are going to spend a hint, spend it where you have counted, and then check the disassembly to see which side ended up inline.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
The author reports that as the share of iterations taking the first branch decreases, the likely hint becomes less accurate and performance gets worse, because execution goes to the branch the compiler was told to deprioritise.
The article states the assembly was generated with the command gcc -O2 unlikely.c -o bin/unlikely.
The if (unlikely(condition)) ... else ... pattern appears throughout the Linux kernel codebase.
unlikely is a macro defined as #define unlikely(e) __builtin_expect(!!(e), 0).
__builtin_expect annotates an expression to tell the compiler to expect the expression's value to equal the second argument.
The test uses two otherwise identical loops, unlikely_simple and likely_simple, differing only in whether the condition i % 1000 == 0 is wrapped in unlikely or likely; each branch body is a single addition to a running total.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Mechanism shown, measurements missing
The verifiable core is strong for a single source: the macro definition, both C functions, and two full disassembly listings are printed, and the fall-through asymmetry can be checked line by line at the given addresses. But the performance assertion rests on a figure whose numbers, iteration counts, and test hardware never appear in the text, the build command is inconsistent with the Mach-O AArch64 output shown, and the whole demonstration is one compiler configuration on one instruction set. That caps evidence a little above the midpoint.
No adoption events in cluster
The cluster contains one explainer post and no releases, deployments, published benchmarks, usage disclosures, or licence or pricing events. The remark that the idiom is widespread in the Linux kernel is an undated background observation about long-standing practice, not an adoption signal, so no adoption score is warranted.
Framing outruns the demonstration
Modestly overstated rather than inflated. The article promises a 'huge benefit to performance' and explains it as priming CPU branch-prediction probabilities, but what it actually demonstrates is basic-block ordering, and it shows the direction of a difference without publishing a single number. The disassembly is honest work, which keeps the gap small; the causal story and the missing measurements push it positive.
Individual explainer, no commercial stake
The source is a personal post on a developer community platform about a decades-old GCC builtin and a kernel idiom. It sells no product, promotes no vendor, cites no sponsor, and takes no position from which the author benefits commercially; the visible incentive is audience-building and pedagogy, which is why the score is low rather than zero.
Solid on mechanism, thin on corroboration
One publisher, one author, no corroborating source. Confidence in the code-and-assembly facts is high because they are reproduced in full and self-checkable; confidence in the performance conclusion and its stated cause is materially lower because the data is absent from the text, the toolchain description is internally inconsistent, and nothing outside this post confirms the result.
build
The failure modes of AI agents in low-level code have names, and names can be gated in CI1 distinct publisher
build
Two builds, one instruction stream: where GCC actually records a non-executable stack1 distinct publisher
build
Exit code 137 is the kernel collecting on a bet you did not know it placed1 distinct publisher
build
Coherent or streaming DMA is not a style choice: three ways ownership gets broken1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 22, 2026