Using the GNU Compiler Collection (GCC): Loop-Specific Pragmas |
---|
Previous: Function Specific Option Pragmas, Up: Pragmas [Contents][Index]
With this pragma, the programmer asserts that there are no loop-carried dependencies which would prevent consecutive iterations of the following loop from executing concurrently with SIMD (single instruction multiple data) instructions.
For example, the compiler can only unconditionally vectorize the following loop with the pragma:
void foo (int n, int *a, int *b, int *c) { int i, j; #pragma GCC ivdep for (i = 0; i < n; ++i) a[i] = b[i] + c[i]; }
In this example, using the restrict
qualifier had the same
effect. In the following example, that would not be possible. Assume
k < -m or k >= m. Only with the pragma, the compiler knows
that it can unconditionally vectorize the following loop:
void ignore_vec_dep (int *a, int k, int c, int m) { #pragma GCC ivdep for (int i = 0; i < m; i++) a[i] = a[i + k] * c; }