2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / no-vfa-vect-43.c
blob16a01d1a32066b7d9ff9a2c7c1da5ac7f860c00c
1 /* { dg-require-effective-target vect_float } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 256
8 __attribute__ ((noinline))
9 void bar (float *pa, float *pb, float *pc)
11 int i;
13 /* check results: */
14 for (i = 0; i < N; i++)
16 if (pa[i] != (pb[i] * pc[i]))
17 abort ();
20 return;
24 __attribute__ ((noinline)) int
25 main1 (float *pa, float *pb, float *pc)
27 int i;
28 float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
29 float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
31 for (i = 0; i < N; i++)
33 b[i] = pb[i];
34 c[i] = pc[i];
37 /* Vectorizable: pa may not alias pb and/or pc, even though their
38 addresses escape. &pa would need to escape to point to escaped memory. */
39 for (i = 0; i < N; i++)
41 pa[i] = b[i] * c[i];
44 bar (pa,b,c);
46 return 0;
49 __attribute__ ((noinline)) int
50 main2 (float *pa, float *pb, float *pc)
52 int i;
53 float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
54 float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
56 for (i = 0; i < N; i++)
58 b[i] = pb[i];
59 c[i] = pc[i];
62 /* Vectorizable: pb and pc addresses do not escape. */
63 for (i = 0; i < N; i++)
65 pa[i] = b[i] * c[i];
68 /* check results: */
69 for (i = 0; i < N; i++)
71 if (pa[i] != (b[i] * c[i]))
72 abort ();
75 return 0;
78 int main (void)
80 int i;
81 float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
82 float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
83 float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
85 check_vect ();
87 main1 (a,b,c);
88 main2 (a,b,c);
89 return 0;
92 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" } } */
93 /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 6 "vect" { target vect_no_align } } } */
94 /* { dg-final { cleanup-tree-dump "vect" } } */