unrolled(9)
β¨ NAME β¨
okay bestie, meet unrolled(9) β the Kernel API Manual page for loop attributes that literally ask the compiler to unroll your loop π
. It's filed under unrolled, and its whole personality is: loop attributes to ask the compiler to unroll it. Slay.
πΈ SYNOPSIS πΈ
unrolled
π¦ DESCRIPTION π¦
Here's the usage, bestie β copy-paste energy:
#define BATCH 8
unrolled_count(BATCH) for (u32 i = 0; i < BATCH; i++) // loop body
without cross-iteration dependencies
So yeah: unrolled_count(BATCH) goes right before that for loop, and the loop body is the no-cross-iteration-dependencies vibe. π
β οΈ plot twist: this is only a hint. The compiler is free to disable unrolling if it thinks the count is suboptimal and may hurt performance and/or hugely increase object code size. No cap β it can ghost your unroll π.
Not having any cross-iteration dependencies β i.e. when iter x + 1 depends on what iter x will do with variables β is not a strict requirement, but it provides best performance and object code size. That's the highkey ideal scenario β¨.
π Available only on Clang and GCC 8.x onwards. If your compiler is older, this is not the vibe.
π SEE ALSO π
Kernel file ./include/linux/unroll.h β go peek, bestie π«Ά.
made with π from ./include/linux β October 2026 β unrolled(9) out π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms