Real Time Systems Design And Analysis

Chapter 7.6.16 - Loop Jamming

7.6.16   Loop Jamming

Loop jamming or loop fusion is a technique for combining two similar loops into
one, thus reducing loop overhead by a factor of 2. For example, the following
C code:

for (i=1;i<=100;i++)
  x[i]=y[i]*8;

for (i=1;i<=100;i++)
  z[i]=x[i]*y[i];


can be replaced by

for (i=1;i<=100;i++)
{
    x[i]=y[i]*8;
    z[i]=x[i]*y[i];
};



7.6.16.1   Cross-Jump Elimination     If the same code appears in more than
one case in a case or switch statement, then it is better to combine the cases
into one. This eliminates an additional jump or cross jump. For example, the
following code :

switch (x)
{  
 case 0:x=x+1;
  break;
 case 1:x=x*2;
  break;
 case 2:x=x+1;
  break;
 case 3:x=2;
  break;
};  

can be replaced by

switch (x)
{  
 case 0: 
 case 2:x=x+1;
  break;
 case 1:x=x*2;
  break;
 case 3:x=2;
  break;
};  

 

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: PCMCIA Memory Cards
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.