Loop-Invariant Code Motion とは?
loop-invariant code motion は、ループ内で毎回の反復で値が同じになる式を特定し、それらをループ開始前に 1 回だけ実行するよう移動する最適化です。コンパイラは引き上げる前に、オペランドがループ内で変化しないことを確認します。ループ本体には、反復ごとに実際に変わる作業だけが残されます。
なぜ重要か
不変な作業をホットなループの外に引き上げると、繰り返される計算の大きな割合を削れます。コンパイラが行うループ最適化の中でも、最も効果の大きいものの 1 つです。
関連ガイド
What Is Loop Unrolling?Loop unrolling replicates a loop body multiple times per iteration to cut loop overhead and expose more instr…
What Is Common Subexpression Elimination?Common subexpression elimination removes redundant computations by reusing a previously computed result inste…
What Is Strength Reduction?Strength reduction replaces expensive operations with cheaper equivalent ones, such as turning a multiplicati…