| 1 |
/* { dg-require-effective-target vect_float } */ |
| 2 |
/* { dg-add-options double_vectors } */ |
| 3 |
/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ |
| 4 |
|
| 5 |
#include <stdarg.h> |
| 6 |
#include "tree-vect.h" |
| 7 |
|
| 8 |
#define N 256 |
| 9 |
|
| 10 |
__attribute__ ((noinline)) |
| 11 |
void bar (float *pa, float *pb, float *pc) |
| 12 |
{ |
| 13 |
int i; |
| 14 |
|
| 15 |
/* check results: */ |
| 16 |
#pragma GCC novector |
| 17 |
for (i = 0; i < N; i++) |
| 18 |
{ |
| 19 |
if (pa[i] != (pb[i] * pc[i])) |
| 20 |
abort(); |
| 21 |
} |
| 22 |
|
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
/* Aligned pointer accesses. |
| 27 |
The loop bound is unknown. |
| 28 |
No aliasing problems. |
| 29 |
vect-40.c is similar to this one with one difference: |
| 30 |
the loop bound is known. */ |
| 31 |
|
| 32 |
float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) |
| 33 |
= {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; |
| 34 |
float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) |
| 35 |
= {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; |
| 36 |
|
| 37 |
__attribute__ ((noinline)) int |
| 38 |
main1 (int n) |
| 39 |
{ |
| 40 |
int i; |
| 41 |
float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 42 |
float *pa = a; |
| 43 |
float *pb = b; |
| 44 |
float *pc = c; |
| 45 |
|
| 46 |
for (i = 0; i < n; i++) |
| 47 |
{ |
| 48 |
pa[i] = pb[i] * pc[i]; |
| 49 |
} |
| 50 |
|
| 51 |
bar (pa,pb,pc); |
| 52 |
|
| 53 |
return 0; |
| 54 |
} |
| 55 |
|
| 56 |
int main (void) |
| 57 |
{ |
| 58 |
int i; |
| 59 |
int n=N; |
| 60 |
check_vect (); |
| 61 |
main1 (n); |
| 62 |
return 0; |
| 63 |
} |
| 64 |
|
| 65 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ |
| 66 |
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" { xfail { ! vect_align_stack_vars } } } } */ |
| 67 |
/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ |