Intermediate
Compilers & Programming Language Theory
Q50 / 100
What is loop-invariant code motion (LICM)?
Correct! Well done.
Incorrect.
The correct answer is B) Moving computations that produce the same result on every iteration out of the loop, reducing redundant computation
B
Correct Answer
Moving computations that produce the same result on every iteration out of the loop, reducing redundant computation
Explanation
LICM: for(i=0;i<n;i++) x=a*b+c; → x=a*b+c; for(i=0;i<n;i++). The a*b+c doesn't change each iteration. Requires proving the computation is loop-invariant and loop always executes. Reduces N iterations to 1.
Progress
50/100