10.8 LOOP JAMMING


10.7 LOOP UNROLLING

Loop unrolling involves replicating the body of the loop to reduce the required number of tests if the number of iterations are constant. For example consider the following loop:

  I  = 1 while (  I  <= 100) {  x  [  I  ] = 0;  I  ++; } 

In this case, the test I <= 100 will be performed 100 times. But if the body of the loop is replicated, then the number of times this test will need to be performed will be 50. After replication of the body, the loop will be:

  I  = 1 while(  I  <= 100) {  x  [  I  ] = 0;  I  ++;  X  [  I  ] = 0;  I  ++; } 

It is possible to choose any divisor for the number of times the loop is executed, and the body will be replicated that many times. Unrolling once ”that is, replicating the body to form two copies of the body ”saves 50% of the maximum possible executions.




Algorithms for Compiler Design
Algorithms for Compiler Design (Electrical and Computer Engineering Series)
ISBN: 1584501006
EAN: 2147483647
Year: 2005
Pages: 108
Authors: O G Kakde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net