|
Loop Unrolling
Loop overhead can be reduced by reducing the number of iterations and replicating the body of the loop. Example:In the code fragment below, the body of the loop can be replicated once and the number of iterations can be reduced from 100 to 50. for (i = 0; i < 100; i++) g (); Below is the code fragment after loop unrolling. for (i = 0; i < 100; i += 2) { g (); g (); } © 1990-2012 Nullstone Corporation. All Rights Reserved. |