OSDN Git Service

PR tree-optimization/40238
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / no-vfa-vect-43.c
1 /* { dg-require-effective-target vect_float } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 256
7
8 __attribute__ ((noinline))
9 void bar (float *pa, float *pb, float *pc) 
10 {
11   int i;
12
13   /* check results:  */
14   for (i = 0; i < N; i++)
15     {
16       if (pa[i] != (pb[i] * pc[i]))
17         abort ();
18     }
19
20   return;
21 }
22
23
24 __attribute__ ((noinline)) int
25 main1 (float *pa)
26 {
27   int i;
28   float pb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
29   float pc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
30
31   /* Vectorizable: pa may not alias pb and/or pc, even though their
32      addresses escape.  &pa would need to escape to point to escaped memory.  */
33   for (i = 0; i < N; i++)
34     {
35       pa[i] = pb[i] * pc[i];
36     }
37
38   bar (pa,pb,pc);
39
40   return 0;
41 }
42
43 __attribute__ ((noinline)) int
44 main2 (float * pa)
45 {
46   int i;
47   float pb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
48   float pc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
49
50   /* Vectorizable: pb and pc addresses do not escape.  */
51   for (i = 0; i < N; i++)
52     {
53       pa[i] = pb[i] * pc[i];
54     }   
55   
56   /* check results:  */
57   for (i = 0; i < N; i++)
58     {
59       if (pa[i] != (pb[i] * pc[i]))
60         abort ();
61     }
62   
63   return 0;
64 }
65
66 int main (void)
67 {
68   int i;
69   float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
70
71   check_vect ();
72
73   main1 (a);
74   main2 (a);
75   return 0;
76 }
77
78 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */
79 /*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target vect_no_align } } } */
80 /* { dg-final { cleanup-tree-dump "vect" } } */