ループの構造

を使用できます。ループは、一般的な forwhile 構造で構成することができます。ループは、入口が 1 つだけでかつ出口が 1 つだけでなければ、ベクトル化できません。以下の例は、ベクトル化が可能なループ構造とベクトル化が不可能なループ構造を示しています。

例: ベクトル化が可能な構造

void vec(float a[], float b[], float c[])

{

  int i = 0;

  while (i < 100) {

// The if branch is inside body of loop.

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

    if (a[i] < 0.0)

      a[i] = 0.0;

    i++;

  }

}

次の例は、ループが途中で終了する可能性があるために、ベクトル化が不可能なループを示しています。

例: ベクトル化が不可能な構造

void no_vec(float a[], float b[], float c[])

{

  int i = 0;

  while (i < 100) {

    if (i < 50)

// The next statement is a second exit

// that allows an early exit from the loop.

      break;

    ++i;

  }

}