3 ms·
>Large binaries are slow binaries. False. Loop unrolling is always faster.
by anthk 6y ago
>Large binaries are slow binaries.
False. Loop unrolling is always faster.
- JoeAltmaier 6y agoDepends largely on the state of code caches, microcode and bus structure. Loop unrolling can be the worst thing you can do, on some architectures. See, the hardware folks have listened in on the compiler people and their problems. They've done things like identify loops and rewritten them in microcode for optimization. If a short loop can fit entirely within the CPU code buffer, speed goes way up. Unroll the loop and blow the CPU code buffer, defeat the optimization and lose all that.
- arghwhat 6y ago> False. Loop unrolling is always faster. Blatantly false, which is why heuristics decide when to unroll. Large code trashes instruction caches, and cache misses are very expensive. More code, more misses. For very small loops, the unroll can pay off, but these are often too small to have significant size detriment.