Loop Constructs

Loops can be formed with the usual for and while constructs. However, the loops must have a single entry and a single exit to be vectorized.

Correct Usage

while(i<n)

{

   // If branch is inside body of loop

 

   a[i]=b[i]*c[i];

   if(a[i]<0.0)

   {

      a[i]=0.0;

   }

   i++;

}

Incorrect Usage

while(i<n)

{

   if (condition) break; 

   // 2nd exit.

   ++i;

}