Developer Guide and Reference

Contents

GAP Message (Diagnostic ID 30515)

Message

Assign a value to the variable(s) "%s" at the beginning of the body of the loop in line %d. This will allow the loop to be vectorized.

Advice

You should unconditionally initialize the scalar variables at the beginning of the specified loop. This allows the vectorizer to privatize those variables for each iteration and vectorize the loop. You must ensure that all the uses of those variables see the same values before and after the source code change.

Example

Consider the following:
void foo(float *a, int n) { int i; float b; for (i=0; i<n; i++) { if (a[i] > 0) { b = a[i]; a[i] = 1 / a[i]; } if (a[i] > 1) { a[i] += b; } } return; }
In this case, the compiler is unable to vectorize the loop because it failed to privatize the variable
b
. Vectorization is assisted when assignment to
b
occurs in each iteration where the value of
b
is used. One of the ways to do this is to assign the value in every iteration.
If you determine it is safe to do so, you can modify the program code as follows:
void foo(float *a, int n) { int i; float b; for (i=0; i<n; i++) { b = a[i]; if (a[i] > 0) { a[i] = 1 / a[i]; } if (a[i] > 1) { a[i] += b; } } return; }

Verify

Confirm that in the original program, any variables
read
in any iteration of the loop have been defined earlier in the same iteration.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that ar