When you use the auto-vectorization, you might find that some transformations cannot be performed. If you compile with -qhot and -qlistfmt=xml=transforms or -qlistfmt=xml=all, you can get a compiler report that lists the reasons why some transformations were not performed. For detailed information about the possible reasons, see Using compiler reports to diagnose optimization opportunities.
This section uses two code examples to illustrate why auto-vectorization cannot be performed under certain situations.
Example 1:
program try
real*8 x(100)
integer i
x(1)=9
do i=2,100
x(i)=x(i-1)
enddo
end
The x(i)=x(i-1) statement violates the restriction that "a loop cannot be automatically parallelized if one of its variable carries a dependency". x(i) or x(i-1) depends on each other in this sample, which makes the loop non-vectorizable.
Example 2:
program try
real*8 x(100)
integer i
do i=1,100,5
x(i)=i + 8;
x(i+1)=i + 9;
x(i+2)=i + 12;
x(i+3)=i + 15;
enddo
end
The following statements violate the restriction that auto-vectorization cannot be performed if the loop contains a non stride one store.
x(i)=i + 8;
x(i+1)=i + 9;
x(i+2)=i + 12;
x(i+3)=i + 15;
In each iteration of the loop, four elements in the array x are accessed and one element is skipped. This continues until the end of the loop, which makes the loop cannot be vectorized.