| 1 |
/* { dg-require-effective-target vect_float } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#define N 64 |
| 7 |
#define MAX 42 |
| 8 |
|
| 9 |
extern void abort(void); |
| 10 |
|
| 11 |
__attribute__ ((noinline)) |
| 12 |
int main1 () |
| 13 |
{ |
| 14 |
float A[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 15 |
float B[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 16 |
float C[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 17 |
float D[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 18 |
float E[4] = {0,480,960,1440}; |
| 19 |
float s; |
| 20 |
|
| 21 |
int i, j; |
| 22 |
|
| 23 |
for (i = 0; i < N; i++) |
| 24 |
{ |
| 25 |
A[i] = i; |
| 26 |
B[i] = i; |
| 27 |
C[i] = i; |
| 28 |
D[i] = i; |
| 29 |
} |
| 30 |
|
| 31 |
/* Outer-loop 1: Vectorizable with respect to dependence distance. */ |
| 32 |
for (i = 0; i < N-20; i++) |
| 33 |
{ |
| 34 |
s = 0; |
| 35 |
for (j=0; j<N; j+=4) |
| 36 |
s += C[j]; |
| 37 |
A[i] = A[i+20] + s; |
| 38 |
} |
| 39 |
|
| 40 |
/* check results: */ |
| 41 |
#pragma GCC novector |
| 42 |
for (i = 0; i < N-20; i++) |
| 43 |
{ |
| 44 |
s = 0; |
| 45 |
for (j=0; j<N; j+=4) |
| 46 |
s += C[j]; |
| 47 |
if (A[i] != D[i+20] + s) |
| 48 |
abort (); |
| 49 |
} |
| 50 |
|
| 51 |
/* Outer-loop 2: Not vectorizable because of dependence distance. */ |
| 52 |
for (i = 0; i < 4; i++) |
| 53 |
{ |
| 54 |
s = 0; |
| 55 |
for (j=0; j<N; j+=4) |
| 56 |
s += C[j]; |
| 57 |
B[i+1] = B[i] + s; |
| 58 |
} |
| 59 |
|
| 60 |
/* check results: */ |
| 61 |
#pragma GCC novector |
| 62 |
for (i = 0; i < 4; i++) |
| 63 |
{ |
| 64 |
if (B[i] != E[i]) |
| 65 |
abort (); |
| 66 |
} |
| 67 |
|
| 68 |
return 0; |
| 69 |
} |
| 70 |
|
| 71 |
int main () |
| 72 |
{ |
| 73 |
check_vect (); |
| 74 |
return main1(); |
| 75 |
} |
| 76 |
|
| 77 |
/* NOTE: We temporarily xfail the following check until versioning for |
| 78 |
aliasing is fixed to avoid versioning when the dependence distance |
| 79 |
is known. */ |
| 80 |
/* { dg-final { scan-tree-dump-times "not vectorized: possible dependence between data-refs" 1 "vect" { xfail *-*-* } } } */ |
| 81 |
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */ |
| 82 |
/* { dg-final { scan-tree-dump "zero step in outer loop." "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ |