Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

GAP Message (Diagnostic ID 30515)

NOTE:
This feature is only available for ifort.

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:

subroutine foo(a, n)
  integer n
  do i=1,n
    if (a(i) .gt. 0) then
      b = a(i)
      a(i) = 1 / a(i)
    endif
    if (a(i) .gt. 1) then
      a(i) = a(i) + b
    endif
  enddo 
end

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:

subroutine foo(a, n)
  integer n
  real a(n), b
  do i=1,n
    b = a(i)
    if (a(i) .gt. 0) then
      a(i) = 1 / a(i)
    endif
    if (a(i) .gt. 1) then
      a(i) = a(i) + b
    endif
  enddo 
end

Verify

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