Loop Optimization
Loop Optimization
UIT-RGPV
By:
Mr. Praveen Yadav
Assistant Professor
DoCSE, UIT-RGPV
Bhopal
Loop Optimization
• The running time of a program can be improved if we decree
the amount of instructions in an inner loop.
• Three techniques are important for loop optimization:
1. Code Motion.
2. Induction Variable Elimination.
3. Reduction in Strength.
Initial code:
Optimized code:
Int i = 1; Int i = 1;
while(I <= 100) while(I <= 100)
{ {
a[i] = b[i]; a[i] = b[i];
i++; i++;
} a[i] = b[i];
i++;
}