ループアンローリングとは?
ループアンローリングは、各反復が数回分の処理を行うようにループ本体を複製し、分岐とカウンタ更新の回数を減らす最適化です。ループ制御命令が減り、独立した操作がより多く露出することで、プロセッサはより効果的に処理を重ね合わせられます。トレードオフはコードが大きくなることで、命令キャッシュを圧迫し得ます。
なぜ重要か
ループのオーバーヘッドは本体の小さいタイトなループを支配することがあり、アンローリングはそのコストをより有用な処理へと分散します。また、スケジューラやベクトライザに最適化の材料をより多く与えます。
関連ガイド
What Is Loop-Invariant Code Motion?Loop-invariant code motion hoists computations whose result does not change across iterations out of a loop s…
What Is Strength Reduction?Strength reduction replaces expensive operations with cheaper equivalent ones, such as turning a multiplicati…
What Is Instruction Scheduling?Instruction scheduling reorders machine instructions to keep the CPU pipeline busy and hide latencies, withou…